| Chris Lattner | 0f342da | 2002-02-01 04:24:47 +0000 | [diff] [blame] | 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: |
| Chris Lattner | 9600e8d | 2003-05-14 18:39:57 +0000 | [diff] [blame^] | 8 | # |
| 9 | # %s - Replaced with the input name of the program, or the program to |
| 10 | # execute, as appropriate. |
| Chris Lattner | 0f342da | 2002-02-01 04:24:47 +0000 | [diff] [blame] | 11 | # |
| 12 | |
| Chris Lattner | 9600e8d | 2003-05-14 18:39:57 +0000 | [diff] [blame^] | 13 | FILENAME=$1 |
| 14 | SUBST=$1 |
| 15 | OUTPUT=$FILENAME.out |
| 16 | |
| 17 | if test $# != 1; then |
| 18 | # If more than one parameter is passed in, there must be three parameters: |
| 19 | # The filename to read from (already processed), the command used to execute, |
| 20 | # and the file to output to. |
| 21 | SUBST=$2 |
| 22 | OUTPUT=$3 |
| 23 | fi |
| 24 | |
| 25 | SCRIPT=Output/$OUTPUT.script |
| 26 | grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g" > $SCRIPT |
| Chris Lattner | 0f342da | 2002-02-01 04:24:47 +0000 | [diff] [blame] | 27 | |
| Chris Lattner | 004b053 | 2002-02-11 23:32:43 +0000 | [diff] [blame] | 28 | |
| Chris Lattner | 9600e8d | 2003-05-14 18:39:57 +0000 | [diff] [blame^] | 29 | /bin/sh $SCRIPT > $OUTPUT 2>&1 || ( |
| 30 | echo "******************** TEST '$FILENAME' FAILED! ********************" |
| Chris Lattner | 004b053 | 2002-02-11 23:32:43 +0000 | [diff] [blame] | 31 | echo "Command: " |
| Chris Lattner | 9600e8d | 2003-05-14 18:39:57 +0000 | [diff] [blame^] | 32 | cat $SCRIPT |
| Chris Lattner | 0f342da | 2002-02-01 04:24:47 +0000 | [diff] [blame] | 33 | echo "Output:" |
| 34 | cat $OUTPUT |
| 35 | rm $OUTPUT |
| Chris Lattner | 9600e8d | 2003-05-14 18:39:57 +0000 | [diff] [blame^] | 36 | echo "******************** TEST '$FILENAME' FAILED! ********************" |
| Chris Lattner | 0f342da | 2002-02-01 04:24:47 +0000 | [diff] [blame] | 37 | ) |
| 38 | |