summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/tests/test_output.sh
blob: dff48d2c286f933b377bf8de1a34727eac05dbcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash

OS=`uname`
CXX=$1
CC=$2
CXXFLAGS="-mno-omit-leaf-frame-pointer"
SYMBOLIZER=../scripts/asan_symbolize.py

C_TEST=use-after-free
$CC -g -faddress-sanitizer -O2 $C_TEST.c  || exit 1
echo "Sanity checking a test in pure C"
./a.out 2>&1 | grep "heap-use-after-free" > /dev/null || exit 1
rm ./a.out

for t in  *.tmpl; do
  for b in 32 64; do
    for O in 0 1 2 3; do
      c=`basename $t .tmpl`
      c_so=$c-so
      exe=$c.$b.O$O
      so=$c_so.$b.O$O.so
      $CXX $CXXFLAGS -g -m$b -faddress-sanitizer -O$O $c.cc -o $exe
      [ -e "$c_so.cc" ] && $CXX $CXXFLAGS -g -m$b -faddress-sanitizer -O$O $c_so.cc -fPIC -shared -o $so
      # If there's an OS-specific template, use it.
      # Please minimize the use of OS-specific templates.
      if [ -e "$t.$OS" ]
      then
        actual_t="$t.$OS"
      else
        actual_t="$t"
      fi
      ./$exe 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt | ./match_output.py $actual_t || exit 1
      echo $exe
      rm ./$exe
      [ -e "$so" ] && rm ./$so
    done
  done
done

exit 0
OpenPOWER on IntegriCloud