From ba412430a97ffbc02b3911c1b34db63e1524f7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 12 Apr 2018 15:51:39 +0200 Subject: tests: use manager_load_startable_unit_or_warn() to load units Doing manager_load_unit() followed by UNIT_VTABLE(unit)->start(unit) would result in an assertion failure in ->start() if the unit failed to load properly. Something like this is okey-ish is tests, since the test units are not expected to fail to load, but the reason for failure is clearer if we fail immediately. --- src/test/test-cgroup-mask.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/test/test-cgroup-mask.c') 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); -- cgit v1.2.1