aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-06-06 21:44:24 -0700
committerIan Lance Taylor <iant@golang.org>2016-06-08 05:08:11 +0000
commitd1b5d08f341cbc702e1d2a3cd86ab1ad93a90c41 (patch)
treec2afce82a5ef25bced3bb8ec512dfd6fa330a9e9
parentf605c77bbcc7946531e0914f13a0a14aae5f2991 (diff)
downloadgo-d1b5d08f341cbc702e1d2a3cd86ab1ad93a90c41.tar.gz
go-d1b5d08f341cbc702e1d2a3cd86ab1ad93a90c41.zip
misc/cgo/testsanitizers: don't run some TSAN tests on GCC < 7
Before GCC 7 defined __SANITIZE_THREAD__ when using TSAN, runtime/cgo/libcgo.h could not determine reliably whether TSAN was in use when using GCC. Fixes #15983. Change-Id: I5581c9f88e1cde1974c280008b2230fe5e971f44 Reviewed-on: https://go-review.googlesource.com/23833 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
-rwxr-xr-xmisc/cgo/testsanitizers/test.bash25
1 files changed, 21 insertions, 4 deletions
diff --git a/misc/cgo/testsanitizers/test.bash b/misc/cgo/testsanitizers/test.bash
index 12ddba5dfa..78747d141a 100755
--- a/misc/cgo/testsanitizers/test.bash
+++ b/misc/cgo/testsanitizers/test.bash
@@ -135,11 +135,28 @@ if test "$tsan" = "yes"; then
testtsan tsan3.go
testtsan tsan4.go
- # This test requires rebuilding os/user with -fsanitize=thread.
- testtsan tsan5.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
+ # These tests are only reliable using clang or GCC version 7 or later.
+ # Otherwise runtime/cgo/libcgo.h can't tell whether TSAN is in use.
+ ok=false
+ if ${CC} --version | grep clang >/dev/null 2>&1; then
+ ok=true
+ else
+ ver=$($CC -dumpversion)
+ major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/')
+ if test "$major" -lt 7; then
+ echo "skipping remaining TSAN tests: GCC version $major (older than 7)"
+ else
+ ok=true
+ fi
+ fi
+
+ if test "$ok" = "true"; then
+ # This test requires rebuilding os/user with -fsanitize=thread.
+ testtsan tsan5.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
- # This test requires rebuilding runtime/cgo with -fsanitize=thread.
- testtsan tsan6.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
+ # This test requires rebuilding runtime/cgo with -fsanitize=thread.
+ testtsan tsan6.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
+ fi
fi
exit $status