[cfe-commits] r48621 - in /cfe/trunk/test: Makefile Makefile.parallel TestRunner.sh
Gabor Greif
ggreif at gmail.com
Thu Mar 20 15:50:54 PDT 2008
Author: ggreif
Date: Thu Mar 20 17:50:54 2008
New Revision: 48621
URL: http://llvm.org/viewvc/llvm-project?rev=48621&view=rev
Log:
Add ability to run clang tests under valgrind. Patch by Sam Bishop.
Modified:
cfe/trunk/test/Makefile
cfe/trunk/test/Makefile.parallel
cfe/trunk/test/TestRunner.sh
Modified: cfe/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Makefile?rev=48621&r1=48620&r2=48621&view=diff
==============================================================================
--- cfe/trunk/test/Makefile (original)
+++ cfe/trunk/test/Makefile Thu Mar 20 17:50:54 2008
@@ -9,7 +9,7 @@
endif
all::
- PATH=$$PATH:$(ToolDir):$(LLVM_SRC_ROOT)/test/Scripts \
+ PATH=$$PATH:$(ToolDir):$(LLVM_SRC_ROOT)/test/Scripts VG=$(VG) \
find $(TESTDIRS) \( -name '*.c' -or -name '*.cpp' -or -name '*.m' \) \
-print -exec ./TestRunner.sh {} \;
Modified: cfe/trunk/test/Makefile.parallel
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Makefile.parallel?rev=48621&r1=48620&r2=48621&view=diff
==============================================================================
--- cfe/trunk/test/Makefile.parallel (original)
+++ cfe/trunk/test/Makefile.parallel Thu Mar 20 17:50:54 2008
@@ -22,7 +22,7 @@
Output/%.testresults: %
@ $(PROGRESS)
- @ PATH=$$PATH:$(ToolDir):$(LLVM_SRC_ROOT)/test/Scripts ./TestRunner.sh $< > $@ || $(REPORTFAIL)
+ @ PATH=$$PATH:$(ToolDir):$(LLVM_SRC_ROOT)/test/Scripts VG=$(VG) ./TestRunner.sh $< > $@ || $(REPORTFAIL)
all::
@ mkdir -p $(addprefix Output/, $(TESTDIRS))
Modified: cfe/trunk/test/TestRunner.sh
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/TestRunner.sh?rev=48621&r1=48620&r2=48621&view=diff
==============================================================================
--- cfe/trunk/test/TestRunner.sh (original)
+++ cfe/trunk/test/TestRunner.sh Thu Mar 20 17:50:54 2008
@@ -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 @@
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
More information about the cfe-commits
mailing list