1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package sanitizers_test
12 func TestTSAN(t *testing.T) {
13 goos, err := goEnv("GOOS")
17 goarch, err := goEnv("GOARCH")
21 // The msan tests require support for the -msan option.
22 if !compilerRequiredTsanVersion(goos, goarch) {
23 t.Skipf("skipping on %s/%s; compiler version for -tsan option is too old.", goos, goarch)
28 config := configure("thread")
29 config.skipIfCSanitizerBroken(t)
31 mustRun(t, config.goCmd("build", "std"))
41 {src: "tsan5.go", needsRuntime: true},
42 {src: "tsan6.go", needsRuntime: true},
43 {src: "tsan7.go", needsRuntime: true},
46 {src: "tsan10.go", needsRuntime: true},
47 {src: "tsan11.go", needsRuntime: true},
48 {src: "tsan12.go", needsRuntime: true},
50 for _, tc := range cases {
52 name := strings.TrimSuffix(tc.src, ".go")
53 t.Run(name, func(t *testing.T) {
57 defer dir.RemoveAll(t)
59 outPath := dir.Join(name)
60 mustRun(t, config.goCmd("build", "-o", outPath, srcPath(tc.src)))
62 cmd := hangProneCmd(outPath)
64 config.skipIfRuntimeIncompatible(t)