050-misc.t 943 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. BEGIN {
  5. use File::Basename;
  6. use lib (dirname(__FILE__));
  7. }
  8. use Test::More tests => 6;
  9. use nrpe;
  10. my @output;
  11. # Various misc tests. Some just for code coverage
  12. @output = `$checknrpe`;
  13. is($?, STATE_UNKNOWN, 'usage') || diag @output;
  14. @output = `$checknrpe -l`;
  15. is($?, STATE_UNKNOWN, 'license') || diag @output;
  16. @output = `$checknrpe -f configs/check_nrpe.cfg`;
  17. is($?, STATE_UNKNOWN, 'config') || diag @output;
  18. @output = `$checknrpe -f configs/nonexistant.cfg`;
  19. is($?, STATE_UNKNOWN, 'config nonexistant') || diag @output;
  20. @output = `$checknrpe -f configs/check_nrpe.cfg -H 127.0.0.1 -p 40000`;
  21. is($?, STATE_CRITICAL, 'invalid port') || diag @output;
  22. # We're trying to invoke alarm_handler() due to a timeout. Use an IP address that shouldn't be in use
  23. @output = `$checknrpe -f configs/check_nrpe.cfg -t 1:WARNING -H 0.0.0.111 -p 40000`;
  24. is($?, STATE_WARNING, 'invalid ip') || diag @output;