Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Dmitry Vyukov | d004b99 | 2012-05-14 15:25:35 +0000 | [diff] [blame] | 3 | ulimit -s 8192 |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 4 | set -e # fail on any error |
| 5 | |
Kostya Serebryany | 0e6705e | 2012-05-11 14:58:20 +0000 | [diff] [blame] | 6 | ROOTDIR=$(dirname $0)/.. |
Alexey Samsonov | 8474843 | 2012-12-28 10:06:26 +0000 | [diff] [blame] | 7 | BLACKLIST=$ROOTDIR/lit_tests/Helpers/blacklist.txt |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 8 | |
| 9 | # Assuming clang is in path. |
| 10 | CC=clang |
| 11 | CXX=clang++ |
| 12 | |
| 13 | # TODO: add testing for all of -O0...-O3 |
Alexey Samsonov | 8474843 | 2012-12-28 10:06:26 +0000 | [diff] [blame] | 14 | CFLAGS="-fsanitize=thread -fsanitize-blacklist=$BLACKLIST -fPIE -O1 -g -fno-builtin -Wall" |
Kostya Serebryany | 5b7cb1d | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 15 | LDFLAGS="-pie -lpthread -ldl $ROOTDIR/rtl/libtsan.a" |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 16 | |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 17 | test_file() { |
| 18 | SRC=$1 |
| 19 | COMPILER=$2 |
Kostya Serebryany | 0e6705e | 2012-05-11 14:58:20 +0000 | [diff] [blame] | 20 | echo ----- TESTING $(basename $1) |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 21 | OBJ=$SRC.o |
| 22 | EXE=$SRC.exe |
| 23 | $COMPILER $SRC $CFLAGS -c -o $OBJ |
Dmitry Vyukov | d004b99 | 2012-05-14 15:25:35 +0000 | [diff] [blame] | 24 | $COMPILER $OBJ $LDFLAGS -o $EXE |
Dmitry Vyukov | 9c7bcfe | 2012-12-18 12:19:50 +0000 | [diff] [blame] | 25 | RES=$($EXE 2>&1 || true) |
Kostya Serebryany | 0e6705e | 2012-05-11 14:58:20 +0000 | [diff] [blame] | 26 | printf "%s\n" "$RES" | FileCheck $SRC |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 27 | if [ "$3" == "" ]; then |
Kostya Serebryany | 0e6705e | 2012-05-11 14:58:20 +0000 | [diff] [blame] | 28 | rm -f $EXE $OBJ |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 29 | fi |
| 30 | } |
| 31 | |
| 32 | if [ "$1" == "" ]; then |
Alexey Samsonov | 341e5bc | 2012-09-18 07:23:54 +0000 | [diff] [blame] | 33 | for c in $ROOTDIR/lit_tests/*.{c,cc}; do |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 34 | if [[ $c == */failing_* ]]; then |
| 35 | echo SKIPPING FAILING TEST $c |
| 36 | continue |
| 37 | fi |
Kostya Serebryany | 0e6705e | 2012-05-11 14:58:20 +0000 | [diff] [blame] | 38 | COMPILER=$CXX |
| 39 | case $c in |
| 40 | *.c) COMPILER=$CC |
| 41 | esac |
Dmitry Vyukov | 0c40a56 | 2012-10-02 11:51:40 +0000 | [diff] [blame] | 42 | test_file $c $COMPILER & |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 43 | done |
Dmitry Vyukov | 0c40a56 | 2012-10-02 11:51:40 +0000 | [diff] [blame] | 44 | for job in `jobs -p`; do |
| 45 | wait $job || exit 1 |
| 46 | done |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 47 | else |
Alexey Samsonov | 341e5bc | 2012-09-18 07:23:54 +0000 | [diff] [blame] | 48 | test_file $ROOTDIR/lit_tests/$1 $CXX "DUMP" |
Kostya Serebryany | ff15ef0 | 2012-05-10 14:18:22 +0000 | [diff] [blame] | 49 | fi |