]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: change exit hooks test to use RaceDetectorSupported
authorThan McIntosh <thanm@google.com>
Tue, 4 Oct 2022 13:43:29 +0000 (09:43 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 4 Oct 2022 18:52:38 +0000 (18:52 +0000)
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 <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/ehooks_test.go

index afb17eac08c404576b3156f333d2c3b258d0d54b..ee286ecb9a76adcef6a6340adf8a0e19cec3a3fc 100644 (file)
@@ -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 {