check_hpjd.t 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # HP JetDirect Test via check_hpjd
  4. #
  5. # $Id$
  6. #
  7. use strict;
  8. use Test::More;
  9. use NPTest;
  10. plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
  11. plan tests => 5;
  12. my $successOutput = '/^Printer ok - /';
  13. my $failureOutput = '/Timeout: No [Rr]esponse from /';
  14. my $host_tcp_hpjd = getTestParameter(
  15. "NP_HOST_TCP_HPJD",
  16. "A host (usually a printer) providing the HP-JetDirect Services"
  17. );
  18. my $host_nonresponsive = getTestParameter(
  19. "NP_HOST_NONRESPONSIVE",
  20. "The hostname of system not responsive to network requests",
  21. "10.0.0.1",
  22. );
  23. my $hostname_invalid = getTestParameter(
  24. "NP_HOSTNAME_INVALID",
  25. "An invalid (not known to DNS) hostname",
  26. "nosuchhost",
  27. );
  28. my $res;
  29. SKIP: {
  30. skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd;
  31. $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd");
  32. cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" );
  33. like ( $res->output, $successOutput, "Output correct" );
  34. }
  35. $res = NPTest->testCmd("./check_hpjd $host_nonresponsive");
  36. cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
  37. like ( $res->output, $failureOutput, "Output OK" );
  38. $res = NPTest->testCmd("./check_hpjd $hostname_invalid");
  39. cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");