| 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. |
| 4 |
|
| 5 |
package sanitizers_test |
| 6 |
|
| 7 |
import ( |
| 8 |
"strings" |
| 9 |
"testing" |
| 10 |
) |
| 11 |
|
| 12 |
func TestTSAN(t *testing.T) { |
| 13 |
t.Parallel() |
| 14 |
requireOvercommit(t) |
| 15 |
config := configure("thread") |
| 16 |
config.skipIfCSanitizerBroken(t) |
| 17 |
|
| 18 |
mustRun(t, config.goCmd("build", "std")) |
| 19 |
|
| 20 |
cases := []struct { |
| 21 |
src string |
| 22 |
needsRuntime bool |
| 23 |
}{ |
| 24 |
{src: "tsan.go"}, |
| 25 |
{src: "tsan2.go"}, |
| 26 |
{src: "tsan3.go"}, |
| 27 |
{src: "tsan4.go"}, |
| 28 |
{src: "tsan5.go", needsRuntime: true}, |
| 29 |
{src: "tsan6.go", needsRuntime: true}, |
| 30 |
{src: "tsan7.go", needsRuntime: true}, |
| 31 |
{src: "tsan8.go"}, |
| 32 |
{src: "tsan9.go"}, |
| 33 |
{src: "tsan10.go", needsRuntime: true}, |
| 34 |
{src: "tsan11.go", needsRuntime: true}, |
| 35 |
{src: "tsan12.go", needsRuntime: true}, |
| 36 |
} |
| 37 |
for _, tc := range cases { |
| 38 |
tc := tc |
| 39 |
name := strings.TrimSuffix(tc.src, ".go") |
| 40 |
t.Run(name, func(t *testing.T) { |
| 41 |
t.Parallel() |
| 42 |
|
| 43 |
dir := newTempDir(t) |
| 44 |
defer dir.RemoveAll(t) |
| 45 |
|
| 46 |
outPath := dir.Join(name) |
| 47 |
mustRun(t, config.goCmd("build", "-o", outPath, srcPath(tc.src))) |
| 48 |
|
| 49 |
cmd := hangProneCmd(outPath) |
| 50 |
if tc.needsRuntime { |
| 51 |
config.skipIfRuntimeIncompatible(t) |
| 52 |
} |
| 53 |
mustRun(t, cmd) |
| 54 |
}) |
| 55 |
} |
| 56 |
} |