aboutsummaryrefslogtreecommitdiff
path: root/lib/tsan/lit_tests/test_output.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tsan/lit_tests/test_output.sh')
-rwxr-xr-xlib/tsan/lit_tests/test_output.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/tsan/lit_tests/test_output.sh b/lib/tsan/lit_tests/test_output.sh
new file mode 100755
index 000000000000..d21c9a797ad3
--- /dev/null
+++ b/lib/tsan/lit_tests/test_output.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+ulimit -s 8192
+set -e # fail on any error
+
+ROOTDIR=$(dirname $0)/..
+BLACKLIST=$ROOTDIR/lit_tests/Helpers/blacklist.txt
+
+# Assuming clang is in path.
+CC=clang
+CXX=clang++
+
+# TODO: add testing for all of -O0...-O3
+CFLAGS="-fsanitize=thread -fsanitize-blacklist=$BLACKLIST -fPIE -O1 -g -fno-builtin -Wall"
+LDFLAGS="-pie -lpthread -ldl $ROOTDIR/rtl/libtsan.a"
+
+test_file() {
+ SRC=$1
+ COMPILER=$2
+ echo ----- TESTING $(basename $1)
+ OBJ=$SRC.o
+ EXE=$SRC.exe
+ $COMPILER $SRC $CFLAGS -c -o $OBJ
+ $COMPILER $OBJ $LDFLAGS -o $EXE
+ RES=$($EXE 2>&1 || true)
+ printf "%s\n" "$RES" | FileCheck $SRC
+ if [ "$3" == "" ]; then
+ rm -f $EXE $OBJ
+ fi
+}
+
+if [ "$1" == "" ]; then
+ for c in $ROOTDIR/lit_tests/*.{c,cc}; do
+ if [[ $c == */failing_* ]]; then
+ echo SKIPPING FAILING TEST $c
+ continue
+ fi
+ COMPILER=$CXX
+ case $c in
+ *.c) COMPILER=$CC
+ esac
+ test_file $c $COMPILER &
+ done
+ for job in `jobs -p`; do
+ wait $job || exit 1
+ done
+else
+ test_file $ROOTDIR/lit_tests/$1 $CXX "DUMP"
+fi