3 # Copyright (C) 1992-2016, 2021 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, see <http://www.gnu.org/licenses/>.
20 # This script was written by Rob Savoye. The script finds the proper
21 # expect shell and then starts DejaGnu.
23 # shellcheck disable=SC2003
24 # The shellcheck tool complains about use of expr and recommends using
25 # newer shell features instead. Solaris 10 /bin/sh does not support the
26 # newer features, so we must use expr in this script.
28 # shellcheck disable=SC2006
29 # The shellcheck tool complains about the old style backtick command
30 # substitution. Solaris 10 /bin/sh does not support the new style $()
31 # command substitution and the usage of command substitution in this script
32 # is simple enough to work. Most notably, nesting backtick command
33 # substitution is tricky, but we do not do that.
35 # Get the execution path to this script and the current directory.
38 if expr "$mypath" : '.*/.*' > /dev
/null
42 IFS
="${IFS= }"; save_ifs
="$IFS"; IFS
="${IFS}:"
45 test -z "$dir" && dir
=.
46 if test -x "$dir/$mypath"
54 execpath
=`echo "$mypath" | sed -e 's@/[^/]*$@@'`
56 # Get the name by which runtest was invoked and extract the config
59 runtest
=`echo "$mypath" | sed -e 's@^.*/@@'`
60 target
=`echo "$runtest" | sed -e 's/-runtest$//'`
61 if [ "$target" != runtest
] ; then
62 target
="--target ${target}"
67 # Find the right expect binary to use. If a variable EXPECT exists, it
68 # takes precedence over all other tests. Otherwise look for a freshly
69 # built one, and then use one in the path.
71 if [ -n "$EXPECT" ] ; then
74 if [ -x "$execpath/expect" ] ; then
75 expectbin
="$execpath/expect"
83 if [ -z "$expectbin" ]; then
84 echo "ERROR: No expect shell found"
88 # This wrapper script will set up run-time library search PATHs.
90 if [ -x "$expectbin-bld.sh" ]; then
91 expectbin
="${CONFIG_SHELL-/bin/sh} $expectbin-bld.sh"
94 # Extract a few options from the option list.
100 -v|
--v|
-verb*|
--verb*) verbose
=`expr $verbose + 1` ;;
101 -D0|
--D0) debug
="-D 0" ;;
102 -D1|
--D1) debug
="-D 1" ;;
106 if expr "$verbose" \
> 0 > /dev
/null
; then
107 echo Expect binary is
"$expectbin"
110 # Find runtest.exp. First we look in its installed location,
111 # otherwise start if from the source tree.
113 # runtest.exp is found in @datadir@ (set by configure), but $execpath
114 # is @bindir@. We're assuming that:
116 # @datadir@ == @bindir@/../share
118 # @datadir@ == @bindir@/../../share
120 # .. which is a very weak assumption
122 bindir1up_check
=`echo "$execpath" | sed -e 's@/[^/]*$@/share/dejagnu@'`
123 bindir2up_check
=`echo "$execpath" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@'`
126 "${bindir1up_check}" "${bindir2up_check}" "$execpath" \
128 /usr
/local
/share
/dejagnu
; do
129 if expr "$verbose" \
> 1 > /dev
/null
; then
130 echo Looking
for "$i"/runtest.exp.
132 if [ -f "$i/runtest.exp" ] ; then
134 if expr "$verbose" \
> 0 > /dev
/null
; then
135 echo Using
"$i"/runtest.exp as main
test driver
141 # Check for an environment variable.
143 if [ -n "$DEJAGNULIBS" ] ; then
144 runpath
="$DEJAGNULIBS"
145 if expr "$verbose" \
> 0 > /dev
/null
; then
146 echo Using
"$DEJAGNULIBS"/runtest.exp as main
test driver
149 if [ -z "$runpath" ] ; then
150 echo "ERROR: runtest.exp does not exist"
154 if command -v "$expectbin" > /dev
/null
; then :; else
155 echo "ERROR: unable to find expect in the PATH"
159 # The `debug' and `target' variables are _intended_ to contain zero or two
160 # words each. Word splitting is desired here.
161 # shellcheck disable=SC2086
162 exec "$expectbin" $debug -- "$runpath"/runtest.exp
$target ${1+"$@"}