summaryrefslogtreecommitdiff
path: root/src/test/test-fileio.c
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-04-18 10:15:25 +0200
committerHarald Hoyer <harald@redhat.com>2013-04-18 11:29:00 +0200
commit98f59e59e0c31ffcb953d3a7dba0da5e6f2f55f7 (patch)
tree236c8c85234c6d8063639b079dee26d585764552 /src/test/test-fileio.c
parentbef89518003a37f0fbd2f53beaa6bb7d01efed45 (diff)
fileio.c: do not parse comments after non-whitespace chars
systemd does not want to understand comments after the first non-whitespace char occured. key=foo #comment will result into key == "foo #comment" key="foo" #comment will result into key == "foo#comment" "key= #comment" will result into key == "#comment" "key #comment" is an invalid line
Diffstat (limited to 'src/test/test-fileio.c')
-rw-r--r--src/test/test-fileio.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 2a74104e7a..d56f7cc856 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -47,16 +47,18 @@ static void test_parse_env_file(void) {
fputs("one=BAR \n"
"# comment\n"
" # comment \n"
+ " ; comment \n"
" two = bar \n"
"invalid line\n"
+ "invalid line #comment\n"
"three = \"333\n"
"xxxx\"\n"
"four = \'44\\\"44\'\n"
"five = \'55\\\'55\' \"FIVE\" cinco \n"
"six = seis sechs\\\n"
" sis\n"
- "seven=\"sevenval\"#comment\n"
- "eight=#comment\n"
+ "seven=\"sevenval\" #nocomment\n"
+ "eight=eightval #nocomment\n"
"export nine=nineval\n"
"ten=", f);
@@ -75,20 +77,14 @@ static void test_parse_env_file(void) {
assert_se(streq(a[3], "four=44\"44"));
assert_se(streq(a[4], "five=55\'55FIVEcinco"));
assert_se(streq(a[5], "six=seis sechs sis"));
- assert_se(streq(a[6], "seven=sevenval"));
- assert_se(streq(a[7], "eight="));
+ assert_se(streq(a[6], "seven=sevenval#nocomment"));
+ assert_se(streq(a[7], "eight=eightval #nocomment"));
assert_se(streq(a[8], "export nine=nineval"));
assert_se(streq(a[9], "ten="));
assert_se(a[10] == NULL);
strv_env_clean_log(a, "/tmp/test-fileio");
- r = write_env_file("/tmp/test-fileio", a);
- assert_se(r >= 0);
-
- r = load_env_file("/tmp/test-fileio", NULL, &b);
- assert_se(r >= 0);
-
k = 0;
STRV_FOREACH(i, b) {
log_info("Got2: <%s>", *i);
@@ -128,11 +124,17 @@ static void test_parse_env_file(void) {
assert_se(streq(four, "44\"44"));
assert_se(streq(five, "55\'55FIVEcinco"));
assert_se(streq(six, "seis sechs sis"));
- assert_se(streq(seven, "sevenval"));
- assert_se(eight == NULL);
+ assert_se(streq(seven, "sevenval#nocomment"));
+ assert_se(streq(eight, "eightval #nocomment"));
assert_se(streq(nine, "nineval"));
assert_se(ten == NULL);
+ r = write_env_file("/tmp/test-fileio", a);
+ assert_se(r >= 0);
+
+ r = load_env_file("/tmp/test-fileio", NULL, &b);
+ assert_se(r >= 0);
+
unlink(t);
unlink("/tmp/test-fileio");
}