Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Commit

Permalink
runtime: set PPROF_TMPDIR before running pprof
Browse files Browse the repository at this point in the history
Fixes golang#16121.

Change-Id: I7b838fb6fb9f098e6c348d67379fdc81fb0d69a4
Reviewed-on: https://go-review.googlesource.com/24270
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Michael Hudson-Doyle <[email protected]>
  • Loading branch information
ianlancetaylor committed Jun 20, 2016
1 parent 109823e commit 659b9a1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/runtime/crash_cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 659b9a1

Please sign in to comment.