diff options
author | Michal Koutný <mkoutny@suse.com> | 2019-06-06 23:27:20 +0200 |
---|---|---|
committer | Michal Koutný <xm.koutny@gmail.com> | 2019-06-26 23:16:31 +0200 |
commit | 804cdabc31b38b840eec2b64dc8bdd9a8e660a6f (patch) | |
tree | ce1bbbb84bc92f82b9e9d025f673a3802009c234 /src/test | |
parent | dfd79eca55e3d4bd61813ca4cf8887544d952c28 (diff) | |
download | systemd-804cdabc31b38b840eec2b64dc8bdd9a8e660a6f.tar.gz systemd-804cdabc31b38b840eec2b64dc8bdd9a8e660a6f.tar.bz2 systemd-804cdabc31b38b840eec2b64dc8bdd9a8e660a6f.zip |
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------'
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-engine.c | 18 |
1 files changed, 17 insertions, 1 deletions
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)); |