From 279ade1311982e91a8baadf4deb6dabf651a1e5f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 20 Jan 2010 18:26:29 +0100 Subject: [PATCH] add missing test code --- test-engine.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test2/Makefile | 7 +++++++ test2/a.service | 4 ++++ test2/b.service | 2 ++ test2/c.service | 3 +++ test2/d.service | 5 +++++ test2/e.service | 5 +++++ 7 files changed, 72 insertions(+) create mode 100644 test-engine.c create mode 100644 test2/Makefile create mode 100644 test2/a.service create mode 100644 test2/b.service create mode 100644 test2/c.service create mode 100644 test2/d.service create mode 100644 test2/e.service diff --git a/test-engine.c b/test-engine.c new file mode 100644 index 00000000..61882a96 --- /dev/null +++ b/test-engine.c @@ -0,0 +1,46 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +#include +#include +#include +#include + +#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 00000000..9aa46b4e --- /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 00000000..4ddb8b46 --- /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 00000000..b096e0d3 --- /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 00000000..8800ff70 --- /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 00000000..279c1716 --- /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 00000000..2e86e33d --- /dev/null +++ b/test2/e.service @@ -0,0 +1,5 @@ +[Meta] +Description=E:Cyclic +After=b.service +Before=a.service +Wants=a.service -- 2.39.5