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------'
This commit is contained in:
parent
dfd79eca55
commit
804cdabc31
|
@ -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));
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=I
|
||||
Conflicts=a.service d.service
|
||||
Wants=b.service
|
||||
After=b.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/true
|
|
@ -26,6 +26,7 @@ test_data_files = '''
|
|||
hello-after-sleep.target
|
||||
hello.service
|
||||
hwdb/10-bad.hwdb
|
||||
i.service
|
||||
journal-data/journal-1.txt
|
||||
journal-data/journal-2.txt
|
||||
nomem.slice
|
||||
|
|
Loading…
Reference in New Issue