diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index 907531b045..c63c4d5a1a 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -66,16 +66,11 @@ static int test_cgroup_mask(void) { assert_se(manager_startup(m, serial, fdset) >= 0); /* Load units and verify hierarchy. */ - assert_se(manager_load_unit(m, "parent.slice", NULL, NULL, &parent) >= 0); - assert_se(manager_load_unit(m, "son.service", NULL, NULL, &son) >= 0); - assert_se(manager_load_unit(m, "daughter.service", NULL, NULL, &daughter) >= 0); - assert_se(manager_load_unit(m, "grandchild.service", NULL, NULL, &grandchild) >= 0); - assert_se(manager_load_unit(m, "parent-deep.slice", NULL, NULL, &parent_deep) >= 0); - assert_se(parent->load_state == UNIT_LOADED); - assert_se(son->load_state == UNIT_LOADED); - assert_se(daughter->load_state == UNIT_LOADED); - assert_se(grandchild->load_state == UNIT_LOADED); - assert_se(parent_deep->load_state == UNIT_LOADED); + assert_se(manager_load_startable_unit_or_warn(m, "parent.slice", NULL, &parent) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "son.service", NULL, &son) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "daughter.service", NULL, &daughter) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "grandchild.service", NULL, &grandchild) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "parent-deep.slice", NULL, &parent_deep) >= 0); assert_se(UNIT_DEREF(son->slice) == parent); assert_se(UNIT_DEREF(daughter->slice) == parent); assert_se(UNIT_DEREF(parent_deep->slice) == parent); diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 5d7cd8cfd5..e5ec3972b4 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -56,9 +56,9 @@ int main(int argc, char *argv[]) { assert_se(manager_startup(m, serial, fdset) >= 0); printf("Load1:\n"); - assert_se(manager_load_unit(m, "a.service", NULL, NULL, &a) >= 0); - assert_se(manager_load_unit(m, "b.service", NULL, NULL, &b) >= 0); - assert_se(manager_load_unit(m, "c.service", NULL, NULL, &c) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "a.service", NULL, &a) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "b.service", NULL, &b) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "c.service", NULL, &c) >= 0); manager_dump_units(m, stdout, "\t"); printf("Test1: (Trivial)\n"); @@ -70,8 +70,8 @@ int main(int argc, char *argv[]) { printf("Load2:\n"); manager_clear_jobs(m); - assert_se(manager_load_unit(m, "d.service", NULL, NULL, &d) >= 0); - assert_se(manager_load_unit(m, "e.service", NULL, NULL, &e) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "d.service", NULL, &d) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "e.service", NULL, &e) >= 0); manager_dump_units(m, stdout, "\t"); printf("Test2: (Cyclic Order, Unfixable)\n"); @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) { manager_dump_jobs(m, stdout, "\t"); printf("Load3:\n"); - assert_se(manager_load_unit(m, "g.service", NULL, NULL, &g) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "g.service", NULL, &g) >= 0); manager_dump_units(m, stdout, "\t"); printf("Test5: (Colliding transaction, fail)\n"); @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) { manager_dump_jobs(m, stdout, "\t"); printf("Load4:\n"); - assert_se(manager_load_unit(m, "h.service", NULL, NULL, &h) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "h.service", NULL, &h) >= 0); manager_dump_units(m, stdout, "\t"); printf("Test10: (Unmergeable job type of auxiliary job, fail)\n"); diff --git a/src/test/test-execute.c b/src/test/test-execute.c index db8a9c75a9..81f9b7c344 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -145,7 +145,7 @@ static void test(Manager *m, const char *unit_name, int status_expected, int cod assert_se(unit_name); - assert_se(manager_load_unit(m, unit_name, NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, unit_name, NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); check(m, unit, status_expected, code_expected); } diff --git a/src/test/test-path.c b/src/test/test-path.c index ec9d2626e2..9eaa61f950 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -134,7 +134,7 @@ static void test_path_exists(Manager *m) { assert_se(m); - assert_se(manager_load_unit(m, "path-exists.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-exists.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); assert_se(touch(test_path) >= 0); @@ -147,7 +147,7 @@ static void test_path_existsglob(Manager *m) { Unit *unit = NULL; assert_se(m); - assert_se(manager_load_unit(m, "path-existsglob.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-existsglob.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); assert_se(touch(test_path) >= 0); @@ -164,7 +164,7 @@ static void test_path_changed(Manager *m) { assert_se(touch(test_path) >= 0); - assert_se(manager_load_unit(m, "path-changed.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-changed.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); f = fopen(test_path, "w"); @@ -183,7 +183,7 @@ static void test_path_modified(Manager *m) { assert_se(touch(test_path) >= 0); - assert_se(manager_load_unit(m, "path-modified.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-modified.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); f = fopen(test_path, "w"); @@ -199,7 +199,7 @@ static void test_path_unit(Manager *m) { assert_se(m); - assert_se(manager_load_unit(m, "path-unit.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-unit.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); assert_se(touch(test_path) >= 0); @@ -215,7 +215,7 @@ static void test_path_directorynotempty(Manager *m) { assert_se(access(test_path, F_OK) < 0); - assert_se(manager_load_unit(m, "path-directorynotempty.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-directorynotempty.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); /* MakeDirectory default to no */ @@ -236,7 +236,7 @@ static void test_path_makedirectory_directorymode(Manager *m) { assert_se(access(test_path, F_OK) < 0); - assert_se(manager_load_unit(m, "path-makedirectory.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-makedirectory.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); /* Check if the directory has been created */ diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index abcda4dab5..6272505ce7 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -53,8 +53,7 @@ int main(int argc, char *argv[]) { assert_se(manager_startup(m, serial, fdset) >= 0); /* load idle ok */ - assert_se(manager_load_unit(m, "sched_idle_ok.service", NULL, NULL, &idle_ok) >= 0); - assert_se(idle_ok->load_state == UNIT_LOADED); + assert_se(manager_load_startable_unit_or_warn(m, "sched_idle_ok.service", NULL, &idle_ok) >= 0); ser = SERVICE(idle_ok); assert_se(ser->exec_context.cpu_sched_policy == SCHED_OTHER); assert_se(ser->exec_context.cpu_sched_priority == 0); @@ -62,8 +61,7 @@ int main(int argc, char *argv[]) { /* * load idle bad. This should print a warning but we have no way to look at it. */ - assert_se(manager_load_unit(m, "sched_idle_bad.service", NULL, NULL, &idle_bad) >= 0); - assert_se(idle_bad->load_state == UNIT_LOADED); + assert_se(manager_load_startable_unit_or_warn(m, "sched_idle_bad.service", NULL, &idle_bad) >= 0); ser = SERVICE(idle_ok); assert_se(ser->exec_context.cpu_sched_policy == SCHED_OTHER); assert_se(ser->exec_context.cpu_sched_priority == 0); @@ -72,8 +70,7 @@ int main(int argc, char *argv[]) { * load rr ok. * Test that the default priority is moving from 0 to 1. */ - assert_se(manager_load_unit(m, "sched_rr_ok.service", NULL, NULL, &rr_ok) >= 0); - assert_se(rr_ok->load_state == UNIT_LOADED); + assert_se(manager_load_startable_unit_or_warn(m, "sched_rr_ok.service", NULL, &rr_ok) >= 0); ser = SERVICE(rr_ok); assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR); assert_se(ser->exec_context.cpu_sched_priority == 1); @@ -82,8 +79,7 @@ int main(int argc, char *argv[]) { * load rr bad. * Test that the value of 0 and 100 is ignored. */ - assert_se(manager_load_unit(m, "sched_rr_bad.service", NULL, NULL, &rr_bad) >= 0); - assert_se(rr_bad->load_state == UNIT_LOADED); + assert_se(manager_load_startable_unit_or_warn(m, "sched_rr_bad.service", NULL, &rr_bad) >= 0); ser = SERVICE(rr_bad); assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR); assert_se(ser->exec_context.cpu_sched_priority == 1); @@ -92,8 +88,7 @@ int main(int argc, char *argv[]) { * load rr change. * Test that anything between 1 and 99 can be set. */ - assert_se(manager_load_unit(m, "sched_rr_change.service", NULL, NULL, &rr_sched) >= 0); - assert_se(rr_sched->load_state == UNIT_LOADED); + assert_se(manager_load_startable_unit_or_warn(m, "sched_rr_change.service", NULL, &rr_sched) >= 0); ser = SERVICE(rr_sched); assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR); assert_se(ser->exec_context.cpu_sched_priority == 99);