dejagnu   [plain text]


#! /bin/sh
#
# This scripts should start a fully compatible DejaGnu runtest
# application using [incr Expect] and Classes compatible with [incr Tcl]
#
#   Copyright (C) 1998 jotOmega dsc, Inc.

# This file is part of BlueGnu.
# It asumes that the iexpect program is on your PATH
#

#
# Get the execution path to this script
#
execpath=`echo ${0-.} | sed  -e 's@/[^/]*$@@'`

#
# get the name by which dejagnu was invoked and extract the config triplet
#
dejagnu=`echo ${0-.} | sed -e 's@^.*/@@'`
target=`echo $dejagnu | sed -e 's/-dejagnu$//'`
if [ "$target" != dejagnu ] ; then
    target="--target ${target}"
else
    target=""
fi

#
# Find the right expect binary to use. If a variable EXPECT exists,
# it takes precedence over all other tests. Otherwise look for a freshly
# built one, and then use one in the path.
#
if [ x"$EXPECT" != x ] ; then
  expectbin=$EXPECT
else
  if [ -x "$execpath/expect" ] ; then
    expectbin=$execpath/iexpect
  else
      expectbin=iexpect
    fi
fi

# just to be safe...
if [ -z "$expectbin" ]; then
  echo "ERROR: No $expectbin shell found"
  exit 1
fi

#
# Extract a few options from the option list.
#
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

#
# find dejagnu.itcl. First we look in it's installed location, otherwise
# start if from the source tree.
#
for i in $execpath/../lib/bluegnu $execpath ; do
    if expr $verbose \> 1 > /dev/null ; then
	echo Looking for $i/dejagnu.itcl.
    fi  
    if [ -f $i/dejagnu.itcl ] ; then
	runpath=$i
	if expr $verbose \> 0 > /dev/null ; then
	    echo Using $i/dejagnu.itcl as main test driver
	fi
    fi
done
# check for an environment variable
if [ x"$BLUEGNULIBS" != x ] ; then
    runpath=$BLUEGNULIBS
    if expr $verbose \> 0 > /dev/null ; then
	echo Using $BLUEGNULIBS/dejagnu.itcl as main test driver
    fi
fi
if [ x"$runpath" = x ] ; then
    echo "ERROR: dejagnu.itcl does not exist."
    exit 1
fi

exec $expectbin $debug -- $runpath/dejagnu.itcl $target ${1+"$@"}