3 # Copyright (C) 1992-2016 Free Software Foundation, Inc.
5 # This file is part of DejaGnu.
7 # DejaGnu is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # DejaGnu is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with DejaGnu; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
21 # This script was written by Rob Savoye. The script finds the proper
22 # expect shell and then starts DejaGnu.
24 # Get the execution path to this script and the current directory.
27 if expr "$mypath" : '.*/.*' > /dev
/null
31 IFS
="${IFS= }"; save_ifs
="$IFS"; IFS
="${IFS}:"
34 test -z "$dir" && dir
=.
35 if test -x "$dir/$mypath"
43 execpath
=$
(echo "$mypath" |
sed -e 's@/[^/]*$@@')
45 # Get the name by which runtest was invoked and extract the config
48 runtest
=$
(echo "$mypath" |
sed -e 's@^.*/@@')
49 target
=$
(echo "$runtest" |
sed -e 's/-runtest$//')
50 if [ "$target" != runtest
] ; then
51 target
="--target ${target}"
56 # Find the right expect binary to use. If a variable EXPECT exists, it
57 # takes precedence over all other tests. Otherwise look for a freshly
58 # built one, and then use one in the path.
60 if [ -n "$EXPECT" ] ; then
63 if [ -x "$execpath/expect" ] ; then
64 expectbin
="$execpath/expect"
72 if [ -z "$expectbin" ]; then
73 echo "ERROR: No expect shell found"
77 # This wrapper script will set up run-time library search PATHs.
79 if [ -x "$expectbin-bld.sh" ]; then
80 expectbin
="${CONFIG_SHELL-/bin/sh} $expectbin-bld.sh"
83 # Extract a few options from the option list.
89 -v|
--v|
-verb*|
--verb*) verbose
=$
((verbose
+ 1)) ;;
90 -D0|
--D0) debug
="-D 0" ;;
91 -D1|
--D1) debug
="-D 1" ;;
95 if expr "$verbose" \
> 0 > /dev
/null
; then
96 echo Expect binary is
"$expectbin"
99 # Find runtest.exp. First we look in its installed location,
100 # otherwise start if from the source tree.
102 # runtest.exp is found in @datadir@ (set by configure), but $execpath
103 # is @bindir@. We're assuming that:
105 # @datadir@ == @bindir@/../share
107 # @datadir@ == @bindir@/../../share
109 # .. which is a very weak assumption
112 $
(echo "$execpath" |
sed -e 's@/[^/]*$@/share/dejagnu@') \
113 $
(echo "$execpath" |
sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@') \
116 /usr
/local
/share
/dejagnu
; do
117 if expr "$verbose" \
> 1 > /dev
/null
; then
118 echo Looking
for "$i"/runtest.exp.
120 if [ -f "$i/runtest.exp" ] ; then
122 if expr "$verbose" \
> 0 > /dev
/null
; then
123 echo Using
"$i"/runtest.exp as main
test driver
129 # Check for an environment variable.
131 if [ -n "$DEJAGNULIBS" ] ; then
132 runpath
="$DEJAGNULIBS"
133 if expr "$verbose" \
> 0 > /dev
/null
; then
134 echo Using
"$DEJAGNULIBS"/runtest.exp as main
test driver
137 if [ -z "$runpath" ] ; then
138 echo "ERROR: runtest.exp does not exist"
142 if ! command -v "$expectbin" > /dev
/null
; then
143 echo "ERROR: unable to find expect in the PATH"
147 exec "$expectbin" $debug -- "$runpath"/runtest.exp
$target ${1+"$@"}