4 # Variables: (* = exported)
5 # *SNMP_TMPDIR: place to put files used in testing.
6 # SNMP_TESTDIR: where the test scripts are kept.
7 # *SNMP_PERSISTENT_FILE: where to store the agent's persistent information
8 # (XXX: this should be specific to just the agent)
11 # Only allow ourselves to be eval'ed once
13 if [ "x$TESTCONF_SH_EVALED" != "xyes" ]; then
14 TESTCONF_SH_EVALED=yes
17 # Set up an NL suppressing echo command
19 case "`echo 'x\c'`" in
21 ECHO() { echo -n $*; }
24 ECHO() { echo $*\\c; }
27 echo "I don't understand your echo command ..."
32 # how verbose should we be (0 or 1)
34 if [ "x$SNMP_VERBOSE" = "x" ]; then
39 if [ "x$MIBDIRS" = "x" ]; then
40 MIBDIRS=${SNMP_BASEDIR}/../mibs
44 # Set up the path to the programs we want to use.
45 if [ "x$SNMP_PATH" = "x" ]; then
46 PATH=../agent:../apps:../../agent:../../apps:$PATH
53 # Set up temporary directory
54 if [ "x$SNMP_TMPDIR" = "x" -a "x$SNMP_HEADERONLY" != "xyes" ]; then
55 if [ "x$testnum" = "x" ] ; then
58 SNMP_TMPDIR="/tmp/snmp-test-$testnum-$$"
60 if [ -d $SNMP_TMPDIR ]; then
61 echo "$0: ERROR: $SNMP_TMPDIR already existed."
67 if [ "x$SNMP_SAVE_TMPDIR" = "x" ]; then
69 export SNMP_SAVE_TMPDIR
72 SNMP_TESTDIR="$SNMP_BASEDIR/tests"
73 SNMP_CONFIG_FILE="$SNMP_TMPDIR/snmpd.conf"
74 SNMPTRAPD_CONFIG_FILE="$SNMP_TMPDIR/snmptrapd.conf"
75 SNMP_SNMPTRAPD_LOG_FILE="$SNMP_TMPDIR/snmptrapd.log"
76 SNMP_SNMPTRAPD_PID_FILE="$SNMP_TMPDIR/snmptrapd.pid"
77 SNMP_SNMPD_PID_FILE="$SNMP_TMPDIR/snmpd.pid"
78 SNMP_SNMPD_LOG_FILE="$SNMP_TMPDIR/snmpd.log"
79 SNMP_PERSISTENT_FILE="$SNMP_TMPDIR/persistent-store.conf"
80 export SNMP_PERSISTENT_FILE
82 ## Setup default flags and ports iff not done
83 if [ "x$SNMP_FLAGS" = "x" ]; then
89 if test -x /bin/netstat ; then
91 elif test -x /usr/bin/netstat ; then
92 NETSTAT=/usr/bin/netstat
96 if test -x $NETSTAT ; then
97 if test -z "$RANDOM"; then
102 IN_USE=`$NETSTAT -a 2>/dev/null | grep "[\.:]$BASE_PORT "`
103 if [ $? -eq 0 ]; then
104 #echo "Port $BASE_PORT in use:"
106 BASE_PORT=`expr $BASE_PORT + \( $RANDOM % 100 \)`
108 #echo "Using port $BASE_PORT"
111 MAX_RETRIES=`expr $MAX_RETRIES - 1`
112 if [ $MAX_RETRIES -eq 0 ]; then
113 echo "ERROR: Could not find available port."
119 if [ "x$SNMP_SNMPD_PORT" = "x" ]; then
120 SNMP_SNMPD_PORT=$BASE_PORT
123 if [ "x$SNMP_SNMPTRAPD_PORT" = "x" ]; then
124 SNMP_SNMPTRAPD_PORT=`expr $BASE_PORT - 1`
126 export SNMP_FLAGS SNMP_SNMPD_PORT SNMP_SNMPTRAPD_PORT
128 # Make sure the agent doesn't parse any config file but what we give it.
129 # this is mainly to protect against a broken agent that doesn't
130 # properly handle combinations of -c and -C. (since I've broke it before).
131 SNMPCONFPATH="$SNMP_TMPDIR/does-not-exist"
134 fi # Only allow ourselves to be eval'ed once