diff options
| author | Michael Pratt <mpratt@google.com> | 2025-03-17 12:11:42 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-03-25 11:51:29 -0700 |
| commit | 2c0a0fc6b92eff337a8eb8ff79d7a0e47ada2e46 (patch) | |
| tree | f9241fc789db7b45c7a9961bc7b691a26e69173f | |
| parent | c855149768c70eb349c2e9a42b03a8a30b99672e (diff) | |
| download | go-2c0a0fc6b92eff337a8eb8ff79d7a0e47ada2e46.tar.xz | |
[release-branch.go1.23] 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.
For #72876.
For #72871.
Change-Id: I6a6a636cbf6b16abcbba8771178fe1d001be9d9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/658415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/658435
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
| -rw-r--r-- | src/internal/testenv/testenv.go | 23 | ||||
| -rw-r--r-- | src/runtime/crash_cgo_test.go | 3 | ||||
| -rw-r--r-- | src/runtime/pprof/pprof_test.go | 23 |
3 files changed, 27 insertions, 22 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 9fb92406e8..a6ebcb0f70 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -522,3 +522,26 @@ func ParallelOn64Bit(t *testing.T) { } t.Parallel() } + +// CPUProfilingBroken returns true if CPU profiling has known issues on this +// platform. +func CPUProfilingBroken() bool { + switch runtime.GOOS { + case "plan9": + // Profiling unimplemented. + return true + case "aix": + // See https://golang.org/issue/45170. + return true + case "ios", "dragonfly", "netbsd", "illumos", "solaris": + // See https://golang.org/issue/13841. + return true + case "openbsd": + if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { + // See https://golang.org/issue/13841. + return true + } + } + + return false +} diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 755a4e619d..494a534296 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -82,6 +82,9 @@ func TestCgoCallbackPprof(t *testing.T) { case "plan9", "windows": t.Skipf("no pthreads on %s", runtime.GOOS) } + if testenv.CPUProfilingBroken() { + t.Skip("skipping on platform with broken profiling") + } got := runTestProg(t, "testprogcgo", "CgoCallbackPprof") if want := "OK\n"; got != want { diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index da4ad17d77..2b58daafe4 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -415,27 +415,6 @@ func parseProfile(t *testing.T, valBytes []byte, f func(uintptr, []*profile.Loca return p } -func cpuProfilingBroken() bool { - switch runtime.GOOS { - case "plan9": - // Profiling unimplemented. - return true - case "aix": - // See https://golang.org/issue/45170. - return true - case "ios", "dragonfly", "netbsd", "illumos", "solaris": - // See https://golang.org/issue/13841. - return true - case "openbsd": - if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { - // See https://golang.org/issue/13841. - return true - } - } - - return false -} - // testCPUProfile runs f under the CPU profiler, checking for some conditions specified by need, // as interpreted by matches, and returns the parsed profile. func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Duration)) *profile.Profile { @@ -453,7 +432,7 @@ func testCPUProfile(t *testing.T, matches profileMatchFunc, f func(dur time.Dura t.Skip("skipping on wasip1") } - broken := cpuProfilingBroken() + broken := testenv.CPUProfilingBroken() deadline, ok := t.Deadline() if broken || !ok { |
