From 804cdabc31b38b840eec2b64dc8bdd9a8e660a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= Date: Thu, 6 Jun 2019 23:27:20 +0200 Subject: tests: Check job ordering on execution cycles The test-engine Test2 tests the cycle detection when units a, b and d all start at once ,-------------------after-----------------, v | a/start ---after---> d/start ---after---> b/start Extend the test with Test11 that adds i.service which causes a and d stop (by unordered Conflicts=) while starting b. Because stops precede starts, we effectively eliminate the job cycle and all transaction jobs should be applicable. ,-------------------after-----------------, v | a/stop <---after--- d/stop <---after--- b/start . . ^ . . | '. . . . . . . . . i/start ---after------' --- src/test/test-engine.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 701594fe53..3624a274e2 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -9,12 +9,14 @@ #include "rm-rf.h" #include "test-helper.h" #include "tests.h" +#include "service.h" 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_with_multiple_dashes = NULL; + Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, + *h = NULL, *i = NULL, *unit_with_multiple_dashes = NULL; Job *j; int r; @@ -94,6 +96,20 @@ int main(int argc, char *argv[]) { assert_se(manager_add_job(m, JOB_START, h, JOB_FAIL, NULL, NULL, &j) == 0); manager_dump_jobs(m, stdout, "\t"); + printf("Load5:\n"); + manager_clear_jobs(m); + assert_se(manager_load_startable_unit_or_warn(m, "i.service", NULL, &i) >= 0); + SERVICE(a)->state = SERVICE_RUNNING; + SERVICE(d)->state = SERVICE_RUNNING; + manager_dump_units(m, stdout, "\t"); + + printf("Test11: (Start/stop job ordering, execution cycle)\n"); + assert_se(manager_add_job(m, JOB_START, i, JOB_FAIL, NULL, NULL, &j) == 0); + assert_se(a->job && a->job->type == JOB_STOP); + assert_se(d->job && d->job->type == JOB_STOP); + assert_se(b->job && b->job->type == JOB_START); + manager_dump_jobs(m, stdout, "\t"); + assert_se(!hashmap_get(a->dependencies[UNIT_PROPAGATES_RELOAD_TO], b)); assert_se(!hashmap_get(b->dependencies[UNIT_RELOAD_PROPAGATED_FROM], a)); assert_se(!hashmap_get(a->dependencies[UNIT_PROPAGATES_RELOAD_TO], c)); -- cgit v1.2.3