1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
4 ######################### We start with some black magic to print on failure.
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
9 BEGIN { $| = 1; print "1..5\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use NetSNMP::agent (':all');
12 use NetSNMP::default_store (':all');
13 use NetSNMP::agent::default_store (':all');
14 use NetSNMP::ASN (':all');
16 #use NetSNMP::agent (':all');
21 ######################### End of black magic.
25 return "ok " . $_[1] . "\n";
27 return "not ok ". $_[1] ."\n";
31 # Insert your test code below (better if it prints "ok 13"
32 # (correspondingly "not ok 13") depending on the success of chunk 13
35 print it((MODE_GET == 0xa0 &&
36 MODE_GETNEXT == 0xa1 &&
37 MODE_GETBULK == 0xa5 &&
38 MODE_SET_BEGIN == -1 &&
39 MODE_SET_RESERVE1 == 0 &&
40 MODE_SET_RESERVE2 == 1 &&
41 MODE_SET_ACTION == 2 &&
42 MODE_SET_COMMIT == 3 &&
44 MODE_SET_UNDO == 5), 2);
46 my $agent = new NetSNMP::agent('Name' => 'test',
50 $regitem = $agent->register("test_reg", ".1.3.6.1.8888", \&testsub);
51 print it($regitem, 4);
52 #print STDERR $regitem,":",ref($regitem),"\n";
53 print it(ref($regitem) eq "netsnmp_handler_registrationPtr", 5);
57 print netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
58 NETSNMP_DS_AGENT_PORTS), "\n";
59 $agent->agent_check_and_process(1);
60 print netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
61 NETSNMP_DS_AGENT_PORTS), "\n";
62 print "got something\n";
66 $x = NetSNMP::agent::handler_registration::new("hi",\&testsub,".1.3.6.1.999");
67 print ((ref($x) eq "handler_registrationPtr") ? "ok 2\n" : "not ok 2\n");
69 print (($x->register() == 0) ? "ok 3\n" : "not ok 3\n");
71 my $y = NetSNMP::agent::register_mib("me",\&testsub,".1.3.6.1.8888");
73 NetSNMP::agent::agent_check_and_process();
74 print "got something\n";
79 print STDERR "in perl handler sub\n";
80 print STDERR " args: ", join(", ", @_), "\n";
81 print STDERR " dumped args: ", Dumper(@_);
82 $oid= $_[3]->getOID();
83 print STDERR " request oid: ", ref($oid), " -> ", $oid, "\n";
84 print STDERR " mode: ", $_[2]->getMode(),"\n";
85 $_[3]->setOID(".1.3.6.1.8888.1");
86 $_[3]->setValue(2, 42);
87 $_[3]->setValue(ASN_INTEGER, 42);
88 print STDERR " oid: ", $_[3]->getOID(),"\n";
89 print STDERR " ref: ", ref($_[3]),"\n";
90 print STDERR " val: ", $_[3]->getValue(),"\n";