blob: 2c96fd5b48672fb2ac1f9cbec9c48e46d54cc281 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001#!/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# %llvmgcc - llvm-gcc command
12# %llvmgxx - llvm-g++ command
13# %prcontext - prcontext.tcl script
14#
15
16FILENAME=$1
17TESTNAME=$1
18SUBST=$1
19FILENAME_ONLY=`basename $1`
20OUTPUT=Output/$FILENAME_ONLY.out
21
22# create the output directory if it does not already exist
23mkdir Output > /dev/null 2>&1
24
25if test $# != 1; then
26 # If more than one parameter is passed in, there must be three parameters:
27 # The filename to read from (already processed), the command used to execute,
28 # and the file to output to.
29 SUBST=$2
30 OUTPUT=$3
31 TESTNAME=$3
32fi
33
34ulimit -t 40
35
36SCRIPT=$OUTPUT.script
37grep '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
38
39grep -q XFAIL $FILENAME && (printf "XFAILED '$TESTNAME': "; grep XFAIL $FILENAME)
40
41/bin/sh $SCRIPT > $OUTPUT 2>&1 || (
42 echo "******************** TEST '$TESTNAME' FAILED! ********************"
43 echo "Command: "
44 cat $SCRIPT
45 echo "Output:"
46 cat $OUTPUT
47 rm $OUTPUT
48 echo "******************** TEST '$TESTNAME' FAILED! ********************"
49)
50