2001-11-02 Philip A. Wilsey <philip.wilsey@cliftonlabs.com>
[dejagnu.git] / runtest
blob8bc6a53de09a7cf8b191b05e3293b1b3f5f464d6
1 #!/bin/sh
3 # runtest -- basically all this script does is find the proper expect
4 # shell and then run DejaGnu.
6 # Written by Rob Savoye <rob@welcomehome.org>
10 # Get the execution path to this script and the current directory.
12 mypath=${0-.}
13 if expr ${mypath} : '.*/.*' > /dev/null
14 then
16 else
17 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
18 for dir in $PATH
20 test -z "$dir" && dir=.
21 if test -x $dir/$mypath
22 then
23 mypath=$dir/$mypath
24 break
26 done
27 IFS="$save_ifs"
29 execpath=`echo ${mypath} | sed -e 's@/[^/]*$@@'`
30 # rootme=`pwd`
33 # get the name by which runtest was invoked and extract the config triplet
35 runtest=`echo ${mypath} | sed -e 's@^.*/@@'`
36 target=`echo $runtest | sed -e 's/-runtest$//'`
37 if [ "$target" != runtest ] ; then
38 target="--target ${target}"
39 else
40 target=""
44 # Find the right expect binary to use. If a variable EXPECT exists,
45 # it takes precedence over all other tests. Otherwise look for a freshly
46 # built one, and then use one in the path.
48 if [ x"$EXPECT" != x ] ; then
49 expectbin=$EXPECT
50 else
51 if [ -x "$execpath/expect" ] ; then
52 expectbin=$execpath/expect
53 else
54 expectbin=expect
58 # just to be safe...
59 if [ -z "$expectbin" ]; then
60 echo "ERROR: No expect shell found"
61 exit 1
64 # This wrapper script will set up run-time library search PATHs
65 if [ -x "$expectbin-bld.sh" ]; then
66 expectbin="${CONFIG_SHELL-/bin/sh} $expectbin-bld.sh"
70 # Extract a few options from the option list.
72 verbose=0
73 debug=""
74 for a in "$@" ; do
75 case $a in
76 -v|--v|-verb*|--verb*) verbose=`expr $verbose + 1`;;
77 -D0|--D0) debug="-D 0" ;;
78 -D1|--D1) debug="-D 1" ;;
79 esac
80 done
82 if expr $verbose \> 0 > /dev/null ; then
83 echo Expect binary is $expectbin
87 # find runtest.exp. First we look in it's installed location, otherwise
88 # start if from the source tree.
90 # runtest.exp is found in (autoconf-configure-set) @datadir@, but
91 # $execpath is @bindir@. We're assuming that
93 # @datadir@ == @bindir@/../share
94 # or
95 # @datadir@ == @bindir@/../../share
97 # which is a very weak assumption
99 for i in `echo ${execpath} | sed -e 's@/[^/]*$@/share/dejagnu@'` `echo ${execpath} | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@'` $execpath ; do
100 if expr $verbose \> 1 > /dev/null ; then
101 echo Looking for $i/runtest.exp.
103 if [ -f $i/runtest.exp ] ; then
104 runpath=$i
105 if expr $verbose \> 0 > /dev/null ; then
106 echo Using $i/runtest.exp as main test driver
109 done
110 # check for an environment variable
111 if [ x"$DEJAGNULIBS" != x ] ; then
112 runpath=$DEJAGNULIBS
113 if expr $verbose \> 0 > /dev/null ; then
114 echo Using $DEJAGNULIBS/runtest.exp as main test driver
117 if [ x"$runpath" = x ] ; then
118 echo "ERROR: runtest.exp does not exist."
119 exit 1
122 exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}