Commit 8c24e522 authored by Russ Cox's avatar Russ Cox

runtime: check that pprof accepts but doesn't need executable

The profiles are self-contained now.
Check that they work by themselves in the tests that invoke pprof,
but also keep checking that the old command lines work.

Change-Id: I24c74b5456f0b50473883c3640625c6612f72309
Reviewed-on: https://go-review.googlesource.com/37166
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMichael Matloob <matloob@golang.org>
parent 0b8c983e
......@@ -287,7 +287,14 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) {
fn := strings.TrimSpace(string(got))
defer os.Remove(fn)
cmd := testEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-top", "-nodecount=1", exe, fn))
for try := 0; try < 2; try++ {
cmd := testEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-top", "-nodecount=1"))
// Check that pprof works both with and without explicit executable on command line.
if try == 0 {
cmd.Args = append(cmd.Args, exe, fn)
} else {
cmd.Args = append(cmd.Args, fn)
}
found := false
for i, e := range cmd.Env {
......@@ -302,14 +309,13 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) {
}
top, err := cmd.CombinedOutput()
t.Logf("%s", top)
t.Logf("%s:\n%s", cmd.Args, top)
if err != nil {
t.Fatal(err)
}
if !bytes.Contains(top, []byte("cpuHog")) {
t.Error(err)
} else if !bytes.Contains(top, []byte("cpuHog")) {
t.Error("missing cpuHog in pprof output")
}
}
}
func TestCgoPprof(t *testing.T) {
......
......@@ -476,8 +476,14 @@ func TestMemPprof(t *testing.T) {
fn := strings.TrimSpace(string(got))
defer os.Remove(fn)
cmd := testEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-alloc_space", "-top", exe, fn))
for try := 0; try < 2; try++ {
cmd := testEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-alloc_space", "-top"))
// Check that pprof works both with and without explicit executable on command line.
if try == 0 {
cmd.Args = append(cmd.Args, exe, fn)
} else {
cmd.Args = append(cmd.Args, fn)
}
found := false
for i, e := range cmd.Env {
if strings.HasPrefix(e, "PPROF_TMPDIR=") {
......@@ -491,14 +497,13 @@ func TestMemPprof(t *testing.T) {
}
top, err := cmd.CombinedOutput()
t.Logf("%s", top)
t.Logf("%s:\n%s", cmd.Args, top)
if err != nil {
t.Fatal(err)
}
if !bytes.Contains(top, []byte("MemProf")) {
t.Error(err)
} else if !bytes.Contains(top, []byte("MemProf")) {
t.Error("missing MemProf in pprof output")
}
}
}
var concurrentMapTest = flag.Bool("run_concurrent_map_tests", false, "also run flaky concurrent map tests")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment