Fixed the CBE on Solaris/Sparc. We need to define the return value of
[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 if test $# != 1; then
19   # If more than one parameter is passed in, there must be three parameters:
20   # The filename to read from (already processed), the command used to execute,
21   # and the file to output to.
22   SUBST=$2
23   OUTPUT=$3
24   TESTNAME=$3
25 fi
26
27 ulimit -t 40
28
29 SCRIPT=$OUTPUT.script
30 grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g" > $SCRIPT
31
32
33 /bin/sh $SCRIPT > $OUTPUT 2>&1 || (
34   echo "******************** TEST '$TESTNAME' FAILED! ********************"
35   echo "Command: "
36   cat $SCRIPT
37   echo "Output:"
38   cat $OUTPUT
39   rm $OUTPUT
40   echo "******************** TEST '$TESTNAME' FAILED! ********************"
41 )
42