diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index eeb6d109dd..65d0a0aa8e 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -143,7 +143,9 @@ func testCPUProfile(t *testing.T, need []string, f func()) { // Check that profile is well formed and contains need. have := make([]uintptr, len(need)) + var samples uintptr parseProfile(t, prof.Bytes(), func(count uintptr, stk []uintptr) { + samples += count for _, pc := range stk { f := runtime.FuncForPC(pc) if f == nil { @@ -156,6 +158,7 @@ func testCPUProfile(t *testing.T, need []string, f func()) { } } }) + t.Logf("total %d CPU profile samples collected", samples) if len(need) == 0 { return @@ -200,6 +203,8 @@ func testCPUProfile(t *testing.T, need []string, f func()) { } } +// Fork can hang if preempted with signals frequently enough (see issue 5517). +// Ensure that we do not do this. func TestCPUProfileWithFork(t *testing.T) { if runtime.GOOS == "darwin" { if runtime.GOARCH == "arm" { @@ -207,9 +212,11 @@ func TestCPUProfileWithFork(t *testing.T) { } } - // Fork can hang if preempted with signals frequently enough (see issue 5517). - // Ensure that we do not do this. heap := 1 << 30 + if runtime.GOOS == "android" { + // Use smaller size for Android to avoid crash. + heap = 100 << 20 + } if testing.Short() { heap = 100 << 20 } @@ -232,7 +239,7 @@ func TestCPUProfileWithFork(t *testing.T) { defer StopCPUProfile() for i := 0; i < 10; i++ { - exec.Command("go").CombinedOutput() + exec.Command(os.Args[0], "-h").CombinedOutput() } }