home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / devtools / dejagnu-971222 / usr / local / bin / runtest < prev    next >
Encoding:
Text File  |  1998-03-22  |  2.6 KB  |  116 lines

  1. #!/bin/sh
  2. #
  3. # runtest -- basically all this script does is find the proper expect shell and then
  4. #            run DejaGnu. <rob@cygnus.com>
  5. #
  6.  
  7. #
  8. # Get the execution path to this script and the current directory.
  9. #
  10. mypath=${0-.}
  11. if expr ${mypath} : '.*/.*' > /dev/null
  12. then
  13.     :
  14. else
  15.     IFS="${IFS=     }"; save_ifs="$IFS"; IFS="${IFS}:"
  16.     for dir in $PATH
  17.     do
  18.     test -z "$dir" && dir=.
  19.     if test -x $dir/$mypath
  20.     then
  21.         mypath=$dir/$mypath
  22.         break
  23.     fi
  24.     done
  25.     IFS="$save_ifs"
  26. fi
  27. execpath=`echo ${mypath} | sed  -e 's@/[^/]*$@@'`
  28. # rootme=`pwd`
  29.  
  30. #
  31. # get the name by which runtest was invoked and extract the config triplet
  32. #
  33. runtest=`echo ${mypath} | sed -e 's@^.*/@@'`
  34. target=`echo $runtest | sed -e 's/-runtest$//'`
  35. if [ "$target" != runtest ] ; then
  36.     target="--target ${target}"
  37. else
  38.     target=""
  39. fi
  40.  
  41. #
  42. # Find the right expect binary to use. If a variable EXPECT exists,
  43. # it takes precedence over all other tests. Otherwise look for a freshly
  44. # built one, and then use one in the path.
  45. #
  46. if [ x"$EXPECT" != x ] ; then
  47.   expectbin=$EXPECT
  48. else
  49.   if [ -x "$execpath/expect" ] ; then
  50.     expectbin=$execpath/expect
  51.   else
  52.       expectbin=expect
  53.     fi
  54. fi
  55.  
  56. # just to be safe...
  57. if [ -z "$expectbin" ]; then
  58.   echo "ERROR: No expect shell found"
  59.   exit 1
  60. fi
  61.  
  62. #
  63. # Extract a few options from the option list.
  64. #
  65. verbose=0
  66. debug=""
  67. for a in "$@" ; do
  68.   case $a in        
  69.       -v|--v|-verb*|--verb*)    verbose=`expr $verbose + 1`;;
  70.       -D0|--D0)       debug="-D 0" ;;
  71.       -D1|--D1)       debug="-D 1" ;;
  72.   esac
  73. done
  74.  
  75. if expr $verbose \> 0 > /dev/null ; then
  76.   echo Expect binary is $expectbin
  77. fi
  78.  
  79. #
  80. # find runtest.exp. First we look in it's installed location, otherwise
  81. # start if from the source tree.
  82. #
  83. # runtest.exp is found in (autoconf-configure-set) @datadir@, but
  84. # $execpath is @bindir@.  We're assuming that 
  85. #
  86. # @datadir@ == @bindir@/../share
  87. # or
  88. # @datadir@ == @bindir@/../../share
  89. #
  90. # which is a very weak assumption
  91. #
  92. for i in $execpath/../share/dejagnu $execpath/../../share/dejagnu $execpath ; do
  93.     if expr $verbose \> 1 > /dev/null ; then
  94.     echo Looking for $i/runtest.exp.
  95.     fi  
  96.     if [ -f $i/runtest.exp ] ; then
  97.     runpath=$i
  98.     if expr $verbose \> 0 > /dev/null ; then
  99.         echo Using $i/runtest.exp as main test driver
  100.     fi
  101.     fi
  102. done
  103. # check for an environment variable
  104. if [ x"$DEJAGNULIBS" != x ] ; then
  105.     runpath=$DEJAGNULIBS
  106.     if expr $verbose \> 0 > /dev/null ; then
  107.     echo Using $DEJAGNULIBS/runtest.exp as main test driver
  108.     fi
  109. fi
  110. if [ x"$runpath" = x ] ; then
  111.     echo "ERROR: runtest.exp does not exist."
  112.     exit 1
  113. fi
  114.  
  115. exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}
  116.