diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-03-24 16:13:40 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-03-24 16:13:40 +0000 |
commit | f6bfe34a3e3c8c46c2cb5fc728773c2f4b191c8f (patch) | |
tree | 21b284bdf8a01667e95f82ca7e74e8d738e3ce83 /plugins/t/check_hpjd.t | |
parent | 8c3e7428ae21999e813b288c3d55d3870c9ef258 (diff) | |
download | monitoring-plugins-f6bfe34a3e3c8c46c2cb5fc728773c2f4b191c8f.tar.gz |
Tests converted to new style
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1354 f882894a-f735-0410-b71e-b25c423dba1c
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 | ||