Update credits and fix sorting issue.
[llvm-complete.git] / test / TestRunner.sh
blob68091c2188b85bba3177393b8cbaf1de1d7acb15
1 #!/bin/sh
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.
7 # This runner recognizes and replaces the following strings in the command:
9 # %s - Replaced with the input name of the program, or the program to
10 # execute, as appropriate.
13 FILENAME=$1
14 TESTNAME=$1
15 SUBST=$1
16 FILENAME_ONLY=`basename $1`
17 OUTPUT=Output/$FILENAME_ONLY.out
19 # create the output directory if it does not already exist
20 mkdir Output > /dev/null 2>&1
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
31 ulimit -t 40
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
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! ********************"