blob: d0e4ad71b8fce1c8419aab309fa42dbef4e7f5d2 [file] [log] [blame]
Chris Lattner9a3c2b52002-02-01 04:24:47 +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:
Chris Lattnerdec2d792003-05-14 18:39:57 +00008#
9# %s - Replaced with the input name of the program, or the program to
10# execute, as appropriate.
Chris Lattner9a3c2b52002-02-01 04:24:47 +000011#
12
Chris Lattnerdec2d792003-05-14 18:39:57 +000013FILENAME=$1
Chris Lattner1b2bde92003-05-14 19:54:07 +000014TESTNAME=$1
Chris Lattnerdec2d792003-05-14 18:39:57 +000015SUBST=$1
Chris Lattnerec26d4d2003-05-14 18:44:22 +000016OUTPUT=Output/$FILENAME.out
Chris Lattnerdec2d792003-05-14 18:39:57 +000017
18if test $# != 1; then
19 # If more than one parameter is passed in, there must be three parameters:
20 # The filename to read from (already processed), the command used to execute,
21 # and the file to output to.
22 SUBST=$2
23 OUTPUT=$3
Chris Lattner1b2bde92003-05-14 19:54:07 +000024 TESTNAME=$3
Chris Lattnerdec2d792003-05-14 18:39:57 +000025fi
26
Chris Lattner1b2bde92003-05-14 19:54:07 +000027ulimit -t 40
28
Chris Lattnerec26d4d2003-05-14 18:44:22 +000029SCRIPT=$OUTPUT.script
Chris Lattnere845b1a2004-01-12 05:01:13 +000030grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g;s|%llvmgcc|llvmgcc|g" > $SCRIPT
Chris Lattner9a3c2b52002-02-01 04:24:47 +000031
Chris Lattnerd24d4af2002-02-11 23:32:43 +000032
Chris Lattnerdec2d792003-05-14 18:39:57 +000033/bin/sh $SCRIPT > $OUTPUT 2>&1 || (
Chris Lattner1b2bde92003-05-14 19:54:07 +000034 echo "******************** TEST '$TESTNAME' FAILED! ********************"
Chris Lattnerd24d4af2002-02-11 23:32:43 +000035 echo "Command: "
Chris Lattnerdec2d792003-05-14 18:39:57 +000036 cat $SCRIPT
Chris Lattner9a3c2b52002-02-01 04:24:47 +000037 echo "Output:"
38 cat $OUTPUT
39 rm $OUTPUT
Chris Lattner1b2bde92003-05-14 19:54:07 +000040 echo "******************** TEST '$TESTNAME' FAILED! ********************"
Chris Lattner9a3c2b52002-02-01 04:24:47 +000041)
42