Fix path problem
[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 SUBST=$1
15 OUTPUT=Output/$FILENAME.out
16
17 if test $# != 1; then
18   # If more than one parameter is passed in, there must be three parameters:
19   # The filename to read from (already processed), the command used to execute,
20   # and the file to output to.
21   SUBST=$2
22   OUTPUT=$3
23 fi
24
25 SCRIPT=$OUTPUT.script
26 grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g" > $SCRIPT
27
28
29 /bin/sh $SCRIPT > $OUTPUT 2>&1 || (
30   echo "******************** TEST '$FILENAME' FAILED! ********************"
31   echo "Command: "
32   cat $SCRIPT
33   echo "Output:"
34   cat $OUTPUT
35   rm $OUTPUT
36   echo "******************** TEST '$FILENAME' FAILED! ********************"
37 )
38