summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_hpjd.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_hpjd.t')
-rw-r--r--plugins/t/check_hpjd.t59
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
8use strict; 8use strict;
9use Test; 9use Test::More;
10use NPTest; 10use NPTest;
11 11
12use vars qw($tests); 12plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
13BEGIN {$tests = 5; plan tests => $tests} 13
14plan tests => 5;
14 15
15my $successOutput = '/^Printer ok - /'; 16my $successOutput = '/^Printer ok - /';
16my $failureOutput = '/Timeout: No [Rr]esponse from /'; 17my $failureOutput = '/Timeout: No [Rr]esponse from /';
17 18
18my $host_tcp_hpjd = getTestParameter( "host_tcp_hpjd", "NP_HOST_TCP_HPJD", undef, 19my $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"
21my $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 24my $host_nonresponsive = getTestParameter(
24my $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",
27my $t; 28 );
28 29
29if ( -x "./check_hpjd" ) 30my $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
35else 36my $res;
36{ 37
37 $t += skipMissingCmd( "./check_hpjd", $tests ); 38SKIP: {
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
40exit(0) if defined($Test::Harness::VERSION); 45$res = NPTest->testCmd("./check_hpjd $host_nonresponsive");
41exit($tests - $t); 46cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
47like ( $res->output, $failureOutput, "Output OK" );
48
49$res = NPTest->testCmd("./check_hpjd $hostname_invalid");
50cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");
42 51