test_ini3.t 851 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/perl
  2. use Test::More;
  3. use strict;
  4. use warnings;
  5. if (! -e "./test_ini3") {
  6. plan skip_all => "./test_ini not compiled - please enable libtap library and/or extra-opts to test";
  7. }
  8. # array of argument arrays
  9. # - First value is the expected return code
  10. # - 2nd value is the NAGIOS_CONFIG_PATH
  11. # TODO: looks like we look in default path after looking trough this variable - shall we?
  12. # - 3rd value is the plugin name
  13. # - 4th is the ini locator
  14. my @TESTS = (
  15. [3, undef, "section", "section_unknown@./config-tiny.ini"],
  16. );
  17. plan tests => scalar(@TESTS);
  18. my $count=1;
  19. foreach my $args (@TESTS) {
  20. my $rc = shift(@$args);
  21. if (my $env = shift(@$args)) {
  22. $ENV{"NAGIOS_CONFIG_PATH"} = $env;
  23. } else {
  24. delete($ENV{"NAGIOS_CONFIG_PATH"});
  25. }
  26. system {'./test_ini3'} @$args;
  27. cmp_ok($?>>8, '==', $rc, "Parse-ini die " . $count++);
  28. }