Fix INADDR_NONE value (for systems which don't define it).
[monitoring-plugins.git] / plugins / t / check_hpjd.t
blob2fe5600055434d2b84b7a56daf11bfd0cc782723
1 #! /usr/bin/perl -w -I ..
3 # HP JetDirect Test via check_hpjd
5 # $Id$
8 use strict;
9 use Test::More;
10 use NPTest;
12 plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
14 plan tests => 5;
16 my $successOutput = '/^Printer ok - /';
17 my $failureOutput = '/Timeout: No [Rr]esponse from /';
19 my $host_tcp_hpjd = getTestParameter(
20 "NP_HOST_TCP_HPJD",
21 "A host (usually a printer) providing the HP-JetDirect Services"
24 my $host_nonresponsive = getTestParameter(
25 "NP_HOST_NONRESPONSIVE",
26 "The hostname of system not responsive to network requests",
27 "10.0.0.1",
30 my $hostname_invalid = getTestParameter(
31 "NP_HOSTNAME_INVALID",
32 "An invalid (not known to DNS) hostname",
33 "nosuchhost",
36 my $res;
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" );
45 $res = NPTest->testCmd("./check_hpjd $host_nonresponsive");
46 cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
47 like ( $res->output, $failureOutput, "Output OK" );
49 $res = NPTest->testCmd("./check_hpjd $hostname_invalid");
50 cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");