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