mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
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.
This commit is contained in:
parent
804cdabc31
commit
594057fd99
@ -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));
|
||||
|
8
test/a-conj.service
Normal file
8
test/a-conj.service
Normal file
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=A conjugate
|
||||
Requires=a.service
|
||||
After=a.service
|
||||
Before=a.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/true
|
@ -2,6 +2,7 @@
|
||||
|
||||
test_data_files = '''
|
||||
a.service
|
||||
a-conj.service
|
||||
b.service
|
||||
basic.target
|
||||
c.service
|
||||
|
Loading…
Reference in New Issue
Block a user