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