summaryrefslogtreecommitdiffstats
path: root/lib/tests
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-03-26 09:46:27 (GMT)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-03-26 09:46:27 (GMT)
commitaf71e9fc0ef268b322c4f4677773273c07926a7a (patch)
treefa0b6b2a3b87b6cb5177acd4f2a4b48276313102 /lib/tests
parenta34cf37404104ff5bb13fb5fecdf5e492401c6a3 (diff)
downloadmonitoring-plugins-af71e9fc0ef268b322c4f4677773273c07926a7a.tar.gz
write ini-file lookup function + tests
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1962 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/plugins.ini7
-rw-r--r--lib/tests/test_opts.c60
2 files changed, 66 insertions, 1 deletions
diff --git a/lib/tests/plugins.ini b/lib/tests/plugins.ini
new file mode 100644
index 0000000..5e20ded
--- /dev/null
+++ b/lib/tests/plugins.ini
@@ -0,0 +1,7 @@
1
2[check_disk]
3foo=bar
4
5[section1]
6foobar=baz
7
diff --git a/lib/tests/test_opts.c b/lib/tests/test_opts.c
index 1272605..769a2df 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