X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftest%2Ftest-unit-file.c;h=c1a2d4a7f3ca35c3198f3aeeb6bba638590532ea;hb=2b4ac8896bdc6cc5159088d7d208559d53caacf3;hp=85191310d457f0205cb848db3f1861136eaacae3;hpb=7742f7e999d58062b9784be83553eda109fff366;p=elogind.git diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index 85191310d..c1a2d4a7f 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -34,6 +34,7 @@ #include "hashmap.h" #include "load-fragment.h" #include "strv.h" +#include "fileio.h" static void test_unit_file_get_set(void) { int r; @@ -193,6 +194,11 @@ static void test_config_parse_exec(void) { #define env_file_2 \ "a\\\n" +#define env_file_3 \ + "#SPAMD_ARGS=\"-d --socketpath=/var/lib/bulwark/spamd \\\n" \ + "#--nouser-config \\\n" \ + "normal=line" + static void test_load_env_file_1(void) { char _cleanup_strv_free_ **data = NULL; int r; @@ -230,17 +236,32 @@ static void test_load_env_file_2(void) { unlink(name); } +static void test_load_env_file_3(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_3, sizeof(env_file_3)) == sizeof(env_file_3)); + + r = load_env_file(name, &data); + assert(r == 0); + assert(data == NULL); + unlink(name); +} + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnonnull" static void test_install_printf(void) { char name[] = "name.service", - path[] = "/run/systemd/systemd/name.service", + path[] = "/run/systemd/system/name.service", user[] = "xxxx-no-such-user"; InstallInfo i = {name, path, user}; InstallInfo i2 = {name, path, NULL}; char name3[] = "name@inst.service", - path3[] = "/run/systemd/systemd/name.service"; + path3[] = "/run/systemd/system/name.service"; InstallInfo i3 = {name3, path3, user}; InstallInfo i4 = {name3, path3, NULL}; @@ -305,6 +326,7 @@ int main(int argc, char *argv[]) { test_config_parse_exec(); test_load_env_file_1(); test_load_env_file_2(); + test_load_env_file_3(); test_install_printf(); return 0;