[systemd-commits] Makefile.am src/test-cgroup.c src/test-daemon.c src/test-engine.c src/test-env-replace.c src/test-hostname.c src/test-id128.c src/test-install.c src/test-job-type.c src/test-loopback.c src/test-ns.c src/test-strv.c src/test-watchdog.c test/test-cgroup.c test/test-daemon.c test/test-engine.c test/test-env-replace.c test/test-hostname.c test/test-id128.c test/test-install.c test/test-job-type.c test/test-loopback.c test/test-ns.c test/test-strv.c test/test-watchdog.c

Kay Sievers kay at kemper.freedesktop.org
Thu Apr 12 04:21:26 PDT 2012


 Makefile.am             |   24 ++--
 src/test-cgroup.c       |  104 ------------------
 src/test-daemon.c       |   37 ------
 src/test-engine.c       |   99 ------------------
 src/test-env-replace.c  |  127 -----------------------
 src/test-hostname.c     |   37 ------
 src/test-id128.c        |   52 ---------
 src/test-install.c      |  264 ------------------------------------------------
 src/test-job-type.c     |   84 ---------------
 src/test-loopback.c     |   37 ------
 src/test-ns.c           |   60 ----------
 src/test-strv.c         |   66 ------------
 src/test-watchdog.c     |   51 ---------
 test/test-cgroup.c      |  104 ++++++++++++++++++
 test/test-daemon.c      |   37 ++++++
 test/test-engine.c      |   99 ++++++++++++++++++
 test/test-env-replace.c |  127 +++++++++++++++++++++++
 test/test-hostname.c    |   37 ++++++
 test/test-id128.c       |   52 +++++++++
 test/test-install.c     |  264 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/test-job-type.c    |   84 +++++++++++++++
 test/test-loopback.c    |   37 ++++++
 test/test-ns.c          |   60 ++++++++++
 test/test-strv.c        |   66 ++++++++++++
 test/test-watchdog.c    |   51 +++++++++
 25 files changed, 1030 insertions(+), 1030 deletions(-)

New commits:
commit 6af684ee5cf49f3d0fef16369c3c2782c8a73357
Author: Kay Sievers <kay at vrfy.org>
Date:   Thu Apr 12 13:17:41 2012 +0200

    move a couple of test-*.c to test/

diff --git a/Makefile.am b/Makefile.am
index 3a1e042..4a12d89 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -828,7 +828,7 @@ systemd_LDADD = \
 
 # ------------------------------------------------------------------------------
 test_engine_SOURCES = \
-	src/test-engine.c
+	test/test-engine.c
 
 test_engine_CFLAGS = \
 	$(AM_CFLAGS) \
@@ -839,7 +839,7 @@ test_engine_LDADD = \
 	libsystemd-daemon.la
 
 test_job_type_SOURCES = \
-	src/test-job-type.c
+	test/test-job-type.c
 
 test_job_type_CFLAGS = \
 	$(AM_CFLAGS) \
@@ -849,51 +849,51 @@ test_job_type_LDADD = \
 	libsystemd-core.la
 
 test_ns_SOURCES = \
-	src/test-ns.c
+	test/test-ns.c
 
 test_ns_LDADD = \
 	libsystemd-core.la
 
 test_loopback_SOURCES = \
-	src/test-loopback.c
+	test/test-loopback.c
 
 test_loopback_LDADD = \
 	libsystemd-shared.la
 
 test_hostname_SOURCES = \
-	src/test-hostname.c
+	test/test-hostname.c
 
 test_hostname_LDADD = \
 	libsystemd-shared.la
 
 test_daemon_SOURCES = \
-	src/test-daemon.c
+	test/test-daemon.c
 
 test_daemon_LDADD = \
 	libsystemd-shared.la \
 	libsystemd-daemon.la
 
 test_cgroup_SOURCES = \
-	src/test-cgroup.c
+	test/test-cgroup.c
 
 test_cgroup_LDADD = \
 	libsystemd-label.la \
 	libsystemd-shared.la
 
 test_env_replace_SOURCES = \
-	src/test-env-replace.c
+	test/test-env-replace.c
 
 test_env_replace_LDADD = \
 	libsystemd-shared.la
 
 test_strv_SOURCES = \
-	src/test-strv.c
+	test/test-strv.c
 
 test_strv_LDADD = \
 	libsystemd-shared.la
 
 test_install_SOURCES = \
-	src/test-install.c
+	test/test-install.c
 
 test_install_CFLAGS = \
 	$(AM_CFLAGS) \
@@ -904,7 +904,7 @@ test_install_LDADD = \
 	libsystemd-shared.la
 
 test_watchdog_SOURCES = \
-	src/test-watchdog.c
+	test/test-watchdog.c
 
 test_watchdog_LDADD = \
 	libsystemd-shared.la
@@ -1863,7 +1863,7 @@ libsystemd_id128_la_LIBADD = \
 	libsystemd-shared.la
 
 test_id128_SOURCES = \
-	src/test-id128.c
+	test/test-id128.c
 
 test_id128_LDADD = \
 	libsystemd-shared.la \
diff --git a/src/test-cgroup.c b/src/test-cgroup.c
deleted file mode 100644
index e742632..0000000
--- a/src/test-cgroup.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-#include <string.h>
-
-#include "cgroup-util.h"
-#include "util.h"
-#include "log.h"
-
-int main(int argc, char*argv[]) {
-        char *path;
-        char *c, *p;
-
-        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
-        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
-        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b") == 0);
-        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-c") == 0);
-        assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0) == 0);
-
-        assert_se(cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, getpid(), &path) == 0);
-        assert_se(streq(path, "/test-b"));
-        free(path);
-
-        assert_se(cg_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-a", 0) == 0);
-
-        assert_se(cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, getpid(), &path) == 0);
-        assert_se(path_equal(path, "/test-a"));
-        free(path);
-
-        assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", 0) == 0);
-
-        assert_se(cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, getpid(), &path) == 0);
-        assert_se(path_equal(path, "/test-b/test-d"));
-        free(path);
-
-        assert_se(cg_get_path(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", NULL, &path) == 0);
-        assert_se(path_equal(path, "/sys/fs/cgroup/systemd/test-b/test-d"));
-        free(path);
-
-        assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, "/test-a", false) > 0);
-        assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, "/test-b", false) > 0);
-        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", false) > 0);
-        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", false) == 0);
-
-        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", 0, false, false, false, NULL) == 0);
-        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0, false, false, false, NULL) > 0);
-
-        assert_se(cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", "/test-a", false, false) > 0);
-
-        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", false) == 0);
-        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", false) > 0);
-
-        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", 0, false, false, false, NULL) > 0);
-        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0, false, false, false, NULL) == 0);
-
-        cg_trim(SYSTEMD_CGROUP_CONTROLLER, "/", false);
-
-        assert_se(cg_delete(SYSTEMD_CGROUP_CONTROLLER, "/test-b") < 0);
-        assert_se(cg_delete(SYSTEMD_CGROUP_CONTROLLER, "/test-a") >= 0);
-
-        assert_se(cg_split_spec("foobar:/", &c, &p) == 0);
-        assert(streq(c, "foobar"));
-        assert(streq(p, "/"));
-        free(c);
-        free(p);
-
-        assert_se(cg_split_spec("foobar:", &c, &p) < 0);
-        assert_se(cg_split_spec("foobar:asdfd", &c, &p) < 0);
-        assert_se(cg_split_spec(":///", &c, &p) < 0);
-        assert_se(cg_split_spec(":", &c, &p) < 0);
-        assert_se(cg_split_spec("", &c, &p) < 0);
-        assert_se(cg_split_spec("fo/obar:/", &c, &p) < 0);
-
-        assert_se(cg_split_spec("/", &c, &p) >= 0);
-        assert(c == NULL);
-        assert(streq(p, "/"));
-        free(p);
-
-        assert_se(cg_split_spec("foo", &c, &p) >= 0);
-        assert(streq(c, "foo"));
-        assert(p == NULL);
-        free(c);
-
-        return 0;
-}
diff --git a/src/test-daemon.c b/src/test-daemon.c
deleted file mode 100644
index 3215f0c..0000000
--- a/src/test-daemon.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-
-#include <systemd/sd-daemon.h>
-
-int main(int argc, char*argv[]) {
-
-        sd_notify(0, "STATUS=Starting up");
-        sleep(5);
-        sd_notify(0,
-                  "STATUS=Running\n"
-                  "READY=1");
-        sleep(10);
-        sd_notify(0, "STATUS=Quitting");
-
-        return 0;
-}
diff --git a/src/test-engine.c b/src/test-engine.c
deleted file mode 100644
index 11389a5..0000000
--- a/src/test-engine.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "manager.h"
-
-int main(int argc, char *argv[]) {
-        Manager *m = NULL;
-        Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, *h = NULL;
-        Job *j;
-
-        assert_se(set_unit_path("test") >= 0);
-
-        assert_se(manager_new(MANAGER_SYSTEM, &m) >= 0);
-
-        printf("Load1:\n");
-        assert_se(manager_load_unit(m, "a.service", NULL, NULL, &a) >= 0);
-        assert_se(manager_load_unit(m, "b.service", NULL, NULL, &b) >= 0);
-        assert_se(manager_load_unit(m, "c.service", NULL, NULL, &c) >= 0);
-        manager_dump_units(m, stdout, "\t");
-
-        printf("Test1: (Trivial)\n");
-        assert_se(manager_add_job(m, JOB_START, c, JOB_REPLACE, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Load2:\n");
-        manager_clear_jobs(m);
-        assert_se(manager_load_unit(m, "d.service", NULL, NULL, &d) >= 0);
-        assert_se(manager_load_unit(m, "e.service", NULL, NULL, &e) >= 0);
-        manager_dump_units(m, stdout, "\t");
-
-        printf("Test2: (Cyclic Order, Unfixable)\n");
-        assert_se(manager_add_job(m, JOB_START, d, JOB_REPLACE, false, NULL, &j) == -ENOEXEC);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Test3: (Cyclic Order, Fixable, Garbage Collector)\n");
-        assert_se(manager_add_job(m, JOB_START, e, JOB_REPLACE, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Test4: (Identical transaction)\n");
-        assert_se(manager_add_job(m, JOB_START, e, JOB_FAIL, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Load3:\n");
-        assert_se(manager_load_unit(m, "g.service", NULL, NULL, &g) >= 0);
-        manager_dump_units(m, stdout, "\t");
-
-        printf("Test5: (Colliding transaction, fail)\n");
-        assert_se(manager_add_job(m, JOB_START, g, JOB_FAIL, false, NULL, &j) == -EEXIST);
-
-        printf("Test6: (Colliding transaction, replace)\n");
-        assert_se(manager_add_job(m, JOB_START, g, JOB_REPLACE, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Test7: (Unmergeable job type, fail)\n");
-        assert_se(manager_add_job(m, JOB_STOP, g, JOB_FAIL, false, NULL, &j) == -EEXIST);
-
-        printf("Test8: (Mergeable job type, fail)\n");
-        assert_se(manager_add_job(m, JOB_RESTART, g, JOB_FAIL, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Test9: (Unmergeable job type, replace)\n");
-        assert_se(manager_add_job(m, JOB_STOP, g, JOB_REPLACE, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        printf("Load4:\n");
-        assert_se(manager_load_unit(m, "h.service", NULL, NULL, &h) >= 0);
-        manager_dump_units(m, stdout, "\t");
-
-        printf("Test10: (Unmergeable job type of auxiliary job, fail)\n");
-        assert_se(manager_add_job(m, JOB_START, h, JOB_FAIL, false, NULL, &j) == 0);
-        manager_dump_jobs(m, stdout, "\t");
-
-        manager_free(m);
-
-        return 0;
-}
diff --git a/src/test-env-replace.c b/src/test-env-replace.c
deleted file mode 100644
index 4b6b884..0000000
--- a/src/test-env-replace.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-#include <string.h>
-
-#include "util.h"
-#include "log.h"
-#include "strv.h"
-
-int main(int argc, char *argv[]) {
-
-        const char *env[] = {
-                "FOO=BAR BAR",
-                "BAR=waldo",
-                NULL
-        };
-
-        const char *line[] = {
-                "FOO$FOO",
-                "FOO$FOOFOO",
-                "FOO${FOO}$FOO",
-                "FOO${FOO}",
-                "${FOO}",
-                "$FOO",
-                "$FOO$FOO",
-                "${FOO}${BAR}",
-                "${FOO",
-                NULL
-        };
-
-        char **i, **r, *t, **a, **b;
-        const char nulstr[] = "fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx";
-
-        a = strv_parse_nulstr(nulstr, sizeof(nulstr)-1);
-
-        STRV_FOREACH(i, a)
-                printf("nulstr--%s\n", *i);
-
-        strv_free(a);
-
-        r = replace_env_argv((char**) line, (char**) env);
-
-        STRV_FOREACH(i, r)
-                printf("%s\n", *i);
-
-        strv_free(r);
-
-        t = normalize_env_assignment("foo=bar");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("=bar");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("foo=");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("=");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("a=\"waldo\"");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("a=\"waldo");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("a=waldo\"");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("a=\'");
-        printf("%s\n", t);
-        free(t);
-
-        t = normalize_env_assignment("a=\'\'");
-        printf("%s\n", t);
-        free(t);
-
-        a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", NULL);
-        b = strv_new("FOO=KKK", "FOO=", "PIEP=", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
-
-        r = strv_env_merge(2, a, b);
-        strv_free(a);
-        strv_free(b);
-
-        STRV_FOREACH(i, r)
-                printf("%s\n", *i);
-
-        printf("CLEANED UP:\n");
-
-        r = strv_env_clean(r);
-
-        STRV_FOREACH(i, r)
-                printf("%s\n", *i);
-
-        strv_free(r);
-
-        return 0;
-}
diff --git a/src/test-hostname.c b/src/test-hostname.c
deleted file mode 100644
index 8c1a60f..0000000
--- a/src/test-hostname.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#include "hostname-setup.h"
-#include "util.h"
-
-int main(int argc, char* argv[]) {
-        int r;
-
-        if ((r = hostname_setup()) < 0)
-                fprintf(stderr, "hostname: %s\n", strerror(-r));
-
-        return 0;
-}
diff --git a/src/test-id128.c b/src/test-id128.c
deleted file mode 100644
index bfd743e..0000000
--- a/src/test-id128.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2011 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <string.h>
-
-#include <systemd/sd-id128.h>
-
-#include "util.h"
-#include "macro.h"
-
-#define ID128_WALDI SD_ID128_MAKE(01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0c, 0d, 0e, 0f, 10)
-
-int main(int argc, char *argv[]) {
-        sd_id128_t id, id2;
-        char t[33];
-
-        assert_se(sd_id128_randomize(&id) == 0);
-        printf("random: %s\n", sd_id128_to_string(id, t));
-
-        assert_se(sd_id128_from_string(t, &id2) == 0);
-        assert_se(sd_id128_equal(id, id2));
-
-        assert_se(sd_id128_get_machine(&id) == 0);
-        printf("machine: %s\n", sd_id128_to_string(id, t));
-
-        assert_se(sd_id128_get_boot(&id) == 0);
-        printf("boot: %s\n", sd_id128_to_string(id, t));
-
-        printf("waldi: %s\n", sd_id128_to_string(ID128_WALDI, t));
-
-        printf("waldi2: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(ID128_WALDI));
-
-        return 0;
-}
diff --git a/src/test-install.c b/src/test-install.c
deleted file mode 100644
index 709974f..0000000
--- a/src/test-install.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2011 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#include "util.h"
-#include "install.h"
-
-static void dump_changes(UnitFileChange *c, unsigned n) {
-        unsigned i;
-
-        assert(n == 0 || c);
-
-        for (i = 0; i < n; i++) {
-                if (c[i].type == UNIT_FILE_UNLINK)
-                        printf("rm '%s'\n", c[i].path);
-                else if (c[i].type == UNIT_FILE_SYMLINK)
-                        printf("ln -s '%s' '%s'\n", c[i].source, c[i].path);
-        }
-}
-
-int main(int argc, char* argv[]) {
-        Hashmap *h;
-        UnitFileList *p;
-        Iterator i;
-        int r;
-        const char *const files[] = { "avahi-daemon.service", NULL };
-        const char *const files2[] = { "/home/lennart/test.service", NULL };
-        UnitFileChange *changes = NULL;
-        unsigned n_changes = 0;
-
-        h = hashmap_new(string_hash_func, string_compare_func);
-        r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h);
-        assert_se(r == 0);
-
-        HASHMAP_FOREACH(p, h, i) {
-                UnitFileState s;
-
-                s = unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(p->path));
-
-                assert_se(p->state == s);
-
-                fprintf(stderr, "%s (%s)\n",
-                        p->path,
-                        unit_file_state_to_string(p->state));
-        }
-
-        unit_file_list_free(h);
-
-        log_error("enable");
-
-        r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        log_error("enable2");
-
-        r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_ENABLED);
-
-        log_error("disable");
-
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_DISABLED);
-
-        log_error("mask");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
-        assert_se(r >= 0);
-        log_error("mask2");
-        r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_MASKED);
-
-        log_error("unmask");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
-        assert_se(r >= 0);
-        log_error("unmask2");
-        r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_DISABLED);
-
-        log_error("mask");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_MASKED);
-
-        log_error("disable");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
-        assert_se(r >= 0);
-        log_error("disable2");
-        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_MASKED);
-
-        log_error("umask");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_DISABLED);
-
-        log_error("enable files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_ENABLED);
-
-        log_error("disable files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
-
-        log_error("link files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_link(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_LINKED);
-
-        log_error("disable files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
-
-        log_error("link files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_link(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_LINKED);
-
-        log_error("reenable files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_reenable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_ENABLED);
-
-        log_error("disable files2");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
-        log_error("preset files");
-        changes = NULL;
-        n_changes = 0;
-
-        r = unit_file_preset(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
-        assert_se(r >= 0);
-
-        dump_changes(changes, n_changes);
-        unit_file_changes_free(changes, n_changes);
-
-        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files[0])) == UNIT_FILE_ENABLED);
-
-        return 0;
-}
diff --git a/src/test-job-type.c b/src/test-job-type.c
deleted file mode 100644
index ba8b307..0000000
--- a/src/test-job-type.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "job.h"
-
-int main(int argc, char*argv[]) {
-        JobType a, b, c, d, e, f, g;
-
-        for (a = 0; a < _JOB_TYPE_MAX; a++)
-                for (b = 0; b < _JOB_TYPE_MAX; b++) {
-
-                        if (!job_type_is_mergeable(a, b))
-                                printf("Not mergeable: %s + %s\n", job_type_to_string(a), job_type_to_string(b));
-
-                        for (c = 0; c < _JOB_TYPE_MAX; c++) {
-
-                                /* Verify transitivity of mergeability
-                                 * of job types */
-                                assert(!job_type_is_mergeable(a, b) ||
-                                       !job_type_is_mergeable(b, c) ||
-                                       job_type_is_mergeable(a, c));
-
-                                d = a;
-                                if (job_type_merge(&d, b) >= 0) {
-
-                                        printf("%s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(d));
-
-                                        /* Verify that merged entries can be
-                                         * merged with the same entries they
-                                         * can be merged with separately */
-                                        assert(!job_type_is_mergeable(a, c) || job_type_is_mergeable(d, c));
-                                        assert(!job_type_is_mergeable(b, c) || job_type_is_mergeable(d, c));
-
-                                        /* Verify that if a merged
-                                         * with b is not mergeable with
-                                         * c then either a or b is not
-                                         * mergeable with c either. */
-                                        assert(job_type_is_mergeable(d, c) || !job_type_is_mergeable(a, c) || !job_type_is_mergeable(b, c));
-
-                                        e = b;
-                                        if (job_type_merge(&e, c) >= 0) {
-
-                                                /* Verify associativity */
-
-                                                f = d;
-                                                assert(job_type_merge(&f, c) == 0);
-
-                                                g = e;
-                                                assert(job_type_merge(&g, a) == 0);
-
-                                                assert(f == g);
-
-                                                printf("%s + %s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(c), job_type_to_string(d));
-                                        }
-                                }
-                        }
-                }
-
-
-        return 0;
-}
diff --git a/src/test-loopback.c b/src/test-loopback.c
deleted file mode 100644
index ab330ac..0000000
--- a/src/test-loopback.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#include "loopback-setup.h"
-#include "util.h"
-
-int main(int argc, char* argv[]) {
-        int r;
-
-        if ((r = loopback_setup()) < 0)
-                fprintf(stderr, "loopback: %s\n", strerror(-r));
-
-        return 0;
-}
diff --git a/src/test-ns.c b/src/test-ns.c
deleted file mode 100644
index 102b005..0000000
--- a/src/test-ns.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mount.h>
-#include <linux/fs.h>
-
-#include "namespace.h"
-#include "log.h"
-
-int main(int argc, char *argv[]) {
-        const char * const writable[] = {
-                "/home",
-                NULL
-        };
-
-        const char * const readable[] = {
-                "/",
-                "/usr",
-                "/boot",
-                NULL
-        };
-
-        const char * const inaccessible[] = {
-                "/home/lennart/projects",
-                NULL
-        };
-
-        int r;
-
-        if ((r = setup_namespace((char**) writable, (char**) readable, (char**) inaccessible, true, MS_SHARED)) < 0) {
-                log_error("Failed to setup namespace: %s", strerror(-r));
-                return 1;
-        }
-
-        execl("/bin/sh", "/bin/sh", NULL);
-        log_error("execl(): %m");
-
-        return 1;
-}
diff --git a/src/test-strv.c b/src/test-strv.c
deleted file mode 100644
index 5ee4447..0000000
--- a/src/test-strv.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <string.h>
-
-#include "util.h"
-#include "specifier.h"
-
-int main(int argc, char *argv[]) {
-        const Specifier table[] = {
-                { 'a', specifier_string, (char*) "AAAA" },
-                { 'b', specifier_string, (char*) "BBBB" },
-                { 0, NULL, NULL }
-        };
-
-        char *w, *state;
-        size_t l;
-        const char test[] = "test a b c 'd' e '' '' hhh '' ''";
-
-        printf("<%s>\n", test);
-
-        FOREACH_WORD_QUOTED(w, l, test, state) {
-                char *t;
-
-                assert_se(t = strndup(w, l));
-                printf("<%s>\n", t);
-                free(t);
-        }
-
-        printf("%s\n", default_term_for_tty("/dev/tty23"));
-        printf("%s\n", default_term_for_tty("/dev/ttyS23"));
-        printf("%s\n", default_term_for_tty("/dev/tty0"));
-        printf("%s\n", default_term_for_tty("/dev/pty0"));
-        printf("%s\n", default_term_for_tty("/dev/pts/0"));
-        printf("%s\n", default_term_for_tty("/dev/console"));
-        printf("%s\n", default_term_for_tty("tty23"));
-        printf("%s\n", default_term_for_tty("ttyS23"));
-        printf("%s\n", default_term_for_tty("tty0"));
-        printf("%s\n", default_term_for_tty("pty0"));
-        printf("%s\n", default_term_for_tty("pts/0"));
-        printf("%s\n", default_term_for_tty("console"));
-
-        w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
-        printf("<%s>\n", w);
-        free(w);
-
-        return 0;
-}
diff --git a/src/test-watchdog.c b/src/test-watchdog.c
deleted file mode 100644
index ccb1854..0000000
--- a/src/test-watchdog.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2012 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-#include <string.h>
-
-#include "watchdog.h"
-#include "log.h"
-
-int main(int argc, char *argv[]) {
-        usec_t t = 10 * USEC_PER_SEC;
-        unsigned i;
-        int r;
-
-        log_set_max_level(LOG_DEBUG);
-        log_parse_environment();
-
-        r = watchdog_set_timeout(&t);
-        if (r < 0)
-                log_warning("Failed to open watchdog: %s", strerror(-r));
-
-        for (i = 0; i < 5; i++) {
-                log_info("Pinging...");
-                r = watchdog_ping();
-                if (r < 0)
-                        log_warning("Failed to ping watchdog: %s", strerror(-r));
-
-                usleep(t/2);
-        }
-
-        watchdog_close(true);
-        return 0;
-}
diff --git a/test/test-cgroup.c b/test/test-cgroup.c
new file mode 100644
index 0000000..e742632
--- /dev/null
+++ b/test/test-cgroup.c
@@ -0,0 +1,104 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <unistd.h>
+#include <string.h>
+
+#include "cgroup-util.h"
+#include "util.h"
+#include "log.h"
+
+int main(int argc, char*argv[]) {
+        char *path;
+        char *c, *p;
+
+        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
+        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
+        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b") == 0);
+        assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-c") == 0);
+        assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0) == 0);
+
+        assert_se(cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, getpid(), &path) == 0);
+        assert_se(streq(path, "/test-b"));
+        free(path);
+
+        assert_se(cg_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-a", 0) == 0);
+
+        assert_se(cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, getpid(), &path) == 0);
+        assert_se(path_equal(path, "/test-a"));
+        free(path);
+
+        assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", 0) == 0);
+
+        assert_se(cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, getpid(), &path) == 0);
+        assert_se(path_equal(path, "/test-b/test-d"));
+        free(path);
+
+        assert_se(cg_get_path(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", NULL, &path) == 0);
+        assert_se(path_equal(path, "/sys/fs/cgroup/systemd/test-b/test-d"));
+        free(path);
+
+        assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, "/test-a", false) > 0);
+        assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, "/test-b", false) > 0);
+        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", false) > 0);
+        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", false) == 0);
+
+        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", 0, false, false, false, NULL) == 0);
+        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0, false, false, false, NULL) > 0);
+
+        assert_se(cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", "/test-a", false, false) > 0);
+
+        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", false) == 0);
+        assert_se(cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", false) > 0);
+
+        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", 0, false, false, false, NULL) > 0);
+        assert_se(cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0, false, false, false, NULL) == 0);
+
+        cg_trim(SYSTEMD_CGROUP_CONTROLLER, "/", false);
+
+        assert_se(cg_delete(SYSTEMD_CGROUP_CONTROLLER, "/test-b") < 0);
+        assert_se(cg_delete(SYSTEMD_CGROUP_CONTROLLER, "/test-a") >= 0);
+
+        assert_se(cg_split_spec("foobar:/", &c, &p) == 0);
+        assert(streq(c, "foobar"));
+        assert(streq(p, "/"));
+        free(c);
+        free(p);
+
+        assert_se(cg_split_spec("foobar:", &c, &p) < 0);
+        assert_se(cg_split_spec("foobar:asdfd", &c, &p) < 0);
+        assert_se(cg_split_spec(":///", &c, &p) < 0);
+        assert_se(cg_split_spec(":", &c, &p) < 0);
+        assert_se(cg_split_spec("", &c, &p) < 0);
+        assert_se(cg_split_spec("fo/obar:/", &c, &p) < 0);
+
+        assert_se(cg_split_spec("/", &c, &p) >= 0);
+        assert(c == NULL);
+        assert(streq(p, "/"));
+        free(p);
+
+        assert_se(cg_split_spec("foo", &c, &p) >= 0);
+        assert(streq(c, "foo"));
+        assert(p == NULL);
+        free(c);
+
+        return 0;
+}
diff --git a/test/test-daemon.c b/test/test-daemon.c
new file mode 100644
index 0000000..3215f0c
--- /dev/null
+++ b/test/test-daemon.c
@@ -0,0 +1,37 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <unistd.h>
+
+#include <systemd/sd-daemon.h>
+
+int main(int argc, char*argv[]) {
+
+        sd_notify(0, "STATUS=Starting up");
+        sleep(5);
+        sd_notify(0,
+                  "STATUS=Running\n"
+                  "READY=1");
+        sleep(10);
+        sd_notify(0, "STATUS=Quitting");
+
+        return 0;
+}
diff --git a/test/test-engine.c b/test/test-engine.c
new file mode 100644
index 0000000..11389a5
--- /dev/null
+++ b/test/test-engine.c
@@ -0,0 +1,99 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "manager.h"
+
+int main(int argc, char *argv[]) {
+        Manager *m = NULL;
+        Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, *h = NULL;
+        Job *j;
+
+        assert_se(set_unit_path("test") >= 0);
+
+        assert_se(manager_new(MANAGER_SYSTEM, &m) >= 0);
+
+        printf("Load1:\n");
+        assert_se(manager_load_unit(m, "a.service", NULL, NULL, &a) >= 0);
+        assert_se(manager_load_unit(m, "b.service", NULL, NULL, &b) >= 0);
+        assert_se(manager_load_unit(m, "c.service", NULL, NULL, &c) >= 0);
+        manager_dump_units(m, stdout, "\t");
+
+        printf("Test1: (Trivial)\n");
+        assert_se(manager_add_job(m, JOB_START, c, JOB_REPLACE, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Load2:\n");
+        manager_clear_jobs(m);
+        assert_se(manager_load_unit(m, "d.service", NULL, NULL, &d) >= 0);
+        assert_se(manager_load_unit(m, "e.service", NULL, NULL, &e) >= 0);
+        manager_dump_units(m, stdout, "\t");
+
+        printf("Test2: (Cyclic Order, Unfixable)\n");
+        assert_se(manager_add_job(m, JOB_START, d, JOB_REPLACE, false, NULL, &j) == -ENOEXEC);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Test3: (Cyclic Order, Fixable, Garbage Collector)\n");
+        assert_se(manager_add_job(m, JOB_START, e, JOB_REPLACE, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Test4: (Identical transaction)\n");
+        assert_se(manager_add_job(m, JOB_START, e, JOB_FAIL, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Load3:\n");
+        assert_se(manager_load_unit(m, "g.service", NULL, NULL, &g) >= 0);
+        manager_dump_units(m, stdout, "\t");
+
+        printf("Test5: (Colliding transaction, fail)\n");
+        assert_se(manager_add_job(m, JOB_START, g, JOB_FAIL, false, NULL, &j) == -EEXIST);
+
+        printf("Test6: (Colliding transaction, replace)\n");
+        assert_se(manager_add_job(m, JOB_START, g, JOB_REPLACE, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Test7: (Unmergeable job type, fail)\n");
+        assert_se(manager_add_job(m, JOB_STOP, g, JOB_FAIL, false, NULL, &j) == -EEXIST);
+
+        printf("Test8: (Mergeable job type, fail)\n");
+        assert_se(manager_add_job(m, JOB_RESTART, g, JOB_FAIL, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Test9: (Unmergeable job type, replace)\n");
+        assert_se(manager_add_job(m, JOB_STOP, g, JOB_REPLACE, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        printf("Load4:\n");
+        assert_se(manager_load_unit(m, "h.service", NULL, NULL, &h) >= 0);
+        manager_dump_units(m, stdout, "\t");
+
+        printf("Test10: (Unmergeable job type of auxiliary job, fail)\n");
+        assert_se(manager_add_job(m, JOB_START, h, JOB_FAIL, false, NULL, &j) == 0);
+        manager_dump_jobs(m, stdout, "\t");
+
+        manager_free(m);
+
+        return 0;
+}
diff --git a/test/test-env-replace.c b/test/test-env-replace.c
new file mode 100644
index 0000000..4b6b884
--- /dev/null
+++ b/test/test-env-replace.c
@@ -0,0 +1,127 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <unistd.h>
+#include <string.h>
+
+#include "util.h"
+#include "log.h"
+#include "strv.h"
+
+int main(int argc, char *argv[]) {
+
+        const char *env[] = {
+                "FOO=BAR BAR",
+                "BAR=waldo",
+                NULL
+        };
+
+        const char *line[] = {
+                "FOO$FOO",
+                "FOO$FOOFOO",
+                "FOO${FOO}$FOO",
+                "FOO${FOO}",
+                "${FOO}",
+                "$FOO",
+                "$FOO$FOO",
+                "${FOO}${BAR}",
+                "${FOO",
+                NULL
+        };
+
+        char **i, **r, *t, **a, **b;
+        const char nulstr[] = "fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx";
+
+        a = strv_parse_nulstr(nulstr, sizeof(nulstr)-1);
+
+        STRV_FOREACH(i, a)
+                printf("nulstr--%s\n", *i);
+
+        strv_free(a);
+
+        r = replace_env_argv((char**) line, (char**) env);
+
+        STRV_FOREACH(i, r)
+                printf("%s\n", *i);
+
+        strv_free(r);
+
+        t = normalize_env_assignment("foo=bar");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("=bar");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("foo=");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("=");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("a=\"waldo\"");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("a=\"waldo");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("a=waldo\"");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("a=\'");
+        printf("%s\n", t);
+        free(t);
+
+        t = normalize_env_assignment("a=\'\'");
+        printf("%s\n", t);
+        free(t);
+
+        a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", NULL);
+        b = strv_new("FOO=KKK", "FOO=", "PIEP=", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
+
+        r = strv_env_merge(2, a, b);
+        strv_free(a);
+        strv_free(b);
+
+        STRV_FOREACH(i, r)
+                printf("%s\n", *i);
+
+        printf("CLEANED UP:\n");
+
+        r = strv_env_clean(r);
+
+        STRV_FOREACH(i, r)
+                printf("%s\n", *i);
+
+        strv_free(r);
+
+        return 0;
+}
diff --git a/test/test-hostname.c b/test/test-hostname.c
new file mode 100644
index 0000000..8c1a60f
--- /dev/null
+++ b/test/test-hostname.c
@@ -0,0 +1,37 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include "hostname-setup.h"
+#include "util.h"
+
+int main(int argc, char* argv[]) {
+        int r;
+
+        if ((r = hostname_setup()) < 0)
+                fprintf(stderr, "hostname: %s\n", strerror(-r));
+
+        return 0;
+}
diff --git a/test/test-id128.c b/test/test-id128.c
new file mode 100644
index 0000000..bfd743e
--- /dev/null
+++ b/test/test-id128.c
@@ -0,0 +1,52 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2011 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <string.h>
+
+#include <systemd/sd-id128.h>
+
+#include "util.h"
+#include "macro.h"
+
+#define ID128_WALDI SD_ID128_MAKE(01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0c, 0d, 0e, 0f, 10)
+
+int main(int argc, char *argv[]) {
+        sd_id128_t id, id2;
+        char t[33];
+
+        assert_se(sd_id128_randomize(&id) == 0);
+        printf("random: %s\n", sd_id128_to_string(id, t));
+
+        assert_se(sd_id128_from_string(t, &id2) == 0);
+        assert_se(sd_id128_equal(id, id2));
+
+        assert_se(sd_id128_get_machine(&id) == 0);
+        printf("machine: %s\n", sd_id128_to_string(id, t));
+
+        assert_se(sd_id128_get_boot(&id) == 0);
+        printf("boot: %s\n", sd_id128_to_string(id, t));
+
+        printf("waldi: %s\n", sd_id128_to_string(ID128_WALDI, t));
+
+        printf("waldi2: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(ID128_WALDI));
+
+        return 0;
+}
diff --git a/test/test-install.c b/test/test-install.c
new file mode 100644
index 0000000..709974f
--- /dev/null
+++ b/test/test-install.c
@@ -0,0 +1,264 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2011 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include "util.h"
+#include "install.h"
+
+static void dump_changes(UnitFileChange *c, unsigned n) {
+        unsigned i;
+
+        assert(n == 0 || c);
+
+        for (i = 0; i < n; i++) {
+                if (c[i].type == UNIT_FILE_UNLINK)
+                        printf("rm '%s'\n", c[i].path);
+                else if (c[i].type == UNIT_FILE_SYMLINK)
+                        printf("ln -s '%s' '%s'\n", c[i].source, c[i].path);
+        }
+}
+
+int main(int argc, char* argv[]) {
+        Hashmap *h;
+        UnitFileList *p;
+        Iterator i;
+        int r;
+        const char *const files[] = { "avahi-daemon.service", NULL };
+        const char *const files2[] = { "/home/lennart/test.service", NULL };
+        UnitFileChange *changes = NULL;
+        unsigned n_changes = 0;
+
+        h = hashmap_new(string_hash_func, string_compare_func);
+        r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h);
+        assert_se(r == 0);
+
+        HASHMAP_FOREACH(p, h, i) {
+                UnitFileState s;
+
+                s = unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(p->path));
+
+                assert_se(p->state == s);
+
+                fprintf(stderr, "%s (%s)\n",
+                        p->path,
+                        unit_file_state_to_string(p->state));
+        }
+
+        unit_file_list_free(h);
+
+        log_error("enable");
+
+        r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        log_error("enable2");
+
+        r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_ENABLED);
+
+        log_error("disable");
+
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_DISABLED);
+
+        log_error("mask");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
+        assert_se(r >= 0);
+        log_error("mask2");
+        r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_MASKED);
+
+        log_error("unmask");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
+        assert_se(r >= 0);
+        log_error("unmask2");
+        r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_DISABLED);
+
+        log_error("mask");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_mask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_MASKED);
+
+        log_error("disable");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
+        assert_se(r >= 0);
+        log_error("disable2");
+        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_MASKED);
+
+        log_error("umask");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_unmask(UNIT_FILE_SYSTEM, false, NULL, (char**) files, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, files[0]) == UNIT_FILE_DISABLED);
+
+        log_error("enable files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_enable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_ENABLED);
+
+        log_error("disable files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
+
+        log_error("link files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_link(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_LINKED);
+
+        log_error("disable files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
+
+        log_error("link files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_link(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_LINKED);
+
+        log_error("reenable files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_reenable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == UNIT_FILE_ENABLED);
+
+        log_error("disable files2");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_disable(UNIT_FILE_SYSTEM, false, NULL, (char**) files2, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files2[0])) == _UNIT_FILE_STATE_INVALID);
+        log_error("preset files");
+        changes = NULL;
+        n_changes = 0;
+
+        r = unit_file_preset(UNIT_FILE_SYSTEM, false, NULL, (char**) files, false, &changes, &n_changes);
+        assert_se(r >= 0);
+
+        dump_changes(changes, n_changes);
+        unit_file_changes_free(changes, n_changes);
+
+        assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, NULL, file_name_from_path(files[0])) == UNIT_FILE_ENABLED);
+
+        return 0;
+}
diff --git a/test/test-job-type.c b/test/test-job-type.c
new file mode 100644
index 0000000..ba8b307
--- /dev/null
+++ b/test/test-job-type.c
@@ -0,0 +1,84 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "job.h"
+
+int main(int argc, char*argv[]) {
+        JobType a, b, c, d, e, f, g;
+
+        for (a = 0; a < _JOB_TYPE_MAX; a++)
+                for (b = 0; b < _JOB_TYPE_MAX; b++) {
+
+                        if (!job_type_is_mergeable(a, b))
+                                printf("Not mergeable: %s + %s\n", job_type_to_string(a), job_type_to_string(b));
+
+                        for (c = 0; c < _JOB_TYPE_MAX; c++) {
+
+                                /* Verify transitivity of mergeability
+                                 * of job types */
+                                assert(!job_type_is_mergeable(a, b) ||
+                                       !job_type_is_mergeable(b, c) ||
+                                       job_type_is_mergeable(a, c));
+
+                                d = a;
+                                if (job_type_merge(&d, b) >= 0) {
+
+                                        printf("%s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(d));
+
+                                        /* Verify that merged entries can be
+                                         * merged with the same entries they
+                                         * can be merged with separately */
+                                        assert(!job_type_is_mergeable(a, c) || job_type_is_mergeable(d, c));
+                                        assert(!job_type_is_mergeable(b, c) || job_type_is_mergeable(d, c));
+
+                                        /* Verify that if a merged
+                                         * with b is not mergeable with
+                                         * c then either a or b is not
+                                         * mergeable with c either. */
+                                        assert(job_type_is_mergeable(d, c) || !job_type_is_mergeable(a, c) || !job_type_is_mergeable(b, c));
+
+                                        e = b;
+                                        if (job_type_merge(&e, c) >= 0) {
+
+                                                /* Verify associativity */
+
+                                                f = d;
+                                                assert(job_type_merge(&f, c) == 0);
+
+                                                g = e;
+                                                assert(job_type_merge(&g, a) == 0);
+
+                                                assert(f == g);
+
+                                                printf("%s + %s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(c), job_type_to_string(d));
+                                        }
+                                }
+                        }
+                }
+
+
+        return 0;
+}
diff --git a/test/test-loopback.c b/test/test-loopback.c
new file mode 100644
index 0000000..ab330ac
--- /dev/null
+++ b/test/test-loopback.c
@@ -0,0 +1,37 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include "loopback-setup.h"
+#include "util.h"
+
+int main(int argc, char* argv[]) {
+        int r;
+
+        if ((r = loopback_setup()) < 0)
+                fprintf(stderr, "loopback: %s\n", strerror(-r));
+
+        return 0;
+}
diff --git a/test/test-ns.c b/test/test-ns.c
new file mode 100644
index 0000000..102b005
--- /dev/null
+++ b/test/test-ns.c
@@ -0,0 +1,60 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mount.h>
+#include <linux/fs.h>
+
+#include "namespace.h"
+#include "log.h"
+
+int main(int argc, char *argv[]) {
+        const char * const writable[] = {
+                "/home",
+                NULL
+        };
+
+        const char * const readable[] = {
+                "/",
+                "/usr",
+                "/boot",
+                NULL
+        };
+
+        const char * const inaccessible[] = {
+                "/home/lennart/projects",
+                NULL
+        };
+
+        int r;
+
+        if ((r = setup_namespace((char**) writable, (char**) readable, (char**) inaccessible, true, MS_SHARED)) < 0) {
+                log_error("Failed to setup namespace: %s", strerror(-r));
+                return 1;
+        }
+
+        execl("/bin/sh", "/bin/sh", NULL);
+        log_error("execl(): %m");
+
+        return 1;
+}
diff --git a/test/test-strv.c b/test/test-strv.c
new file mode 100644
index 0000000..5ee4447
--- /dev/null
+++ b/test/test-strv.c
@@ -0,0 +1,66 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <string.h>
+
+#include "util.h"
+#include "specifier.h"
+
+int main(int argc, char *argv[]) {
+        const Specifier table[] = {
+                { 'a', specifier_string, (char*) "AAAA" },
+                { 'b', specifier_string, (char*) "BBBB" },
+                { 0, NULL, NULL }
+        };
+
+        char *w, *state;
+        size_t l;
+        const char test[] = "test a b c 'd' e '' '' hhh '' ''";
+
+        printf("<%s>\n", test);
+
+        FOREACH_WORD_QUOTED(w, l, test, state) {
+                char *t;
+
+                assert_se(t = strndup(w, l));
+                printf("<%s>\n", t);
+                free(t);
+        }
+
+        printf("%s\n", default_term_for_tty("/dev/tty23"));
+        printf("%s\n", default_term_for_tty("/dev/ttyS23"));
+        printf("%s\n", default_term_for_tty("/dev/tty0"));
+        printf("%s\n", default_term_for_tty("/dev/pty0"));
+        printf("%s\n", default_term_for_tty("/dev/pts/0"));
+        printf("%s\n", default_term_for_tty("/dev/console"));
+        printf("%s\n", default_term_for_tty("tty23"));
+        printf("%s\n", default_term_for_tty("ttyS23"));
+        printf("%s\n", default_term_for_tty("tty0"));
+        printf("%s\n", default_term_for_tty("pty0"));
+        printf("%s\n", default_term_for_tty("pts/0"));
+        printf("%s\n", default_term_for_tty("console"));
+
+        w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
+        printf("<%s>\n", w);
+        free(w);
+
+        return 0;
+}
diff --git a/test/test-watchdog.c b/test/test-watchdog.c
new file mode 100644
index 0000000..ccb1854
--- /dev/null
+++ b/test/test-watchdog.c
@@ -0,0 +1,51 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2012 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <unistd.h>
+#include <string.h>
+
+#include "watchdog.h"
+#include "log.h"
+
+int main(int argc, char *argv[]) {
+        usec_t t = 10 * USEC_PER_SEC;
+        unsigned i;
+        int r;
+
+        log_set_max_level(LOG_DEBUG);
+        log_parse_environment();
+
+        r = watchdog_set_timeout(&t);
+        if (r < 0)
+                log_warning("Failed to open watchdog: %s", strerror(-r));
+
+        for (i = 0; i < 5; i++) {
+                log_info("Pinging...");
+                r = watchdog_ping();
+                if (r < 0)
+                        log_warning("Failed to ping watchdog: %s", strerror(-r));
+
+                usleep(t/2);
+        }
+
+        watchdog_close(true);
+        return 0;
+}



More information about the systemd-commits mailing list