summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 92b969e)
raw | patch | inline | side by side (parent: 92b969e)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sun, 16 Mar 2008 18:10:47 +0000 (18:10 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sun, 16 Mar 2008 18:10:47 +0000 (18:10 +0000) |
- DOS-newline ini file
- section defined twice
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1951 f882894a-f735-0410-b71e-b25c423dba1c
- section defined twice
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1951 f882894a-f735-0410-b71e-b25c423dba1c
lib/tests/config-dos.ini | [new file with mode: 0644] | patch | blob |
lib/tests/plugin.ini | patch | blob | history | |
lib/tests/test_ini.c | patch | blob | history |
diff --git a/lib/tests/config-dos.ini b/lib/tests/config-dos.ini
--- /dev/null
+++ b/lib/tests/config-dos.ini
@@ -0,0 +1,24 @@
+# This config file is amended from perl's Config::Tiny's testcases\r
+\r
+# Line below is allowed in perl's Config::Tiny, but not in our parse_ini.c\r
+#root=something\r
+\r
+[section]\r
+one=two\r
+Foo=Bar\r
+this=Your Mother!\r
+blank=\r
+\r
+[Section Two]\r
+something else=blah\r
+ remove = whitespace \r
+\r
+[ /path/to/file.txt ]\r
+this=that\r
+\r
+[ section2]\r
+this=that\r
+\r
+[section3 ]\r
+this=that\r
+\r
diff --git a/lib/tests/plugin.ini b/lib/tests/plugin.ini
index d07fc4f363762c4fa1641c64c8506bb1e6164b48..e22f8bdb309e2ceb7719f56c9e626dc58f16df04 100644 (file)
--- a/lib/tests/plugin.ini
+++ b/lib/tests/plugin.ini
username=operator
password=secret # Remember to change later
+[section_twice]
+foo=bar
+
[check_mysql2]
u=admin
p=secret
+[section_twice]
+bar=foo
+
[check space_and_flags]
foo=bar
a=
diff --git a/lib/tests/test_ini.c b/lib/tests/test_ini.c
index 9031f7f8abce45863a27f8bbb8750e55a8afe9a9..84749279b1a713442c7aed48ac8e3963dacaf5b0 100644 (file)
--- a/lib/tests/test_ini.c
+++ b/lib/tests/test_ini.c
list2str(np_arg_list *optlst)
{
char *optstr=NULL;
+ np_arg_list *optltmp;
/* Put everything as a space-separated string */
asprintf(&optstr, "");
while (optlst) {
asprintf(&optstr, "%s%s ", optstr, optlst->arg);
+ optltmp=optlst;
optlst=optlst->next;
+ free(optltmp);
}
/* Strip last whitespace */
if (strlen(optstr)>1) optstr[strlen(optstr)-1]='\0';
{
char *optstr=NULL;
- plan_tests(10);
+ plan_tests(12);
optstr=list2str(np_get_defaults("section@./config-tiny.ini", "check_disk"));
ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "config-tiny.ini's section as expected");
ok( !strcmp(optstr, "--foo=bar -a -b --bar"), "plugin.ini space in stanza and flag arguments");
my_free(optstr);
+ optstr=list2str(np_get_defaults("Section Two@./config-dos.ini", "check_disk"));
+ ok( !strcmp(optstr, "--something else=blah --remove=whitespace"), "config-dos.ini's Section Two as expected");
+ my_free(optstr);
+
+ optstr=list2str(np_get_defaults("section_twice@./plugin.ini", "check_disk"));
+ ok( !strcmp(optstr, "--foo=bar --bar=foo"), "plugin.ini's section_twice defined twice in the file");
+ my_free(optstr);
+
return exit_status();
}