diff options
-rw-r--r-- | test-engine.c | 46 | ||||
-rw-r--r-- | test2/Makefile | 7 | ||||
-rw-r--r-- | test2/a.service | 4 | ||||
-rw-r--r-- | test2/b.service | 2 | ||||
-rw-r--r-- | test2/c.service | 3 | ||||
-rw-r--r-- | test2/d.service | 5 | ||||
-rw-r--r-- | test2/e.service | 5 |
7 files changed, 72 insertions, 0 deletions
diff --git a/test-engine.c b/test-engine.c new file mode 100644 index 0000000000..61882a960f --- /dev/null +++ b/test-engine.c @@ -0,0 +1,46 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <unistd.h> + +#include "manager.h" + +int main(int argc, char *argv[]) { + Manager *m = NULL; + Name *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e; + Job *j; + + assert_se(chdir("test2") == 0); + + assert_se(m = manager_new()); + + printf("Loaded1:\n"); + assert_se(manager_load_name(m, "a.service", &a) == 0); + assert_se(manager_load_name(m, "b.service", &b) == 0); + assert_se(manager_load_name(m, "c.service", &c) == 0); + manager_dump_names(m, stdout, "\t"); + + printf("Test1: (Trivial)\n"); + assert_se(manager_add_job(m, JOB_START, c, JOB_REPLACE, false, &j) == 0); + manager_dump_jobs(m, stdout, "\t"); + + printf("Loaded2:\n"); + manager_clear_jobs(m); + assert_se(manager_load_name(m, "d.service", &d) == 0); + assert_se(manager_load_name(m, "e.service", &e) == 0); + manager_dump_names(m, stdout, "\t"); + + printf("Test2: (Cyclic Order, Unfixable)\n"); + assert_se(manager_add_job(m, JOB_START, d, JOB_REPLACE, false, &j) == -ELOOP); + manager_dump_jobs(m, stdout, "\t"); + + printf("Test2: (Cyclic Order, Fixable)\n"); + assert_se(manager_add_job(m, JOB_START, e, JOB_REPLACE, false, &j) == 0); + manager_dump_jobs(m, stdout, "\t"); + + manager_free(m); + + return 0; +} diff --git a/test2/Makefile b/test2/Makefile new file mode 100644 index 0000000000..9aa46b4eb6 --- /dev/null +++ b/test2/Makefile @@ -0,0 +1,7 @@ +# Just a little hook script to easy building when in this directory + +all: + $(MAKE) -C .. + +clean: + $(MAKE) -C .. clean diff --git a/test2/a.service b/test2/a.service new file mode 100644 index 0000000000..4ddb8b4622 --- /dev/null +++ b/test2/a.service @@ -0,0 +1,4 @@ +[Meta] +Description=A +Requires=b.service +Before=b.service diff --git a/test2/b.service b/test2/b.service new file mode 100644 index 0000000000..b096e0d3fb --- /dev/null +++ b/test2/b.service @@ -0,0 +1,2 @@ +[Meta] +Description=B diff --git a/test2/c.service b/test2/c.service new file mode 100644 index 0000000000..8800ff70c7 --- /dev/null +++ b/test2/c.service @@ -0,0 +1,3 @@ +[Meta] +Description=C +Requires=a.service diff --git a/test2/d.service b/test2/d.service new file mode 100644 index 0000000000..279c1716c2 --- /dev/null +++ b/test2/d.service @@ -0,0 +1,5 @@ +[Meta] +Description=D:Cyclic +After=b.service +Before=a.service +Requires=a.service diff --git a/test2/e.service b/test2/e.service new file mode 100644 index 0000000000..2e86e33daf --- /dev/null +++ b/test2/e.service @@ -0,0 +1,5 @@ +[Meta] +Description=E:Cyclic +After=b.service +Before=a.service +Wants=a.service |