test: add test for prefix unit loading
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Mar 2018 18:55:54 +0000 (19:55 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 13 Apr 2018 09:34:48 +0000 (11:34 +0200)
src/test/test-engine.c
test/meson.build
test/unit-.service.d/10-override.conf [new file with mode: 0644]
test/unit-with-.service.d/20-override.conf [new file with mode: 0644]
test/unit-with-multiple-.service.d/20-override.conf [new file with mode: 0644]
test/unit-with-multiple-.service.d/30-override.conf [new file with mode: 0644]
test/unit-with-multiple-dashes.service [new file with mode: 0644]
test/unit-with-multiple-dashes.service.d/10-override.conf [new file with mode: 0644]

index 566874a..1c12a86 100644 (file)
@@ -19,12 +19,16 @@ int main(int argc, char *argv[]) {
         _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
         _cleanup_(sd_bus_error_free) sd_bus_error err = SD_BUS_ERROR_NULL;
         _cleanup_(manager_freep) Manager *m = NULL;
-        Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, *h = NULL;
+        Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, *h = NULL, *unit_with_multiple_dashes = NULL;
         FILE *serial = NULL;
         FDSet *fdset = NULL;
         Job *j;
         int r;
 
+        log_set_max_level(LOG_DEBUG);
+        log_parse_environment();
+        log_open();
+
         r = enter_cgroup_subroot();
         if (r == -ENOMEDIUM) {
                 log_notice_errno(r, "Skipping test: cgroupfs not available");
@@ -130,5 +134,10 @@ int main(int argc, char *argv[]) {
         assert_se(!hashmap_get(a->dependencies[UNIT_PROPAGATES_RELOAD_TO], c));
         assert_se(!hashmap_get(c->dependencies[UNIT_RELOAD_PROPAGATED_FROM], a));
 
+        assert_se(manager_load_unit(m, "unit-with-multiple-dashes.service", NULL, NULL, &unit_with_multiple_dashes) >= 0);
+
+        assert_se(strv_equal(unit_with_multiple_dashes->documentation, STRV_MAKE("man:test", "man:override2", "man:override3")));
+        assert_se(streq_ptr(unit_with_multiple_dashes->description, "override4"));
+
         return 0;
 }
index 0bd45cd..c112e09 100644 (file)
@@ -158,13 +158,18 @@ test_data_files = '''
         test-path/path-unit.path
         test-path/paths.target
         test-path/sysinit.target
-        testsuite.target
-        timers.target
-        unstoppable.service
         test-umount/empty.mountinfo
+        test-umount/example.swaps
         test-umount/garbled.mountinfo
         test-umount/rhbug-1554943.mountinfo
-        test-umount/example.swaps
+        testsuite.target
+        timers.target
+        unit-with-.service.d/20-override.conf
+        unit-with-multiple-.service.d/20-override.conf
+        unit-with-multiple-.service.d/30-override.conf
+        unit-with-multiple-dashes.service
+        unit-with-multiple-dashes.service.d/10-override.conf
+        unstoppable.service
 '''.split()
 
 if conf.get('ENABLE_RESOLVE') == 1
diff --git a/test/unit-.service.d/10-override.conf b/test/unit-.service.d/10-override.conf
new file mode 100644 (file)
index 0000000..916737d
--- /dev/null
@@ -0,0 +1,2 @@
+[Unit]
+Description=override0
diff --git a/test/unit-with-.service.d/20-override.conf b/test/unit-with-.service.d/20-override.conf
new file mode 100644 (file)
index 0000000..c6c2438
--- /dev/null
@@ -0,0 +1,2 @@
+[Unit]
+Documentation=man:override1
diff --git a/test/unit-with-multiple-.service.d/20-override.conf b/test/unit-with-multiple-.service.d/20-override.conf
new file mode 100644 (file)
index 0000000..62fafd2
--- /dev/null
@@ -0,0 +1,2 @@
+[Unit]
+Documentation=man:override2
diff --git a/test/unit-with-multiple-.service.d/30-override.conf b/test/unit-with-multiple-.service.d/30-override.conf
new file mode 100644 (file)
index 0000000..b9616da
--- /dev/null
@@ -0,0 +1,2 @@
+[Unit]
+Documentation=man:override3
diff --git a/test/unit-with-multiple-dashes.service b/test/unit-with-multiple-dashes.service
new file mode 100644 (file)
index 0000000..b38b360
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=A unit with multiple dashes
+Documentation=man:test
+
+[Service]
+ExecStart=/bin/true
diff --git a/test/unit-with-multiple-dashes.service.d/10-override.conf b/test/unit-with-multiple-dashes.service.d/10-override.conf
new file mode 100644 (file)
index 0000000..982c362
--- /dev/null
@@ -0,0 +1,2 @@
+[Unit]
+Description=override4