aboutsummaryrefslogtreecommitdiff
path: root/lib/tests/test_opts.c
diff options
context:
space:
mode:
authorGravatar Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> 2008-03-26 09:46:27 +0000
committerGravatar Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> 2008-03-26 09:46:27 +0000
commitaf71e9fc0ef268b322c4f4677773273c07926a7a (patch)
treefa0b6b2a3b87b6cb5177acd4f2a4b48276313102 /lib/tests/test_opts.c
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/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)
char **argv_test=NULL, **argv_known=NULL;
int i, argc_test, argc_new;
- plan_tests(8);
+ plan_tests(11);
argv_test=(char **)malloc(2*sizeof(char **));
argv_test[0] = "prog_name";
@@ -203,6 +203,64 @@ main (int argc, char **argv)
ok(array_diff(argc_new, argv_test, 4, argv_known), "Missing section 3");
my_free(&argc_new,argv_test);
+ setenv("NAGIOS_CONFIG_PATH", ".", 1);
+ argv_test=(char **)malloc(6*sizeof(char **));
+ argv_test[0] = "prog_name";
+ argv_test[1] = "arg1";
+ argv_test[2] = "--extra-opts";
+ argv_test[3] = "--arg3";
+ argv_test[4] = "val2";
+ argv_test[5] = NULL;
+ argc_test=5;
+ argv_known=(char **)realloc(argv_known, 6*sizeof(char **));
+ argv_known[0] = "prog_name";
+ argv_known[1] = "--foo=bar";
+ argv_known[2] = "arg1";
+ argv_known[3] = "--arg3";
+ argv_known[4] = "val2";
+ argv_known[5] = NULL;
+ argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new);
+ ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 1");
+ my_free(&argc_new,argv_test);
+
+ argv_test=(char **)malloc(6*sizeof(char **));
+ argv_test[0] = "prog_name";
+ argv_test[1] = "arg1";
+ argv_test[2] = "--extra-opts=section1";
+ argv_test[3] = "--arg3";
+ argv_test[4] = "val2";
+ argv_test[5] = NULL;
+ argc_test=5;
+ argv_known=(char **)realloc(argv_known, 6*sizeof(char **));
+ argv_known[0] = "prog_name";
+ argv_known[1] = "--foobar=baz";
+ argv_known[2] = "arg1";
+ argv_known[3] = "--arg3";
+ argv_known[4] = "val2";
+ argv_known[5] = NULL;
+ argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new);
+ ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 2");
+ my_free(&argc_new,argv_test);
+
+ argv_test=(char **)malloc(6*sizeof(char **));
+ argv_test[0] = "prog_name";
+ argv_test[1] = "arg1";
+ argv_test[2] = "--extra-opts=section2";
+ argv_test[3] = "--arg3";
+ argv_test[4] = "val2";
+ argv_test[5] = NULL;
+ argc_test=5;
+ argv_known=(char **)realloc(argv_known, 6*sizeof(char **));
+ argv_known[0] = "prog_name";
+ argv_known[1] = "--foo=bar";
+ argv_known[2] = "arg1";
+ argv_known[3] = "--arg3";
+ argv_known[4] = "val2";
+ argv_known[5] = NULL;
+ argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new);
+ ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 3");
+ my_free(&argc_new,argv_test);
+
return exit_status();
}