diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse_ini.c | 3 | ||||
-rwxr-xr-x | lib/tests/test_opts3.t | 23 |
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c index 1d64a506..004396fe 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c | |||
@@ -75,6 +75,9 @@ static void parse_locator(const char *locator, const char *def_stanza, np_ini_in | |||
75 | /* if there is no @file part */ | 75 | /* if there is no @file part */ |
76 | if(stanza_len==locator_len){ | 76 | if(stanza_len==locator_len){ |
77 | i->file=default_file(); | 77 | i->file=default_file(); |
78 | if(strcmp(i->file, "") == 0){ | ||
79 | die(STATE_UNKNOWN, _("Cannot find '%s' or '%s' in any standard location.\n"), NP_DEFAULT_INI_FILENAME1, NP_DEFAULT_INI_FILENAME2); | ||
80 | } | ||
78 | } else { | 81 | } else { |
79 | i->file=strdup(&(locator[stanza_len+1])); | 82 | i->file=strdup(&(locator[stanza_len+1])); |
80 | } | 83 | } |
diff --git a/lib/tests/test_opts3.t b/lib/tests/test_opts3.t index 47ec26b3..35b44687 100755 --- a/lib/tests/test_opts3.t +++ b/lib/tests/test_opts3.t | |||
@@ -8,15 +8,19 @@ if (! -e "./test_opts3") { | |||
8 | } | 8 | } |
9 | 9 | ||
10 | # array of argument arrays | 10 | # array of argument arrays |
11 | # - first value is the NAGIOS_CONFIG_PATH | 11 | # - First value is the expected return code |
12 | # - 2nd value is the plugin name | 12 | # - 2nd value is the NAGIOS_CONFIG_PATH |
13 | # - 3rc and up are arguments | 13 | # TODO: looks like we look in default path after looking trough this variable - shall we? |
14 | # - 3rd value is the plugin name | ||
15 | # - 4th and up are arguments | ||
14 | my @TESTS = ( | 16 | my @TESTS = ( |
15 | ['/nonexistent', 'prog_name', 'arg1', '--extra-opts', '--arg3', 'val2'], | 17 | [3, '/nonexistent', 'prog_name', 'arg1', '--extra-opts', '--arg3', 'val2'], |
16 | ['.', 'prog_name', 'arg1', '--extra-opts=missing@./config-opts.ini', '--arg3', 'val2'], | 18 | [3, '.', 'prog_name', 'arg1', '--extra-opts=missing@./config-opts.ini', '--arg3', 'val2'], |
17 | ['.', 'prog_name', 'arg1', '--extra-opts', 'missing@./config-opts.ini', '--arg3', 'val2'], | 19 | [3, '', 'prog_name', 'arg1', '--extra-opts', 'missing@./config-opts.ini', '--arg3', 'val2'], |
18 | ['.', 'check_missing', 'arg1', '--extra-opts=@./config-opts.ini', '--arg3', 'val2'], | 20 | [3, '.', 'check_missing', 'arg1', '--extra-opts=@./config-opts.ini', '--arg3', 'val2'], |
19 | ['.', 'check_missing', 'arg1', '--extra-opts', '--arg3', 'val2'], | 21 | [3, '.', 'check_missing', 'arg1', '--extra-opts', '--arg3', 'val2'], |
22 | [0, '/tmp:/var:/nonexistent:.', 'check_tcp', 'arg1', '--extra-opts', '--arg3', 'val2'], | ||
23 | [0, '/usr/local/nagios/etc:.:/etc', 'check_missing', 'arg1', '--extra-opts=check_tcp', '--arg3', 'val2'], | ||
20 | ); | 24 | ); |
21 | 25 | ||
22 | plan tests => scalar(@TESTS); | 26 | plan tests => scalar(@TESTS); |
@@ -24,8 +28,9 @@ plan tests => scalar(@TESTS); | |||
24 | my $count=1; | 28 | my $count=1; |
25 | 29 | ||
26 | foreach my $args (@TESTS) { | 30 | foreach my $args (@TESTS) { |
31 | my $rc = shift(@$args); | ||
27 | $ENV{"NAGIOS_CONFIG_PATH"} = shift(@$args); | 32 | $ENV{"NAGIOS_CONFIG_PATH"} = shift(@$args); |
28 | system {'./test_opts3'} @$args; | 33 | system {'./test_opts3'} @$args; |
29 | cmp_ok($?>>8, '==', 3, "Extra-opts die " . $count++); | 34 | cmp_ok($?>>8, '==', $rc, "Extra-opts die " . $count++); |
30 | } | 35 | } |
31 | 36 | ||