From 841873f27c4d08d266779a9ef719a7f0d1a0e74d Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Tue, 4 Oct 2022 09:43:29 -0400 Subject: [PATCH] runtime: change exit hooks test to use RaceDetectorSupported Use internal/syssup.RaceDetectorSupported in the exit hooks tests as a better way to tell if the race detector is available. Change-Id: I8f43f93319f68b9910f2eea88fc375f7ef3bb2e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/438476 Reviewed-by: Bryan Mills Run-TryBot: Than McIntosh TryBot-Result: Gopher Robot --- src/runtime/ehooks_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/runtime/ehooks_test.go b/src/runtime/ehooks_test.go index afb17eac08..ee286ecb9a 100644 --- a/src/runtime/ehooks_test.go +++ b/src/runtime/ehooks_test.go @@ -5,6 +5,7 @@ package runtime_test import ( + "internal/platform" "internal/testenv" "os/exec" "runtime" @@ -14,12 +15,13 @@ import ( func TestExitHooks(t *testing.T) { bmodes := []string{""} - // Race detector is not supported everywhere -- limit to just - // linux/amd64 to keep things simple. Note the HasCGO() test - // below; this is to prevent the test running if CGO_ENABLED=0 - // is in effect. - if !testing.Short() && runtime.GOARCH == "amd64" && - runtime.GOOS == "linux" && testenv.HasCGO() { + if testing.Short() { + t.Skip("skipping due to -short") + } + // Note the HasCGO() test below; this is to prevent the test + // running if CGO_ENABLED=0 is in effect. + haverace := platform.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH) + if haverace && testenv.HasCGO() { bmodes = append(bmodes, "-race") } for _, bmode := range bmodes {