summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabrist <abrist@nagios.com>2014-01-28 00:06:46 (GMT)
committerJan Wagner <waja@cyconet.org>2014-07-20 21:36:05 (GMT)
commit479509ad59cdb05894ab39206157e6dd3f4e7faf (patch)
tree103c2037486ca6aec67f7b7fa2043b6426db2edc
parent8e187dfefef1397b1f87a1008e162e46a74f4782 (diff)
downloadmonitoring-plugins-479509a.tar.gz
added tests for check_hpjd port options
--- Closes #1160 and #973
-rw-r--r--plugins/t/check_hpjd.t35
1 files changed, 28 insertions, 7 deletions
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t
index 10ded54..4d64852 100644
--- a/plugins/t/check_hpjd.t
+++ b/plugins/t/check_hpjd.t
@@ -10,7 +10,6 @@ use NPTest;
10 10
11plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); 11plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
12 12
13plan tests => 5;
14 13
15my $successOutput = '/^Printer ok - /'; 14my $successOutput = '/^Printer ok - /';
16my $failureOutput = '/Timeout: No [Rr]esponse from /'; 15my $failureOutput = '/Timeout: No [Rr]esponse from /';
@@ -20,31 +19,53 @@ my $host_tcp_hpjd = getTestParameter(
20 "A host (usually a printer) providing the HP-JetDirect Services" 19 "A host (usually a printer) providing the HP-JetDirect Services"
21 ); 20 );
22 21
22my $host_hpjd_port_invalid = getTestParameter(
23 "NP_HOST_HPJD_PORT_INVALID",
24 "A port that HP-JetDirect Services is not listening on",
25 "162"
26 );
27
28my $host_hpjd_port_valid = getTestParameter(
29 "NP_HOST_HPJD_PORT_VALID",
30 "The port that HP-JetDirect Services is currently listening on",
31 "161"
32 );
33
23my $host_nonresponsive = getTestParameter( 34my $host_nonresponsive = getTestParameter(
24 "NP_HOST_NONRESPONSIVE", 35 "NP_HOST_NONRESPONSIVE",
25 "The hostname of system not responsive to network requests", 36 "The hostname of system not responsive to network requests",
26 "10.0.0.1", 37 "10.0.0.1"
27 ); 38 );
28 39
29my $hostname_invalid = getTestParameter( 40my $hostname_invalid = getTestParameter(
30 "NP_HOSTNAME_INVALID", 41 "NP_HOSTNAME_INVALID",
31 "An invalid (not known to DNS) hostname", 42 "An invalid (not known to DNS) hostname",
32 "nosuchhost", 43 "nosuchhost"
33 ); 44 );
34 45
46my $tests = $host_tcp_hpjd ? 9 : 5;
47plan tests => $tests;
35my $res; 48my $res;
36 49
37SKIP: { 50SKIP: {
38 skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd; 51 skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd;
39 $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd"); 52 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd");
40 cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" ); 53 cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding" );
41 like ( $res->output, $successOutput, "Output correct" ); 54 like ( $res->output, $successOutput, "Output correct" );
55
56 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_valid");
57 cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding on port $host_hpjd_port_valid" );
58 like ( $res->output, $successOutput, "Output correct" );
59
60 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_invalid");
61 cmp_ok( $res->return_code, 'eq', 2, "Jetdirect not responding on port $host_hpjd_port_invalid" );
62 like ( $res->output, $failureOutput, "Output correct" );
42} 63}
43 64
44$res = NPTest->testCmd("./check_hpjd $host_nonresponsive"); 65$res = NPTest->testCmd("./check_hpjd -H $host_nonresponsive");
45cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); 66cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
46like ( $res->output, $failureOutput, "Output OK" ); 67like ( $res->output, $failureOutput, "Output OK" );
47 68
48$res = NPTest->testCmd("./check_hpjd $hostname_invalid"); 69$res = NPTest->testCmd("./check_hpjd -H $hostname_invalid");
49cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); 70cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");
50 71