New upstream version 2.3.3

This commit is contained in:
Jan Wagner 2023-02-02 09:13:25 +00:00
parent 21323d25dd
commit e7bdd1c6c6
49 changed files with 13068 additions and 34075 deletions

View file

@ -21,7 +21,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
my $common_tests = 72;
my $common_tests = 73;
my $ssl_only_tests = 8;
# Check that all dependent modules are available
eval "use HTTP::Daemon 6.01;";
@ -200,6 +200,14 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
} elsif ($r->url->path eq "/chunked") {
my $chunks = ["chunked", "encoding", "test\n"];
$c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
my $chunk = shift @{$chunks};
return unless $chunk;
sleep(1);
return($chunk);
}));
} else {
$c->send_error(HTTP::Status->RC_FORBIDDEN);
}
@ -472,7 +480,8 @@ sub run_common_tests {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(2);
$result = NPTest->testCmd( $cmd );
alarm(0); };
};
alarm(0);
isnt( $@, "alarm\n", $cmd );
is( $result->return_code, 0, $cmd );
@ -482,7 +491,8 @@ sub run_common_tests {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(2);
$result = NPTest->testCmd( $cmd );
alarm(0); };
};
alarm(0);
isnt( $@, "alarm\n", $cmd );
isnt( $result->return_code, 0, $cmd );
@ -508,4 +518,9 @@ sub run_common_tests {
};
is( $@, "", $cmd );
$cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
eval {
$result = NPTest->testCmd( $cmd, 5 );
};
is( $@, "", $cmd );
}

View file

@ -12,7 +12,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
my $common_tests = 70;
my $common_tests = 71;
my $virtual_port_tests = 8;
my $ssl_only_tests = 12;
# Check that all dependent modules are available
@ -190,6 +190,14 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
} elsif ($r->url->path eq "/chunked") {
my $chunks = ["chunked", "encoding", "test\n"];
$c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
my $chunk = shift @{$chunks};
return unless $chunk;
sleep(1);
return($chunk);
}));
} else {
$c->send_error(HTTP::Status->RC_FORBIDDEN);
}
@ -497,4 +505,9 @@ sub run_common_tests {
};
is( $@, "", $cmd );
$cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
eval {
$result = NPTest->testCmd( $cmd, 5 );
};
is( $@, "", $cmd );
}

View file

@ -9,7 +9,7 @@ use NPTest;
use FindBin qw($Bin);
use POSIX qw/strftime/;
my $tests = 73;
my $tests = 81;
# Check that all dependent modules are available
eval {
require NetSNMP::OID;
@ -57,9 +57,9 @@ if ($pid) {
exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
}
END {
END {
foreach my $pid (@pids) {
if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
}
};
@ -268,3 +268,19 @@ like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" );
is($res->return_code, 2, "Multiple OIDs with some thresholds" );
like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19");
is($res->return_code, 0, "Test plain .1.3.6.1.4.1.8072.3.2.67.6 RC" );
is($res->output,'SNMP OK - 42 | iso.3.6.1.4.1.8072.3.2.67.19=42 ', "Test plain value of .1.3.6.1.4.1.8072.3.2.67.1" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 -M .1");
is($res->return_code, 0, "Test multiply RC" );
is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' , "Test multiply .1 output" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
is($res->return_code, 0, "Test multiply RC + format" );
is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
is($res->return_code, 1, "Test multiply RC + format + thresholds" );
is($res->output, 'SNMP WARNING - *4.20* | iso.3.6.1.4.1.8072.3.2.67.19=4.20;1 ', "Test multiply .1 output + format + thresholds" );

View file

@ -32,11 +32,11 @@ my $multilin5 = 'And now have fun with with this: "C:\\"
because we\'re not done yet!';
# Next are arrays of indexes (Type, initial value and increments)
# 0..16 <---- please update comment when adding/removing fields
my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR );
my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' );
# 0..19 <---- please update comment when adding/removing fields
my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER );
my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 );
# undef increments are randomized
my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef );
my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 );
# Number of elements in our OID
my $oidelts;