Mention GNU Automake manual for more information
[dejagnu.git] / runtest
blobee6880c3b14636043b024d8a6dacd200c4c83e8a
1 #!/bin/sh
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.
26 mypath=${0-.}
27 if expr "$mypath" : '.*/.*' > /dev/null
28 then
30 else
31 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
32 for dir in $PATH
34 test -z "$dir" && dir=.
35 if test -x "$dir/$mypath"
36 then
37 mypath="$dir/$mypath"
38 break
40 done
41 IFS="$save_ifs"
43 execpath=$(echo "$mypath" | sed -e 's@/[^/]*$@@')
45 # Get the name by which runtest was invoked and extract the config
46 # triplet.
48 runtest=$(echo "$mypath" | sed -e 's@^.*/@@')
49 target=$(echo "$runtest" | sed -e 's/-runtest$//')
50 if [ "$target" != runtest ] ; then
51 target="--target ${target}"
52 else
53 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
61 expectbin="$EXPECT"
62 else
63 if [ -x "$execpath/expect" ] ; then
64 expectbin="$execpath/expect"
65 else
66 expectbin=expect
70 # Just to be safe ..
72 if [ -z "$expectbin" ]; then
73 echo "ERROR: No expect shell found"
74 exit 1
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.
85 verbose=0
86 debug=""
87 for a in "$@" ; do
88 case $a in
89 -v|--v|-verb*|--verb*) verbose=$((verbose + 1)) ;;
90 -D0|--D0) debug="-D 0" ;;
91 -D1|--D1) debug="-D 1" ;;
92 esac
93 done
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
106 # or
107 # @datadir@ == @bindir@/../../share
109 # .. which is a very weak assumption
111 for i in \
112 $(echo "$execpath" | sed -e 's@/[^/]*$@/share/dejagnu@') \
113 $(echo "$execpath" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@') \
114 "$execpath" \
115 /usr/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
121 runpath="$i"
122 if expr "$verbose" \> 0 > /dev/null ; then
123 echo Using "$i"/runtest.exp as main test driver
125 break
127 done
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"
139 exit 1
142 if ! command -v "$expectbin" > /dev/null ; then
143 echo "ERROR: unable to find expect in the PATH"
144 exit 1
147 exec "$expectbin" $debug -- "$runpath"/runtest.exp $target ${1+"$@"}