#! /bin/echo this_file_should_be_sourced,_not_executed
#  -*- Mode: Shell-script -*-
# ----------------------------------------------------------------------
# defs --- define the environment for autogen tests.
#
# Author:            Bruce Korb <bkorb@gnu.org>
# Time-stamp:        "2006-09-23 19:38:20 bkorb"
# Last Modified:     $Date: 2006/09/24 02:59:00 $
#            by: bkorb
#
# $Id: defs,v 4.3 2006/09/24 02:59:00 bkorb Exp $
# ----------------------------------------------------------------------

# Make sure srcdir is an absolute path.  Supply the variable
# if it does not exist.  We want to be able to run the tests
# stand-alone!!
#
srcdir=${srcdir-.}
if test ! -d $srcdir ; then
    echo "defs: installation error" 1>&2
    exit 1
fi

#  IF the source directory is a Unix or a DOS root directory, ...
#
case "$srcdir" in
    /* | [A-Za-z]:\\*) ;;
    *) srcdir=`\cd $srcdir && pwd` ;;
esac

lo_dir=`cd ../../autoopts && pwd`
test -d ${lo_dir}/.libs && lo_dir=${lo_dir}/.libs
LD_LIBRARY_PATH=${lo_dir}:${LD_LIBRARY_PATH-/dev/null}
export LD_LIBRARY_PATH

progname=`echo "$0" | sed 's,^.*/,,'`
testname=`echo "$progname" | sed 's,\..*$,,'`
testsubdir=${testsubdir-testdir}

# User can set VERBOSE to prevent output redirection
case x$VERBOSE in
    xNO | xno | x0 | x)
        exec > /dev/null 2>&1
        rm -rf $testsubdir
        ;;
esac

test -d $testsubdir || mkdir $testsubdir
cd $testsubdir
if test $? != 0 ; then
    echo "Cannot make or change into $testsubdir"
    exit 1
fi

echo "=== Running $progname"

# A standard failure function
failure()
{
  cd ${testsubdir}
  test -d ../FAILURES || mkdir ../FAILURES
  l=`echo *`
  ( \cd ../FAILURES ; rm -f $l )
  mv -f * ../FAILURES
  echo "$*"
  exit 1
}
# defs ends here
