[llvm-commits] [compiler-rt] r150366 - in /compiler-rt/trunk/lib/asan/tests: test_output.sh use-after-free.c
Alexey Samsonov
samsonov at google.com
Mon Feb 13 00:27:10 PST 2012
Author: samsonov
Date: Mon Feb 13 02:27:10 2012
New Revision: 150366
URL: http://llvm.org/viewvc/llvm-project?rev=150366&view=rev
Log:
AddressSanitizer: Use FileCheck instead of grep for pure C output tests
Modified:
compiler-rt/trunk/lib/asan/tests/test_output.sh
compiler-rt/trunk/lib/asan/tests/use-after-free.c
Modified: compiler-rt/trunk/lib/asan/tests/test_output.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/test_output.sh?rev=150366&r1=150365&r2=150366&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/test_output.sh (original)
+++ compiler-rt/trunk/lib/asan/tests/test_output.sh Mon Feb 13 02:27:10 2012
@@ -7,22 +7,37 @@
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
Modified: compiler-rt/trunk/lib/asan/tests/use-after-free.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/use-after-free.c?rev=150366&r1=150365&r2=150366&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/use-after-free.c (original)
+++ compiler-rt/trunk/lib/asan/tests/use-after-free.c Mon Feb 13 02:27:10 2012
@@ -4,3 +4,6 @@
free(x);
return x[5];
}
+
+// CHECK: heap-use-after-free
+// CHECKSLEEP: Sleeping for 1 second
More information about the llvm-commits
mailing list