]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testsanitizers: don't run tsan tests on old clang
authorIan Lance Taylor <iant@golang.org>
Mon, 29 Feb 2016 18:05:46 +0000 (10:05 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 1 Mar 2016 00:56:14 +0000 (00:56 +0000)
Fixes #14570.

Change-Id: Ief84a14585bfc209e38cdf15702c2f54ba759714
Reviewed-on: https://go-review.googlesource.com/20057
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
misc/cgo/testsanitizers/test.bash

index ff4a585271cb542dd22a468e0a9580c2c80bf74d..76628abaff87410d5e976adaee5510c90e70e5a5 100755 (executable)
@@ -25,14 +25,18 @@ if $CC -fsanitize=memory -c ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsaniti
 fi
 rm -f ${TMPDIR}/testsanitizers$$.*
 
-# The memory sanitizer in versions of clang before 3.6 don't work with Go.
+tsan=yes
+
+# The memory and thread sanitizers in versions of clang before 3.6
+# don't work with Go.
 if test "$msan" = "yes" && $CC --version | grep clang >& /dev/null; then
   ver=$($CC --version | sed -e 's/.* version \([0-9.-]*\).*/\1/')
   major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/')
   minor=$(echo $ver | sed -e 's/[0-9]*\.\([0-9]*\).*/\1/')
   if test "$major" -lt 3 || test "$major" -eq 3 -a "$minor" -lt 6; then
-    echo "skipping msan tests: clang version $major.$minor (older than 3.6)"
+    echo "skipping msan/tsan tests: clang version $major.$minor (older than 3.6)"
     msan=no
+    tsan=no
   fi
 
   # Clang before 3.8 does not work with Linux at or after 4.1.
@@ -43,8 +47,9 @@ if test "$msan" = "yes" && $CC --version | grep clang >& /dev/null; then
       linuxmajor=$(echo $linuxver | sed -e 's/\([0-9]*\).*/\1/')
       linuxminor=$(echo $linuxver | sed -e 's/[0-9]*\.\([0-9]*\).*/\1/')
       if test "$linuxmajor" -gt 4 || test "$linuxmajor" -eq 4 -a "$linuxminor" -ge 1; then
-        echo "skipping msan tests: clang version $major.$minor (older than 3.8) incompatible with linux version $linuxmajor.$linuxminor (4.1 or newer)"
+        echo "skipping msan/tsan tests: clang version $major.$minor (older than 3.8) incompatible with linux version $linuxmajor.$linuxminor (4.1 or newer)"
        msan=no
+       tsan=no
       fi
     fi
   fi
@@ -89,15 +94,22 @@ if test "$msan" = "yes"; then
     fi
 fi
 
-tsan=yes
-
-TMPDIR=${TMPDIR:-/tmp}
-echo > ${TMPDIR}/testsanitizers$$.c
-if $CC -fsanitize=thread ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$ 2>&1 | grep "unrecognized" >& /dev/null; then
-  echo "skipping tsan tests: -fsanitize=thread not supported"
-  tsan=no
+if test "$tsan" = "yes"; then
+    echo 'int main() { return 0; }' > ${TMPDIR}/testsanitizers$$.c
+    ok=yes
+    if ! $CC -fsanitize=thread ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$ &> ${TMPDIR}/testsanitizers$$.err; then
+       ok=no
+    fi
+     if grep "unrecognized" ${TMPDIR}/testsanitizers$$.err >& /dev/null; then
+       echo "skipping tsan tests: -fsanitize=thread not supported"
+       tsan=no
+     elif test "$ok" != "yes"; then
+        cat ${TMPDIR}/testsanitizers$$.err
+        echo "skipping tsan tests: -fsanitizer=thread build failed"
+        tsan=no
+     fi
+     rm -f ${TMPDIR}/testsanitizers$$*
 fi
-rm -f ${TMPDIR}/testsanitizers$$.*
 
 if test "$tsan" = "yes"; then
     err=${TMPDIR}/tsanerr$$.out