mirror of
https://github.com/golang/go
synced 2024-11-17 10:44:43 -07:00
runtime: set PPROF_TMPDIR before running pprof
Fixes #16121. Change-Id: I7b838fb6fb9f098e6c348d67379fdc81fb0d69a4 Reviewed-on: https://go-review.googlesource.com/24270 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
This commit is contained in:
parent
109823ec93
commit
659b9a19aa
@ -252,7 +252,21 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) {
|
||||
fn := strings.TrimSpace(string(got))
|
||||
defer os.Remove(fn)
|
||||
|
||||
top, err := exec.Command("go", "tool", "pprof", "-top", "-nodecount=1", exe, fn).CombinedOutput()
|
||||
cmd := testEnv(exec.Command("go", "tool", "pprof", "-top", "-nodecount=1", exe, fn))
|
||||
|
||||
found := false
|
||||
for i, e := range cmd.Env {
|
||||
if strings.HasPrefix(e, "PPROF_TMPDIR=") {
|
||||
cmd.Env[i] = "PPROF_TMPDIR=" + os.TempDir()
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
cmd.Env = append(cmd.Env, "PPROF_TMPDIR="+os.TempDir())
|
||||
}
|
||||
|
||||
top, err := cmd.CombinedOutput()
|
||||
t.Logf("%s", top)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user