summaryrefslogtreecommitdiff
path: root/src/test/test-sched-prio.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-12 15:51:39 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-16 16:08:52 +0200
commitba412430a97ffbc02b3911c1b34db63e1524f7f9 (patch)
tree3138435150b872c7a045be6d65001c4d4cee3787 /src/test/test-sched-prio.c
parent4109ede7788c90e961b08c0da7d4da2d402931d7 (diff)
downloadsystemd-ba412430a97ffbc02b3911c1b34db63e1524f7f9.tar.gz
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.
Diffstat (limited to 'src/test/test-sched-prio.c')
-rw-r--r--src/test/test-sched-prio.c15
1 files changed, 5 insertions, 10 deletions
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);