Fix PR1355: Only compute the SUBPATH and TESTDIR once.
[oota-llvm.git] / test / TestRunner.sh
1 #!/bin/sh
2 #
3 #  TestRunner.sh - This script is used to run the deja-gnu tests exactly like
4 #  deja-gnu does, by executing the Tcl script specified in the test case's 
5 #  RUN: lines. This is made possible by a simple make target supported by the
6 #  test/Makefile. All this script does is invoke that make target. 
7 #
8 #  Usage:
9 #     TestRunner.sh {script_names}
10 #
11 #     This script is typically used by cd'ing to a test directory and then
12 #     running TestRunner.sh with a list of test file names you want to run.
13 #
14 TESTPATH=`pwd`
15 SUBDIR=""
16 while test `basename $TESTPATH` != "test" -a ! -z "$TESTPATH" ; do
17   tmp=`basename $TESTPATH`
18   SUBDIR="$tmp/$SUBDIR"
19   TESTPATH=`dirname $TESTPATH`
20 done
21
22 for TESTFILE in "$@" ; do 
23   if test `dirname $TESTFILE` == . ; then
24     if test -d "$TESTPATH" ; then
25       cd $TESTPATH
26       make check-one TESTONE="$SUBDIR$TESTFILE"
27       cd $PWD
28     else
29       echo "Can't find llvm/test directory in " `pwd`
30     fi
31   else
32     make check-one TESTONE=$TESTFILE
33   fi
34 done