summaryrefslogtreecommitdiff
path: root/test-engine.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-20 18:26:29 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-20 18:26:29 +0100
commit279ade1311982e91a8baadf4deb6dabf651a1e5f (patch)
treedb7a9ee567707e5b574c1b39701cd73aad9e9696 /test-engine.c
parent7fad411cb551c3c1cbe801a3991e7a6966e462b5 (diff)
add missing test code
Diffstat (limited to 'test-engine.c')
-rw-r--r--test-engine.c46
1 files changed, 46 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;
+}