Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 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 |
Ted Kremenek | 6a18c76 | 2007-11-28 19:16:54 +0000 | [diff] [blame] | 19 | |
| 20 | OUTPUT=Output/$1.out |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 21 | |
| 22 | # create the output directory if it does not already exist |
Ted Kremenek | 6a18c76 | 2007-11-28 19:16:54 +0000 | [diff] [blame] | 23 | mkdir -p `dirname $OUTPUT` > /dev/null 2>&1 |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 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 | grep -q XFAIL $FILENAME && (printf "XFAILED '$TESTNAME': "; grep XFAIL $FILENAME) |
| 40 | |
| 41 | /bin/sh $SCRIPT > $OUTPUT 2>&1 || ( |
| 42 | echo "******************** TEST '$TESTNAME' FAILED! ********************" |
| 43 | echo "Command: " |
| 44 | cat $SCRIPT |
| 45 | echo "Output:" |
| 46 | cat $OUTPUT |
| 47 | rm $OUTPUT |
| 48 | echo "******************** TEST '$TESTNAME' FAILED! ********************" |
| 49 | ) |
| 50 | |