blob: 07a49890aa495dfdc67182bb7a74292ffe1f081d [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
Ted Kremenek6a18c762007-11-28 19:16:54 +000019
20OUTPUT=Output/$1.out
Reid Spencer5f016e22007-07-11 17:01:13 +000021
22# create the output directory if it does not already exist
Ted Kremenek6a18c762007-11-28 19:16:54 +000023mkdir -p `dirname $OUTPUT` > /dev/null 2>&1
Reid Spencer5f016e22007-07-11 17:01:13 +000024
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