diff options
author | Fabricio Voznika <fvoznika@google.com> | 2021-05-27 19:51:54 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-27 19:55:03 -0700 |
commit | 394c6089c3b8700164756677f53314d165f8d383 (patch) | |
tree | 61e947c2f697f750851fbd335c7c992fabc7a290 /test/cmd | |
parent | e8fc815b6ef58b6faa136ef239f89ec98a8e55b4 (diff) |
Fix test_app task-tree
Executing `select {}` to wait forever triggers Go runtime deadlock
detection and kills the child, causing the number actual processes
be less than expected.
PiperOrigin-RevId: 376298799
Diffstat (limited to 'test/cmd')
-rw-r--r-- | test/cmd/test_app/test_app.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/cmd/test_app/test_app.go b/test/cmd/test_app/test_app.go index 3ba4f38f8..2d08ce2db 100644 --- a/test/cmd/test_app/test_app.go +++ b/test/cmd/test_app/test_app.go @@ -160,14 +160,17 @@ func (c *taskTree) SetFlags(f *flag.FlagSet) { // Execute implements subcommands.Command. func (c *taskTree) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus { - stop := testutil.StartReaper() - defer stop() - if c.depth == 0 { log.Printf("Child sleeping, PID: %d\n", os.Getpid()) - select {} + for { + time.Sleep(time.Hour) + } } - log.Printf("Parent %d sleeping, PID: %d\n", c.depth, os.Getpid()) + + log.Printf("Parent %d creating %d children, PID: %d\n", c.depth, c.width, os.Getpid()) + + stop := testutil.StartReaper() + defer stop() var cmds []*exec.Cmd for i := 0; i < c.width; i++ { @@ -175,7 +178,7 @@ func (c *taskTree) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa "/proc/self/exe", c.Name(), "--depth", strconv.Itoa(c.depth-1), "--width", strconv.Itoa(c.width), - "--pause", strconv.FormatBool(c.pause)) + fmt.Sprintf("--pause=%t", c.pause)) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -190,7 +193,10 @@ func (c *taskTree) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa } if c.pause { - select {} + log.Printf("Parent %d sleeping, PID: %d\n", c.depth, os.Getpid()) + for { + time.Sleep(time.Hour) + } } return subcommands.ExitSuccess |