From 660feea72f64d9d6d619529f10afd8c042299c65 Mon Sep 17 00:00:00 2001 From: Cosmos Nicolaou Date: Tue, 29 Aug 2023 14:34:40 -0700 Subject: [PATCH] runtime/pprof: print stderr on test failure Print Stderr on test failure to track down the intermittent test failure reported in issue #62352. Change-Id: I547a3220dc07d05578dac093d6c028a9103b552a Reviewed-on: https://go-review.googlesource.com/c/go/+/524156 Reviewed-by: Michael Knyszek Reviewed-by: Dmitri Shuralyov Reviewed-by: Bryan Mills Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI --- src/runtime/pprof/vminfo_darwin_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/runtime/pprof/vminfo_darwin_test.go b/src/runtime/pprof/vminfo_darwin_test.go index c476110b09..b2b025668e 100644 --- a/src/runtime/pprof/vminfo_darwin_test.go +++ b/src/runtime/pprof/vminfo_darwin_test.go @@ -12,6 +12,7 @@ import ( "internal/abi" "internal/testenv" "os" + "os/exec" "strconv" "strings" "testing" @@ -54,9 +55,14 @@ func TestVMInfo(t *testing.T) { func useVMMap(t *testing.T) (hi, lo uint64) { pid := strconv.Itoa(os.Getpid()) testenv.MustHaveExecPath(t, "vmmap") - out, err := testenv.Command(t, "vmmap", pid).Output() + cmd := testenv.Command(t, "vmmap", pid) + out, err := cmd.Output() if err != nil { - t.Fatal(err) + t.Logf("vmmap failed: %s", out) + if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 { + t.Fatalf("%v: %v\n%s", cmd, err, ee.Stderr) + } + t.Fatalf("%v: %v", cmd, err) } return parseVmmap(t, out) } -- 2.50.0