| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
if [ $# = 0 ]; then |
| 4 |
echo "Usage: $0 <testscript> [<args>]" |
| 5 |
exit 1 |
| 6 |
fi |
| 7 |
|
| 8 |
if [ "x$builddir" = "x" ]; then |
| 9 |
builddir=`pwd` |
| 10 |
builddir=`dirname "$builddir"` |
| 11 |
if [ -d "${builddir}/testing" ]; then |
| 12 |
: |
| 13 |
else |
| 14 |
echo "Error: $0 must be started from inside the testing directory in the source tree." |
| 15 |
echo "The builddir environment variable can be set to point to the build directory." |
| 16 |
exit 1 |
| 17 |
fi |
| 18 |
fi |
| 19 |
|
| 20 |
if [ "x$srcdir" = "x" ]; then |
| 21 |
srcdir=`dirname "$0"` |
| 22 |
srcdir=`dirname "$srcdir"` |
| 23 |
srcdir=`dirname "$srcdir"` |
| 24 |
srcdir=`dirname "$srcdir"` |
| 25 |
if [ -d "${srcdir}/testing" ]; then |
| 26 |
: |
| 27 |
else |
| 28 |
echo "Error: $0 must be started from inside the testing directory in the source tree." |
| 29 |
echo "The builddir environment variable can be set to point to the build directory." |
| 30 |
exit 1 |
| 31 |
fi |
| 32 |
fi |
| 33 |
|
| 34 |
testscript=$1 |
| 35 |
if [ `echo "$testscript" | cut -c 1-1` != '/' ]; then |
| 36 |
testscript="`pwd`/$1" |
| 37 |
fi |
| 38 |
|
| 39 |
SNMP_BASEDIR=`dirname "$0"` |
| 40 |
if [ `echo "$SNMP_BASEDIR" | cut -c 1-1` != '/' ]; then |
| 41 |
SNMP_BASEDIR="`pwd`/$SNMP_BASEDIR" |
| 42 |
fi |
| 43 |
|
| 44 |
## prefer MIB files found in source hierarchy |
| 45 |
SNMP_PREFER_NEAR_MIBS=1 |
| 46 |
|
| 47 |
export SNMP_PREFER_NEAR_MIBS |
| 48 |
SNMP_TEST_PREFIX=${SNMP_TEST_PREFIX:=T} |
| 49 |
export SNMP_TEST_PREFIX |
| 50 |
|
| 51 |
if [ "x$DYNAMIC_ANALYZER" = "x" ]; then |
| 52 |
SNMP_SLEEP_DEFAULT=1 |
| 53 |
else |
| 54 |
SNMP_SLEEP_DEFAULT=10 |
| 55 |
fi |
| 56 |
SNMP_SLEEP=${SNMP_SLEEP:=$SNMP_SLEEP_DEFAULT} ## default seconds to sleep |
| 57 |
export SNMP_SLEEP |
| 58 |
|
| 59 |
# Find executables in source first, then build, then existing PATH. |
| 60 |
## Add to PATH if a binary is found. |
| 61 |
|
| 62 |
SNMP_UPDIR=${builddir} ## build directory |
| 63 |
bf=snmpget |
| 64 |
if [ -x "$SNMP_UPDIR/$bf" ] ; then |
| 65 |
PATH=$SNMP_UPDIR:$PATH |
| 66 |
else |
| 67 |
for dd in apps bin ; do |
| 68 |
bf=$dd/snmpget |
| 69 |
if [ -x "$SNMP_UPDIR/$bf" ] ; then |
| 70 |
PATH=$SNMP_UPDIR/$dd:$PATH |
| 71 |
break |
| 72 |
fi |
| 73 |
done |
| 74 |
fi |
| 75 |
for dd in agent bin sbin ; do |
| 76 |
bf=$dd/snmpd |
| 77 |
if [ -x "$SNMP_UPDIR/$bf" ] ; then |
| 78 |
PATH=$SNMP_UPDIR/$dd:$PATH |
| 79 |
break |
| 80 |
fi |
| 81 |
done |
| 82 |
|
| 83 |
bf=include/net-snmp/net-snmp-config.h |
| 84 |
if [ ! -s "$SNMP_UPDIR/$bf" ] ; then |
| 85 |
echo "No \"$bf\" in $SNMP_UPDIR . Some tests will be skipped" |
| 86 |
fi |
| 87 |
unset bf |
| 88 |
|
| 89 |
# Run from the test scripts directory. |
| 90 |
cd "${SNMP_BASEDIR}" || return $? |
| 91 |
export SNMP_BASEDIR |
| 92 |
|
| 93 |
PATH=${SNMP_BASEDIR}:$PATH |
| 94 |
export PATH |
| 95 |
SNMP_PATH=yes |
| 96 |
export SNMP_PATH |
| 97 |
|
| 98 |
export SNMP_UPDIR |
| 99 |
|
| 100 |
# |
| 101 |
# Source the testing configuration file |
| 102 |
# |
| 103 |
|
| 104 |
testnum="`basename $testscript`" |
| 105 |
|
| 106 |
. simple_TESTCONF.sh |
| 107 |
|
| 108 |
. simple_eval_tools.sh |
| 109 |
|
| 110 |
cd `dirname "$testscript"` || return $? |
| 111 |
PATH=`pwd`:$PATH |
| 112 |
export PATH |
| 113 |
|
| 114 |
. `basename "$testscript"` |
| 115 |
|
| 116 |
FINISHED |