From: Bryan C. Mills Date: Fri, 30 Jun 2023 16:47:06 +0000 (-0400) Subject: runtime/pprof: use testenv.Command in tests instead of exec.Command X-Git-Tag: go1.22rc1~1582 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ffc8a25569ed107ebc1786bbd4f993dd6689601;p=gostls13.git runtime/pprof: use testenv.Command in tests instead of exec.Command If the test is about to time out, testenv.Command sends SIGQUIT to the child process. The runtime's SIGQUIT goroutine dump should help us to determine whether the hangs observed in TestCPUProfileWithFork are a symptom of #60108 or a separate bug. For #59995. Updates #60108. Change-Id: I26342ca262b2b0772795c8be142cfcad8d90db30 Reviewed-on: https://go-review.googlesource.com/c/go/+/507356 Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Reviewed-by: Michael Knyszek Auto-Submit: Bryan Mills --- diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 56ba6d9803..1ade860441 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -18,7 +18,6 @@ import ( "math" "math/big" "os" - "os/exec" "regexp" "runtime" "runtime/debug" @@ -440,7 +439,7 @@ func cpuProfilingBroken() bool { func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Duration)) *profile.Profile { switch runtime.GOOS { case "darwin": - out, err := exec.Command("uname", "-a").CombinedOutput() + out, err := testenv.Command(t, "uname", "-a").CombinedOutput() if err != nil { t.Fatal(err) } @@ -653,6 +652,11 @@ func matchAndAvoidStacks(matches sampleMatchFunc, need []string, avoid []string) func TestCPUProfileWithFork(t *testing.T) { testenv.MustHaveExec(t) + exe, err := os.Executable() + if err != nil { + t.Fatal(err) + } + heap := 1 << 30 if runtime.GOOS == "android" { // Use smaller size for Android to avoid crash. @@ -684,7 +688,7 @@ func TestCPUProfileWithFork(t *testing.T) { defer StopCPUProfile() for i := 0; i < 10; i++ { - exec.Command(os.Args[0], "-h").CombinedOutput() + testenv.Command(t, exe, "-h").CombinedOutput() } }