aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-06-30 12:47:06 -0400
committerGopher Robot <gobot@golang.org>2023-07-20 19:30:53 +0000
commit3ffc8a25569ed107ebc1786bbd4f993dd6689601 (patch)
treece050073592b2aaa5c9c1ec706afb9cc475ad1b8 /src/runtime
parent7c1157f9544922e96945196b47b95664b1e39108 (diff)
downloadgo-3ffc8a25569ed107ebc1786bbd4f993dd6689601.tar.xz
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 <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/pprof/pprof_test.go10
1 files changed, 7 insertions, 3 deletions
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()
}
}