1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#!./perl
use strict;
use warnings;
BEGIN {
$ENV{'MIBS'} = '';
}
# This merely checks to see if the default_store routines work from
# read configuration files. Functionally, if this fails then it's a
# serious problem because they linked with static libraries instead of
# shared ones as the memory space is different.
use Config;
use Test;
BEGIN {plan tests => 3}
SNMP::setenv('SNMPCONFPATH', '.' . $Config{path_sep} . 't', 1);
ok(1); # just start up
use SNMP;
use NetSNMP::default_store(':all');
# should be 0, as it's un-initialized
my $myint = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
ok($myint == 0);
SNMP::init_snmp("conftest");
$myint = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
# ok, should be 1 as it's initalized by the snmp.conf config file.
ok($myint == 1);
# this is a pretty major error, so if it's not true we really really
# print a big big warning. Technically, I suspect this is a bad thing
# to do in perl tests but...
if ($myint != 1) {
die "\n\n\n" . "*" x 75 . "\nBIG PROBLEM($myint): I wasn't able to read
data from a configuration file. This likely means that you've
compiled the net-snmp package with static libraries, which can
cause real problems with the perl module. Please reconfigure your
net-snmp package for use with shared libraries (run configure with
--enable-shared)\n" . "*" x 75 . "\n\n\n\n";
}
|