diff options
author | Gabor Greif <ggreif@gmail.com> | 2008-03-20 22:50:54 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2008-03-20 22:50:54 +0000 |
commit | 1e2db03f3f782b201be5a4542cd6bad8d869f8c9 (patch) | |
tree | bb837bfc806eae16fb7e83c3037dc284bb873872 /test/TestRunner.sh | |
parent | fa59f1f053235e9adf32425f2b6049185771246d (diff) |
Add ability to run clang tests under valgrind. Patch by Sam Bishop.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/TestRunner.sh')
-rwxr-xr-x | test/TestRunner.sh | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/test/TestRunner.sh b/test/TestRunner.sh index bc09a99065..8a0d87d3d5 100755 --- a/test/TestRunner.sh +++ b/test/TestRunner.sh @@ -11,7 +11,7 @@ # %llvmgcc - llvm-gcc command # %llvmgxx - llvm-g++ command # %prcontext - prcontext.tcl script -# %t1 - temporary file name (derived from testcase name) +# %t - temporary file name (derived from testcase name) # FILENAME=$1 @@ -40,20 +40,50 @@ grep -q 'RUN:' $FILENAME || ( exit 1 ) +# Run under valgrind if the VG environment variable has been set. +CLANG="clang" +if [ -n "$VG" ]; then + rm -f $OUTPUT.vg.* + CLANG="valgrind --leak-check=full --quiet --log-file=$OUTPUT.vg $CLANG" +fi + SCRIPT=$OUTPUT.script TEMPOUTPUT=$OUTPUT.tmp -grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g;s|%llvmgcc|llvm-gcc -emit-llvm|g;s|%llvmgxx|llvm-g++ -emit-llvm|g;s|%prcontext|prcontext.tcl|g;s|%t|$TEMPOUTPUT|g" > $SCRIPT +grep 'RUN:' $FILENAME | \ + sed -e "s|^.*RUN:\(.*\)$|\1|g" \ + -e "s|%s|$SUBST|g" \ + -e "s|%llvmgcc|llvm-gcc -emit-llvm|g" \ + -e "s|%llvmgxx|llvm-g++ -emit-llvm|g" \ + -e "s|%prcontext|prcontext.tcl|g" \ + -e "s|%t|$TEMPOUTPUT|g" \ + -e "s|clang|$CLANG|g" > $SCRIPT grep -q XFAIL $FILENAME && (printf "XFAILED '$TESTNAME': "; grep XFAIL $FILENAME) -/bin/sh $SCRIPT > $OUTPUT 2>&1 || ( +/bin/sh $SCRIPT > $OUTPUT 2>&1 +SCRIPT_STATUS=$? + +if [ -n "$VG" ]; then + VG_STATUS=`cat $OUTPUT.vg.* | wc -l` +else + VG_STATUS=0 +fi + +if [ $SCRIPT_STATUS -ne 0 -o $VG_STATUS -ne 0 ]; then echo "******************** TEST '$TESTNAME' FAILED! ********************" echo "Command: " cat $SCRIPT - echo "Output:" + if [ $SCRIPT_STATUS -eq 0 ]; then + echo "Output:" + else + echo "Incorrect Output:" + fi cat $OUTPUT - rm $OUTPUT + if [ $VG_STATUS -ne 0 ]; then + echo "Valgrind Output:" + cat $OUTPUT.vg.* + fi echo "******************** TEST '$TESTNAME' FAILED! ********************" exit 1 -) +fi |