summaryrefslogtreecommitdiff
path: root/src/test/test-conf-parser.c
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2018-05-09 18:10:07 -0700
committerSven Eden <yamakuzure@gmx.net>2018-06-28 09:24:07 +0200
commit996045a96a16b35cb4eff859ed69d12464f95797 (patch)
treeac0b94dfd32322972d21733a3d37eccc40e4ae1c /src/test/test-conf-parser.c
parentf6bdcb639582b5025266fb85465f74ffb7b2cca8 (diff)
conf-parser: accept trailing backslash at the end of the file (#8941)
This makes it behave the same whether there is a blank line or not at the end of the file. This is also consistent with the behavior of the shell on a shell script that ends on a trailing backslash at the last line. Added tests to test_config_parse(), which only pass if the corresponding change to config_parse() is included. (cherry picked from commit 4f29e0db127dce9e1a28af4d7bf88c124ba257b7)
Diffstat (limited to 'src/test/test-conf-parser.c')
-rw-r--r--src/test/test-conf-parser.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/test/test-conf-parser.c b/src/test/test-conf-parser.c
index c7f18b33f..c36204197 100644
--- a/src/test/test-conf-parser.c
+++ b/src/test/test-conf-parser.c
@@ -307,6 +307,11 @@ static const char* const config_file[] = {
"3\n",
"[Section]\n"
+ "setting1=1\\\n" /* continuation with extra trailing backslash at the end */
+ "2\\\n"
+ "3\\\n",
+
+ "[Section]\n"
"setting1=1\\\\\\\n" /* continuation with trailing escape symbols */
"\\\\2\n", /* note that C requires one level of escaping, so the
* parser gets "…1 BS BS BS NL BS BS 2 NL", which
@@ -323,6 +328,11 @@ static const char* const config_file[] = {
"foobar",
"[Section]\n"
+ "setting1=" /* a line above LINE_MAX length, with continuation */
+ x1000("ABCD") "\\\n" /* and an extra trailing backslash */
+ "foobar\\\n",
+
+ "[Section]\n"
"setting1=" /* a line above the allowed limit: 9 + 1050000 + 1 */
x1000(x1000("x") x10("abcde")) "\n",
@@ -375,27 +385,27 @@ static void test_config_parse(unsigned i, const char *s) {
assert_se(streq(setting1, "1"));
break;
- case 4:
+ case 4 ... 5:
assert_se(r == 0);
assert_se(streq(setting1, "1 2 3"));
break;
- case 5:
+ case 6:
assert_se(r == 0);
assert_se(streq(setting1, "1\\\\ \\\\2"));
break;
- case 6:
+ case 7:
assert_se(r == 0);
assert_se(streq(setting1, x1000("ABCD")));
break;
- case 7:
+ case 8 ... 9:
assert_se(r == 0);
assert_se(streq(setting1, x1000("ABCD") " foobar"));
break;
- case 8 ... 9:
+ case 10 ... 11:
assert_se(r == -ENOBUFS);
assert_se(setting1 == NULL);
break;