We actually don't have spiff anymore
[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 #
12
13 FILENAME=$1
14 TESTNAME=$1
15 SUBST=$1
16 OUTPUT=Output/$FILENAME.out
17
18 # create the output directory if it does not already exist
19 mkdir Output > /dev/null 2>&1
20
21 if test $# != 1; then
22   # If more than one parameter is passed in, there must be three parameters:
23   # The filename to read from (already processed), the command used to execute,
24   # and the file to output to.
25   SUBST=$2
26   OUTPUT=$3
27   TESTNAME=$3
28 fi
29
30 ulimit -t 40
31
32 SCRIPT=$OUTPUT.script
33 grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g;s|%llvmgcc|llvmgcc|g" > $SCRIPT
34
35
36 /bin/sh $SCRIPT > $OUTPUT 2>&1 || (
37   echo "******************** TEST '$TESTNAME' FAILED! ********************"
38   echo "Command: "
39   cat $SCRIPT
40   echo "Output:"
41   cat $OUTPUT
42   rm $OUTPUT
43   echo "******************** TEST '$TESTNAME' FAILED! ********************"
44 )
45