testrunner should print out xfail info.
[oota-llvm.git] / test / TestRunner.sh
1 #!/bin/sh
2 #
3 #  TestRunner.sh - This script is used to run arbitrary unit tests.  Unit
4 #  tests must contain the command used to run them in the input file, starting
5 #  immediately after a "RUN:" string.
6 #
7 #  This runner recognizes and replaces the following strings in the command:
8 #
9 #     %s - Replaced with the input name of the program, or the program to
10 #          execute, as appropriate.
11 #     %llvmgcc - llvm-gcc command
12 #     %llvmgxx - llvm-g++ command
13 #     %prcontext - prcontext.tcl script
14 #
15
16 FILENAME=$1
17 TESTNAME=$1
18 SUBST=$1
19 FILENAME_ONLY=`basename $1`
20 OUTPUT=Output/$FILENAME_ONLY.out
21
22 # create the output directory if it does not already exist
23 mkdir Output > /dev/null 2>&1
24
25 if test $# != 1; then
26   # If more than one parameter is passed in, there must be three parameters:
27   # The filename to read from (already processed), the command used to execute,
28   # and the file to output to.
29   SUBST=$2
30   OUTPUT=$3
31   TESTNAME=$3
32 fi
33
34 ulimit -t 40
35
36 SCRIPT=$OUTPUT.script
37 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" > $SCRIPT
38
39
40 /bin/sh $SCRIPT > $OUTPUT 2>&1 || (
41   echo "******************** TEST '$TESTNAME' FAILED! ********************"
42   grep XFAIL $FILENAME
43   echo "Command: "
44   cat $SCRIPT
45   echo "Output:"
46   cat $OUTPUT
47   rm $OUTPUT
48   echo "******************** TEST '$TESTNAME' FAILED! ********************"
49 )
50