Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / perl / SNMP / t / getnext.t
1 #!./perl
2
3 BEGIN {
4     unless(grep /blib/, @INC) {
5         chdir 't' if -d 't';
6         @INC = '../lib' if -d '../lib';
7     }
8 }
9
10 use Test;
11 BEGIN { plan tests => 9 }
12 use SNMP;
13 use vars qw($agent_port $comm $agent_host);
14 require "t/startagent.pl";
15
16
17 my $junk_oid = ".1.3.6.1.2.1.1.1.1.1.1";
18 my $oid = '.1.3.6.1.2.1.1.1';
19 my $junk_name = 'fooDescr';
20 my $junk_host = 'no.host.here';
21 my $name = "gmarzot\@nortelnetworks.com";
22
23 $SNMP::debugging = 0;
24 my $n = 9;  # Number of tests to run
25
26 #print "1..$n\n";
27 #if ($n == 0) { exit 0; }
28
29 # create list of varbinds for GETS, val field can be null or omitted
30 my $vars = new SNMP::VarList (
31                            ['sysDescr', '0', ''],
32                            ['sysContact', '0'],
33                            ['sysName', '0'],
34                            ['sysLocation', '0'],
35                            ['sysServices', '0'],
36                            ['ifNumber', '0'],
37                            ['ifDescr', '1'],
38                            ['ifSpeed', '1'],
39                           );
40
41
42 ##############################  1  #####################################
43 # Fire up a session.
44     my $s1 =
45     new SNMP::Session (DestHost=>$agent_host,Version=>1,Community=>$comm,RemotePort=>$agent_port);
46     ok(defined($s1));
47
48 #############################  2  #######################################
49 # Try getnext on sysDescr.0
50
51 my $next = $s1->getnext('sysDescr.0');
52 #print ("The next OID is : $next\n");
53 ok($s1->{ErrorStr} eq '');
54 #print STDERR "Error string1 = $s1->{ErrorStr}:$s1->{ErrorInd}\n";
55 #print("\n");
56
57 ###########################  3  ########################################
58 #$v1 = $s1->getnext('sysLocation.0');
59 #print ("The next OID is : $v1\n");
60 my $v2 = $s1->getnext('sysServices.0');
61 #print ("The next OID is : $v2\n");
62 ok($s1->{ErrorStr} eq '');
63 #print STDERR "Error string2 = $s1->{ErrorStr}:$s1->{ErrorInd}\n";
64 #print("\n");
65
66
67 ############################  4  #######################################
68 # try it on an unknown OID
69 my $v3 = $s1->getnext('Srivathsan.0');
70 #print ("The unknown  OID is : $v3\n");
71 ok($s1->{ErrorStr} =~ /^Unknown/);
72 #print STDERR "Error string5 = $s1->{ErrorStr}:$s1->{ErrorInd}\n";
73 #print("\n");
74 ############################# 5  #######################################
75 # On a non-accessible value
76 #my $kkk = $s1->getnext('vacmSecurityName.1');
77 #print("kkk is $kkk\n");
78 #ok($s1->{ErrorInd} != 0);
79 #print STDERR "Error string5 = $s1->{ErrorStr}:$s1->{ErrorInd}\n";
80 #print("\n");
81
82 #############################  6  ####################################
83 # We should get back sysDescr.0 here.
84 my $var = new SNMP::Varbind(['sysDescr']);
85 my $res2 = $s1->getnext($var);
86 #print("res2 is : $res2\n");
87 ok((not $s1->{ErrorStr} and not $s1->{ErrorInd}));
88 ok((defined $var->iid and $var->iid eq 0));
89 ok((defined $var->val and $var->val eq $res2));
90
91 #############################  7  ######################################
92 # get the next one after that as well for a second check
93 my $res3 = $s1->getnext($var);
94 #print("res3 is : $res3\n");
95 ok((defined $var->tag and $var->tag eq 'sysObjectID'));
96 ok((defined $var->val and $var->val eq $res3));
97
98
99     snmptest_cleanup();