| 1 |
#!./perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
BEGIN { |
| 7 |
eval "use Cwd qw(abs_path)"; |
| 8 |
} |
| 9 |
|
| 10 |
use File::Spec; |
| 11 |
use Test; |
| 12 |
BEGIN {plan tests => 7} |
| 13 |
use SNMP; |
| 14 |
|
| 15 |
require "t/startagent.pl"; |
| 16 |
use vars qw($mibdir); |
| 17 |
|
| 18 |
$SNMP::verbose = 0; |
| 19 |
|
| 20 |
my $mib_file = File::Spec->catfile('t', 'mib.txt'); |
| 21 |
my $junk_mib_file = 'mib.txt'; |
| 22 |
|
| 23 |
my $mibfile1 = File::Spec->catfile($mibdir, "TCP-MIB.txt"); |
| 24 |
my @mibdir = ("$mibdir"); |
| 25 |
my $mibfile2 = File::Spec->catfile($mibdir, "IPV6-TCP-MIB.txt"); |
| 26 |
|
| 27 |
|
| 28 |
###################################################################### |
| 29 |
# See if we can find a mib to use, return of 0 means the file wasn't |
| 30 |
# found or isn't readable. |
| 31 |
|
| 32 |
my $res = SNMP::setMib($junk_mib_file,1); |
| 33 |
ok(defined(!$res)); |
| 34 |
###################################################################### |
| 35 |
# Now we give the right name |
| 36 |
|
| 37 |
$res = SNMP::setMib($mib_file,1); |
| 38 |
ok(defined($res)); |
| 39 |
###################################################################### |
| 40 |
# See if we can find a mib to use |
| 41 |
|
| 42 |
$res = SNMP::setMib($mib_file,0); |
| 43 |
ok(defined($res)); |
| 44 |
######################## 4 ################################ |
| 45 |
# add a mib dir |
| 46 |
|
| 47 |
$res = SNMP::addMibDirs($mibdir[0]); |
| 48 |
|
| 49 |
SNMP::loadModules("IP-MIB", "IF-MIB", "IANAifType-MIB", "RFC1213-MIB"); |
| 50 |
#SNMP::unloadModules(RMON-MIB); |
| 51 |
#etherStatsDataSource shouldn't be found. |
| 52 |
#present only in 1271 & RMON-MIB. |
| 53 |
# |
| 54 |
# XXX: because we can't count on user .conf files, we should turn off |
| 55 |
# support for them (maybe set SNMPCONFPATH at the top of this |
| 56 |
# script?). But for the mean time just search for a bogus node that |
| 57 |
# will never exist. |
| 58 |
$res = $SNMP::MIB{bogusetherStatsDataSource}; |
| 59 |
|
| 60 |
ok(!defined($res)); |
| 61 |
|
| 62 |
######################## 5 ############################ |
| 63 |
# add mib file |
| 64 |
|
| 65 |
my $res1 = SNMP::addMibFiles($mibfile1); |
| 66 |
ok(defined($res1)); |
| 67 |
my $res2 = SNMP::addMibFiles($mibfile2); |
| 68 |
ok(defined($res2)); |
| 69 |
|
| 70 |
$res = $SNMP::MIB{ipv6TcpConnState}{moduleID}; |
| 71 |
|
| 72 |
ok($res =~ /^IPV6-TCP-MIB/); |
| 73 |
################################################# |
| 74 |
|
| 75 |
snmptest_cleanup(); |
| 76 |
|