mirror of
https://github.com/golang/go
synced 2024-11-17 09:54:46 -07:00
cmd/pprof: debug TestDisasm
If pprof -disasm fails, print the profile content for debugging. For #56574. Change-Id: I5d9377b7fb80f6b85317bc53f3ebb18f70c2f06d Reviewed-on: https://go-review.googlesource.com/c/go/+/450281 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
febe7b8e2a
commit
362713183a
@ -115,12 +115,22 @@ func TestDisasm(t *testing.T) {
|
||||
cmd = exec.Command(pprofExe, "-disasm", "main.main", cpuExe, profile)
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("pprof failed: %v\n%s", err, out)
|
||||
t.Errorf("pprof -disasm failed: %v\n%s", err, out)
|
||||
|
||||
// Try to print out profile content for debugging.
|
||||
cmd = exec.Command(pprofExe, "-raw", cpuExe, profile)
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Logf("pprof -raw failed: %v\n%s", err, out)
|
||||
} else {
|
||||
t.Logf("profile content:\n%s", out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
sout := string(out)
|
||||
want := "ROUTINE ======================== main.main"
|
||||
if !strings.Contains(sout, want) {
|
||||
t.Errorf("pprof disasm got %s want contains %q", sout, want)
|
||||
t.Errorf("pprof -disasm got %s want contains %q", sout, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user