summaryrefslogtreecommitdiff
path: root/src/test/test-unit-file.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-13 20:22:53 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-13 20:24:39 -0400
commitd3b6d0c21ea5a0d15ec6dbd8b8d179138b7463bc (patch)
tree7388d97b95b47d81737025ec0b88f63452a3c6f5 /src/test/test-unit-file.c
parent7914d6bba47a21b98617d04c992a9075ff5af4c0 (diff)
fileio: in envfiles, do not skip lines following empty lines
https://bugs.freedesktop.org/show_bug.cgi?id=63477
Diffstat (limited to 'src/test/test-unit-file.c')
-rw-r--r--src/test/test-unit-file.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 3cf84637e8..1bf11e66a5 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -199,6 +199,17 @@ static void test_config_parse_exec(void) {
"#--nouser-config \\\n" \
"normal=line"
+#define env_file_4 \
+ "# Generated\n" \
+ "\n" \
+ "HWMON_MODULES=\"coretemp f71882fg\"\n" \
+ "\n" \
+ "# For compatibility reasons\n" \
+ "\n" \
+ "MODULE_0=coretemp\n" \
+ "MODULE_1=f71882fg"
+
+
static void test_load_env_file_1(void) {
char _cleanup_strv_free_ **data = NULL;
int r;
@@ -251,6 +262,25 @@ static void test_load_env_file_3(void) {
unlink(name);
}
+static void test_load_env_file_4(void) {
+ char _cleanup_strv_free_ **data = NULL;
+ int r;
+
+ char name[] = "/tmp/test-load-env-file.XXXXXX";
+ int _cleanup_close_ fd = mkstemp(name);
+ assert(fd >= 0);
+ assert_se(write(fd, env_file_4, sizeof(env_file_4)) == sizeof(env_file_4));
+
+ r = load_env_file(name, NULL, &data);
+ assert(r == 0);
+ assert(streq(data[0], "HWMON_MODULES=coretemp f71882fg"));
+ assert(streq(data[1], "MODULE_0=coretemp"));
+ assert(streq(data[2], "MODULE_1=f71882fg"));
+ assert(data[3] == NULL);
+ unlink(name);
+}
+
+
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull"
@@ -327,6 +357,7 @@ int main(int argc, char *argv[]) {
test_load_env_file_1();
test_load_env_file_2();
test_load_env_file_3();
+ test_load_env_file_4();
test_install_printf();
return 0;