}
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
+ }
+}
if err != nil {
t.Fatal(err)
}
+
+ GOARCH, err := goEnv("GOARCH")
+ if err != nil {
+ t.Fatal(err)
+ }
+
libExt := "so"
if GOOS == "darwin" {
libExt = "dylib"
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)
)
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")
if gohostos == "linux" && goarch == "amd64" {
t.registerTest("testasan", "../misc/cgo/testasan", "go", "run", ".")
}
- if mSanSupported(goos, goarch) {
- t.registerHostTest("testsanitizers/msan", "../misc/cgo/testsanitizers", "misc/cgo/testsanitizers", ".")
+ if goos == "linux" {
+ // because syscall.SysProcAttri struct used in misc/cgo/testsanitizers is only built on linux.
+ t.registerHostTest("testsanitizers", "../misc/cgo/testsanitizers", "misc/cgo/testsanitizers", ".")
}
if t.hasBash() && goos != "android" && !t.iOS() && gohostos != "windows" {
t.registerHostTest("cgo_errors", "../misc/cgo/errors", "misc/cgo/errors", ".")
}
}
-// mSanSupported is a copy of the function cmd/internal/sys.MSanSupported,
-// which can't be used here because cmd/dist has to be buildable by Go 1.4.
-func mSanSupported(goos, goarch string) bool {
- switch goos {
- case "linux":
- return goarch == "amd64" || goarch == "arm64"
- default:
- return false
- }
-}
-
// isUnsupportedVMASize reports whether the failure is caused by an unsupported
// VMA for the race detector (for example, running the race detector on an
// arm64 machine configured with 39-bit VMA)
}
// MSanSupported reports whether goos/goarch supports the memory
-// sanitizer option. There is a copy of this function in cmd/dist/test.go.
+// sanitizer option.
+// There is a copy of this function in misc/cgo/testsanitizers/cc_test.go.
func MSanSupported(goos, goarch string) bool {
switch goos {
case "linux":