#!/bin/bash
#  $HeadURL: http://dione.no-ip.org/svn/ade/tags/1.7.6/lib/tests/bin/ADESTDTEST002_basic_verify_path.sh $ $LastChangedRevision: 5309 $
set -e
PROGNAME=`basename $0`
SANDPIT=`pwd`
. $(ade-config ade_include_prefix)/adetestsupport.sh

##############################################################################
#
#  LOAD TEST-SPECIFIC CONFIGURATION FILE
#
##############################################################################

[ "X$ADETEST_MODROOT" != X ] || error "'ADETEST_MODROOT' not defined"
[ -r "$ADETEST_MODROOT/tests/in/$PROGNAME" ] || error "can't read $ADETEST_MODROOT/tests/in/$PROGNAME"
. "$ADETEST_MODROOT/tests/in/$PROGNAME" || error "problem sourcing $ADETEST_MODROOT/tests/in/$PROGNAME"
[ "X$PROGRAMS" != X ] || error "'PROGRAMS' not defined"

##############################################################################
#
#  START OF TESTS
#
##############################################################################

#  Do not use the OS's native which, it *may* turn /a/b/c/../d into /a/b/d and
#  that generates inconsistent results.

echo "checking programs executed are the right ones ..."
debug 10 "PATH=$PATH"
for PROGRAM in $PROGRAMS; do
    WHICH_PROGRAM=$(which $PROGRAM) || true
    [ "X$WHICH_PROGRAM" = "X$ADETEST_MODROOT/bin/$PROGRAM" -o "X$WHICH_PROGRAM" = "X$ADETEST_MODROOT/sbin/$PROGRAM" ] || error "would not execute the right version '$PROGRAM'! (should execute '$ADETEST_MODROOT/bin/$PROGRAM', will execute '`which $PROGRAM`'; PATH is $PATH)"
done 
