aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/pprof
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2022-11-15 10:47:46 -0500
committerGopher Robot <gobot@golang.org>2022-11-15 20:24:42 +0000
commitddf78189d47ff97afb76d3b4e47edbf3eb0ee11c (patch)
treef5f0a8e53918824f4ba2bac9d903e7f0e2fb7510 /src/cmd/pprof
parenta68f9113a2d4043ef28d2e4395485ee187e5532d (diff)
downloadgo-ddf78189d47ff97afb76d3b4e47edbf3eb0ee11c.tar.xz
cmd/pprof: use testenv.Command instead of exec.Command in tests
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: Iabd114dd23b85da524e7ea8415f2bbf2c54b380f Reviewed-on: https://go-review.googlesource.com/c/go/+/450709 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/pprof')
-rw-r--r--src/cmd/pprof/pprof_test.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/cmd/pprof/pprof_test.go b/src/cmd/pprof/pprof_test.go
index ed6a9386d5..353781ac04 100644
--- a/src/cmd/pprof/pprof_test.go
+++ b/src/cmd/pprof/pprof_test.go
@@ -7,7 +7,6 @@ package main
import (
"internal/testenv"
"os"
- "os/exec"
"path/filepath"
"runtime"
"strings"
@@ -91,7 +90,7 @@ func TestDisasm(t *testing.T) {
tmpdir := t.TempDir()
cpuExe := filepath.Join(tmpdir, "cpu.exe")
- cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", cpuExe, "cpu.go")
+ cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", cpuExe, "cpu.go")
cmd.Dir = "testdata/"
out, err := cmd.CombinedOutput()
if err != nil {
@@ -99,19 +98,19 @@ func TestDisasm(t *testing.T) {
}
profile := filepath.Join(tmpdir, "cpu.pprof")
- cmd = exec.Command(cpuExe, "-output", profile)
+ cmd = testenv.Command(t, cpuExe, "-output", profile)
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("cpu failed: %v\n%s", err, out)
}
- cmd = exec.Command(pprofPath(t), "-disasm", "main.main", cpuExe, profile)
+ cmd = testenv.Command(t, pprofPath(t), "-disasm", "main.main", cpuExe, profile)
out, err = cmd.CombinedOutput()
if err != nil {
t.Errorf("pprof -disasm failed: %v\n%s", err, out)
// Try to print out profile content for debugging.
- cmd = exec.Command(pprofPath(t), "-raw", cpuExe, profile)
+ cmd = testenv.Command(t, pprofPath(t), "-raw", cpuExe, profile)
out, err = cmd.CombinedOutput()
if err != nil {
t.Logf("pprof -raw failed: %v\n%s", err, out)