summaryrefslogtreecommitdiffstats
path: root/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/test_ini.c12
-rw-r--r--lib/tests/test_opts.c26
2 files changed, 21 insertions, 17 deletions
diff --git a/lib/tests/test_ini.c b/lib/tests/test_ini.c
index 80396ca..1ab1e5d 100644
--- a/lib/tests/test_ini.c
+++ b/lib/tests/test_ini.c
@@ -55,7 +55,7 @@ main (int argc, char **argv)
55{ 55{
56 char *optstr=NULL; 56 char *optstr=NULL;
57 57
58 plan_tests(12); 58 plan_tests(11);
59 59
60 optstr=list2str(np_get_defaults("section@./config-tiny.ini", "check_disk")); 60 optstr=list2str(np_get_defaults("section@./config-tiny.ini", "check_disk"));
61 ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "config-tiny.ini's section as expected"); 61 ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "config-tiny.ini's section as expected");
@@ -65,9 +65,13 @@ main (int argc, char **argv)
65 ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name, without specific"); 65 ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name, without specific");
66 my_free(optstr); 66 my_free(optstr);
67 67
68 optstr=list2str(np_get_defaults("section_unknown@./config-tiny.ini", "section")); 68 /*
69 ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name over specified one"); 69 * This check is expected to die - It's commented so we can eventually put
70 my_free(optstr); 70 * it in a separate file for testing the return value
71 */
72 /* optstr=list2str(np_get_defaults("section_unknown@./config-tiny.ini", "section"));
73 ok( 0, "die if section isn't found");
74 my_free(optstr); */
71 75
72 optstr=list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk")); 76 optstr=list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk"));
73 ok( !strcmp(optstr, "--something else=blah --remove=whitespace"), "config-tiny.ini's Section Two as expected"); 77 ok( !strcmp(optstr, "--something else=blah --remove=whitespace"), "config-tiny.ini's Section Two as expected");
diff --git a/lib/tests/test_opts.c b/lib/tests/test_opts.c
index 61370a9..e878abd 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; 60 int i, argc_test;
61 61
62 plan_tests(12); 62 plan_tests(9);
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";
@@ -145,10 +145,10 @@ main (int argc, char **argv)
145 ok(array_diff(argc_test, argv_test, 7, argv_known), "twice extra opts using two sections"); 145 ok(array_diff(argc_test, argv_test, 7, argv_known), "twice extra opts using two sections");
146 my_free(&argc_test,argv_test); 146 my_free(&argc_test,argv_test);
147 147
148 /* Next three checks should die according to N::P - for now they're useful 148 /* Next three checks dre expected to die. They are commented out as they
149 * to test code is working properly (i.e. no srash or unexpected behavior) 149 * could possibly go in a sepatare test checked for return value.
150 */ 150 */
151 argv_test=(char **)malloc(6*sizeof(char **)); 151 /* argv_test=(char **)malloc(6*sizeof(char **));
152 argv_test[0] = "prog_name"; 152 argv_test[0] = "prog_name";
153 argv_test[1] = "arg1"; 153 argv_test[1] = "arg1";
154 argv_test[2] = "--extra-opts=missing@./config-opts.ini"; 154 argv_test[2] = "--extra-opts=missing@./config-opts.ini";
@@ -164,9 +164,9 @@ main (int argc, char **argv)
164 argv_known[4] = NULL; 164 argv_known[4] = NULL;
165 argv_test=np_extra_opts(&argc_test, argv_test, "check_missing"); 165 argv_test=np_extra_opts(&argc_test, argv_test, "check_missing");
166 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 1"); 166 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 1");
167 my_free(&argc_test,argv_test); 167 my_free(&argc_test,argv_test); */
168 168
169 argv_test=(char **)malloc(7*sizeof(char **)); 169 /* argv_test=(char **)malloc(7*sizeof(char **));
170 argv_test[0] = "prog_name"; 170 argv_test[0] = "prog_name";
171 argv_test[1] = "arg1"; 171 argv_test[1] = "arg1";
172 argv_test[2] = "--extra-opts"; 172 argv_test[2] = "--extra-opts";
@@ -183,9 +183,9 @@ main (int argc, char **argv)
183 argv_known[4] = NULL; 183 argv_known[4] = NULL;
184 argv_test=np_extra_opts(&argc_test, argv_test, "check_missing"); 184 argv_test=np_extra_opts(&argc_test, argv_test, "check_missing");
185 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 2"); 185 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 2");
186 my_free(&argc_test,argv_test); 186 my_free(&argc_test,argv_test); */
187 187
188 argv_test=(char **)malloc(6*sizeof(char **)); 188 /* argv_test=(char **)malloc(6*sizeof(char **));
189 argv_test[0] = "prog_name"; 189 argv_test[0] = "prog_name";
190 argv_test[1] = "arg1"; 190 argv_test[1] = "arg1";
191 argv_test[2] = "--extra-opts"; 191 argv_test[2] = "--extra-opts";
@@ -201,7 +201,7 @@ main (int argc, char **argv)
201 argv_known[4] = NULL; 201 argv_known[4] = NULL;
202 argv_test=np_extra_opts(&argc_test, argv_test, "check_missing"); 202 argv_test=np_extra_opts(&argc_test, argv_test, "check_missing");
203 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 3"); 203 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 3");
204 my_free(&argc_test,argv_test); 204 my_free(&argc_test,argv_test); */
205 205
206 setenv("NAGIOS_CONFIG_PATH", ".", 1); 206 setenv("NAGIOS_CONFIG_PATH", ".", 1);
207 argv_test=(char **)malloc(6*sizeof(char **)); 207 argv_test=(char **)malloc(6*sizeof(char **));
@@ -257,8 +257,8 @@ main (int argc, char **argv)
257 argv_test=(char **)malloc(6*sizeof(char **)); 257 argv_test=(char **)malloc(6*sizeof(char **));
258 argv_test[0] = "prog_name"; 258 argv_test[0] = "prog_name";
259 argv_test[1] = "arg1"; 259 argv_test[1] = "arg1";
260 argv_test[2] = "--extra-opts=section2"; 260 argv_test[2] = "--extra-opts";
261 argv_test[3] = "--arg3"; 261 argv_test[3] = "-arg3";
262 argv_test[4] = "val2"; 262 argv_test[4] = "val2";
263 argv_test[5] = NULL; 263 argv_test[5] = NULL;
264 argc_test=5; 264 argc_test=5;
@@ -266,11 +266,11 @@ main (int argc, char **argv)
266 argv_known[0] = "prog_name"; 266 argv_known[0] = "prog_name";
267 argv_known[1] = "--foo=bar"; 267 argv_known[1] = "--foo=bar";
268 argv_known[2] = "arg1"; 268 argv_known[2] = "arg1";
269 argv_known[3] = "--arg3"; 269 argv_known[3] = "-arg3";
270 argv_known[4] = "val2"; 270 argv_known[4] = "val2";
271 argv_known[5] = NULL; 271 argv_known[5] = NULL;
272 argv_test=np_extra_opts(&argc_test, argv_test, "check_disk"); 272 argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
273 ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 3"); 273 ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 4");
274 my_free(&argc_test,argv_test); 274 my_free(&argc_test,argv_test);
275 275
276 return exit_status(); 276 return exit_status();