diff options
Diffstat (limited to 'plugins/t/check_hpjd.t')
-rw-r--r-- | plugins/t/check_hpjd.t | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t index b749c778..2fe56000 100644 --- a/plugins/t/check_hpjd.t +++ b/plugins/t/check_hpjd.t | |||
@@ -6,37 +6,46 @@ | |||
6 | # | 6 | # |
7 | 7 | ||
8 | use strict; | 8 | use strict; |
9 | use Test; | 9 | use Test::More; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | use vars qw($tests); | 12 | plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); |
13 | BEGIN {$tests = 5; plan tests => $tests} | 13 | |
14 | plan tests => 5; | ||
14 | 15 | ||
15 | my $successOutput = '/^Printer ok - /'; | 16 | my $successOutput = '/^Printer ok - /'; |
16 | my $failureOutput = '/Timeout: No [Rr]esponse from /'; | 17 | my $failureOutput = '/Timeout: No [Rr]esponse from /'; |
17 | 18 | ||
18 | my $host_tcp_hpjd = getTestParameter( "host_tcp_hpjd", "NP_HOST_TCP_HPJD", undef, | 19 | my $host_tcp_hpjd = getTestParameter( |
19 | "A host (usually a printer) providing the HP-JetDirect Services" ); | 20 | "NP_HOST_TCP_HPJD", |
20 | 21 | "A host (usually a printer) providing the HP-JetDirect Services" | |
21 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | 22 | ); |
22 | "The hostname of system not responsive to network requests" ); | 23 | |
23 | 24 | my $host_nonresponsive = getTestParameter( | |
24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | 25 | "NP_HOST_NONRESPONSIVE", |
25 | "An invalid (not known to DNS) hostname" ); | 26 | "The hostname of system not responsive to network requests", |
26 | 27 | "10.0.0.1", | |
27 | my $t; | 28 | ); |
28 | 29 | ||
29 | if ( -x "./check_hpjd" ) | 30 | my $hostname_invalid = getTestParameter( |
30 | { | 31 | "NP_HOSTNAME_INVALID", |
31 | $t += checkCmd( "./check_hpjd $host_tcp_hpjd", 0, $successOutput ); | 32 | "An invalid (not known to DNS) hostname", |
32 | $t += checkCmd( "./check_hpjd $host_nonresponsive", 2, $failureOutput ); | 33 | "nosuchhost", |
33 | $t += checkCmd( "./check_hpjd $hostname_invalid", 3 ); | 34 | ); |
34 | } | 35 | |
35 | else | 36 | my $res; |
36 | { | 37 | |
37 | $t += skipMissingCmd( "./check_hpjd", $tests ); | 38 | SKIP: { |
39 | skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd; | ||
40 | $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd"); | ||
41 | cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" ); | ||
42 | like ( $res->output, $successOutput, "Output correct" ); | ||
38 | } | 43 | } |
39 | 44 | ||
40 | exit(0) if defined($Test::Harness::VERSION); | 45 | $res = NPTest->testCmd("./check_hpjd $host_nonresponsive"); |
41 | exit($tests - $t); | 46 | cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); |
47 | like ( $res->output, $failureOutput, "Output OK" ); | ||
48 | |||
49 | $res = NPTest->testCmd("./check_hpjd $hostname_invalid"); | ||
50 | cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); | ||
42 | 51 | ||