chiark / gitweb /
test: support empty environment variables in unit files
authorIago López Galeiras <iago@endocode.com>
Thu, 20 Nov 2014 20:18:23 +0000 (21:18 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 23 Nov 2014 21:29:11 +0000 (16:29 -0500)
Also update TODO, empty environment variables in Environment= and
EnvironmentFile= options work.

TODO
src/test/test-unit-file.c

diff --git a/TODO b/TODO
index d4138fe6c44a1344e722dad94b0c9cc5cc0a3571..3e8d04cec53e465fcc30f4a004cf4fc706ab63db 100644 (file)
--- a/TODO
+++ b/TODO
@@ -191,8 +191,6 @@ Features:
 
 * generator that automatically discovers btrfs subvolumes, identifies their purpose based on some xattr on them.
 
 
 * generator that automatically discovers btrfs subvolumes, identifies their purpose based on some xattr on them.
 
-* support setting empty environment variables with Environment= and EnvironmentFile=
-
 * timer units: actually add extra delays to timer units with high AccuracySec values, don't start them already when we are awake...
 
 * a way for container managers to turn off getty starting via $container_headless= or so...
 * timer units: actually add extra delays to timer units with high AccuracySec values, don't start them already when we are awake...
 
 * a way for container managers to turn off getty starting via $container_headless= or so...
index 03b3e259399c019c75c7fb3e8ffa08e48fb12c46..f31a1bbc9bc4d12091c6193449d3251eaa26dfb1 100644 (file)
@@ -222,6 +222,9 @@ static void test_config_parse_exec(void) {
        "MODULE_0=coretemp\n" \
        "MODULE_1=f71882fg"
 
        "MODULE_0=coretemp\n" \
        "MODULE_1=f71882fg"
 
+#define env_file_5                              \
+        "a=\n"                                 \
+        "b="
 
 static void test_load_env_file_1(void) {
         _cleanup_strv_free_ char **data = NULL;
 
 static void test_load_env_file_1(void) {
         _cleanup_strv_free_ char **data = NULL;
@@ -300,6 +303,24 @@ static void test_load_env_file_4(void) {
         unlink(name);
 }
 
         unlink(name);
 }
 
+static void test_load_env_file_5(void) {
+        _cleanup_strv_free_ char **data = NULL;
+        int r;
+
+        char name[] = "/tmp/test-load-env-file.XXXXXX";
+        _cleanup_close_ int fd;
+
+        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
+        assert_se(fd >= 0);
+        assert_se(write(fd, env_file_5, sizeof(env_file_5)) == sizeof(env_file_5));
+
+        r = load_env_file(NULL, name, NULL, &data);
+        assert_se(r == 0);
+        assert_se(streq(data[0], "a="));
+        assert_se(streq(data[1], "b="));
+        assert_se(data[2] == NULL);
+        unlink(name);
+}
 
 static void test_install_printf(void) {
         char    name[] = "name.service",
 
 static void test_install_printf(void) {
         char    name[] = "name.service",
@@ -387,6 +408,7 @@ int main(int argc, char *argv[]) {
         test_load_env_file_2();
         test_load_env_file_3();
         test_load_env_file_4();
         test_load_env_file_2();
         test_load_env_file_3();
         test_load_env_file_4();
+        test_load_env_file_5();
         TEST_REQ_RUNNING_SYSTEMD(test_install_printf());
 
         return r;
         TEST_REQ_RUNNING_SYSTEMD(test_install_printf());
 
         return r;