summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bf4abd5)
raw | patch | inline | side by side (parent: bf4abd5)
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Thu, 22 Jan 2009 07:24:39 +0000 (02:24 -0500) | ||
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Thu, 22 Jan 2009 07:24:39 +0000 (02:24 -0500) |
It makes no sense to return unknown if an implicit section is not found, but
go on if the file is missing
go on if the file is missing
lib/parse_ini.c | patch | blob | history | |
lib/tests/test_opts3.t | patch | blob | history |
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 1d64a5062512e098dcec5efc97b4b33e8afe99e6..004396fe803378c18c501bb17743364b8cb6508b 100644 (file)
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
/* if there is no @file part */
if(stanza_len==locator_len){
i->file=default_file();
+ if(strcmp(i->file, "") == 0){
+ die(STATE_UNKNOWN, _("Cannot find '%s' or '%s' in any standard location.\n"), NP_DEFAULT_INI_FILENAME1, NP_DEFAULT_INI_FILENAME2);
+ }
} else {
i->file=strdup(&(locator[stanza_len+1]));
}
diff --git a/lib/tests/test_opts3.t b/lib/tests/test_opts3.t
index 47ec26b3ab863cf6f89911e461eadd06dfc9537d..35b446874afbc5965bd75347872fe030f53488ce 100755 (executable)
--- a/lib/tests/test_opts3.t
+++ b/lib/tests/test_opts3.t
}
# array of argument arrays
-# - first value is the NAGIOS_CONFIG_PATH
-# - 2nd value is the plugin name
-# - 3rc and up are arguments
+# - First value is the expected return code
+# - 2nd value is the NAGIOS_CONFIG_PATH
+# TODO: looks like we look in default path after looking trough this variable - shall we?
+# - 3rd value is the plugin name
+# - 4th and up are arguments
my @TESTS = (
- ['/nonexistent', 'prog_name', 'arg1', '--extra-opts', '--arg3', 'val2'],
- ['.', 'prog_name', 'arg1', '--extra-opts=missing@./config-opts.ini', '--arg3', 'val2'],
- ['.', 'prog_name', 'arg1', '--extra-opts', 'missing@./config-opts.ini', '--arg3', 'val2'],
- ['.', 'check_missing', 'arg1', '--extra-opts=@./config-opts.ini', '--arg3', 'val2'],
- ['.', 'check_missing', 'arg1', '--extra-opts', '--arg3', 'val2'],
+ [3, '/nonexistent', 'prog_name', 'arg1', '--extra-opts', '--arg3', 'val2'],
+ [3, '.', 'prog_name', 'arg1', '--extra-opts=missing@./config-opts.ini', '--arg3', 'val2'],
+ [3, '', 'prog_name', 'arg1', '--extra-opts', 'missing@./config-opts.ini', '--arg3', 'val2'],
+ [3, '.', 'check_missing', 'arg1', '--extra-opts=@./config-opts.ini', '--arg3', 'val2'],
+ [3, '.', 'check_missing', 'arg1', '--extra-opts', '--arg3', 'val2'],
+ [0, '/tmp:/var:/nonexistent:.', 'check_tcp', 'arg1', '--extra-opts', '--arg3', 'val2'],
+ [0, '/usr/local/nagios/etc:.:/etc', 'check_missing', 'arg1', '--extra-opts=check_tcp', '--arg3', 'val2'],
);
plan tests => scalar(@TESTS);
my $count=1;
foreach my $args (@TESTS) {
+ my $rc = shift(@$args);
$ENV{"NAGIOS_CONFIG_PATH"} = shift(@$args);
system {'./test_opts3'} @$args;
- cmp_ok($?>>8, '==', 3, "Extra-opts die " . $count++);
+ cmp_ok($?>>8, '==', $rc, "Extra-opts die " . $count++);
}