Skip to content

Commit 3ffc8a2

Browse files
Bryan C. Millsgopherbot
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent 7c1157f commit 3ffc8a2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/runtime/pprof/pprof_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"math"
1919
"math/big"
2020
"os"
21-
"os/exec"
2221
"regexp"
2322
"runtime"
2423
"runtime/debug"
@@ -440,7 +439,7 @@ func cpuProfilingBroken() bool {
440439
func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Duration)) *profile.Profile {
441440
switch runtime.GOOS {
442441
case "darwin":
443-
out, err := exec.Command("uname", "-a").CombinedOutput()
442+
out, err := testenv.Command(t, "uname", "-a").CombinedOutput()
444443
if err != nil {
445444
t.Fatal(err)
446445
}
@@ -653,6 +652,11 @@ func matchAndAvoidStacks(matches sampleMatchFunc, need []string, avoid []string)
653652
func TestCPUProfileWithFork(t *testing.T) {
654653
testenv.MustHaveExec(t)
655654

655+
exe, err := os.Executable()
656+
if err != nil {
657+
t.Fatal(err)
658+
}
659+
656660
heap := 1 << 30
657661
if runtime.GOOS == "android" {
658662
// Use smaller size for Android to avoid crash.
@@ -684,7 +688,7 @@ func TestCPUProfileWithFork(t *testing.T) {
684688
defer StopCPUProfile()
685689

686690
for i := 0; i < 10; i++ {
687-
exec.Command(os.Args[0], "-h").CombinedOutput()
691+
testenv.Command(t, exe, "-h").CombinedOutput()
688692
}
689693
}
690694

0 commit comments

Comments
 (0)