From 7ce49e656b1377713ade999dfe381807a78313cd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Mar 2018 19:55:54 +0100 Subject: [PATCH] test: add test for prefix unit loading --- src/test/test-engine.c | 11 ++++++++++- test/meson.build | 13 +++++++++---- test/unit-.service.d/10-override.conf | 2 ++ test/unit-with-.service.d/20-override.conf | 2 ++ test/unit-with-multiple-.service.d/20-override.conf | 2 ++ test/unit-with-multiple-.service.d/30-override.conf | 2 ++ test/unit-with-multiple-dashes.service | 6 ++++++ .../10-override.conf | 2 ++ 8 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 test/unit-.service.d/10-override.conf create mode 100644 test/unit-with-.service.d/20-override.conf create mode 100644 test/unit-with-multiple-.service.d/20-override.conf create mode 100644 test/unit-with-multiple-.service.d/30-override.conf create mode 100644 test/unit-with-multiple-dashes.service create mode 100644 test/unit-with-multiple-dashes.service.d/10-override.conf diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 566874a299..1c12a8644d 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -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; } diff --git a/test/meson.build b/test/meson.build index 0bd45cd891..c112e09577 100644 --- a/test/meson.build +++ b/test/meson.build @@ -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 index 0000000000..916737d415 --- /dev/null +++ b/test/unit-.service.d/10-override.conf @@ -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 index 0000000000..c6c2438f73 --- /dev/null +++ b/test/unit-with-.service.d/20-override.conf @@ -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 index 0000000000..62fafd2e3b --- /dev/null +++ b/test/unit-with-multiple-.service.d/20-override.conf @@ -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 index 0000000000..b9616da8a8 --- /dev/null +++ b/test/unit-with-multiple-.service.d/30-override.conf @@ -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 index 0000000000..b38b3604b8 --- /dev/null +++ b/test/unit-with-multiple-dashes.service @@ -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 index 0000000000..982c3621a6 --- /dev/null +++ b/test/unit-with-multiple-dashes.service.d/10-override.conf @@ -0,0 +1,2 @@ +[Unit] +Description=override4