diff options
author | abrist <abrist@nagios.com> | 2014-01-28 00:06:46 (GMT) |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-07-20 21:36:05 (GMT) |
commit | 479509ad59cdb05894ab39206157e6dd3f4e7faf (patch) | |
tree | 103c2037486ca6aec67f7b7fa2043b6426db2edc /plugins | |
parent | 8e187dfefef1397b1f87a1008e162e46a74f4782 (diff) | |
download | monitoring-plugins-479509ad59cdb05894ab39206157e6dd3f4e7faf.tar.gz |
added tests for check_hpjd port options
---
Closes #1160 and #973
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/t/check_hpjd.t | 35 |
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 | ||
11 | plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); | 11 | plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); |
12 | 12 | ||
13 | plan tests => 5; | ||
14 | 13 | ||
15 | my $successOutput = '/^Printer ok - /'; | 14 | my $successOutput = '/^Printer ok - /'; |
16 | my $failureOutput = '/Timeout: No [Rr]esponse from /'; | 15 | my $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 | ||
22 | my $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 | |||
28 | my $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 | |||
23 | my $host_nonresponsive = getTestParameter( | 34 | my $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 | ||
29 | my $hostname_invalid = getTestParameter( | 40 | my $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 | ||
46 | my $tests = $host_tcp_hpjd ? 9 : 5; | ||
47 | plan tests => $tests; | ||
35 | my $res; | 48 | my $res; |
36 | 49 | ||
37 | SKIP: { | 50 | SKIP: { |
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"); |
45 | cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); | 66 | cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); |
46 | like ( $res->output, $failureOutput, "Output OK" ); | 67 | like ( $res->output, $failureOutput, "Output OK" ); |
47 | 68 | ||
48 | $res = NPTest->testCmd("./check_hpjd $hostname_invalid"); | 69 | $res = NPTest->testCmd("./check_hpjd -H $hostname_invalid"); |
49 | cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); | 70 | cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); |
50 | 71 | ||