summaryrefslogtreecommitdiffstats
path: root/lib/tests/test_opts.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tests/test_opts.c')
-rw-r--r--lib/tests/test_opts.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/lib/tests/test_opts.c b/lib/tests/test_opts.c
index 12726059..769a2df2 100644
--- a/lib/tests/test_opts.c
+++ b/lib/tests/test_opts.c
@@ -59,7 +59,7 @@ main (int argc, char **argv)
59 char **argv_test=NULL, **argv_known=NULL; 59 char **argv_test=NULL, **argv_known=NULL;
60 int i, argc_test, argc_new; 60 int i, argc_test, argc_new;
61 61
62 plan_tests(8); 62 plan_tests(11);
63 63
64 argv_test=(char **)malloc(2*sizeof(char **)); 64 argv_test=(char **)malloc(2*sizeof(char **));
65 argv_test[0] = "prog_name"; 65 argv_test[0] = "prog_name";
@@ -203,6 +203,64 @@ main (int argc, char **argv)
203 ok(array_diff(argc_new, argv_test, 4, argv_known), "Missing section 3"); 203 ok(array_diff(argc_new, argv_test, 4, argv_known), "Missing section 3");
204 my_free(&argc_new,argv_test); 204 my_free(&argc_new,argv_test);
205 205
206 setenv("NAGIOS_CONFIG_PATH", ".", 1);
207 argv_test=(char **)malloc(6*sizeof(char **));
208 argv_test[0] = "prog_name";
209 argv_test[1] = "arg1";
210 argv_test[2] = "--extra-opts";
211 argv_test[3] = "--arg3";
212 argv_test[4] = "val2";
213 argv_test[5] = NULL;
214 argc_test=5;
215 argv_known=(char **)realloc(argv_known, 6*sizeof(char **));
216 argv_known[0] = "prog_name";
217 argv_known[1] = "--foo=bar";
218 argv_known[2] = "arg1";
219 argv_known[3] = "--arg3";
220 argv_known[4] = "val2";
221 argv_known[5] = NULL;
222 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new);
223 ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 1");
224 my_free(&argc_new,argv_test);
225
226 argv_test=(char **)malloc(6*sizeof(char **));
227 argv_test[0] = "prog_name";
228 argv_test[1] = "arg1";
229 argv_test[2] = "--extra-opts=section1";
230 argv_test[3] = "--arg3";
231 argv_test[4] = "val2";
232 argv_test[5] = NULL;
233 argc_test=5;
234 argv_known=(char **)realloc(argv_known, 6*sizeof(char **));
235 argv_known[0] = "prog_name";
236 argv_known[1] = "--foobar=baz";
237 argv_known[2] = "arg1";
238 argv_known[3] = "--arg3";
239 argv_known[4] = "val2";
240 argv_known[5] = NULL;
241 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new);
242 ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 2");
243 my_free(&argc_new,argv_test);
244
245 argv_test=(char **)malloc(6*sizeof(char **));
246 argv_test[0] = "prog_name";
247 argv_test[1] = "arg1";
248 argv_test[2] = "--extra-opts=section2";
249 argv_test[3] = "--arg3";
250 argv_test[4] = "val2";
251 argv_test[5] = NULL;
252 argc_test=5;
253 argv_known=(char **)realloc(argv_known, 6*sizeof(char **));
254 argv_known[0] = "prog_name";
255 argv_known[1] = "--foo=bar";
256 argv_known[2] = "arg1";
257 argv_known[3] = "--arg3";
258 argv_known[4] = "val2";
259 argv_known[5] = NULL;
260 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new);
261 ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 3");
262 my_free(&argc_new,argv_test);
263
206 return exit_status(); 264 return exit_status();
207} 265}
208 266