3 # Written by John Stoffel (jfs@fluent.com) - 10/13/1997
6 unless(grep /blib/, @INC) {
8 @INC = '../lib' if -d '../lib';
12 # to print the description...
13 $SNMP::save_descriptions = 1;
16 BEGIN {plan tests => 28}
21 use vars qw($bad_oid);
22 require "t/startagent.pl";
23 my $mib_file = 't/mib.txt';
24 my $bad_mib_file = 'mib.txt';
26 ############################# 1 ######################################
28 my $res = $SNMP::MIB{sysDescr}{label};
29 #print("Label is:$res\n");
30 ok("sysDescr" eq $res);
32 ############################# 2 ######################################
33 $res = $SNMP::MIB{sysDescr}{objectID};
34 #print("OID is: $res\n");
37 ############################# 3 ######################################
38 $res = $SNMP::MIB{sysDescr}{access};
39 #print("access is: $res\n");
40 ok($res eq 'ReadOnly');
42 ############################## 4 ###################################
43 $res = $SNMP::MIB{sysLocation}{access};
44 #$res = $SNMP::MIB{sysORIndex}{access};
45 ok($res eq 'ReadWrite');
46 ############################## 5 ###################################
47 $res = $SNMP::MIB{sysLocation}{type};
48 ok($res eq 'OCTETSTR');
49 ############################# 6 ####################################
50 $res = $SNMP::MIB{sysLocation}{status};
51 #print STDERR ("status is: $res\n");
52 #XXX: test fails due SMIv1 codes being returned intstead of SMIv2...
53 #ok($res eq 'Current');
55 ############################# 7 #################################
56 $res = $SNMP::MIB{sysORTable}{access};
57 #print("access is: $res\n");
58 ok($res eq 'NoAccess');
60 ############################# 8 ###############################
61 $res = $SNMP::MIB{sysLocation}{subID};
62 #print("subID is: $res\n");
65 ############################ 9 ##############################
66 $res = $SNMP::MIB{sysLocation}{syntax};
67 #print("syntax is: $res\n");
68 ok($res eq 'DisplayString');
70 ############################ 10 ###########################
71 $res = $SNMP::MIB{ipAdEntAddr}{syntax};
74 ########################## 11 ##########################
75 $res = $SNMP::MIB{atNetAddress}{syntax};
76 #print("syntax is: $res\n");
77 #XXX: test fails due SMIv1 codes being returned intstead of SMIv2...
78 #ok($res eq 'IPADDR');
80 ######################## 12 ###############################
81 $res = $SNMP::MIB{ipReasmOKs}{syntax};
82 #print("syntax is: $res\n");
83 ok($res eq 'COUNTER');
85 ###################### 13 ##############################
86 $res = $SNMP::MIB{sysDescr}{moduleID};
87 #print("Module ID is: $res\n");
90 ###################### 14 #########################
91 $des = $SNMP::MIB{atNetAddress}{description};
92 #print("des is --> $des\n");
96 ###################### 15 #########################
97 $res = $SNMP::MIB{atNetAddress}{nextNode};
98 #print("res is --> $res\n");
99 ok(ref($res) eq "HASH");
102 ######################## 16 #########################
103 $res = $SNMP::MIB{sysDescr}{children};
104 #print("res is --> $res\n");
105 ok(ref($res) eq "ARRAY");
107 #################### 17 #########################
109 $res = $SNMP::MIB{sysDescr}{badField};
113 ###################### 18 #########################
114 $res = $SNMP::MIB{sysDescr}{hint};
115 #print("res is --> $res\n");
116 #XXX: test fails due SMIv1 codes being returned intstead of SMIv2...
117 #ok(defined($res) && $res =~ /^255a/);
119 ###################### 19 #########################
121 $res = $SNMP::MIB{ifPhysAddress}{hint};
122 #print("res is --> $res\n");
123 #XXX: test fails due SMIv1 codes being returned intstead of SMIv2...
124 #ok(defined($res) && $res =~ /^1x:/);
128 ###################### some translate tests #######
130 ##################### 20 #########################
131 # Garbage names return Undef.
133 my $type1 = SNMP::getType($bad_name);
134 ok(!defined($type1));
135 #printf "%s %d\n", (!defined($type1)) ? "ok" :"not ok", $n++;
137 ######################################################################
138 # getType() supports numeric OIDs now
140 my $type2 = SNMP::getType($oid);
141 #XXX: test fails due SMIv1 codes being returned intstead of SMIv2...
142 #ok(defined($type2) && $type2 =~ /OCTETSTR/);
144 ######################################################################
145 # This tests that sysDescr returns a valid type.
147 my $type3 = SNMP::getType($name);
150 ######################################################################
151 # Translation tests from Name -> oid -> Name
152 ######################################################################
154 $oid_tag = SNMP::translateObj($name);
155 ok($oid eq $oid_tag);
157 ######################################################################
158 # bad name returns 'undef'
161 $oid_tag = SNMP::translateObj($bad_name);
162 ok(!defined($oid_tag));
163 ######################################################################
166 $name_tag = SNMP::translateObj($oid);
167 ok($name eq $name_tag);
169 ######################################################################
172 $name_tag = SNMP::translateObj($bad_oid);
173 ok($name ne $name_tag);
174 #printf "%s %d\n", ($name ne $name_tag) ? "ok" :"not ok", $n++;
176 ######################################################################
179 $node = $SNMP::MIB{snmpTargetAddrMMS};
181 $ranges = $node->{ranges};
182 ok($ranges and ref $ranges eq 'ARRAY');
184 ok($$ranges[0]{low} == 0);
185 ok($$ranges[0]{high} == 0);
186 ok($$ranges[1]{low} == 484);
187 ok($$ranges[1]{high} == 2147483647);