Skip to content

Commit 7dd7d70

Browse files
prattmicgopherbot
authored andcommitted
runtime: skip TestCgoCallbackPprof on platforms with broken profiling
CL 658035 added TestCgoCallbackPprof, which is consistently failing on solaris. runtime/pprof maintains a list of platforms where CPU profiling does not work properly. Since this test requires CPU profiling, skip the this test on those platforms. For #72870. Fixes #72876. Change-Id: I6a6a636cbf6b16abcbba8771178fe1d001be9d9b Reviewed-on: https://go-review.googlesource.com/c/go/+/658415 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent f41fdd9 commit 7dd7d70

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

src/internal/testenv/testenv.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,3 +504,26 @@ func ParallelOn64Bit(t *testing.T) {
504504
}
505505
t.Parallel()
506506
}
507+
508+
// CPUProfilingBroken returns true if CPU profiling has known issues on this
509+
// platform.
510+
func CPUProfilingBroken() bool {
511+
switch runtime.GOOS {
512+
case "plan9":
513+
// Profiling unimplemented.
514+
return true
515+
case "aix":
516+
// See https://golang.org/issue/45170.
517+
return true
518+
case "ios", "dragonfly", "netbsd", "illumos", "solaris":
519+
// See https://golang.org/issue/13841.
520+
return true
521+
case "openbsd":
522+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
523+
// See https://golang.org/issue/13841.
524+
return true
525+
}
526+
}
527+
528+
return false
529+
}

src/runtime/crash_cgo_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ func TestCgoCallbackPprof(t *testing.T) {
7878
case "plan9", "windows":
7979
t.Skipf("no pthreads on %s", runtime.GOOS)
8080
}
81+
if testenv.CPUProfilingBroken() {
82+
t.Skip("skipping on platform with broken profiling")
83+
}
8184

8285
got := runTestProg(t, "testprogcgo", "CgoCallbackPprof")
8386
if want := "OK\n"; got != want {

src/runtime/pprof/pprof_test.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -416,27 +416,6 @@ func parseProfile(t *testing.T, valBytes []byte, f func(uintptr, []*profile.Loca
416416
return p
417417
}
418418

419-
func cpuProfilingBroken() bool {
420-
switch runtime.GOOS {
421-
case "plan9":
422-
// Profiling unimplemented.
423-
return true
424-
case "aix":
425-
// See https://golang.org/issue/45170.
426-
return true
427-
case "ios", "dragonfly", "netbsd", "illumos", "solaris":
428-
// See https://golang.org/issue/13841.
429-
return true
430-
case "openbsd":
431-
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
432-
// See https://golang.org/issue/13841.
433-
return true
434-
}
435-
}
436-
437-
return false
438-
}
439-
440419
// testCPUProfile runs f under the CPU profiler, checking for some conditions specified by need,
441420
// as interpreted by matches, and returns the parsed profile.
442421
func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Duration)) *profile.Profile {
@@ -454,7 +433,7 @@ func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Dura
454433
t.Skip("skipping on wasip1")
455434
}
456435

457-
broken := cpuProfilingBroken()
436+
broken := testenv.CPUProfilingBroken()
458437

459438
deadline, ok := t.Deadline()
460439
if broken || !ok {

0 commit comments

Comments
 (0)