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-05-10 22:18:22 +08:00
|
|
|
|
|
|
|
# Assuming clang is in path.
|
|
|
|
CC=clang
|
|
|
|
CXX=clang++
|
|
|
|
|
|
|
|
# TODO: add testing for all of -O0...-O3
|
2012-11-06 10:31:42 +08:00
|
|
|
CFLAGS="-fsanitize=thread -fPIE -O1 -g -fno-builtin -Wall"
|
2012-05-10 23:10:03 +08:00
|
|
|
LDFLAGS="-pie -lpthread -ldl $ROOTDIR/rtl/libtsan.a"
|
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
|
|
|
|
RES=$(TSAN_OPTIONS="atexit_sleep_ms=0" $EXE 2>&1 || true)
|
2012-05-10 22:18:22 +08:00
|
|
|
if [ "$3" != "" ]; then
|
2012-05-11 22:58:20 +08:00
|
|
|
printf "%s\n" "$RES"
|
2012-05-10 22:18:22 +08:00
|
|
|
fi
|
2012-05-11 22:58:20 +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
|
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
|