2012-05-10 22:18:22 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-05-14 23:25:35 +08:00
|
|
|
ulimit -s 8192
|
2012-05-10 22:18:22 +08:00
|
|
|
set -e # fail on any error
|
|
|
|
|
2012-05-11 22:58:20 +08:00
|
|
|
ROOTDIR=$(dirname $0)/..
|
2012-12-28 18:06:26 +08:00
|
|
|
BLACKLIST=$ROOTDIR/lit_tests/Helpers/blacklist.txt
|
2012-05-10 22:18:22 +08:00
|
|
|
|
2013-03-18 15:00:36 +08:00
|
|
|
# Assume clang and clang++ are in path.
|
|
|
|
: ${CC:=clang}
|
|
|
|
: ${CXX:=clang++}
|
|
|
|
: ${FILECHECK:=FileCheck}
|
2012-05-10 22:18:22 +08:00
|
|
|
|
|
|
|
# TODO: add testing for all of -O0...-O3
|
2013-03-28 16:41:49 +08:00
|
|
|
CFLAGS="-fsanitize=thread -fsanitize-blacklist=$BLACKLIST -fPIE -O1 -g -Wall"
|
2013-11-21 19:49:08 +08:00
|
|
|
LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive"
|
2012-05-10 22:18:22 +08:00
|
|
|
|
|
|
|
test_file() {
|
|
|
|
SRC=$1
|
|
|
|
COMPILER=$2
|
2012-05-11 22:58:20 +08:00
|
|
|
echo ----- TESTING $(basename $1)
|
2012-05-10 22:18:22 +08:00
|
|
|
OBJ=$SRC.o
|
|
|
|
EXE=$SRC.exe
|
|
|
|
$COMPILER $SRC $CFLAGS -c -o $OBJ
|
2012-05-14 23:25:35 +08:00
|
|
|
$COMPILER $OBJ $LDFLAGS -o $EXE
|
2012-12-18 20:19:50 +08:00
|
|
|
RES=$($EXE 2>&1 || true)
|
2013-03-18 15:00:36 +08:00
|
|
|
printf "%s\n" "$RES" | $FILECHECK $SRC
|
2012-05-10 22:18:22 +08:00
|
|
|
if [ "$3" == "" ]; then
|
2012-05-11 22:58:20 +08:00
|
|
|
rm -f $EXE $OBJ
|
2012-05-10 22:18:22 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" == "" ]; then
|
2012-09-18 15:23:54 +08:00
|
|
|
for c in $ROOTDIR/lit_tests/*.{c,cc}; do
|
2012-05-10 22:18:22 +08:00
|
|
|
if [[ $c == */failing_* ]]; then
|
|
|
|
echo SKIPPING FAILING TEST $c
|
|
|
|
continue
|
|
|
|
fi
|
2013-04-09 15:46:20 +08:00
|
|
|
if [[ $c == */load_shared_lib.cc ]]; then
|
|
|
|
echo TEST $c is not supported
|
|
|
|
continue
|
|
|
|
fi
|
2013-06-10 23:39:28 +08:00
|
|
|
if [ "`grep "TSAN_OPTIONS" $c`" ]; then
|
|
|
|
echo SKIPPING $c -- requires TSAN_OPTIONS
|
|
|
|
continue
|
|
|
|
fi
|
2012-05-11 22:58:20 +08:00
|
|
|
COMPILER=$CXX
|
|
|
|
case $c in
|
|
|
|
*.c) COMPILER=$CC
|
|
|
|
esac
|
2012-10-02 19:51:40 +08:00
|
|
|
test_file $c $COMPILER &
|
|
|
|
done
|
|
|
|
for job in `jobs -p`; do
|
|
|
|
wait $job || exit 1
|
2012-05-10 22:18:22 +08:00
|
|
|
done
|
|
|
|
else
|
2012-09-18 15:23:54 +08:00
|
|
|
test_file $ROOTDIR/lit_tests/$1 $CXX "DUMP"
|
2012-05-10 22:18:22 +08:00
|
|
|
fi
|