test: add test for prefix unit loading

This commit is contained in:
Lennart Poettering 2018-03-21 19:55:54 +01:00
parent 5396624506
commit 7ce49e656b
8 changed files with 35 additions and 5 deletions

View 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;
}

View 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

View File

@ -0,0 +1,2 @@
[Unit]
Description=override0

View File

@ -0,0 +1,2 @@
[Unit]
Documentation=man:override1

View File

@ -0,0 +1,2 @@
[Unit]
Documentation=man:override2

View File

@ -0,0 +1,2 @@
[Unit]
Documentation=man:override3

View File

@ -0,0 +1,6 @@
[Unit]
Description=A unit with multiple dashes
Documentation=man:test
[Service]
ExecStart=/bin/true

View File

@ -0,0 +1,2 @@
[Unit]
Description=override4