]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add cgo guard for exit hooks test
authorThan McIntosh <thanm@google.com>
Tue, 27 Sep 2022 00:52:09 +0000 (20:52 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 27 Sep 2022 13:46:23 +0000 (13:46 +0000)
Add an additional guard to ensure that we don't try to run the "-race"
variant of the exit hooks test when CGO is explicitly turned off via
CGO_ENABLED=0 (this fixes a failure on the no-cgo builder caused
by CL 354790).

Change-Id: I9dc7fbd71962e9a098916da69d9119a753f27116
Reviewed-on: https://go-review.googlesource.com/c/go/+/434935
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/ehooks_test.go
src/runtime/testdata/testexithooks/testexithooks.go

index 021495fdf85b27b0090e18e755b3b312ce342066..afb17eac08c404576b3156f333d2c3b258d0d54b 100644 (file)
@@ -5,6 +5,7 @@
 package runtime_test
 
 import (
+       "internal/testenv"
        "os/exec"
        "runtime"
        "strings"
@@ -12,16 +13,16 @@ import (
 )
 
 func TestExitHooks(t *testing.T) {
-       bmodes := []string{"", "-race"}
-       if !testing.Short() {
+       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() {
                bmodes = append(bmodes, "-race")
        }
        for _, bmode := range bmodes {
-               // Race detector is not supported everywhere -- limit to just
-               // amd64 to keep things simple.
-               if bmode == "-race" && runtime.GOARCH != "amd64" {
-                       t.Skipf("Skipping on %s/%s", runtime.GOOS, runtime.GOARCH)
-               }
                scenarios := []struct {
                        mode     string
                        expected string
index 57561faf8e54c4cb90147eb931e03311a962e233..ceb3326c4f1b7208af3c80dfa8136b943d6e677c 100644 (file)
@@ -10,8 +10,6 @@ import (
        _ "unsafe"
 )
 
-import "C"
-
 var modeflag = flag.String("mode", "", "mode to run in")
 
 func main() {