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-sched-prio.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/test/test-sched-prio.c') 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); -- cgit v1.2.1