# BRCM_VERSION=3
[bcm963xx.git] / userapps / opensource / net-snmp / testing / tests / T113agentxtrap
1 #!/bin/sh
2
3 . ../eval_tools.sh
4
5 HEADER AgentX trap sending support
6
7 SKIPIFNOT USING_AGENTX_MODULE
8 SKIPIFNOT USING_EXAMPLES_EXAMPLE_MODULE
9
10 #
11 # Begin test
12 #
13
14 # start the trap demon
15 STARTTRAPD
16
17 # standard V3 configuration for initial user
18 . ./Sv3config
19 # configure the trap receiver.
20 CONFIGAGENT trapsink localhost public $SNMP_SNMPTRAPD_PORT
21
22 # Start the agent without initializing the example mib.
23 ORIG_AGENT_FLAGS="$AGENT_FLAGS -x $SNMP_TMPDIR/agentx_socket"
24 AGENT_FLAGS="$ORIG_AGENT_FLAGS -I -example"
25 STARTAGENT
26
27 # test to see that the current agent doesn't support the example mib
28 CAPTURE "snmpget -On -t 3 $SNMP_FLAGS -v 3 -a MD5 -A initial_test_pass_auth -l anp -u initial udp:localhost:$SNMP_SNMPD_PORT ucdavis.254.1.0"
29
30 CHECK "No Such Object"
31
32 if test "$snmp_last_test_result" = 1; then
33   # test the AgentX subagent by first running it...
34
35   SNMP_SNMPD_PID_FILE_ORIG=$SNMP_SNMPD_PID_FILE
36   SNMP_SNMPD_LOG_FILE_ORIG=$SNMP_SNMPD_LOG_FILE
37   SNMP_SNMPD_PID_FILE=$SNMP_SNMPD_PID_FILE.num2
38   SNMP_SNMPD_LOG_FILE=$SNMP_SNMPD_LOG_FILE.num2
39   AGENT_FLAGS="$ORIG_AGENT_FLAGS -X -I example -Dadd"
40   SNMP_CONFIG_FILE="$SNMP_TMPDIR/bogus.conf"
41
42   STARTAGENT
43
44   # test to see that the agent now supports the example mib
45   CAPTURE "snmpget -On $SNMP_FLAGS -t 5 -v 3 -a MD5 -A initial_test_pass_auth -l anp -u initial udp:localhost:$SNMP_SNMPD_PORT ucdavis.254.1.0"
46
47   CHECK "life the universe and everything"
48
49   if test "$snmp_last_test_result" = 1; then
50
51     # test to see that the agent now sends a trap from the exmaple mib
52     CAPTURE "snmpset -On -r 0 -t 3 $SNMP_FLAGS -v 3 -a MD5 -A initial_test_pass_auth -l anp -u initial udp:localhost:$SNMP_SNMPD_PORT ucdavis.254.8.0 i 1"
53
54     CHECKTRAPD "life the universe and everything"
55
56   fi
57
58   # stop the subagent
59   STOPAGENT
60
61   SNMP_SNMPD_PID_FILE=$SNMP_SNMPD_PID_FILE_ORIG
62   SNMP_SNMPD_LOG_FILE=$SNMP_SNMPD_LOG_FILE_ORIG
63 fi
64
65 # stop the master agent
66 STOPAGENT
67
68 # stop the trap demon
69 STOPTRAPD
70
71 # all done (whew)
72 FINISHED