From: Michal Koutný Date: Thu, 6 Jun 2019 21:27:20 +0000 (+0200) Subject: tests: Check trivial loop between two jobs X-Git-Tag: v243-rc1~152^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=594057fd996ad8401b815ed974f1236c4edc3e08;p=thirdparty%2Fsystemd.git tests: Check trivial loop between two jobs job_compare return value is undefined in case the jobs have a loop between them, so better make a test to make sure transaction cycle detection catches it. --- diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 3624a274e28..9809d408f64 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { _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, *i = NULL, *unit_with_multiple_dashes = NULL; + *h = NULL, *i = NULL, *a_conj = NULL, *unit_with_multiple_dashes = NULL; Job *j; int r; @@ -110,6 +110,16 @@ int main(int argc, char *argv[]) { assert_se(b->job && b->job->type == JOB_START); manager_dump_jobs(m, stdout, "\t"); + printf("Load6:\n"); + manager_clear_jobs(m); + assert_se(manager_load_startable_unit_or_warn(m, "a-conj.service", NULL, &a_conj) >= 0); + SERVICE(a)->state = SERVICE_DEAD; + manager_dump_units(m, stdout, "\t"); + + printf("Test12: (Trivial cycle, Unfixable)\n"); + assert_se(manager_add_job(m, JOB_START, a_conj, JOB_REPLACE, NULL, NULL, &j) == -EDEADLK); + 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)); diff --git a/test/a-conj.service b/test/a-conj.service new file mode 100644 index 00000000000..db37ae71d40 --- /dev/null +++ b/test/a-conj.service @@ -0,0 +1,8 @@ +[Unit] +Description=A conjugate +Requires=a.service +After=a.service +Before=a.service + +[Service] +ExecStart=/bin/true diff --git a/test/meson.build b/test/meson.build index a2435380811..8c71e726678 100644 --- a/test/meson.build +++ b/test/meson.build @@ -2,6 +2,7 @@ test_data_files = ''' a.service + a-conj.service b.service basic.target c.service