summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/tests
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan/tests')
-rwxr-xr-xcompiler-rt/lib/asan/tests/test_output.sh23
-rw-r--r--compiler-rt/lib/asan/tests/use-after-free.c3
2 files changed, 22 insertions, 4 deletions
diff --git a/compiler-rt/lib/asan/tests/test_output.sh b/compiler-rt/lib/asan/tests/test_output.sh
index 385fba25325..f619244b46b 100755
--- a/compiler-rt/lib/asan/tests/test_output.sh
+++ b/compiler-rt/lib/asan/tests/test_output.sh
@@ -7,22 +7,37 @@ CXX=$1
CC=$2
CXXFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls"
SYMBOLIZER=../scripts/asan_symbolize.py
+FILE_CHECK=../../../../../build/Release+Asserts/bin/FileCheck
+
+# check_program exe_file src_file [check_prefix]
+check_program() {
+ exe=$1
+ src=$2
+ prefix="CHECK"
+ if [ "z$3" != "z" ] ; then
+ prefix=$3
+ fi
+ ./$exe 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt | \
+ $FILE_CHECK $src --check-prefix=$prefix
+}
C_TEST=use-after-free
echo "Sanity checking a test in pure C"
$CC -g -faddress-sanitizer -O2 $C_TEST.c
-./a.out 2>&1 | grep "heap-use-after-free" > /dev/null
+check_program a.out $C_TEST.c
rm ./a.out
echo "Sanity checking a test in pure C with -pie"
$CC -g -faddress-sanitizer -O2 $C_TEST.c -pie
-./a.out 2>&1 | grep "heap-use-after-free" > /dev/null
+check_program a.out $C_TEST.c
rm ./a.out
echo "Testing sleep_before_dying"
$CC -g -faddress-sanitizer -O2 $C_TEST.c
-ASAN_OPTIONS=sleep_before_dying=1 ./a.out 2>&1 | grep "Sleeping for 1 second" > /dev/null
-rm a.out
+export ASAN_OPTIONS="sleep_before_dying=1"
+check_program a.out $C_TEST.c CHECKSLEEP
+export ASAN_OPTIONS=""
+rm ./a.out
for t in *.tmpl; do
for b in 32 64; do
diff --git a/compiler-rt/lib/asan/tests/use-after-free.c b/compiler-rt/lib/asan/tests/use-after-free.c
index 60626bff778..801d3f68a46 100644
--- a/compiler-rt/lib/asan/tests/use-after-free.c
+++ b/compiler-rt/lib/asan/tests/use-after-free.c
@@ -4,3 +4,6 @@ int main() {
free(x);
return x[5];
}
+
+// CHECK: heap-use-after-free
+// CHECKSLEEP: Sleeping for 1 second
OpenPOWER on IntegriCloud