Debian Codegraph @

perl/SNMP/t/conf.t

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