check_hpjd.t 1.2 KB

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