diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cgo/testsanitizers/cc_test.go | 11 | ||||
-rw-r--r-- | misc/cgo/testsanitizers/cshared_test.go | 11 | ||||
-rw-r--r-- | misc/cgo/testsanitizers/msan_test.go | 13 |
3 files changed, 35 insertions, 0 deletions
diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go index 0192a663dd..dab13364b8 100644 --- a/misc/cgo/testsanitizers/cc_test.go +++ b/misc/cgo/testsanitizers/cc_test.go @@ -440,3 +440,14 @@ func hangProneCmd(name string, arg ...string) *exec.Cmd { } return cmd } + +// mSanSupported is a copy of the function cmd/internal/sys.MSanSupported, +// because the internal pacakage can't be used here. +func mSanSupported(goos, goarch string) bool { + switch goos { + case "linux": + return goarch == "amd64" || goarch == "arm64" + default: + return false + } +} diff --git a/misc/cgo/testsanitizers/cshared_test.go b/misc/cgo/testsanitizers/cshared_test.go index 56063ea620..b98360c4ae 100644 --- a/misc/cgo/testsanitizers/cshared_test.go +++ b/misc/cgo/testsanitizers/cshared_test.go @@ -19,6 +19,12 @@ func TestShared(t *testing.T) { if err != nil { t.Fatal(err) } + + GOARCH, err := goEnv("GOARCH") + if err != nil { + t.Fatal(err) + } + libExt := "so" if GOOS == "darwin" { libExt = "dylib" @@ -41,6 +47,11 @@ func TestShared(t *testing.T) { for _, tc := range cases { tc := tc name := strings.TrimSuffix(tc.src, ".go") + //The memory sanitizer tests require support for the -msan option. + if tc.sanitizer == "memory" && !mSanSupported(GOOS, GOARCH) { + t.Logf("skipping %s test on %s/%s; -msan option is not supported.", name, GOOS, GOARCH) + continue + } t.Run(name, func(t *testing.T) { t.Parallel() config := configure(tc.sanitizer) diff --git a/misc/cgo/testsanitizers/msan_test.go b/misc/cgo/testsanitizers/msan_test.go index 5e2f9759ba..2a3494fbfc 100644 --- a/misc/cgo/testsanitizers/msan_test.go +++ b/misc/cgo/testsanitizers/msan_test.go @@ -10,6 +10,19 @@ import ( ) func TestMSAN(t *testing.T) { + goos, err := goEnv("GOOS") + if err != nil { + t.Fatal(err) + } + goarch, err := goEnv("GOARCH") + if err != nil { + t.Fatal(err) + } + // The msan tests require support for the -msan option. + if !mSanSupported(goos, goarch) { + t.Skipf("skipping on %s/%s; -msan option is not supported.", goos, goarch) + } + t.Parallel() requireOvercommit(t) config := configure("memory") |