#!/bin/sh
mypath=${0-.}
if expr ${mypath} : '.*/.*' > /dev/null
then
:
else
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for dir in $PATH
do
test -z "$dir" && dir=.
if test -x $dir/$mypath
then
mypath=$dir/$mypath
break
fi
done
IFS="$save_ifs"
fi
execpath=`echo ${mypath} | sed -e 's@/[^/]*$@@'`
runtest=`echo ${mypath} | sed -e 's@^.*/@@'`
target=`echo $runtest | sed -e 's/-runtest$//'`
if [ "$target" != runtest ] ; then
target="--target ${target}"
else
target=""
fi
if [ x"$EXPECT" != x ] ; then
expectbin=$EXPECT
else
if [ -x "$execpath/expect" ] ; then
expectbin=$execpath/expect
else
expectbin=expect
fi
fi
if [ -z "$expectbin" ]; then
echo "ERROR: No expect shell found"
exit 1
fi
if [ -x "$expectbin-bld.sh" ]; then
expectbin="${CONFIG_SHELL-/bin/sh} $expectbin-bld.sh"
fi
verbose=0
debug=""
for a in "$@" ; do
case $a in
-v|--v|-verb*|--verb*) verbose=`expr $verbose + 1`;;
-D0|--D0) debug="-D 0" ;;
-D1|--D1) debug="-D 1" ;;
esac
done
if expr $verbose \> 0 > /dev/null ; then
echo Expect binary is $expectbin
fi
for i in `echo ${execpath} | sed -e 's@/[^/]*$@/share/dejagnu@'` `echo ${execpath} | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@'` $execpath ; do
if expr $verbose \> 1 > /dev/null ; then
echo Looking for $i/runtest.exp.
fi
if [ -f $i/runtest.exp ] ; then
runpath=$i
if expr $verbose \> 0 > /dev/null ; then
echo Using $i/runtest.exp as main test driver
fi
fi
done
if [ x"$DEJAGNULIBS" != x ] ; then
runpath=$DEJAGNULIBS
if expr $verbose \> 0 > /dev/null ; then
echo Using $DEJAGNULIBS/runtest.exp as main test driver
fi
fi
if [ x"$runpath" = x ] ; then
echo "ERROR: runtest.exp does not exist."
exit 1
fi
exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}