chiark / gitweb /
Remove src/test
authorAndy Wingo <wingo@pobox.com>
Sun, 19 Apr 2015 11:28:47 +0000 (13:28 +0200)
committerAndy Wingo <wingo@pobox.com>
Sun, 19 Apr 2015 11:32:26 +0000 (13:32 +0200)
74 files changed:
src/test/.gitignore [deleted file]
src/test/Makefile [deleted symlink]
src/test/test-architecture.c [deleted file]
src/test/test-async.c [deleted file]
src/test/test-barrier.c [deleted file]
src/test/test-boot-timestamps.c [deleted file]
src/test/test-btrfs.c [deleted file]
src/test/test-calendarspec.c [deleted file]
src/test/test-cap-list.c [deleted file]
src/test/test-capability.c [deleted file]
src/test/test-cgroup-mask.c [deleted file]
src/test/test-cgroup-util.c [deleted file]
src/test/test-cgroup.c [deleted file]
src/test/test-condition.c [deleted file]
src/test/test-conf-files.c [deleted file]
src/test/test-copy.c [deleted file]
src/test/test-daemon.c [deleted file]
src/test/test-date.c [deleted file]
src/test/test-device-nodes.c [deleted file]
src/test/test-ellipsize.c [deleted file]
src/test/test-engine.c [deleted file]
src/test/test-env-replace.c [deleted file]
src/test/test-execute.c [deleted file]
src/test/test-fdset.c [deleted file]
src/test/test-fileio.c [deleted file]
src/test/test-fstab-util.c [deleted file]
src/test/test-fw-util.c [deleted file]
src/test/test-hashmap-plain.c [deleted file]
src/test/test-hashmap.c [deleted file]
src/test/test-helper.h [deleted file]
src/test/test-hostname.c [deleted file]
src/test/test-id128.c [deleted file]
src/test/test-install.c [deleted file]
src/test/test-ipcrm.c [deleted file]
src/test/test-job-type.c [deleted file]
src/test/test-json.c [deleted file]
src/test/test-libudev.c [deleted file]
src/test/test-list.c [deleted file]
src/test/test-locale-util.c [deleted file]
src/test/test-log.c [deleted file]
src/test/test-loopback.c [deleted file]
src/test/test-namespace.c [deleted file]
src/test/test-ns.c [deleted file]
src/test/test-path-lookup.c [deleted file]
src/test/test-path-util.c [deleted file]
src/test/test-path.c [deleted file]
src/test/test-prioq.c [deleted file]
src/test/test-pty.c [deleted file]
src/test/test-ratelimit.c [deleted file]
src/test/test-replace-var.c [deleted file]
src/test/test-ring.c [deleted file]
src/test/test-rtnl-manual.c [deleted file]
src/test/test-sched-prio.c [deleted file]
src/test/test-set.c [deleted file]
src/test/test-sigbus.c [deleted file]
src/test/test-sleep.c [deleted file]
src/test/test-socket-util.c [deleted file]
src/test/test-strbuf.c [deleted file]
src/test/test-strip-tab-ansi.c [deleted file]
src/test/test-strv.c [deleted file]
src/test/test-strxcpyx.c [deleted file]
src/test/test-tables.c [deleted file]
src/test/test-time.c [deleted file]
src/test/test-tmpfiles.c [deleted file]
src/test/test-udev.c [deleted file]
src/test/test-uid-range.c [deleted file]
src/test/test-unaligned.c [deleted file]
src/test/test-unit-file.c [deleted file]
src/test/test-unit-name.c [deleted file]
src/test/test-utf8.c [deleted file]
src/test/test-util.c [deleted file]
src/test/test-verbs.c [deleted file]
src/test/test-watchdog.c [deleted file]
src/test/test-xml.c [deleted file]

diff --git a/src/test/.gitignore b/src/test/.gitignore
deleted file mode 100644 (file)
index e4c198a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-test-hashmap-ordered.c
diff --git a/src/test/Makefile b/src/test/Makefile
deleted file mode 120000 (symlink)
index d0b0e8e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile
\ No newline at end of file
diff --git a/src/test/test-architecture.c b/src/test/test-architecture.c
deleted file mode 100644 (file)
index 30bdec4..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Kay Sievers
-
-  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 "virt.h"
-#include "architecture.h"
-#include "util.h"
-#include "log.h"
-
-int main(int argc, char *argv[]) {
-        const char *id = NULL;
-        int a, v;
-
-        v = detect_virtualization(&id);
-        if (v == -EPERM || v == -EACCES)
-                return EXIT_TEST_SKIP;
-
-        assert_se(v >= 0);
-
-        log_info("virtualization=%s id=%s",
-                 v == VIRTUALIZATION_CONTAINER ? "container" : v == VIRTUALIZATION_VM ? "vm" : "n/a",
-                 strna(id));
-
-        a = uname_architecture();
-        assert_se(a >= 0);
-
-        log_info("uname architecture=%s", architecture_to_string(a));
-
-        a = native_architecture();
-        assert_se(a >= 0);
-
-        log_info("native architecture=%s", architecture_to_string(a));
-
-        log_info("primary library architecture=" LIB_ARCH_TUPLE);
-
-        return 0;
-}
diff --git a/src/test/test-async.c b/src/test/test-async.c
deleted file mode 100644 (file)
index abd36d6..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "async.h"
-#include "util.h"
-#include "macro.h"
-
-static bool test_async = false;
-
-static void *async_func(void *arg) {
-        test_async = true;
-
-        return NULL;
-}
-
-int main(int argc, char *argv[]) {
-        int fd;
-        char name[] = "/tmp/test-asynchronous_close.XXXXXX";
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-        asynchronous_close(fd);
-
-        assert_se(asynchronous_job(async_func, NULL) >= 0);
-
-        assert_se(asynchronous_sync() >= 0);
-
-        sleep(1);
-
-        assert_se(fcntl(fd, F_GETFD) == -1);
-        assert_se(test_async);
-
-        unlink(name);
-
-        return 0;
-}
diff --git a/src/test/test-barrier.c b/src/test/test-barrier.c
deleted file mode 100644 (file)
index 2d109a3..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
-  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/>.
-***/
-
-/*
- * IPC barrier tests
- * These tests verify the correct behavior of the IPC Barrier implementation.
- * Note that the tests use alarm-timers to verify dead-locks and timeouts. These
- * might not work on slow machines where 20ms are too short to perform specific
- * operations (though, very unlikely). In case that turns out true, we have to
- * increase it at the slightly cost of lengthen test-duration on other machines.
- */
-
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include "barrier.h"
-#include "util.h"
-
-/* 20ms to test deadlocks; All timings use multiples of this constant as
- * alarm/sleep timers. If this timeout is too small for slow machines to perform
- * the requested operations, we have to increase it. On an i7 this works fine
- * with 1ms base-time, so 20ms should be just fine for everyone. */
-#define BASE_TIME (20 * USEC_PER_MSEC)
-
-static void set_alarm(usec_t usecs) {
-        struct itimerval v = { };
-
-        timeval_store(&v.it_value, usecs);
-        assert_se(setitimer(ITIMER_REAL, &v, NULL) >= 0);
-}
-
-static void sleep_for(usec_t usecs) {
-        /* stupid usleep() might fail if >1000000 */
-        assert_se(usecs < USEC_PER_SEC);
-        usleep(usecs);
-}
-
-#define TEST_BARRIER(_FUNCTION, _CHILD_CODE, _WAIT_CHILD, _PARENT_CODE, _WAIT_PARENT)  \
-        static void _FUNCTION(void) {                                   \
-                Barrier b = BARRIER_NULL;                               \
-                pid_t pid1, pid2;                                       \
-                                                                        \
-                assert_se(barrier_create(&b) >= 0);                     \
-                assert_se(b.me > 0);                                    \
-                assert_se(b.them > 0);                                  \
-                assert_se(b.pipe[0] > 0);                               \
-                assert_se(b.pipe[1] > 0);                               \
-                                                                        \
-                pid1 = fork();                                          \
-                assert_se(pid1 >= 0);                                   \
-                if (pid1 == 0) {                                        \
-                        barrier_set_role(&b, BARRIER_CHILD);            \
-                        { _CHILD_CODE; }                                \
-                        exit(42);                                       \
-                }                                                       \
-                                                                        \
-                pid2 = fork();                                          \
-                assert_se(pid2 >= 0);                                   \
-                if (pid2 == 0) {                                        \
-                        barrier_set_role(&b, BARRIER_PARENT);           \
-                        { _PARENT_CODE; }                               \
-                        exit(42);                                       \
-                }                                                       \
-                                                                        \
-                barrier_destroy(&b);                                    \
-                set_alarm(999999);                                      \
-                { _WAIT_CHILD; }                                        \
-                { _WAIT_PARENT; }                                       \
-                set_alarm(0);                                           \
-        }
-
-#define TEST_BARRIER_WAIT_SUCCESS(_pid) \
-                ({                                                      \
-                        int pidr, status;                               \
-                        pidr = waitpid(_pid, &status, 0);               \
-                        assert_se(pidr == _pid);                        \
-                        assert_se(WIFEXITED(status));                   \
-                        assert_se(WEXITSTATUS(status) == 42);           \
-                })
-
-#define TEST_BARRIER_WAIT_ALARM(_pid) \
-                ({                                                      \
-                        int pidr, status;                               \
-                        pidr = waitpid(_pid, &status, 0);               \
-                        assert_se(pidr == _pid);                        \
-                        assert_se(WIFSIGNALED(status));                 \
-                        assert_se(WTERMSIG(status) == SIGALRM);         \
-                })
-
-/*
- * Test basic sync points
- * This places a barrier in both processes and waits synchronously for them.
- * The timeout makes sure the sync works as expected. The sleep_for() on one side
- * makes sure the exit of the parent does not overwrite previous barriers. Due
- * to the sleep_for(), we know that the parent already exited, thus there's a
- * pending HUP on the pipe. However, the barrier_sync() prefers reads on the
- * eventfd, thus we can safely wait on the barrier.
- */
-TEST_BARRIER(test_barrier_sync,
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                sleep_for(BASE_TIME * 2);
-                assert_se(barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test wait_next()
- * This places a barrier in the parent and syncs on it. The child sleeps while
- * the parent places the barrier and then waits for a barrier. The wait will
- * succeed as the child hasn't read the parent's barrier, yet. The following
- * barrier and sync synchronize the exit.
- */
-TEST_BARRIER(test_barrier_wait_next,
-        ({
-                sleep_for(BASE_TIME);
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_wait_next(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME * 4);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test wait_next() multiple times
- * This places two barriers in the parent and waits for the child to exit. The
- * child sleeps 20ms so both barriers _should_ be in place. It then waits for
- * the parent to place the next barrier twice. The first call will fetch both
- * barriers and return. However, the second call will stall as the parent does
- * not place a 3rd barrier (the sleep caught two barriers). wait_next() is does
- * not look at barrier-links so this stall is expected. Thus this test times
- * out.
- */
-TEST_BARRIER(test_barrier_wait_next_twice,
-        ({
-                sleep_for(BASE_TIME);
-                set_alarm(BASE_TIME);
-                assert_se(barrier_wait_next(&b));
-                assert_se(barrier_wait_next(&b));
-                assert_se(0);
-        }),
-        TEST_BARRIER_WAIT_ALARM(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-                sleep_for(BASE_TIME * 4);
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test wait_next() with local barriers
- * This is the same as test_barrier_wait_next_twice, but places local barriers
- * between both waits. This does not have any effect on the wait so it times out
- * like the other test.
- */
-TEST_BARRIER(test_barrier_wait_next_twice_local,
-        ({
-                sleep_for(BASE_TIME);
-                set_alarm(BASE_TIME);
-                assert_se(barrier_wait_next(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_wait_next(&b));
-                assert_se(0);
-        }),
-        TEST_BARRIER_WAIT_ALARM(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-                sleep_for(BASE_TIME * 4);
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test wait_next() with sync_next()
- * This is again the same as test_barrier_wait_next_twice but uses a
- * synced wait as the second wait. This works just fine because the local state
- * has no barriers placed, therefore, the remote is always in sync.
- */
-TEST_BARRIER(test_barrier_wait_next_twice_sync,
-        ({
-                sleep_for(BASE_TIME);
-                set_alarm(BASE_TIME);
-                assert_se(barrier_wait_next(&b));
-                assert_se(barrier_sync_next(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test wait_next() with sync_next() and local barriers
- * This is again the same as test_barrier_wait_next_twice_local but uses a
- * synced wait as the second wait. This works just fine because the local state
- * is in sync with the remote.
- */
-TEST_BARRIER(test_barrier_wait_next_twice_local_sync,
-        ({
-                sleep_for(BASE_TIME);
-                set_alarm(BASE_TIME);
-                assert_se(barrier_wait_next(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync_next(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test sync_next() and sync()
- * This tests sync_*() synchronizations and makes sure they work fine if the
- * local state is behind the remote state.
- */
-TEST_BARRIER(test_barrier_sync_next,
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_sync_next(&b));
-                assert_se(barrier_sync(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync_next(&b));
-                assert_se(barrier_sync_next(&b));
-                assert_se(barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                sleep_for(BASE_TIME);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test sync_next() and sync() with local barriers
- * This tests timeouts if sync_*() is used if local barriers are placed but the
- * remote didn't place any.
- */
-TEST_BARRIER(test_barrier_sync_next_local,
-        ({
-                set_alarm(BASE_TIME);
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync_next(&b));
-                assert_se(0);
-        }),
-        TEST_BARRIER_WAIT_ALARM(pid1),
-        ({
-                sleep_for(BASE_TIME * 2);
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test sync_next() and sync() with local barriers and abortion
- * This is the same as test_barrier_sync_next_local but aborts the sync in the
- * parent. Therefore, the sync_next() succeeds just fine due to the abortion.
- */
-TEST_BARRIER(test_barrier_sync_next_local_abort,
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(!barrier_sync_next(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                assert_se(barrier_abort(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test matched wait_abortion()
- * This runs wait_abortion() with remote abortion.
- */
-TEST_BARRIER(test_barrier_wait_abortion,
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_wait_abortion(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                assert_se(barrier_abort(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test unmatched wait_abortion()
- * This runs wait_abortion() without any remote abortion going on. It thus must
- * timeout.
- */
-TEST_BARRIER(test_barrier_wait_abortion_unmatched,
-        ({
-                set_alarm(BASE_TIME);
-                assert_se(barrier_wait_abortion(&b));
-                assert_se(0);
-        }),
-        TEST_BARRIER_WAIT_ALARM(pid1),
-        ({
-                sleep_for(BASE_TIME * 2);
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test matched wait_abortion() with local abortion
- * This runs wait_abortion() with local and remote abortion.
- */
-TEST_BARRIER(test_barrier_wait_abortion_local,
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_abort(&b));
-                assert_se(!barrier_wait_abortion(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                assert_se(barrier_abort(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test unmatched wait_abortion() with local abortion
- * This runs wait_abortion() with only local abortion. This must time out.
- */
-TEST_BARRIER(test_barrier_wait_abortion_local_unmatched,
-        ({
-                set_alarm(BASE_TIME);
-                assert_se(barrier_abort(&b));
-                assert_se(!barrier_wait_abortion(&b));
-                assert_se(0);
-        }),
-        TEST_BARRIER_WAIT_ALARM(pid1),
-        ({
-                sleep_for(BASE_TIME * 2);
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test child exit
- * Place barrier and sync with the child. The child only exits()s, which should
- * cause an implicit abortion and wake the parent.
- */
-TEST_BARRIER(test_barrier_exit,
-        ({
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME * 10);
-                assert_se(barrier_place(&b));
-                assert_se(!barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-/*
- * Test child exit with sleep
- * Same as test_barrier_exit but verifies the test really works due to the
- * child-exit. We add a usleep() which triggers the alarm in the parent and
- * causes the test to time out.
- */
-TEST_BARRIER(test_barrier_no_exit,
-        ({
-                sleep_for(BASE_TIME * 2);
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                set_alarm(BASE_TIME);
-                assert_se(barrier_place(&b));
-                assert_se(!barrier_sync(&b));
-        }),
-        TEST_BARRIER_WAIT_ALARM(pid2));
-
-/*
- * Test pending exit against sync
- * The parent places a barrier *and* exits. The 20ms wait in the child
- * guarantees both are pending. However, our logic prefers pending barriers over
- * pending exit-abortions (unlike normal abortions), thus the wait_next() must
- * succeed, same for the sync_next() as our local barrier-count is smaller than
- * the remote. Once we place a barrier our count is equal, so the sync still
- * succeeds. Only if we place one more barrier, we're ahead of the remote, thus
- * we will fail due to HUP on the pipe.
- */
-TEST_BARRIER(test_barrier_pending_exit,
-        ({
-                set_alarm(BASE_TIME * 4);
-                sleep_for(BASE_TIME * 2);
-                assert_se(barrier_wait_next(&b));
-                assert_se(barrier_sync_next(&b));
-                assert_se(barrier_place(&b));
-                assert_se(barrier_sync_next(&b));
-                assert_se(barrier_place(&b));
-                assert_se(!barrier_sync_next(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid1),
-        ({
-                assert_se(barrier_place(&b));
-        }),
-        TEST_BARRIER_WAIT_SUCCESS(pid2));
-
-int main(int argc, char *argv[]) {
-        log_parse_environment();
-        log_open();
-
-        test_barrier_sync();
-        test_barrier_wait_next();
-        test_barrier_wait_next_twice();
-        test_barrier_wait_next_twice_sync();
-        test_barrier_wait_next_twice_local();
-        test_barrier_wait_next_twice_local_sync();
-        test_barrier_sync_next();
-        test_barrier_sync_next_local();
-        test_barrier_sync_next_local_abort();
-        test_barrier_wait_abortion();
-        test_barrier_wait_abortion_unmatched();
-        test_barrier_wait_abortion_local();
-        test_barrier_wait_abortion_local_unmatched();
-        test_barrier_exit();
-        test_barrier_no_exit();
-        test_barrier_pending_exit();
-
-        return 0;
-}
diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c
deleted file mode 100644 (file)
index 06d93af..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-  Copyright 2013 Kay Sievers
-
-  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 "util.h"
-#include "log.h"
-#include "boot-timestamps.h"
-#include "efivars.h"
-#include "acpi-fpdt.h"
-
-static int test_acpi_fpdt(void) {
-        usec_t loader_start;
-        usec_t loader_exit;
-        char ts_start[FORMAT_TIMESPAN_MAX];
-        char ts_exit[FORMAT_TIMESPAN_MAX];
-        char ts_span[FORMAT_TIMESPAN_MAX];
-        int r;
-
-        r = acpi_get_boot_usec(&loader_start, &loader_exit);
-        if (r < 0) {
-                if (r != -ENOENT)
-                        log_error_errno(r, "Failed to read ACPI FPDT: %m");
-                return r;
-        }
-
-        log_info("ACPI FPDT: loader start=%s exit=%s duration=%s",
-                 format_timespan(ts_start, sizeof(ts_start), loader_start, USEC_PER_MSEC),
-                 format_timespan(ts_exit, sizeof(ts_exit), loader_exit, USEC_PER_MSEC),
-                 format_timespan(ts_span, sizeof(ts_span), loader_exit - loader_start, USEC_PER_MSEC));
-
-        return 0;
-}
-
-static int test_efi_loader(void) {
-        usec_t loader_start;
-        usec_t loader_exit;
-        char ts_start[FORMAT_TIMESPAN_MAX];
-        char ts_exit[FORMAT_TIMESPAN_MAX];
-        char ts_span[FORMAT_TIMESPAN_MAX];
-        int r;
-
-        r = efi_loader_get_boot_usec(&loader_start, &loader_exit);
-        if (r < 0) {
-                if (r != -ENOENT)
-                        log_error_errno(r, "Failed to read EFI loader data: %m");
-                return r;
-        }
-
-        log_info("EFI Loader: start=%s exit=%s duration=%s",
-                 format_timespan(ts_start, sizeof(ts_start), loader_start, USEC_PER_MSEC),
-                 format_timespan(ts_exit, sizeof(ts_exit), loader_exit, USEC_PER_MSEC),
-                 format_timespan(ts_span, sizeof(ts_span), loader_exit - loader_start, USEC_PER_MSEC));
-
-        return 0;
-}
-
-int main(int argc, char* argv[]) {
-        char s[MAX(FORMAT_TIMESPAN_MAX, FORMAT_TIMESTAMP_MAX)];
-        int r;
-        dual_timestamp fw, l, k;
-
-        test_acpi_fpdt();
-        test_efi_loader();
-
-        dual_timestamp_from_monotonic(&k, 0);
-
-        r = boot_timestamps(NULL, &fw, &l);
-        if (r < 0) {
-                log_error_errno(r, "Failed to read variables: %m");
-                return 1;
-        }
-
-        log_info("Firmware began %s before kernel.", format_timespan(s, sizeof(s), fw.monotonic, 0));
-        log_info("Loader began %s before kernel.", format_timespan(s, sizeof(s), l.monotonic, 0));
-        log_info("Firmware began %s.", format_timestamp(s, sizeof(s), fw.realtime));
-        log_info("Loader began %s.", format_timestamp(s, sizeof(s), l.realtime));
-        log_info("Kernel began %s.", format_timestamp(s, sizeof(s), k.realtime));
-
-        return 0;
-}
diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c
deleted file mode 100644 (file)
index 9e6538e..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 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 <fcntl.h>
-
-#include "log.h"
-#include "fileio.h"
-#include "util.h"
-#include "btrfs-util.h"
-
-int main(int argc, char *argv[]) {
-        int r;
-        int fd;
-
-        fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY);
-        if (fd < 0)
-                log_error_errno(errno, "Failed to open root directory: %m");
-        else {
-                BtrfsSubvolInfo info;
-                BtrfsQuotaInfo quota;
-                char ts[FORMAT_TIMESTAMP_MAX], bs[FORMAT_BYTES_MAX];
-
-                r = btrfs_subvol_get_info_fd(fd, &info);
-                if (r < 0)
-                        log_error_errno(r, "Failed to get subvolume info: %m");
-                else {
-                        log_info("otime: %s", format_timestamp(ts, sizeof(ts), info.otime));
-                        log_info("read-only (search): %s", yes_no(info.read_only));
-                }
-
-                r = btrfs_subvol_get_quota_fd(fd, &quota);
-                if (r < 0)
-                        log_error_errno(r, "Failed to get quota info: %m");
-                else {
-                        log_info("referenced: %s", strna(format_bytes(bs, sizeof(bs), quota.referenced)));
-                        log_info("exclusive: %s", strna(format_bytes(bs, sizeof(bs), quota.exclusive)));
-                        log_info("referenced_max: %s", strna(format_bytes(bs, sizeof(bs), quota.referenced_max)));
-                        log_info("exclusive_max: %s", strna(format_bytes(bs, sizeof(bs), quota.exclusive_max)));
-                }
-
-                r = btrfs_subvol_get_read_only_fd(fd);
-                if (r < 0)
-                        log_error_errno(r, "Failed to get read only flag: %m");
-                else
-                        log_info("read-only (ioctl): %s", yes_no(r));
-
-                safe_close(fd);
-        }
-
-        r = btrfs_subvol_make("/xxxtest");
-        if (r < 0)
-                log_error_errno(r, "Failed to make subvolume: %m");
-
-        r = write_string_file("/xxxtest/afile", "ljsadhfljasdkfhlkjdsfha");
-        if (r < 0)
-                log_error_errno(r, "Failed to write file: %m");
-
-        r = btrfs_subvol_snapshot("/xxxtest", "/xxxtest2", false, false);
-        if (r < 0)
-                log_error_errno(r, "Failed to make snapshot: %m");
-
-        r = btrfs_subvol_snapshot("/xxxtest", "/xxxtest3", true, false);
-        if (r < 0)
-                log_error_errno(r, "Failed to make snapshot: %m");
-
-        r = btrfs_subvol_remove("/xxxtest");
-        if (r < 0)
-                log_error_errno(r, "Failed to remove subvolume: %m");
-
-        r = btrfs_subvol_remove("/xxxtest2");
-        if (r < 0)
-                log_error_errno(r, "Failed to remove subvolume: %m");
-
-        r = btrfs_subvol_remove("/xxxtest3");
-        if (r < 0)
-                log_error_errno(r, "Failed to remove subvolume: %m");
-
-        r = btrfs_subvol_snapshot("/etc", "/etc2", true, true);
-        if (r < 0)
-                log_error_errno(r, "Failed to make snapshot: %m");
-
-        r = btrfs_subvol_remove("/etc2");
-        if (r < 0)
-                log_error_errno(r, "Failed to remove subvolume: %m");
-
-        return 0;
-}
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
deleted file mode 100644 (file)
index 87e1da1..0000000
+++ /dev/null
@@ -1,92 +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 <string.h>
-
-#include "calendarspec.h"
-#include "util.h"
-
-static void test_one(const char *input, const char *output) {
-        CalendarSpec *c;
-        _cleanup_free_ char *p = NULL, *q = NULL;
-        usec_t u;
-        char buf[FORMAT_TIMESTAMP_MAX];
-        int r;
-
-        assert_se(calendar_spec_from_string(input, &c) >= 0);
-
-        assert_se(calendar_spec_to_string(c, &p) >= 0);
-        printf("\"%s\" → \"%s\"\n", input, p);
-
-        assert_se(streq(p, output));
-
-        u = now(CLOCK_REALTIME);
-        r = calendar_spec_next_usec(c, u, &u);
-        printf("Next: %s\n", r < 0 ? strerror(-r) : format_timestamp(buf, sizeof(buf), u));
-        calendar_spec_free(c);
-
-        assert_se(calendar_spec_from_string(p, &c) >= 0);
-        assert_se(calendar_spec_to_string(c, &q) >= 0);
-        calendar_spec_free(c);
-
-        assert_se(streq(q, p));
-}
-
-int main(int argc, char* argv[]) {
-        CalendarSpec *c;
-
-        test_one("Sat,Thu,Mon-Wed,Sat-Sun", "Mon-Thu,Sat,Sun *-*-* 00:00:00");
-        test_one("Mon,Sun 12-*-* 2,1:23", "Mon,Sun 2012-*-* 01,02:23:00");
-        test_one("Wed *-1", "Wed *-*-01 00:00:00");
-        test_one("Wed-Wed,Wed *-1", "Wed *-*-01 00:00:00");
-        test_one("Wed, 17:48", "Wed *-*-* 17:48:00");
-        test_one("Wed-Sat,Tue 12-10-15 1:2:3", "Tue-Sat 2012-10-15 01:02:03");
-        test_one("*-*-7 0:0:0", "*-*-07 00:00:00");
-        test_one("10-15", "*-10-15 00:00:00");
-        test_one("monday *-12-* 17:00", "Mon *-12-* 17:00:00");
-        test_one("Mon,Fri *-*-3,1,2 *:30:45", "Mon,Fri *-*-01,02,03 *:30:45");
-        test_one("12,14,13,12:20,10,30", "*-*-* 12,13,14:10,20,30:00");
-        test_one("mon,fri *-1/2-1,3 *:30:45", "Mon,Fri *-01/2-01,03 *:30:45");
-        test_one("03-05 08:05:40", "*-03-05 08:05:40");
-        test_one("08:05:40", "*-*-* 08:05:40");
-        test_one("05:40", "*-*-* 05:40:00");
-        test_one("Sat,Sun 12-05 08:05:40", "Sat,Sun *-12-05 08:05:40");
-        test_one("Sat,Sun 08:05:40", "Sat,Sun *-*-* 08:05:40");
-        test_one("2003-03-05 05:40", "2003-03-05 05:40:00");
-        test_one("2003-03-05", "2003-03-05 00:00:00");
-        test_one("03-05", "*-03-05 00:00:00");
-        test_one("hourly", "*-*-* *:00:00");
-        test_one("daily", "*-*-* 00:00:00");
-        test_one("monthly", "*-*-01 00:00:00");
-        test_one("weekly", "Mon *-*-* 00:00:00");
-        test_one("minutely", "*-*-* *:*:00");
-        test_one("quarterly", "*-01,04,07,10-01 00:00:00");
-        test_one("semi-annually", "*-01,07-01 00:00:00");
-        test_one("annually", "*-01-01 00:00:00");
-        test_one("*:2/3", "*-*-* *:02/3:00");
-
-        assert_se(calendar_spec_from_string("test", &c) < 0);
-        assert_se(calendar_spec_from_string("", &c) < 0);
-        assert_se(calendar_spec_from_string("7", &c) < 0);
-        assert_se(calendar_spec_from_string("121212:1:2", &c) < 0);
-
-        return 0;
-}
diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c
deleted file mode 100644 (file)
index 43a2d35..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 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 "util.h"
-#include "fileio.h"
-#include "cap-list.h"
-#include "capability.h"
-#include <sys/prctl.h>
-
-/* verify the capability parser */
-static void test_cap_list(void) {
-        int i;
-
-        assert_se(!capability_to_name(-1));
-        assert_se(!capability_to_name(capability_list_length()));
-
-        for (i = 0; i < capability_list_length(); i++) {
-                const char *n;
-
-                assert_se(n = capability_to_name(i));
-                assert_se(capability_from_name(n) == i);
-                printf("%s = %i\n", n, i);
-        }
-
-        assert_se(capability_from_name("asdfbsd") == -EINVAL);
-        assert_se(capability_from_name("CAP_AUDIT_READ") == CAP_AUDIT_READ);
-        assert_se(capability_from_name("cap_audit_read") == CAP_AUDIT_READ);
-        assert_se(capability_from_name("cAp_aUdIt_rEAd") == CAP_AUDIT_READ);
-        assert_se(capability_from_name("0") == 0);
-        assert_se(capability_from_name("15") == 15);
-        assert_se(capability_from_name("-1") == -EINVAL);
-
-        for (i = 0; i < capability_list_length(); i++) {
-                _cleanup_cap_free_charp_ char *a = NULL;
-                const char *b;
-                unsigned u;
-
-                assert_se(a = cap_to_name(i));
-
-                /* quit the loop as soon as libcap starts returning
-                 * numeric ids, formatted as strings */
-                if (safe_atou(a, &u) >= 0)
-                        break;
-
-                assert_se(b = capability_to_name(i));
-
-                printf("%s vs. %s\n", a, b);
-
-                assert_se(strcasecmp(a, b) == 0);
-        }
-}
-
-/* verify cap_last_cap() against /proc/sys/kernel/cap_last_cap */
-static void test_last_cap_file(void) {
-        _cleanup_free_ char *content = NULL;
-        unsigned long val = 0;
-        int r;
-
-        r = read_one_line_file("/proc/sys/kernel/cap_last_cap", &content);
-        assert_se(r >= 0);
-
-        r = safe_atolu(content, &val);
-        assert_se(r >= 0);
-        assert_se(val != 0);
-        assert_se(val == cap_last_cap());
-}
-
-/* verify cap_last_cap() against syscall probing */
-static void test_last_cap_probe(void) {
-        unsigned long p = (unsigned long)CAP_LAST_CAP;
-
-        if (prctl(PR_CAPBSET_READ, p) < 0) {
-                for (p--; p > 0; p --)
-                        if (prctl(PR_CAPBSET_READ, p) >= 0)
-                                break;
-        } else {
-                for (;; p++)
-                        if (prctl(PR_CAPBSET_READ, p+1) < 0)
-                                break;
-        }
-
-        assert_se(p != 0);
-        assert_se(p == cap_last_cap());
-}
-
-int main(int argc, char *argv[]) {
-        test_cap_list();
-        test_last_cap_file();
-        test_last_cap_probe();
-
-        return 0;
-}
diff --git a/src/test/test-capability.c b/src/test/test-capability.c
deleted file mode 100644 (file)
index f47452c..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 <sys/wait.h>
-#include <sys/capability.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <pwd.h>
-#include <unistd.h>
-
-#include "capability.h"
-#include "util.h"
-#include "macro.h"
-
-static uid_t test_uid = -1;
-static gid_t test_gid = -1;
-// We keep CAP_DAC_OVERRIDE to avoid errors with gcov when doing test coverage
-static uint64_t test_flags = 1ULL << CAP_DAC_OVERRIDE;
-
-static void fork_test(void (*test_func)(void)) {
-        pid_t pid = 0;
-
-        pid = fork();
-        assert_se(pid >= 0);
-        if (pid == 0) {
-                test_func();
-                exit(0);
-        } else if (pid > 0) {
-                int status;
-
-                assert_se(waitpid(pid, &status, 0) > 0);
-                assert_se(WIFEXITED(status) && WEXITSTATUS(status) == 0);
-        }
-}
-
-static void show_capabilities(void) {
-        cap_t caps;
-        char *text;
-
-        caps = cap_get_proc();
-        assert_se(caps);
-
-        text = cap_to_text(caps, NULL);
-        assert_se(text);
-
-        log_info("Capabilities:%s", text);
-        cap_free(caps);
-        cap_free(text);
-}
-
-static int setup_tests(void) {
-        struct passwd *nobody;
-
-        nobody = getpwnam("nobody");
-        if (!nobody) {
-                log_error_errno(errno, "Could not find nobody user: %m");
-                return -EXIT_TEST_SKIP;
-        }
-        test_uid = nobody->pw_uid;
-        test_gid = nobody->pw_gid;
-
-        return 0;
-}
-
-static void test_drop_privileges_keep_net_raw(void) {
-        int sock;
-
-        sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
-        assert_se(sock >= 0);
-        safe_close(sock);
-
-        assert_se(drop_privileges(test_uid, test_gid, test_flags | (1ULL << CAP_NET_RAW)) >= 0);
-        assert_se(getuid() == test_uid);
-        assert_se(getgid() == test_gid);
-        show_capabilities();
-
-        sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
-        assert_se(sock >= 0);
-        safe_close(sock);
-}
-
-static void test_drop_privileges_dontkeep_net_raw(void) {
-        int sock;
-
-        sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
-        assert_se(sock >= 0);
-        safe_close(sock);
-
-        assert_se(drop_privileges(test_uid, test_gid, test_flags) >= 0);
-        assert_se(getuid() == test_uid);
-        assert_se(getgid() == test_gid);
-        show_capabilities();
-
-        sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
-        assert_se(sock < 0);
-}
-
-static void test_drop_privileges_fail(void) {
-        assert_se(drop_privileges(test_uid, test_gid, test_flags) >= 0);
-        assert_se(getuid() == test_uid);
-        assert_se(getgid() == test_gid);
-
-        assert_se(drop_privileges(test_uid, test_gid, test_flags) < 0);
-        assert_se(drop_privileges(0, 0, test_flags) < 0);
-}
-
-static void test_drop_privileges(void) {
-        fork_test(test_drop_privileges_keep_net_raw);
-        fork_test(test_drop_privileges_dontkeep_net_raw);
-        fork_test(test_drop_privileges_fail);
-}
-
-static void test_have_effective_cap(void) {
-        assert_se(have_effective_cap(CAP_KILL));
-        assert_se(have_effective_cap(CAP_CHOWN));
-
-        assert_se(drop_privileges(test_uid, test_gid, test_flags | (1ULL << CAP_KILL)) >= 0);
-        assert_se(getuid() == test_uid);
-        assert_se(getgid() == test_gid);
-
-        assert_se(have_effective_cap(CAP_KILL));
-        assert_se(!have_effective_cap(CAP_CHOWN));
-}
-
-int main(int argc, char *argv[]) {
-        int r;
-
-        log_parse_environment();
-        log_open();
-
-        if (getuid() != 0)
-                return EXIT_TEST_SKIP;
-
-        r = setup_tests();
-        if (r < 0)
-                return -r;
-
-        show_capabilities();
-
-        test_drop_privileges();
-        fork_test(test_have_effective_cap);
-
-        return 0;
-}
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
deleted file mode 100644 (file)
index d14a07e..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 David Strauss
-
-  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 "manager.h"
-#include "unit.h"
-#include "macro.h"
-#include "test-helper.h"
-
-static int test_cgroup_mask(void) {
-        Manager *m = NULL;
-        Unit *son, *daughter, *parent, *root, *grandchild, *parent_deep;
-        FILE *serial = NULL;
-        FDSet *fdset = NULL;
-        int r;
-
-        /* Prepare the manager. */
-        assert_se(set_unit_path(TEST_DIR) >= 0);
-        r = manager_new(SYSTEMD_USER, true, &m);
-        if (r == -EPERM || r == -EACCES) {
-                puts("manager_new: Permission denied. Skipping test.");
-                return EXIT_TEST_SKIP;
-        }
-        assert_se(r >= 0);
-        assert_se(manager_startup(m, serial, fdset) >= 0);
-
-        /* Load units and verify hierarchy. */
-        assert_se(manager_load_unit(m, "parent.slice", NULL, NULL, &parent) >= 0);
-        assert_se(manager_load_unit(m, "son.service", NULL, NULL, &son) >= 0);
-        assert_se(manager_load_unit(m, "daughter.service", NULL, NULL, &daughter) >= 0);
-        assert_se(manager_load_unit(m, "grandchild.service", NULL, NULL, &grandchild) >= 0);
-        assert_se(manager_load_unit(m, "parent-deep.slice", NULL, NULL, &parent_deep) >= 0);
-        assert_se(parent->load_state == UNIT_LOADED);
-        assert_se(son->load_state == UNIT_LOADED);
-        assert_se(daughter->load_state == UNIT_LOADED);
-        assert_se(grandchild->load_state == UNIT_LOADED);
-        assert_se(parent_deep->load_state == UNIT_LOADED);
-        assert_se(UNIT_DEREF(son->slice) == parent);
-        assert_se(UNIT_DEREF(daughter->slice) == parent);
-        assert_se(UNIT_DEREF(parent_deep->slice) == parent);
-        assert_se(UNIT_DEREF(grandchild->slice) == parent_deep);
-        root = UNIT_DEREF(parent->slice);
-
-        /* Verify per-unit cgroups settings. */
-        assert_se(unit_get_cgroup_mask(son) == (CGROUP_CPU | CGROUP_CPUACCT));
-        assert_se(unit_get_cgroup_mask(daughter) == 0);
-        assert_se(unit_get_cgroup_mask(grandchild) == 0);
-        assert_se(unit_get_cgroup_mask(parent_deep) == CGROUP_MEMORY);
-        assert_se(unit_get_cgroup_mask(parent) == CGROUP_BLKIO);
-        assert_se(unit_get_cgroup_mask(root) == 0);
-
-        /* Verify aggregation of member masks */
-        assert_se(unit_get_members_mask(son) == 0);
-        assert_se(unit_get_members_mask(daughter) == 0);
-        assert_se(unit_get_members_mask(grandchild) == 0);
-        assert_se(unit_get_members_mask(parent_deep) == 0);
-        assert_se(unit_get_members_mask(parent) == (CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY));
-        assert_se(unit_get_members_mask(root) == (CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY));
-
-        /* Verify aggregation of sibling masks. */
-        assert_se(unit_get_siblings_mask(son) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_siblings_mask(daughter) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_siblings_mask(grandchild) == 0);
-        assert_se(unit_get_siblings_mask(parent_deep) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_siblings_mask(parent) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_siblings_mask(root) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
-
-        /* Verify aggregation of target masks. */
-        assert_se(unit_get_target_mask(son) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_target_mask(daughter) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_target_mask(grandchild) == 0);
-        assert_se(unit_get_target_mask(parent_deep) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_target_mask(parent) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
-        assert_se(unit_get_target_mask(root) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
-
-        manager_free(m);
-
-        return 0;
-}
-
-int main(int argc, char* argv[]) {
-        int rc = 0;
-        TEST_REQ_RUNNING_SYSTEMD(rc = test_cgroup_mask());
-        return rc;
-}
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
deleted file mode 100644 (file)
index 9834a6a..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Zbigniew Jędrzejewski-Szmek
-
-  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 "util.h"
-#include "cgroup-util.h"
-#include "test-helper.h"
-
-static void check_p_d_u(const char *path, int code, const char *result) {
-        _cleanup_free_ char *unit = NULL;
-        int r;
-
-        r = cg_path_decode_unit(path, &unit);
-        printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit, r, result, code);
-        assert_se(r == code);
-        assert_se(streq_ptr(unit, result));
-}
-
-static void test_path_decode_unit(void) {
-        check_p_d_u("getty@tty2.service", 0, "getty@tty2.service");
-        check_p_d_u("getty@tty2.service/", 0, "getty@tty2.service");
-        check_p_d_u("getty@tty2.service/xxx", 0, "getty@tty2.service");
-        check_p_d_u("getty@.service/", -EINVAL, NULL);
-        check_p_d_u("getty@.service", -EINVAL, NULL);
-        check_p_d_u("getty.service", 0, "getty.service");
-        check_p_d_u("getty", -EINVAL, NULL);
-        check_p_d_u("getty/waldo", -EINVAL, NULL);
-        check_p_d_u("_cpu.service", 0, "cpu.service");
-}
-
-static void check_p_g_u(const char *path, int code, const char *result) {
-        _cleanup_free_ char *unit = NULL;
-        int r;
-
-        r = cg_path_get_unit(path, &unit);
-        printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit, r, result, code);
-        assert_se(r == code);
-        assert_se(streq_ptr(unit, result));
-}
-
-static void test_path_get_unit(void) {
-        check_p_g_u("/system.slice/foobar.service/sdfdsaf", 0, "foobar.service");
-        check_p_g_u("/system.slice/getty@tty5.service", 0, "getty@tty5.service");
-        check_p_g_u("/system.slice/getty@tty5.service/aaa/bbb", 0, "getty@tty5.service");
-        check_p_g_u("/system.slice/getty@tty5.service/", 0, "getty@tty5.service");
-        check_p_g_u("/system.slice/getty@tty6.service/tty5", 0, "getty@tty6.service");
-        check_p_g_u("sadfdsafsda", -EINVAL, NULL);
-        check_p_g_u("/system.slice/getty####@tty6.service/xxx", -EINVAL, NULL);
-        check_p_g_u("/system.slice/system-waldo.slice/foobar.service/sdfdsaf", 0, "foobar.service");
-        check_p_g_u("/system.slice/system-waldo.slice/_cpu.service/sdfdsaf", 0, "cpu.service");
-        check_p_g_u("/user.slice/user-1000.slice/user@1000.service/server.service", 0, "user@1000.service");
-        check_p_g_u("/user.slice/user-1000.slice/user@.service/server.service", -EINVAL, NULL);
-}
-
-static void check_p_g_u_u(const char *path, int code, const char *result) {
-        _cleanup_free_ char *unit = NULL;
-        int r;
-
-        r = cg_path_get_user_unit(path, &unit);
-        printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit, r, result, code);
-        assert_se(r == code);
-        assert_se(streq_ptr(unit, result));
-}
-
-static void test_path_get_user_unit(void) {
-        check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar.service", 0, "foobar.service");
-        check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/waldo.slice/foobar.service", 0, "foobar.service");
-        check_p_g_u_u("/user.slice/user-1002.slice/session-2.scope/foobar.service/waldo", 0, "foobar.service");
-        check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar.service/waldo/uuuux", 0, "foobar.service");
-        check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/waldo/waldo/uuuux", -EINVAL, NULL);
-        check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
-        check_p_g_u_u("/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
-        check_p_g_u_u("/xyz.slice/xyz-waldo.slice/session-77.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
-        check_p_g_u_u("/meh.service", -ENOENT, NULL);
-        check_p_g_u_u("/session-3.scope/_cpu.service", 0, "cpu.service");
-        check_p_g_u_u("/user.slice/user-1000.slice/user@1000.service/server.service", 0, "server.service");
-        check_p_g_u_u("/user.slice/user-1000.slice/user@1000.service/foobar.slice/foobar@pie.service", 0, "foobar@pie.service");
-        check_p_g_u_u("/user.slice/user-1000.slice/user@.service/server.service", -ENOENT, NULL);
-}
-
-static void check_p_g_s(const char *path, int code, const char *result) {
-        _cleanup_free_ char *s = NULL;
-
-        assert_se(cg_path_get_session(path, &s) == code);
-        assert_se(streq_ptr(s, result));
-}
-
-static void test_path_get_session(void) {
-        check_p_g_s("/user.slice/user-1000.slice/session-2.scope/foobar.service", 0, "2");
-        check_p_g_s("/session-3.scope", 0, "3");
-        check_p_g_s("/session-.scope", -ENOENT, NULL);
-        check_p_g_s("", -ENOENT, NULL);
-}
-
-static void check_p_g_o_u(const char *path, int code, uid_t result) {
-        uid_t uid = 0;
-
-        assert_se(cg_path_get_owner_uid(path, &uid) == code);
-        assert_se(uid == result);
-}
-
-static void test_path_get_owner_uid(void) {
-        check_p_g_o_u("/user.slice/user-1000.slice/session-2.scope/foobar.service", 0, 1000);
-        check_p_g_o_u("/user.slice/user-1006.slice", 0, 1006);
-        check_p_g_o_u("", -ENOENT, 0);
-}
-
-static void test_get_paths(void) {
-        _cleanup_free_ char *a = NULL;
-
-        assert_se(cg_get_root_path(&a) >= 0);
-        log_info("Root = %s", a);
-}
-
-static void test_proc(void) {
-        _cleanup_closedir_ DIR *d = NULL;
-        struct dirent *de;
-        int r;
-
-        d = opendir("/proc");
-        assert_se(d);
-
-        FOREACH_DIRENT(de, d, break) {
-                _cleanup_free_ char *path = NULL, *path_shifted = NULL, *session = NULL, *unit = NULL, *user_unit = NULL, *machine = NULL, *slice = NULL;
-                pid_t pid;
-                uid_t uid = UID_INVALID;
-
-                if (de->d_type != DT_DIR &&
-                    de->d_type != DT_UNKNOWN)
-                        continue;
-
-                r = parse_pid(de->d_name, &pid);
-                if (r < 0)
-                        continue;
-
-                if (is_kernel_thread(pid))
-                        continue;
-
-                cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &path);
-                cg_pid_get_path_shifted(pid, NULL, &path_shifted);
-                cg_pid_get_owner_uid(pid, &uid);
-                cg_pid_get_session(pid, &session);
-                cg_pid_get_unit(pid, &unit);
-                cg_pid_get_user_unit(pid, &user_unit);
-                cg_pid_get_machine_name(pid, &machine);
-                cg_pid_get_slice(pid, &slice);
-
-                printf(PID_FMT"\t%s\t%s\t"UID_FMT"\t%s\t%s\t%s\t%s\t%s\n",
-                       pid,
-                       path,
-                       path_shifted,
-                       uid,
-                       session,
-                       unit,
-                       user_unit,
-                       machine,
-                       slice);
-        }
-}
-
-static void test_escape_one(const char *s, const char *r) {
-        _cleanup_free_ char *b;
-
-        b = cg_escape(s);
-        assert_se(b);
-        assert_se(streq(b, r));
-
-        assert_se(streq(cg_unescape(b), s));
-}
-
-static void test_escape(void) {
-        test_escape_one("foobar", "foobar");
-        test_escape_one(".foobar", "_.foobar");
-        test_escape_one("foobar.service", "foobar.service");
-        test_escape_one("cgroup.service", "_cgroup.service");
-        test_escape_one("tasks", "_tasks");
-        if (access("/sys/fs/cgroup/cpu", F_OK) == 0)
-                test_escape_one("cpu.service", "_cpu.service");
-        test_escape_one("_foobar", "__foobar");
-        test_escape_one("", "_");
-        test_escape_one("_", "__");
-        test_escape_one(".", "_.");
-}
-
-static void test_controller_is_valid(void) {
-        assert_se(cg_controller_is_valid("foobar", false));
-        assert_se(cg_controller_is_valid("foo_bar", false));
-        assert_se(cg_controller_is_valid("name=foo", true));
-        assert_se(!cg_controller_is_valid("", false));
-        assert_se(!cg_controller_is_valid("name=", true));
-        assert_se(!cg_controller_is_valid("=", false));
-        assert_se(!cg_controller_is_valid("cpu,cpuacct", false));
-        assert_se(!cg_controller_is_valid("_", false));
-        assert_se(!cg_controller_is_valid("_foobar", false));
-        assert_se(!cg_controller_is_valid("tatü", false));
-}
-
-static void test_slice_to_path_one(const char *unit, const char *path, int error) {
-        _cleanup_free_ char *ret = NULL;
-
-        assert_se(cg_slice_to_path(unit, &ret) == error);
-        assert_se(streq_ptr(ret, path));
-}
-
-static void test_slice_to_path(void) {
-
-        test_slice_to_path_one("foobar.slice", "foobar.slice", 0);
-        test_slice_to_path_one("foobar-waldo.slice", "foobar.slice/foobar-waldo.slice", 0);
-        test_slice_to_path_one("foobar-waldo.service", NULL, -EINVAL);
-        test_slice_to_path_one("-.slice", NULL, -EINVAL);
-        test_slice_to_path_one("-foo-.slice", NULL, -EINVAL);
-        test_slice_to_path_one("-foo.slice", NULL, -EINVAL);
-        test_slice_to_path_one("a-b.slice", "a.slice/a-b.slice", 0);
-        test_slice_to_path_one("a-b-c-d-e.slice", "a.slice/a-b.slice/a-b-c.slice/a-b-c-d.slice/a-b-c-d-e.slice", 0);
-}
-
-static void test_shift_path_one(const char *raw, const char *root, const char *shifted) {
-        const char *s = NULL;
-
-        assert_se(cg_shift_path(raw, root, &s) >= 0);
-        assert_se(streq(s, shifted));
-}
-
-static void test_shift_path(void) {
-
-        test_shift_path_one("/foobar/waldo", "/", "/foobar/waldo");
-        test_shift_path_one("/foobar/waldo", "", "/foobar/waldo");
-        test_shift_path_one("/foobar/waldo", "/foobar", "/waldo");
-        test_shift_path_one("/foobar/waldo", "/fuckfuck", "/foobar/waldo");
-}
-
-int main(void) {
-        test_path_decode_unit();
-        test_path_get_unit();
-        test_path_get_user_unit();
-        test_path_get_session();
-        test_path_get_owner_uid();
-        TEST_REQ_RUNNING_SYSTEMD(test_get_paths());
-        test_proc();
-        TEST_REQ_RUNNING_SYSTEMD(test_escape());
-        test_controller_is_valid();
-        test_slice_to_path();
-        test_shift_path();
-
-        return 0;
-}
diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c
deleted file mode 100644 (file)
index 4be69a4..0000000
+++ /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 "path-util.h"
-#include "util.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_pid_get_path(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_pid_get_path(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_pid_get_path(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", SYSTEMD_CGROUP_CONTROLLER, "/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_se(streq(c, "foobar"));
-        assert_se(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_se(c == NULL);
-        assert_se(streq(p, "/"));
-        free(p);
-
-        assert_se(cg_split_spec("foo", &c, &p) >= 0);
-        assert_se(streq(c, "foo"));
-        assert_se(p == NULL);
-        free(c);
-
-        return 0;
-}
diff --git a/src/test/test-condition.c b/src/test/test-condition.c
deleted file mode 100644 (file)
index 88147c8..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "condition.h"
-#include "macro.h"
-#include "util.h"
-#include "log.h"
-#include "architecture.h"
-#include "sd-id128.h"
-#include "selinux-util.h"
-#include "audit.h"
-#include "ima-util.h"
-#include "apparmor-util.h"
-#include "smack-util.h"
-
-static void test_condition_test_path(void) {
-        Condition *condition;
-
-        condition = condition_new(CONDITION_PATH_EXISTS, "/bin/sh", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_EXISTS, "/bin/s?", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, true);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, true);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_IS_DIRECTORY, "/bin", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_DIRECTORY_NOT_EMPTY, "/bin", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_FILE_NOT_EMPTY, "/bin/sh", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/bin/sh", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/etc/passwd", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/proc", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/bin", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_IS_READ_WRITE, "/tmp", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_PATH_IS_SYMBOLIC_LINK, "/dev/stdout", false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-}
-
-static void test_condition_test_ac_power(void) {
-        Condition *condition;
-
-        condition = condition_new(CONDITION_AC_POWER, "true", false, false);
-        assert_se(condition_test(condition) == on_ac_power());
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_AC_POWER, "false", false, false);
-        assert_se(condition_test(condition) != on_ac_power());
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_AC_POWER, "false", false, true);
-        assert_se(condition_test(condition) == on_ac_power());
-        condition_free(condition);
-}
-
-static void test_condition_test_host(void) {
-        Condition *condition;
-        sd_id128_t id;
-        int r;
-        char sid[SD_ID128_STRING_MAX];
-        _cleanup_free_ char *hostname = NULL;
-
-        r = sd_id128_get_machine(&id);
-        assert_se(r >= 0);
-        assert_se(sd_id128_to_string(id, sid));
-
-        condition = condition_new(CONDITION_HOST, sid, false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_HOST, "garbage value jjjjjjjjjjjjjj", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_HOST, sid, false, true);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        hostname = gethostname_malloc();
-        assert_se(hostname);
-
-        condition = condition_new(CONDITION_HOST, hostname, false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-}
-
-static void test_condition_test_architecture(void) {
-        Condition *condition;
-        const char *sa;
-        int a;
-
-        a = uname_architecture();
-        assert_se(a >= 0);
-
-        sa = architecture_to_string(a);
-        assert_se(sa);
-
-        condition = condition_new(CONDITION_ARCHITECTURE, sa, false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_ARCHITECTURE, "garbage value", false, false);
-        assert_se(condition_test(condition) < 0);
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_ARCHITECTURE, sa, false, true);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-}
-
-static void test_condition_test_kernel_command_line(void) {
-        Condition *condition;
-
-        condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "thisreallyshouldntbeonthekernelcommandline", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "andthis=neither", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-}
-
-static void test_condition_test_null(void) {
-        Condition *condition;
-
-        condition = condition_new(CONDITION_NULL, NULL, false, false);
-        assert_se(condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_NULL, NULL, false, true);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-}
-
-static void test_condition_test_security(void) {
-        Condition *condition;
-
-        condition = condition_new(CONDITION_SECURITY, "garbage oifdsjfoidsjoj", false, false);
-        assert_se(!condition_test(condition));
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_SECURITY, "selinux", false, true);
-        assert_se(condition_test(condition) != mac_selinux_use());
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_SECURITY, "ima", false, false);
-        assert_se(condition_test(condition) == use_ima());
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_SECURITY, "apparmor", false, false);
-        assert_se(condition_test(condition) == mac_apparmor_use());
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_SECURITY, "smack", false, false);
-        assert_se(condition_test(condition) == mac_smack_use());
-        condition_free(condition);
-
-        condition = condition_new(CONDITION_SECURITY, "audit", false, false);
-        assert_se(condition_test(condition) == use_audit());
-        condition_free(condition);
-}
-
-
-int main(int argc, char *argv[]) {
-        log_parse_environment();
-        log_open();
-
-        test_condition_test_path();
-        test_condition_test_ac_power();
-        test_condition_test_host();
-        test_condition_test_architecture();
-        test_condition_test_kernel_command_line();
-        test_condition_test_null();
-        test_condition_test_security();
-
-        return 0;
-}
diff --git a/src/test/test-conf-files.c b/src/test/test-conf-files.c
deleted file mode 100644 (file)
index 894c7f7..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Michael Marineau
-
-  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 <stdarg.h>
-
-#include "conf-files.h"
-#include "macro.h"
-#include "strv.h"
-#include "util.h"
-
-
-static void setup_test_dir(char *tmp_dir, const char *files, ...) {
-        va_list ap;
-
-        assert_se(mkdtemp(tmp_dir) != NULL);
-
-        va_start(ap, files);
-        while (files != NULL) {
-                _cleanup_free_ char *path = strappend(tmp_dir, files);
-                assert_se(touch_file(path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0) == 0);
-                files = va_arg(ap, const char *);
-        }
-        va_end(ap);
-}
-
-static void test_conf_files_list(bool use_root) {
-        char tmp_dir[] = "/tmp/test-conf-files-XXXXXX";
-        _cleanup_strv_free_ char **found_files = NULL;
-        const char *root_dir, *search_1, *search_2, *expect_a, *expect_b;
-
-        setup_test_dir(tmp_dir,
-                       "/dir1/a.conf",
-                       "/dir2/a.conf",
-                       "/dir2/b.conf",
-                       NULL);
-
-        if (use_root) {
-                root_dir = tmp_dir;
-                search_1 = "/dir1";
-                search_2 = "/dir2";
-        } else {
-                root_dir = NULL;
-                search_1 = strjoina(tmp_dir, "/dir1");
-                search_2 = strjoina(tmp_dir, "/dir2");
-        }
-
-        expect_a = strjoina(tmp_dir, "/dir1/a.conf");
-        expect_b = strjoina(tmp_dir, "/dir2/b.conf");
-
-        assert_se(conf_files_list(&found_files, ".conf", root_dir, search_1, search_2, NULL) == 0);
-        strv_print(found_files);
-
-        assert_se(found_files);
-        assert_se(streq_ptr(found_files[0], expect_a));
-        assert_se(streq_ptr(found_files[1], expect_b));
-        assert_se(found_files[2] == NULL);
-
-        assert_se(rm_rf_dangerous(tmp_dir, false, true, false) == 0);
-}
-
-int main(int argc, char **argv) {
-        test_conf_files_list(false);
-        test_conf_files_list(true);
-        return 0;
-}
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
deleted file mode 100644 (file)
index 5c96f61..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "copy.h"
-#include "path-util.h"
-#include "fileio.h"
-#include "mkdir.h"
-#include "strv.h"
-#include "macro.h"
-#include "util.h"
-
-static void test_copy_file(void) {
-        _cleanup_free_ char *buf = NULL;
-        char fn[] = "/tmp/test-copy_file.XXXXXX";
-        char fn_copy[] = "/tmp/test-copy_file.XXXXXX";
-        size_t sz = 0;
-        int fd;
-
-        fd = mkostemp_safe(fn, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-        close(fd);
-
-        fd = mkostemp_safe(fn_copy, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-        close(fd);
-
-        assert_se(write_string_file(fn, "foo bar bar bar foo") == 0);
-
-        assert_se(copy_file(fn, fn_copy, 0, 0644, 0) == 0);
-
-        assert_se(read_full_file(fn_copy, &buf, &sz) == 0);
-        assert_se(streq(buf, "foo bar bar bar foo\n"));
-        assert_se(sz == 20);
-
-        unlink(fn);
-        unlink(fn_copy);
-}
-
-static void test_copy_file_fd(void) {
-        char in_fn[] = "/tmp/test-copy-file-fd-XXXXXX";
-        char out_fn[] = "/tmp/test-copy-file-fd-XXXXXX";
-        _cleanup_close_ int in_fd = -1, out_fd = -1;
-        char text[] = "boohoo\nfoo\n\tbar\n";
-        char buf[64] = {0};
-
-        in_fd = mkostemp_safe(in_fn, O_RDWR);
-        assert_se(in_fd >= 0);
-        out_fd = mkostemp_safe(out_fn, O_RDWR);
-        assert_se(out_fd >= 0);
-
-        assert_se(write_string_file(in_fn, text) == 0);
-        assert_se(copy_file_fd("/a/file/which/does/not/exist/i/guess", out_fd, true) < 0);
-        assert_se(copy_file_fd(in_fn, out_fd, true) >= 0);
-        assert_se(lseek(out_fd, SEEK_SET, 0) == 0);
-
-        assert_se(read(out_fd, buf, sizeof(buf)) == sizeof(text) - 1);
-        assert_se(streq(buf, text));
-
-        unlink(in_fn);
-        unlink(out_fn);
-}
-
-static void test_copy_tree(void) {
-        char original_dir[] = "/tmp/test-copy_tree/";
-        char copy_dir[] = "/tmp/test-copy_tree-copy/";
-        char **files = STRV_MAKE("file", "dir1/file", "dir1/dir2/file", "dir1/dir2/dir3/dir4/dir5/file");
-        char **links = STRV_MAKE("link", "file",
-                                 "link2", "dir1/file");
-        char **p, **link;
-
-        rm_rf_dangerous(copy_dir, false, true, false);
-        rm_rf_dangerous(original_dir, false, true, false);
-
-        STRV_FOREACH(p, files) {
-                char *f = strjoina(original_dir, *p);
-
-                assert_se(mkdir_parents(f, 0755) >= 0);
-                assert_se(write_string_file(f, "file") == 0);
-        }
-
-        STRV_FOREACH_PAIR(link, p, links) {
-                char *f = strjoina(original_dir, *p);
-                char *l = strjoina(original_dir, *link);
-
-                assert_se(mkdir_parents(l, 0755) >= 0);
-                assert_se(symlink(f, l) == 0);
-        }
-
-        assert_se(copy_tree(original_dir, copy_dir, true) == 0);
-
-        STRV_FOREACH(p, files) {
-                _cleanup_free_ char *buf = NULL;
-                size_t sz = 0;
-                char *f = strjoina(copy_dir, *p);
-
-                assert_se(access(f, F_OK) == 0);
-                assert_se(read_full_file(f, &buf, &sz) == 0);
-                assert_se(streq(buf, "file\n"));
-        }
-
-        STRV_FOREACH_PAIR(link, p, links) {
-                _cleanup_free_ char *target = NULL;
-                char *f = strjoina(original_dir, *p);
-                char *l = strjoina(copy_dir, *link);
-
-                assert_se(readlink_and_canonicalize(l, &target) == 0);
-                assert_se(path_equal(f, target));
-        }
-
-        assert_se(copy_tree(original_dir, copy_dir, false) < 0);
-        assert_se(copy_tree("/tmp/inexistent/foo/bar/fsdoi", copy_dir, false) < 0);
-
-        rm_rf_dangerous(copy_dir, false, true, false);
-        rm_rf_dangerous(original_dir, false, true, false);
-}
-
-int main(int argc, char *argv[]) {
-        test_copy_file();
-        test_copy_file_fd();
-        test_copy_tree();
-
-        return 0;
-}
diff --git a/src/test/test-daemon.c b/src/test/test-daemon.c
deleted file mode 100644 (file)
index 7e0ac75..0000000
+++ /dev/null
@@ -1,53 +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(5);
-
-        sd_notify(0,
-                  "STATUS=Reloading\n"
-                  "RELOADING=1");
-        sleep(5);
-
-        sd_notify(0,
-                  "STATUS=Running\n"
-                  "READY=1");
-        sleep(5);
-
-        sd_notify(0,
-                  "STATUS=Quitting\n"
-                  "STOPPING=1");
-        sleep(5);
-
-        return 0;
-}
diff --git a/src/test/test-date.c b/src/test/test-date.c
deleted file mode 100644 (file)
index 00b5690..0000000
+++ /dev/null
@@ -1,64 +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 <string.h>
-
-#include "util.h"
-
-static void test_one(const char *p) {
-        usec_t t, q;
-        char buf[FORMAT_TIMESTAMP_MAX], buf_relative[FORMAT_TIMESTAMP_RELATIVE_MAX];
-
-        assert_se(parse_timestamp(p, &t) >= 0);
-        format_timestamp(buf, sizeof(buf), t);
-        log_info("%s", buf);
-
-        /* Chop off timezone */
-        *strrchr(buf, ' ') = 0;
-
-        assert_se(parse_timestamp(buf, &q) >= 0);
-        assert_se(q == t);
-
-        format_timestamp_relative(buf_relative, sizeof(buf_relative), t);
-        log_info("%s", strna(buf_relative));
-        assert_se(parse_timestamp(buf, &q) >= 0);
-}
-
-int main(int argc, char *argv[]) {
-        test_one("17:41");
-        test_one("18:42:44");
-        test_one("12-10-02 12:13:14");
-        test_one("12-10-2 12:13:14");
-        test_one("12-10-03 12:13");
-        test_one("2012-12-30 18:42");
-        test_one("2012-10-02");
-        test_one("Tue 2012-10-02");
-        test_one("now");
-        test_one("yesterday");
-        test_one("today");
-        test_one("tomorrow");
-        test_one("+2d");
-        test_one("+2y 4d");
-        test_one("5months ago");
-        test_one("@1395716396");
-
-        return 0;
-}
diff --git a/src/test/test-device-nodes.c b/src/test/test-device-nodes.c
deleted file mode 100644 (file)
index 59ba4be..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Dave Reisner
-
-  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 <sys/types.h>
-
-#include "device-nodes.h"
-#include "util.h"
-
-/* helpers for test_encode_devnode_name */
-static char *do_encode_string(const char *in) {
-        size_t out_len = strlen(in) * 4 + 1;
-        char *out = malloc(out_len);
-
-        assert_se(out);
-        assert_se(encode_devnode_name(in, out, out_len) >= 0);
-        puts(out);
-
-        return out;
-}
-
-static bool expect_encoded_as(const char *in, const char *expected) {
-        _cleanup_free_ char *encoded = do_encode_string(in);
-        return streq(encoded, expected);
-}
-
-static void test_encode_devnode_name(void) {
-        assert_se(expect_encoded_as("systemd sucks", "systemd\\x20sucks"));
-        assert_se(expect_encoded_as("pinkiepie", "pinkiepie"));
-        assert_se(expect_encoded_as("valíd\\ųtf8", "valíd\\x5cųtf8"));
-        assert_se(expect_encoded_as("s/ash/ng", "s\\x2fash\\x2fng"));
-        assert_se(expect_encoded_as("/", "\\x2f"));
-        assert_se(expect_encoded_as("!", "\\x21"));
-}
-
-int main(int argc, char *argv[]) {
-        test_encode_devnode_name();
-
-        return 0;
-}
diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c
deleted file mode 100644 (file)
index 6a2f9aa..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Shawn Landden
-
-  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 "util.h"
-#include "def.h"
-
-static void test_one(const char *p) {
-        _cleanup_free_ char *t;
-        t = ellipsize(p, columns(), 70);
-        puts(t);
-}
-
-int main(int argc, char *argv[]) {
-        test_one(DIGITS LETTERS DIGITS LETTERS);
-        test_one("한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어");
-        test_one("-日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国");
-        test_one("中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国-中国中国中国中国中国中国中国中国中国中国中国中国中国");
-        test_one("sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd");
-        test_one("🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮");
-        test_one("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
-        test_one("shórt");
-
-        return 0;
-}
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
deleted file mode 100644 (file)
index d543d23..0000000
+++ /dev/null
@@ -1,112 +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 "manager.h"
-#include "bus-util.h"
-
-int main(int argc, char *argv[]) {
-        _cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL;
-        Manager *m = NULL;
-        Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, *h = NULL;
-        FILE *serial = NULL;
-        FDSet *fdset = NULL;
-        Job *j;
-        int r;
-
-        /* prepare the test */
-        assert_se(set_unit_path(TEST_DIR) >= 0);
-        r = manager_new(SYSTEMD_USER, true, &m);
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
-                printf("Skipping test: manager_new: %s", strerror(-r));
-                return EXIT_TEST_SKIP;
-        }
-        assert_se(r >= 0);
-        assert_se(manager_startup(m, serial, fdset) >= 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");
-        r = manager_add_job(m, JOB_START, c, JOB_REPLACE, false, &err, &j);
-        if (sd_bus_error_is_set(&err))
-                log_error("error: %s: %s", err.name, err.message);
-        assert_se(r == 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) == -EDEADLK);
-        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) == -EDEADLK);
-
-        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) == -EDEADLK);
-
-        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/test-env-replace.c b/src/test/test-env-replace.c
deleted file mode 100644 (file)
index 8f1fcd9..0000000
+++ /dev/null
@@ -1,217 +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 "strv.h"
-#include "env-util.h"
-
-static void test_strv_env_delete(void) {
-        _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL, **d = NULL;
-
-        a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", NULL);
-        assert_se(a);
-
-        b = strv_new("PIEP", "FOO", NULL);
-        assert_se(b);
-
-        c = strv_new("SCHLUMPF", NULL);
-        assert_se(c);
-
-        d = strv_env_delete(a, 2, b, c);
-        assert_se(d);
-
-        assert_se(streq(d[0], "WALDO=WALDO"));
-        assert_se(streq(d[1], "WALDO="));
-        assert_se(strv_length(d) == 2);
-}
-
-static void test_strv_env_unset(void) {
-        _cleanup_strv_free_ char **l = NULL;
-
-        l = strv_new("PIEP", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
-        assert_se(l);
-
-        assert_se(strv_env_unset(l, "SCHLUMPF") == l);
-
-        assert_se(streq(l[0], "PIEP"));
-        assert_se(streq(l[1], "NANANANA=YES"));
-        assert_se(strv_length(l) == 2);
-}
-
-static void test_strv_env_set(void) {
-        _cleanup_strv_free_ char **l = NULL, **r = NULL;
-
-        l = strv_new("PIEP", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
-        assert_se(l);
-
-        r = strv_env_set(l, "WALDO=WALDO");
-        assert_se(r);
-
-        assert_se(streq(r[0], "PIEP"));
-        assert_se(streq(r[1], "SCHLUMPF=SMURFF"));
-        assert_se(streq(r[2], "NANANANA=YES"));
-        assert_se(streq(r[3], "WALDO=WALDO"));
-        assert_se(strv_length(r) == 4);
-}
-
-static void test_strv_env_merge(void) {
-        _cleanup_strv_free_ char **a = NULL, **b = NULL, **r = NULL;
-
-        a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", NULL);
-        assert_se(a);
-
-        b = strv_new("FOO=KKK", "FOO=", "PIEP=", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
-        assert_se(b);
-
-        r = strv_env_merge(2, a, b);
-        assert_se(r);
-        assert_se(streq(r[0], "FOO="));
-        assert_se(streq(r[1], "WALDO="));
-        assert_se(streq(r[2], "PIEP"));
-        assert_se(streq(r[3], "SCHLUMPF=SMURFF"));
-        assert_se(streq(r[4], "PIEP="));
-        assert_se(streq(r[5], "NANANANA=YES"));
-        assert_se(strv_length(r) == 6);
-
-        assert_se(strv_env_clean(r) == r);
-        assert_se(streq(r[0], "FOO="));
-        assert_se(streq(r[1], "WALDO="));
-        assert_se(streq(r[2], "SCHLUMPF=SMURFF"));
-        assert_se(streq(r[3], "PIEP="));
-        assert_se(streq(r[4], "NANANANA=YES"));
-        assert_se(strv_length(r) == 5);
-}
-
-static void test_replace_env_arg(void) {
-        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
-        };
-        _cleanup_strv_free_ char **r = NULL;
-
-        r = replace_env_argv((char**) line, (char**) env);
-        assert_se(r);
-        assert_se(streq(r[0], "FOO$FOO"));
-        assert_se(streq(r[1], "FOO$FOOFOO"));
-        assert_se(streq(r[2], "FOOBAR BAR$FOO"));
-        assert_se(streq(r[3], "FOOBAR BAR"));
-        assert_se(streq(r[4], "BAR BAR"));
-        assert_se(streq(r[5], "BAR"));
-        assert_se(streq(r[6], "BAR"));
-        assert_se(streq(r[7], "BAR BARwaldo"));
-        assert_se(streq(r[8], "${FOO"));
-        assert_se(strv_length(r) == 9);
-}
-
-static void test_one_normalize(const char *input, const char *output) {
-        _cleanup_free_ char *t;
-
-        t = normalize_env_assignment(input);
-        assert_se(t);
-        assert_se(streq(t, output));
-}
-
-static void test_normalize_env_assignment(void) {
-        test_one_normalize("foo=bar", "foo=bar");
-        test_one_normalize("=bar", "=bar");
-        test_one_normalize("foo=", "foo=");
-        test_one_normalize("=", "=");
-        test_one_normalize("", "");
-        test_one_normalize("a=\"waldo\"", "a=waldo");
-        test_one_normalize("a=\"waldo", "a=\"waldo");
-        test_one_normalize("a=waldo\"", "a=waldo\"");
-        test_one_normalize("a=\'", "a='");
-        test_one_normalize("a=\'\'", "a=");
-        test_one_normalize(" xyz  ", "xyz");
-        test_one_normalize(" xyz = bar  ", "xyz=bar");
-        test_one_normalize(" xyz = 'bar ' ", "xyz=bar ");
-        test_one_normalize(" ' xyz' = 'bar ' ", "' xyz'=bar ");
-}
-
-static void test_env_clean(void) {
-        _cleanup_strv_free_ char **e;
-
-        e = strv_new("FOOBAR=WALDO",
-                     "FOOBAR=WALDO",
-                     "FOOBAR",
-                     "F",
-                     "X=",
-                     "F=F",
-                     "=",
-                     "=F",
-                     "",
-                     "0000=000",
-                     "äöüß=abcd",
-                     "abcd=äöüß",
-                     "xyz\n=xyz",
-                     "xyz=xyz\n",
-                     "another=one",
-                     "another=final one",
-                     NULL);
-        assert_se(e);
-        assert_se(!strv_env_is_valid(e));
-        assert_se(strv_env_clean(e) == e);
-        assert_se(strv_env_is_valid(e));
-
-        assert_se(streq(e[0], "FOOBAR=WALDO"));
-        assert_se(streq(e[1], "X="));
-        assert_se(streq(e[2], "F=F"));
-        assert_se(streq(e[3], "abcd=äöüß"));
-        assert_se(streq(e[4], "another=final one"));
-        assert_se(e[5] == NULL);
-}
-
-static void test_env_name_is_valid(void) {
-        assert_se(env_name_is_valid("test"));
-
-        assert_se(!env_name_is_valid(NULL));
-        assert_se(!env_name_is_valid(""));
-        assert_se(!env_name_is_valid("5_starting_with_a_number_is_wrong"));
-        assert_se(!env_name_is_valid("#¤%&?_only_numbers_letters_and_underscore_allowed"));
-}
-
-int main(int argc, char *argv[]) {
-        test_strv_env_delete();
-        test_strv_env_unset();
-        test_strv_env_set();
-        test_strv_env_merge();
-        test_replace_env_arg();
-        test_normalize_env_assignment();
-        test_env_clean();
-        test_env_name_is_valid();
-
-        return 0;
-}
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
deleted file mode 100644 (file)
index 428fd32..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "unit.h"
-#include "manager.h"
-#include "util.h"
-#include "macro.h"
-#include "mkdir.h"
-
-typedef void (*test_function_t)(Manager *m);
-
-static void check(Manager *m, Unit *unit, int status_expected, int code_expected) {
-        Service *service = NULL;
-        usec_t ts;
-        usec_t timeout = 2 * USEC_PER_SEC;
-
-        assert_se(m);
-        assert_se(unit);
-
-        service = SERVICE(unit);
-        printf("%s\n", unit->id);
-        exec_context_dump(&service->exec_context, stdout, "\t");
-        ts = now(CLOCK_MONOTONIC);
-        while (service->state != SERVICE_DEAD && service->state != SERVICE_FAILED) {
-                int r;
-                usec_t n;
-
-                r = sd_event_run(m->event, 100 * USEC_PER_MSEC);
-                assert_se(r >= 0);
-
-                n = now(CLOCK_MONOTONIC);
-                if (ts + timeout < n) {
-                        log_error("Test timeout when testing %s", unit->id);
-                        exit(EXIT_FAILURE);
-                }
-        }
-        exec_status_dump(&service->main_exec_status, stdout, "\t");
-        assert_se(service->main_exec_status.status == status_expected);
-        assert_se(service->main_exec_status.code == code_expected);
-}
-
-static void test(Manager *m, const char *unit_name, int status_expected, int code_expected) {
-        Unit *unit;
-
-        assert_se(unit_name);
-
-        assert_se(manager_load_unit(m, unit_name, NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-        check(m, unit, status_expected, code_expected);
-}
-
-static void test_exec_workingdirectory(Manager *m) {
-        assert_se(mkdir_p("/tmp/test-exec_workingdirectory", 0755) >= 0);
-
-        test(m, "exec-workingdirectory.service", 0, CLD_EXITED);
-
-        rm_rf_dangerous("/tmp/test-exec_workingdirectory", false, true, false);
-}
-
-static void test_exec_personality(Manager *m) {
-        test(m, "exec-personality-x86.service", 0, CLD_EXITED);
-
-#if defined(__x86_64__)
-        test(m, "exec-personality-x86-64.service", 0, CLD_EXITED);
-#endif
-}
-
-static void test_exec_ignoresigpipe(Manager *m) {
-        test(m, "exec-ignoresigpipe-yes.service", 0, CLD_EXITED);
-        test(m, "exec-ignoresigpipe-no.service", SIGPIPE, CLD_KILLED);
-}
-
-static void test_exec_privatetmp(Manager *m) {
-        assert_se(touch("/tmp/test-exec_privatetmp") >= 0);
-
-        test(m, "exec-privatetmp-yes.service", 0, CLD_EXITED);
-        test(m, "exec-privatetmp-no.service", 0, CLD_EXITED);
-
-        unlink("/tmp/test-exec_privatetmp");
-}
-
-static void test_exec_privatedevices(Manager *m) {
-        test(m, "exec-privatedevices-yes.service", 0, CLD_EXITED);
-        test(m, "exec-privatedevices-no.service", 0, CLD_EXITED);
-}
-
-static void test_exec_systemcallfilter(Manager *m) {
-#ifdef HAVE_SECCOMP
-        test(m, "exec-systemcallfilter-not-failing.service", 0, CLD_EXITED);
-        test(m, "exec-systemcallfilter-not-failing2.service", 0, CLD_EXITED);
-        test(m, "exec-systemcallfilter-failing.service", SIGSYS, CLD_KILLED);
-        test(m, "exec-systemcallfilter-failing2.service", SIGSYS, CLD_KILLED);
-#endif
-}
-
-static void test_exec_systemcallerrornumber(Manager *m) {
-#ifdef HAVE_SECCOMP
-        test(m, "exec-systemcallerrornumber.service", 1, CLD_EXITED);
-#endif
-}
-
-static void test_exec_user(Manager *m) {
-        test(m, "exec-user.service", 0, CLD_EXITED);
-}
-
-static void test_exec_group(Manager *m) {
-        test(m, "exec-group.service", 0, CLD_EXITED);
-}
-
-static void test_exec_environment(Manager *m) {
-        test(m, "exec-environment.service", 0, CLD_EXITED);
-        test(m, "exec-environment-multiple.service", 0, CLD_EXITED);
-        test(m, "exec-environment-empty.service", 0, CLD_EXITED);
-}
-
-static void test_exec_umask(Manager *m) {
-        test(m, "exec-umask-default.service", 0, CLD_EXITED);
-        test(m, "exec-umask-0177.service", 0, CLD_EXITED);
-}
-
-int main(int argc, char *argv[]) {
-        test_function_t tests[] = {
-                test_exec_workingdirectory,
-                test_exec_personality,
-                test_exec_ignoresigpipe,
-                test_exec_privatetmp,
-                test_exec_privatedevices,
-                test_exec_systemcallfilter,
-                test_exec_systemcallerrornumber,
-                test_exec_user,
-                test_exec_group,
-                test_exec_environment,
-                test_exec_umask,
-                NULL,
-        };
-        test_function_t *test = NULL;
-        Manager *m = NULL;
-        int r;
-
-        log_parse_environment();
-        log_open();
-
-        /* It is needed otherwise cgroup creation fails */
-        if (getuid() != 0) {
-                printf("Skipping test: not root\n");
-                return EXIT_TEST_SKIP;
-        }
-
-        assert_se(set_unit_path(TEST_DIR ":") >= 0);
-
-        r = manager_new(SYSTEMD_USER, true, &m);
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
-                printf("Skipping test: manager_new: %s", strerror(-r));
-                return EXIT_TEST_SKIP;
-        }
-        assert_se(r >= 0);
-        assert_se(manager_startup(m, NULL, NULL) >= 0);
-
-        for (test = tests; test && *test; test++)
-                (*test)(m);
-
-        manager_free(m);
-
-        return 0;
-}
diff --git a/src/test/test-fdset.c b/src/test/test-fdset.c
deleted file mode 100644 (file)
index 91df7eb..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 <fcntl.h>
-#include <unistd.h>
-
-#include "fdset.h"
-#include "util.h"
-#include "macro.h"
-
-static void test_fdset_new_fill(void) {
-        int fd = -1;
-        _cleanup_fdset_free_ FDSet *fdset = NULL;
-        char name[] = "/tmp/test-fdset_new_fill.XXXXXX";
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-        assert_se(fdset_new_fill(&fdset) >= 0);
-        assert_se(fdset_contains(fdset, fd));
-
-        unlink(name);
-}
-
-static void test_fdset_put_dup(void) {
-        _cleanup_close_ int fd = -1;
-        int copyfd = -1;
-        _cleanup_fdset_free_ FDSet *fdset = NULL;
-        char name[] = "/tmp/test-fdset_put_dup.XXXXXX";
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        fdset = fdset_new();
-        assert_se(fdset);
-        copyfd = fdset_put_dup(fdset, fd);
-        assert_se(copyfd >= 0 && copyfd != fd);
-        assert_se(fdset_contains(fdset, copyfd));
-        assert_se(!fdset_contains(fdset, fd));
-
-        unlink(name);
-}
-
-static void test_fdset_cloexec(void) {
-        int fd = -1;
-        _cleanup_fdset_free_ FDSet *fdset = NULL;
-        int flags = -1;
-        char name[] = "/tmp/test-fdset_cloexec.XXXXXX";
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        fdset = fdset_new();
-        assert_se(fdset);
-        assert_se(fdset_put(fdset, fd));
-
-        assert_se(fdset_cloexec(fdset, false) >= 0);
-        flags = fcntl(fd, F_GETFD);
-        assert_se(flags >= 0);
-        assert_se(!(flags & FD_CLOEXEC));
-
-        assert_se(fdset_cloexec(fdset, true) >= 0);
-        flags = fcntl(fd, F_GETFD);
-        assert_se(flags >= 0);
-        assert_se(flags & FD_CLOEXEC);
-
-        unlink(name);
-}
-
-static void test_fdset_close_others(void) {
-        int fd = -1;
-        int copyfd = -1;
-        _cleanup_fdset_free_ FDSet *fdset = NULL;
-        int flags = -1;
-        char name[] = "/tmp/test-fdset_close_others.XXXXXX";
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        fdset = fdset_new();
-        assert_se(fdset);
-        copyfd = fdset_put_dup(fdset, fd);
-        assert_se(copyfd >= 0);
-
-        assert_se(fdset_close_others(fdset) >= 0);
-        flags = fcntl(fd, F_GETFD);
-        assert_se(flags < 0);
-        flags = fcntl(copyfd, F_GETFD);
-        assert_se(flags >= 0);
-
-        unlink(name);
-}
-
-static void test_fdset_remove(void) {
-        _cleanup_close_ int fd = -1;
-        FDSet *fdset = NULL;
-        char name[] = "/tmp/test-fdset_remove.XXXXXX";
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        fdset = fdset_new();
-        assert_se(fdset);
-        assert_se(fdset_put(fdset, fd) >= 0);
-        assert_se(fdset_remove(fdset, fd) >= 0);
-        assert_se(!fdset_contains(fdset, fd));
-        fdset_free(fdset);
-
-        assert_se(fcntl(fd, F_GETFD) >= 0);
-
-        unlink(name);
-}
-
-static void test_fdset_iterate(void) {
-        int fd = -1;
-        FDSet *fdset = NULL;
-        char name[] = "/tmp/test-fdset_iterate.XXXXXX";
-        Iterator i;
-        int c = 0;
-        int a;
-
-        fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        fdset = fdset_new();
-        assert_se(fdset);
-        assert_se(fdset_put(fdset, fd) >= 0);
-        assert_se(fdset_put(fdset, fd) >= 0);
-        assert_se(fdset_put(fdset, fd) >= 0);
-
-        FDSET_FOREACH(a, fdset, i) {
-                c++;
-                assert_se(a == fd);
-        }
-        assert_se(c == 1);
-
-        fdset_free(fdset);
-
-        unlink(name);
-}
-
-int main(int argc, char *argv[]) {
-        test_fdset_new_fill();
-        test_fdset_put_dup();
-        test_fdset_cloexec();
-        test_fdset_close_others();
-        test_fdset_remove();
-        test_fdset_iterate();
-
-        return 0;
-}
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
deleted file mode 100644 (file)
index 63e4a19..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 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 <fcntl.h>
-#include <unistd.h>
-
-#include "util.h"
-#include "fileio.h"
-#include "strv.h"
-#include "env-util.h"
-#include "def.h"
-#include "ctype.h"
-
-static void test_parse_env_file(void) {
-        char    t[] = "/tmp/test-fileio-in-XXXXXX",
-                p[] = "/tmp/test-fileio-out-XXXXXX";
-        int fd, r;
-        FILE *f;
-        _cleanup_free_ char *one = NULL, *two = NULL, *three = NULL, *four = NULL, *five = NULL,
-                        *six = NULL, *seven = NULL, *eight = NULL, *nine = NULL, *ten = NULL;
-        _cleanup_strv_free_ char **a = NULL, **b = NULL;
-        char **i;
-        unsigned k;
-
-        fd = mkostemp_safe(p, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-        close(fd);
-
-        fd = mkostemp_safe(t, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        f = fdopen(fd, "w");
-        assert_se(f);
-
-        fputs("one=BAR   \n"
-              "# comment\n"
-              " # comment \n"
-              " ; comment \n"
-              "  two   =   bar    \n"
-              "invalid line\n"
-              "invalid line #comment\n"
-              "three = \"333\n"
-              "xxxx\"\n"
-              "four = \'44\\\"44\'\n"
-              "five = \'55\\\'55\' \"FIVE\" cinco   \n"
-              "six = seis sechs\\\n"
-              " sis\n"
-              "seven=\"sevenval\" #nocomment\n"
-              "eight=eightval #nocomment\n"
-              "export nine=nineval\n"
-              "ten=", f);
-
-        fflush(f);
-        fclose(f);
-
-        r = load_env_file(NULL, t, NULL, &a);
-        assert_se(r >= 0);
-
-        STRV_FOREACH(i, a)
-                log_info("Got: <%s>", *i);
-
-        assert_se(streq_ptr(a[0], "one=BAR"));
-        assert_se(streq_ptr(a[1], "two=bar"));
-        assert_se(streq_ptr(a[2], "three=333\nxxxx"));
-        assert_se(streq_ptr(a[3], "four=44\"44"));
-        assert_se(streq_ptr(a[4], "five=55\'55FIVEcinco"));
-        assert_se(streq_ptr(a[5], "six=seis sechs sis"));
-        assert_se(streq_ptr(a[6], "seven=sevenval#nocomment"));
-        assert_se(streq_ptr(a[7], "eight=eightval #nocomment"));
-        assert_se(streq_ptr(a[8], "export nine=nineval"));
-        assert_se(streq_ptr(a[9], "ten="));
-        assert_se(a[10] == NULL);
-
-        strv_env_clean(a);
-
-        k = 0;
-        STRV_FOREACH(i, b) {
-                log_info("Got2: <%s>", *i);
-                assert_se(streq(*i, a[k++]));
-        }
-
-        r = parse_env_file(
-                        t, NULL,
-                       "one", &one,
-                       "two", &two,
-                       "three", &three,
-                       "four", &four,
-                       "five", &five,
-                       "six", &six,
-                       "seven", &seven,
-                       "eight", &eight,
-                       "export nine", &nine,
-                       "ten", &ten,
-                       NULL);
-
-        assert_se(r >= 0);
-
-        log_info("one=[%s]", strna(one));
-        log_info("two=[%s]", strna(two));
-        log_info("three=[%s]", strna(three));
-        log_info("four=[%s]", strna(four));
-        log_info("five=[%s]", strna(five));
-        log_info("six=[%s]", strna(six));
-        log_info("seven=[%s]", strna(seven));
-        log_info("eight=[%s]", strna(eight));
-        log_info("export nine=[%s]", strna(nine));
-        log_info("ten=[%s]", strna(nine));
-
-        assert_se(streq(one, "BAR"));
-        assert_se(streq(two, "bar"));
-        assert_se(streq(three, "333\nxxxx"));
-        assert_se(streq(four, "44\"44"));
-        assert_se(streq(five, "55\'55FIVEcinco"));
-        assert_se(streq(six, "seis sechs sis"));
-        assert_se(streq(seven, "sevenval#nocomment"));
-        assert_se(streq(eight, "eightval #nocomment"));
-        assert_se(streq(nine, "nineval"));
-        assert_se(ten == NULL);
-
-        r = write_env_file(p, a);
-        assert_se(r >= 0);
-
-        r = load_env_file(NULL, p, NULL, &b);
-        assert_se(r >= 0);
-
-        unlink(t);
-        unlink(p);
-}
-
-static void test_parse_multiline_env_file(void) {
-        char    t[] = "/tmp/test-fileio-in-XXXXXX",
-                p[] = "/tmp/test-fileio-out-XXXXXX";
-        int fd, r;
-        FILE *f;
-        _cleanup_strv_free_ char **a = NULL, **b = NULL;
-        char **i;
-
-        fd = mkostemp_safe(p, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-        close(fd);
-
-        fd = mkostemp_safe(t, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        f = fdopen(fd, "w");
-        assert_se(f);
-
-        fputs("one=BAR\\\n"
-              "    VAR\\\n"
-              "\tGAR\n"
-              "#comment\n"
-              "two=\"bar\\\n"
-              "    var\\\n"
-              "\tgar\"\n"
-              "#comment\n"
-              "tri=\"bar \\\n"
-              "    var \\\n"
-              "\tgar \"\n", f);
-
-        fflush(f);
-        fclose(f);
-
-        r = load_env_file(NULL, t, NULL, &a);
-        assert_se(r >= 0);
-
-        STRV_FOREACH(i, a)
-                log_info("Got: <%s>", *i);
-
-        assert_se(streq_ptr(a[0], "one=BAR    VAR\tGAR"));
-        assert_se(streq_ptr(a[1], "two=bar    var\tgar"));
-        assert_se(streq_ptr(a[2], "tri=bar     var \tgar "));
-        assert_se(a[3] == NULL);
-
-        r = write_env_file(p, a);
-        assert_se(r >= 0);
-
-        r = load_env_file(NULL, p, NULL, &b);
-        assert_se(r >= 0);
-
-        unlink(t);
-        unlink(p);
-}
-
-
-static void test_executable_is_script(void) {
-        char t[] = "/tmp/test-executable-XXXXXX";
-        int fd, r;
-        FILE *f;
-        char *command;
-
-        fd = mkostemp_safe(t, O_RDWR|O_CLOEXEC);
-        assert_se(fd >= 0);
-
-        f = fdopen(fd, "w");
-        assert_se(f);
-
-        fputs("#! /bin/script -a -b \ngoo goo", f);
-        fflush(f);
-
-        r = executable_is_script(t, &command);
-        assert_se(r > 0);
-        assert_se(streq(command, "/bin/script"));
-        free(command);
-
-        r = executable_is_script("/bin/sh", &command);
-        assert_se(r == 0);
-
-        r = executable_is_script("/usr/bin/yum", &command);
-        assert_se(r > 0 || r == -ENOENT);
-        if (r > 0) {
-                assert_se(startswith(command, "/"));
-                free(command);
-        }
-
-        fclose(f);
-        unlink(t);
-}
-
-static void test_status_field(void) {
-        _cleanup_free_ char *t = NULL, *p = NULL, *s = NULL, *z = NULL;
-        unsigned long long total = 0, buffers = 0;
-        int r;
-
-        assert_se(get_status_field("/proc/self/status", "\nThreads:", &t) == 0);
-        puts(t);
-        assert_se(streq(t, "1"));
-
-        r = get_status_field("/proc/meminfo", "MemTotal:", &p);
-        if (r != -ENOENT) {
-                assert_se(r == 0);
-                puts(p);
-                assert_se(safe_atollu(p, &total) == 0);
-        }
-
-        r = get_status_field("/proc/meminfo", "\nBuffers:", &s);
-        if (r != -ENOENT) {
-                assert_se(r == 0);
-                puts(s);
-                assert_se(safe_atollu(s, &buffers) == 0);
-        }
-
-        if (p)
-                assert_se(buffers < total);
-
-        /* Seccomp should be a good test for field full of zeros. */
-        r = get_status_field("/proc/meminfo", "\nSeccomp:", &z);
-        if (r != -ENOENT) {
-                assert_se(r == 0);
-                puts(z);
-                assert_se(safe_atollu(z, &buffers) == 0);
-        }
-}
-
-static void test_capeff(void) {
-        int pid, p;
-
-        for (pid = 0; pid < 2; pid++) {
-                _cleanup_free_ char *capeff = NULL;
-                int r;
-
-                r = get_process_capeff(0, &capeff);
-                log_info("capeff: '%s' (r=%d)", capeff, r);
-
-                if (r == -ENOENT || r == -EPERM)
-                        return;
-
-                assert_se(r == 0);
-                assert_se(*capeff);
-                p = capeff[strspn(capeff, DIGITS "abcdefABCDEF")];
-                assert_se(!p || isspace(p));
-        }
-}
-
-static void test_write_string_stream(void) {
-        char fn[] = "/tmp/test-write_string_stream-XXXXXX";
-        _cleanup_fclose_ FILE *f = NULL;
-        int fd;
-        char buf[64];
-
-        fd = mkostemp_safe(fn, O_RDWR);
-        assert_se(fd >= 0);
-
-        f = fdopen(fd, "r");
-        assert_se(f);
-        assert_se(write_string_stream(f, "boohoo") < 0);
-
-        f = freopen(fn, "r+", f);
-        assert_se(f);
-
-        assert_se(write_string_stream(f, "boohoo") == 0);
-        rewind(f);
-
-        assert_se(fgets(buf, sizeof(buf), f));
-        assert_se(streq(buf, "boohoo\n"));
-
-        unlink(fn);
-}
-
-static void test_write_string_file(void) {
-        char fn[] = "/tmp/test-write_string_file-XXXXXX";
-        char buf[64] = {};
-        _cleanup_close_ int fd;
-
-        fd = mkostemp_safe(fn, O_RDWR);
-        assert_se(fd >= 0);
-
-        assert_se(write_string_file(fn, "boohoo") == 0);
-
-        assert_se(read(fd, buf, sizeof(buf)) == 7);
-        assert_se(streq(buf, "boohoo\n"));
-
-        unlink(fn);
-}
-
-static void test_write_string_file_no_create(void) {
-        char fn[] = "/tmp/test-write_string_file_no_create-XXXXXX";
-        _cleanup_close_ int fd;
-        char buf[64] = {0};
-
-        fd = mkostemp_safe(fn, O_RDWR);
-        assert_se(fd >= 0);
-
-        assert_se(write_string_file_no_create("/a/file/which/does/not/exists/i/guess", "boohoo") < 0);
-        assert_se(write_string_file_no_create(fn, "boohoo") == 0);
-
-        assert_se(read(fd, buf, sizeof(buf)) == strlen("boohoo\n"));
-        assert_se(streq(buf, "boohoo\n"));
-
-        unlink(fn);
-}
-
-static void test_load_env_file_pairs(void) {
-        char fn[] = "/tmp/test-load_env_file_pairs-XXXXXX";
-        int fd;
-        int r;
-        _cleanup_fclose_ FILE *f = NULL;
-        _cleanup_strv_free_ char **l = NULL;
-        char **k, **v;
-
-        fd = mkostemp_safe(fn, O_RDWR);
-        assert_se(fd >= 0);
-
-        r = write_string_file(fn,
-                        "NAME=\"Arch Linux\"\n"
-                        "ID=arch\n"
-                        "PRETTY_NAME=\"Arch Linux\"\n"
-                        "ANSI_COLOR=\"0;36\"\n"
-                        "HOME_URL=\"https://www.archlinux.org/\"\n"
-                        "SUPPORT_URL=\"https://bbs.archlinux.org/\"\n"
-                        "BUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n"
-                        );
-        assert_se(r == 0);
-
-        f = fdopen(fd, "r");
-        assert_se(f);
-
-        r = load_env_file_pairs(f, fn, NULL, &l);
-        assert_se(r >= 0);
-
-        assert_se(strv_length(l) == 14);
-        STRV_FOREACH_PAIR(k, v, l) {
-                assert_se(STR_IN_SET(*k, "NAME", "ID", "PRETTY_NAME", "ANSI_COLOR", "HOME_URL", "SUPPORT_URL", "BUG_REPORT_URL"));
-                printf("%s=%s\n", *k, *v);
-                if (streq(*k, "NAME")) assert_se(streq(*v, "Arch Linux"));
-                if (streq(*k, "ID")) assert_se(streq(*v, "arch"));
-                if (streq(*k, "PRETTY_NAME")) assert_se(streq(*v, "Arch Linux"));
-                if (streq(*k, "ANSI_COLOR")) assert_se(streq(*v, "0;36"));
-                if (streq(*k, "HOME_URL")) assert_se(streq(*v, "https://www.archlinux.org/"));
-                if (streq(*k, "SUPPORT_URL")) assert_se(streq(*v, "https://bbs.archlinux.org/"));
-                if (streq(*k, "BUG_REPORT_URL")) assert_se(streq(*v, "https://bugs.archlinux.org/"));
-        }
-
-        unlink(fn);
-}
-
-int main(int argc, char *argv[]) {
-        log_parse_environment();
-        log_open();
-
-        test_parse_env_file();
-        test_parse_multiline_env_file();
-        test_executable_is_script();
-        test_status_field();
-        test_capeff();
-        test_write_string_stream();
-        test_write_string_file();
-        test_write_string_file_no_create();
-        test_load_env_file_pairs();
-
-        return 0;
-}
diff --git a/src/test/test-fstab-util.c b/src/test/test-fstab-util.c
deleted file mode 100644 (file)
index 50e5dee..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2015 Zbigniew Jędrzejewski-Szmek
-
-  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 "fstab-util.h"
-#include "util.h"
-#include "log.h"
-
-/*
-int fstab_filter_options(const char *opts, const char *names,
-                         const char **namefound, char **value, char **filtered);
-*/
-
-static void do_fstab_filter_options(const char *opts,
-                                      const char *remove,
-                                      int r_expected,
-                                      const char *name_expected,
-                                      const char *value_expected,
-                                      const char *filtered_expected) {
-
-        int r;
-        const char *name;
-        _cleanup_free_ char *value, *filtered;
-
-        r = fstab_filter_options(opts, remove, &name, &value, &filtered);
-        log_info("\"%s\" → %d, \"%s\", \"%s\", \"%s\", expected %d, \"%s\", \"%s\", \"%s\"",
-                 opts, r, name, value, filtered,
-                 r_expected, name_expected, value_expected, filtered_expected ?: opts);
-        assert_se(r == r_expected);
-        assert_se(streq_ptr(name, name_expected));
-        assert_se(streq_ptr(value, value_expected));
-        assert_se(streq_ptr(filtered, filtered_expected ?: opts));
-
-        /* also test the malloc-less mode */
-        r = fstab_filter_options(opts, remove, &name, NULL, NULL);
-        log_info("\"%s\" → %d, \"%s\", expected %d, \"%s\"",
-                 opts, r, name,
-                 r_expected, name_expected);
-        assert_se(r == r_expected);
-        assert_se(streq_ptr(name, name_expected));
-}
-
-static void test_fstab_filter_options(void) {
-        do_fstab_filter_options("opt=0", "opt\0x-opt\0", 1, "opt", "0", "");
-        do_fstab_filter_options("opt=0", "x-opt\0opt\0", 1, "opt", "0", "");
-        do_fstab_filter_options("opt", "opt\0x-opt\0", 1, "opt", NULL, "");
-        do_fstab_filter_options("opt", "x-opt\0opt\0", 1, "opt", NULL, "");
-        do_fstab_filter_options("x-opt", "x-opt\0opt\0", 1, "x-opt", NULL, "");
-
-        do_fstab_filter_options("opt=0,other", "opt\0x-opt\0", 1, "opt", "0", "other");
-        do_fstab_filter_options("opt=0,other", "x-opt\0opt\0", 1, "opt", "0", "other");
-        do_fstab_filter_options("opt,other", "opt\0x-opt\0", 1, "opt", NULL, "other");
-        do_fstab_filter_options("opt,other", "x-opt\0opt\0", 1, "opt", NULL, "other");
-        do_fstab_filter_options("x-opt,other", "opt\0x-opt\0", 1, "x-opt", NULL, "other");
-
-        do_fstab_filter_options("opto=0,other", "opt\0x-opt\0", 0, NULL, NULL, NULL);
-        do_fstab_filter_options("opto,other", "opt\0x-opt\0", 0, NULL, NULL, NULL);
-        do_fstab_filter_options("x-opto,other", "opt\0x-opt\0", 0, NULL, NULL, NULL);
-
-        do_fstab_filter_options("first,opt=0", "opt\0x-opt\0", 1, "opt", "0", "first");
-        do_fstab_filter_options("first=1,opt=0", "opt\0x-opt\0", 1, "opt", "0", "first=1");
-        do_fstab_filter_options("first,opt=", "opt\0x-opt\0", 1, "opt", "", "first");
-        do_fstab_filter_options("first=1,opt", "opt\0x-opt\0", 1, "opt", NULL, "first=1");
-        do_fstab_filter_options("first=1,x-opt", "opt\0x-opt\0", 1, "x-opt", NULL, "first=1");
-
-        do_fstab_filter_options("first,opt=0,last=1", "opt\0x-opt\0", 1, "opt", "0", "first,last=1");
-        do_fstab_filter_options("first=1,opt=0,last=2", "x-opt\0opt\0", 1, "opt", "0", "first=1,last=2");
-        do_fstab_filter_options("first,opt,last", "opt\0", 1, "opt", NULL, "first,last");
-        do_fstab_filter_options("first=1,opt,last", "x-opt\0opt\0", 1, "opt", NULL, "first=1,last");
-        do_fstab_filter_options("first=,opt,last", "opt\0noopt\0", 1, "opt", NULL, "first=,last");
-
-        /* check repeated options */
-        do_fstab_filter_options("first,opt=0,noopt=1,last=1", "opt\0noopt\0", 1, "noopt", "1", "first,last=1");
-        do_fstab_filter_options("first=1,opt=0,last=2,opt=1", "opt\0", 1, "opt", "1", "first=1,last=2");
-        do_fstab_filter_options("x-opt=0,x-opt=1", "opt\0x-opt\0", 1, "x-opt", "1", "");
-        do_fstab_filter_options("opt=0,x-opt=1", "opt\0x-opt\0", 1, "x-opt", "1", "");
-
-        /* check that semicolons are not misinterpreted */
-        do_fstab_filter_options("opt=0;", "opt\0", 1, "opt", "0;", "");
-        do_fstab_filter_options("opt;=0", "x-opt\0opt\0noopt\0x-noopt\0", 0, NULL, NULL, NULL);
-        do_fstab_filter_options("opt;", "opt\0x-opt\0", 0, NULL, NULL, NULL);
-
-        /* check that spaces are not misinterpreted */
-        do_fstab_filter_options("opt=0 ", "opt\0", 1, "opt", "0 ", "");
-        do_fstab_filter_options("opt =0", "x-opt\0opt\0noopt\0x-noopt\0", 0, NULL, NULL, NULL);
-        do_fstab_filter_options(" opt ", "opt\0x-opt\0", 0, NULL, NULL, NULL);
-
-        /* check function will NULL args */
-        do_fstab_filter_options(NULL, "opt\0", 0, NULL, NULL, "");
-        do_fstab_filter_options("", "opt\0", 0, NULL, NULL, "");
-}
-
-static void test_fstab_find_pri(void) {
-        int pri = -1;
-
-        assert_se(fstab_find_pri("pri", &pri) == 0);
-        assert_se(pri == -1);
-
-        assert_se(fstab_find_pri("pri=11", &pri) == 1);
-        assert_se(pri == 11);
-
-        assert_se(fstab_find_pri("opt,pri=12,opt", &pri) == 1);
-        assert_se(pri == 12);
-
-        assert_se(fstab_find_pri("opt,opt,pri=12,pri=13", &pri) == 1);
-        assert_se(pri == 13);
-}
-
-static void test_fstab_yes_no_option(void) {
-        assert_se(fstab_test_yes_no_option("nofail,fail,nofail", "nofail\0fail\0") == true);
-        assert_se(fstab_test_yes_no_option("nofail,nofail,fail", "nofail\0fail\0") == false);
-        assert_se(fstab_test_yes_no_option("abc,cde,afail", "nofail\0fail\0") == false);
-        assert_se(fstab_test_yes_no_option("nofail,fail=0,nofail=0", "nofail\0fail\0") == true);
-        assert_se(fstab_test_yes_no_option("nofail,nofail=0,fail=0", "nofail\0fail\0") == false);
-}
-
-int main(void) {
-        test_fstab_filter_options();
-        test_fstab_find_pri();
-        test_fstab_yes_no_option();
-}
diff --git a/src/test/test-fw-util.c b/src/test/test-fw-util.c
deleted file mode 100644 (file)
index ab891aa..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2015 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 "log.h"
-#include "fw-util.h"
-
-#define MAKE_IN_ADDR_UNION(a,b,c,d) (union in_addr_union) { .in.s_addr = htobe32((uint32_t) (a) << 24 | (uint32_t) (b) << 16 | (uint32_t) (c) << 8 | (uint32_t) (d))}
-
-int main(int argc, char *argv[]) {
-        int r;
-        log_set_max_level(LOG_DEBUG);
-
-        r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        r = fw_add_masquerade(false, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, &MAKE_IN_ADDR_UNION(1, 2, 3, 4));
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        r = fw_add_local_dnat(false, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, NULL);
-        if (r < 0)
-                log_error_errno(r, "Failed to modify firewall: %m");
-
-        return 0;
-}
diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c
deleted file mode 100644 (file)
index 84b508f..0000000
+++ /dev/null
@@ -1,869 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2013 Daniel Buch
-
-  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 "strv.h"
-#include "util.h"
-#include "hashmap.h"
-
-void test_hashmap_funcs(void);
-
-static void test_hashmap_replace(void) {
-        Hashmap *m;
-        char *val1, *val2, *val3, *val4, *val5, *r;
-
-        m = hashmap_new(&string_hash_ops);
-
-        val1 = strdup("val1");
-        assert_se(val1);
-        val2 = strdup("val2");
-        assert_se(val2);
-        val3 = strdup("val3");
-        assert_se(val3);
-        val4 = strdup("val4");
-        assert_se(val4);
-        val5 = strdup("val5");
-        assert_se(val5);
-
-        hashmap_put(m, "key 1", val1);
-        hashmap_put(m, "key 2", val2);
-        hashmap_put(m, "key 3", val3);
-        hashmap_put(m, "key 4", val4);
-
-        hashmap_replace(m, "key 3", val1);
-        r = hashmap_get(m, "key 3");
-        assert_se(streq(r, "val1"));
-
-        hashmap_replace(m, "key 5", val5);
-        r = hashmap_get(m, "key 5");
-        assert_se(streq(r, "val5"));
-
-        free(val1);
-        free(val2);
-        free(val3);
-        free(val4);
-        free(val5);
-        hashmap_free(m);
-}
-
-static void test_hashmap_copy(void) {
-        Hashmap *m, *copy;
-        char *val1, *val2, *val3, *val4, *r;
-
-        val1 = strdup("val1");
-        assert_se(val1);
-        val2 = strdup("val2");
-        assert_se(val2);
-        val3 = strdup("val3");
-        assert_se(val3);
-        val4 = strdup("val4");
-        assert_se(val4);
-
-        m = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, "key 1", val1);
-        hashmap_put(m, "key 2", val2);
-        hashmap_put(m, "key 3", val3);
-        hashmap_put(m, "key 4", val4);
-
-        copy = hashmap_copy(m);
-
-        r = hashmap_get(copy, "key 1");
-        assert_se(streq(r, "val1"));
-        r = hashmap_get(copy, "key 2");
-        assert_se(streq(r, "val2"));
-        r = hashmap_get(copy, "key 3");
-        assert_se(streq(r, "val3"));
-        r = hashmap_get(copy, "key 4");
-        assert_se(streq(r, "val4"));
-
-        hashmap_free_free(copy);
-        hashmap_free(m);
-}
-
-static void test_hashmap_get_strv(void) {
-        Hashmap *m;
-        char **strv;
-        char *val1, *val2, *val3, *val4;
-
-        val1 = strdup("val1");
-        assert_se(val1);
-        val2 = strdup("val2");
-        assert_se(val2);
-        val3 = strdup("val3");
-        assert_se(val3);
-        val4 = strdup("val4");
-        assert_se(val4);
-
-        m = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, "key 1", val1);
-        hashmap_put(m, "key 2", val2);
-        hashmap_put(m, "key 3", val3);
-        hashmap_put(m, "key 4", val4);
-
-        strv = hashmap_get_strv(m);
-
-#ifndef ORDERED
-        strv = strv_sort(strv);
-#endif
-
-        assert_se(streq(strv[0], "val1"));
-        assert_se(streq(strv[1], "val2"));
-        assert_se(streq(strv[2], "val3"));
-        assert_se(streq(strv[3], "val4"));
-
-        strv_free(strv);
-
-        hashmap_free(m);
-}
-
-static void test_hashmap_move_one(void) {
-        Hashmap *m, *n;
-        char *val1, *val2, *val3, *val4, *r;
-
-        val1 = strdup("val1");
-        assert_se(val1);
-        val2 = strdup("val2");
-        assert_se(val2);
-        val3 = strdup("val3");
-        assert_se(val3);
-        val4 = strdup("val4");
-        assert_se(val4);
-
-        m = hashmap_new(&string_hash_ops);
-        n = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, "key 1", val1);
-        hashmap_put(m, "key 2", val2);
-        hashmap_put(m, "key 3", val3);
-        hashmap_put(m, "key 4", val4);
-
-        assert_se(hashmap_move_one(n, NULL, "key 3") == -ENOENT);
-        assert_se(hashmap_move_one(n, m, "key 5") == -ENOENT);
-        assert_se(hashmap_move_one(n, m, "key 3") == 0);
-        assert_se(hashmap_move_one(n, m, "key 4") == 0);
-
-        r = hashmap_get(n, "key 3");
-        assert_se(r && streq(r, "val3"));
-        r = hashmap_get(n, "key 4");
-        assert_se(r && streq(r, "val4"));
-        r = hashmap_get(m, "key 3");
-        assert_se(!r);
-
-        assert_se(hashmap_move_one(n, m, "key 3") == -EEXIST);
-
-        hashmap_free_free(m);
-        hashmap_free_free(n);
-}
-
-static void test_hashmap_move(void) {
-        Hashmap *m, *n;
-        char *val1, *val2, *val3, *val4, *r;
-
-        val1 = strdup("val1");
-        assert_se(val1);
-        val2 = strdup("val2");
-        assert_se(val2);
-        val3 = strdup("val3");
-        assert_se(val3);
-        val4 = strdup("val4");
-        assert_se(val4);
-
-        m = hashmap_new(&string_hash_ops);
-        n = hashmap_new(&string_hash_ops);
-
-        hashmap_put(n, "key 1", strdup(val1));
-        hashmap_put(m, "key 1", val1);
-        hashmap_put(m, "key 2", val2);
-        hashmap_put(m, "key 3", val3);
-        hashmap_put(m, "key 4", val4);
-
-        assert_se(hashmap_move(n, NULL) == 0);
-        assert_se(hashmap_move(n, m) == 0);
-
-        assert_se(hashmap_size(m) == 1);
-        r = hashmap_get(m, "key 1");
-        assert_se(r && streq(r, "val1"));
-
-        r = hashmap_get(n, "key 1");
-        assert_se(r && streq(r, "val1"));
-        r = hashmap_get(n, "key 2");
-        assert_se(r && streq(r, "val2"));
-        r = hashmap_get(n, "key 3");
-        assert_se(r && streq(r, "val3"));
-        r = hashmap_get(n, "key 4");
-        assert_se(r && streq(r, "val4"));
-
-        hashmap_free_free(m);
-        hashmap_free_free(n);
-}
-
-static void test_hashmap_update(void) {
-        Hashmap *m;
-        char *val1, *val2, *r;
-
-        m = hashmap_new(&string_hash_ops);
-        val1 = strdup("old_value");
-        assert_se(val1);
-        val2 = strdup("new_value");
-        assert_se(val2);
-
-        hashmap_put(m, "key 1", val1);
-        r = hashmap_get(m, "key 1");
-        assert_se(streq(r, "old_value"));
-
-        assert_se(hashmap_update(m, "key 2", val2) == -ENOENT);
-        r = hashmap_get(m, "key 1");
-        assert_se(streq(r, "old_value"));
-
-        assert_se(hashmap_update(m, "key 1", val2) == 0);
-        r = hashmap_get(m, "key 1");
-        assert_se(streq(r, "new_value"));
-
-        free(val1);
-        free(val2);
-        hashmap_free(m);
-}
-
-static void test_hashmap_put(void) {
-        Hashmap *m = NULL;
-        int valid_hashmap_put;
-        void *val1 = (void*) "val 1";
-        void *val2 = (void*) "val 2";
-        _cleanup_free_ char* key1 = NULL;
-
-        assert_se(hashmap_ensure_allocated(&m, &string_hash_ops) >= 0);
-        assert_se(m);
-
-        valid_hashmap_put = hashmap_put(m, "key 1", val1);
-        assert_se(valid_hashmap_put == 1);
-        assert_se(hashmap_put(m, "key 1", val1) == 0);
-        assert_se(hashmap_put(m, "key 1", val2) == -EEXIST);
-        key1 = strdup("key 1");
-        assert_se(hashmap_put(m, key1, val1) == 0);
-        assert_se(hashmap_put(m, key1, val2) == -EEXIST);
-
-        hashmap_free(m);
-}
-
-static void test_hashmap_remove(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-        char *r;
-
-        r = hashmap_remove(NULL, "key 1");
-        assert_se(r == NULL);
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        r = hashmap_remove(m, "no such key");
-        assert_se(r == NULL);
-
-        hashmap_put(m, "key 1", (void*) "val 1");
-        hashmap_put(m, "key 2", (void*) "val 2");
-
-        r = hashmap_remove(m, "key 1");
-        assert_se(streq(r, "val 1"));
-
-        r = hashmap_get(m, "key 2");
-        assert_se(streq(r, "val 2"));
-        assert_se(!hashmap_get(m, "key 1"));
-}
-
-static void test_hashmap_remove2(void) {
-        _cleanup_hashmap_free_free_free_ Hashmap *m = NULL;
-        char key1[] = "key 1";
-        char key2[] = "key 2";
-        char val1[] = "val 1";
-        char val2[] = "val 2";
-        void *r, *r2;
-
-        r = hashmap_remove2(NULL, "key 1", &r2);
-        assert_se(r == NULL);
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        r = hashmap_remove2(m, "no such key", &r2);
-        assert_se(r == NULL);
-
-        hashmap_put(m, strdup(key1), strdup(val1));
-        hashmap_put(m, strdup(key2), strdup(val2));
-
-        r = hashmap_remove2(m, key1, &r2);
-        assert_se(streq(r, val1));
-        assert_se(streq(r2, key1));
-        free(r);
-        free(r2);
-
-        r = hashmap_get(m, key2);
-        assert_se(streq(r, val2));
-        assert_se(!hashmap_get(m, key1));
-}
-
-static void test_hashmap_remove_value(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-        char *r;
-
-        r = hashmap_remove_value(NULL, "key 1", (void*) "val 1");
-        assert_se(r == NULL);
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        r = hashmap_remove_value(m, "key 1", (void*) "val 1");
-        assert_se(r == NULL);
-
-        hashmap_put(m, "key 1", (void*) "val 1");
-        hashmap_put(m, "key 2", (void*) "val 2");
-
-        r = hashmap_remove_value(m, "key 1", (void*) "val 1");
-        assert_se(streq(r, "val 1"));
-
-        r = hashmap_get(m, "key 2");
-        assert_se(streq(r, "val 2"));
-        assert_se(!hashmap_get(m, "key 1"));
-
-        r = hashmap_remove_value(m, "key 2", (void*) "val 1");
-        assert_se(r == NULL);
-
-        r = hashmap_get(m, "key 2");
-        assert_se(streq(r, "val 2"));
-        assert_se(!hashmap_get(m, "key 1"));
-}
-
-static void test_hashmap_remove_and_put(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-        int valid;
-        char *r;
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        valid = hashmap_remove_and_put(m, "invalid key", "new key", NULL);
-        assert_se(valid == -ENOENT);
-
-        valid = hashmap_put(m, "key 1", (void*) (const char *) "val 1");
-        assert_se(valid == 1);
-
-        valid = hashmap_remove_and_put(NULL, "key 1", "key 2", (void*) (const char *) "val 2");
-        assert_se(valid == -ENOENT);
-
-        valid = hashmap_remove_and_put(m, "key 1", "key 2", (void*) (const char *) "val 2");
-        assert_se(valid == 0);
-
-        r = hashmap_get(m, "key 2");
-        assert_se(streq(r, "val 2"));
-        assert_se(!hashmap_get(m, "key 1"));
-
-        valid = hashmap_put(m, "key 3", (void*) (const char *) "val 3");
-        assert_se(valid == 1);
-        valid = hashmap_remove_and_put(m, "key 3", "key 2", (void*) (const char *) "val 2");
-        assert_se(valid == -EEXIST);
-}
-
-static void test_hashmap_remove_and_replace(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-        int valid;
-        void *key1 = UINT_TO_PTR(1);
-        void *key2 = UINT_TO_PTR(2);
-        void *key3 = UINT_TO_PTR(3);
-        void *r;
-        int i, j;
-
-        m = hashmap_new(&trivial_hash_ops);
-        assert_se(m);
-
-        valid = hashmap_remove_and_replace(m, key1, key2, NULL);
-        assert_se(valid == -ENOENT);
-
-        valid = hashmap_put(m, key1, key1);
-        assert_se(valid == 1);
-
-        valid = hashmap_remove_and_replace(NULL, key1, key2, key2);
-        assert_se(valid == -ENOENT);
-
-        valid = hashmap_remove_and_replace(m, key1, key2, key2);
-        assert_se(valid == 0);
-
-        r = hashmap_get(m, key2);
-        assert_se(r == key2);
-        assert_se(!hashmap_get(m, key1));
-
-        valid = hashmap_put(m, key3, key3);
-        assert_se(valid == 1);
-        valid = hashmap_remove_and_replace(m, key3, key2, key2);
-        assert_se(valid == 0);
-        r = hashmap_get(m, key2);
-        assert_se(r == key2);
-        assert_se(!hashmap_get(m, key3));
-
-        /* Repeat this test several times to increase the chance of hitting
-         * the less likely case in hashmap_remove_and_replace where it
-         * compensates for the backward shift. */
-        for (i = 0; i < 20; i++) {
-                hashmap_clear(m);
-
-                for (j = 1; j < 7; j++)
-                        hashmap_put(m, UINT_TO_PTR(10*i + j), UINT_TO_PTR(10*i + j));
-                valid = hashmap_remove_and_replace(m, UINT_TO_PTR(10*i + 1),
-                                                   UINT_TO_PTR(10*i + 2),
-                                                   UINT_TO_PTR(10*i + 2));
-                assert_se(valid == 0);
-                assert_se(!hashmap_get(m, UINT_TO_PTR(10*i + 1)));
-                for (j = 2; j < 7; j++) {
-                        r = hashmap_get(m, UINT_TO_PTR(10*i + j));
-                        assert_se(r == UINT_TO_PTR(10*i + j));
-                }
-        }
-}
-
-static void test_hashmap_ensure_allocated(void) {
-        Hashmap *m;
-        int valid_hashmap;
-
-        m = hashmap_new(&string_hash_ops);
-
-        valid_hashmap = hashmap_ensure_allocated(&m, &string_hash_ops);
-        assert_se(valid_hashmap == 0);
-
-        assert_se(m);
-        hashmap_free(m);
-}
-
-static void test_hashmap_foreach_key(void) {
-        Hashmap *m;
-        Iterator i;
-        bool key_found[] = { false, false, false, false };
-        const char *s;
-        const char *key;
-        static const char key_table[] =
-                "key 1\0"
-                "key 2\0"
-                "key 3\0"
-                "key 4\0";
-
-        m = hashmap_new(&string_hash_ops);
-
-        NULSTR_FOREACH(key, key_table)
-                hashmap_put(m, key, (void*) (const char*) "my dummy val");
-
-        HASHMAP_FOREACH_KEY(s, key, m, i) {
-                if (!key_found[0] && streq(key, "key 1"))
-                        key_found[0] = true;
-                else if (!key_found[1] && streq(key, "key 2"))
-                        key_found[1] = true;
-                else if (!key_found[2] && streq(key, "key 3"))
-                        key_found[2] = true;
-                else if (!key_found[3] && streq(key, "fail"))
-                        key_found[3] = true;
-        }
-
-        assert_se(m);
-        assert_se(key_found[0] && key_found[1] && key_found[2] && !key_found[3]);
-
-        hashmap_free(m);
-}
-
-static void test_hashmap_foreach(void) {
-        Hashmap *m;
-        Iterator i;
-        bool value_found[] = { false, false, false, false };
-        char *val1, *val2, *val3, *val4, *s;
-        unsigned count;
-
-        val1 = strdup("my val1");
-        assert_se(val1);
-        val2 = strdup("my val2");
-        assert_se(val2);
-        val3 = strdup("my val3");
-        assert_se(val3);
-        val4 = strdup("my val4");
-        assert_se(val4);
-
-        m = NULL;
-
-        count = 0;
-        HASHMAP_FOREACH(s, m, i)
-                count++;
-        assert_se(count == 0);
-
-        m = hashmap_new(&string_hash_ops);
-
-        count = 0;
-        HASHMAP_FOREACH(s, m, i)
-                count++;
-        assert_se(count == 0);
-
-        hashmap_put(m, "Key 1", val1);
-        hashmap_put(m, "Key 2", val2);
-        hashmap_put(m, "Key 3", val3);
-        hashmap_put(m, "Key 4", val4);
-
-        HASHMAP_FOREACH(s, m, i) {
-                if (!value_found[0] && streq(s, val1))
-                        value_found[0] = true;
-                else if (!value_found[1] && streq(s, val2))
-                        value_found[1] = true;
-                else if (!value_found[2] && streq(s, val3))
-                        value_found[2] = true;
-                else if (!value_found[3] && streq(s, val4))
-                        value_found[3] = true;
-        }
-
-        assert_se(m);
-        assert_se(value_found[0] && value_found[1] && value_found[2] && value_found[3]);
-
-        hashmap_free_free(m);
-}
-
-static void test_hashmap_merge(void) {
-        Hashmap *m;
-        Hashmap *n;
-        char *val1, *val2, *val3, *val4, *r;
-
-        val1 = strdup("my val1");
-        assert_se(val1);
-        val2 = strdup("my val2");
-        assert_se(val2);
-        val3 = strdup("my val3");
-        assert_se(val3);
-        val4 = strdup("my val4");
-        assert_se(val4);
-
-        n = hashmap_new(&string_hash_ops);
-        m = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, "Key 1", val1);
-        hashmap_put(m, "Key 2", val2);
-        hashmap_put(n, "Key 3", val3);
-        hashmap_put(n, "Key 4", val4);
-
-        assert_se(hashmap_merge(m, n) == 0);
-        r = hashmap_get(m, "Key 3");
-        assert_se(r && streq(r, "my val3"));
-        r = hashmap_get(m, "Key 4");
-        assert_se(r && streq(r, "my val4"));
-
-        assert_se(n);
-        assert_se(m);
-        hashmap_free(n);
-        hashmap_free_free(m);
-}
-
-static void test_hashmap_contains(void) {
-        Hashmap *m;
-        char *val1;
-
-        val1 = strdup("my val");
-        assert_se(val1);
-
-        m = hashmap_new(&string_hash_ops);
-
-        assert_se(!hashmap_contains(m, "Key 1"));
-        hashmap_put(m, "Key 1", val1);
-        assert_se(hashmap_contains(m, "Key 1"));
-        assert_se(!hashmap_contains(m, "Key 2"));
-
-        assert_se(!hashmap_contains(NULL, "Key 1"));
-
-        assert_se(m);
-        hashmap_free_free(m);
-}
-
-static void test_hashmap_isempty(void) {
-        Hashmap *m;
-        char *val1;
-
-        val1 = strdup("my val");
-        assert_se(val1);
-
-        m = hashmap_new(&string_hash_ops);
-
-        assert_se(hashmap_isempty(m));
-        hashmap_put(m, "Key 1", val1);
-        assert_se(!hashmap_isempty(m));
-
-        assert_se(m);
-        hashmap_free_free(m);
-}
-
-static void test_hashmap_size(void) {
-        Hashmap *m;
-        char *val1, *val2, *val3, *val4;
-
-        val1 = strdup("my val");
-        assert_se(val1);
-        val2 = strdup("my val");
-        assert_se(val2);
-        val3 = strdup("my val");
-        assert_se(val3);
-        val4 = strdup("my val");
-        assert_se(val4);
-
-        assert_se(hashmap_size(NULL) == 0);
-        assert_se(hashmap_buckets(NULL) == 0);
-
-        m = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, "Key 1", val1);
-        hashmap_put(m, "Key 2", val2);
-        hashmap_put(m, "Key 3", val3);
-        hashmap_put(m, "Key 4", val4);
-
-        assert_se(m);
-        assert_se(hashmap_size(m) == 4);
-        assert_se(hashmap_buckets(m) >= 4);
-        hashmap_free_free(m);
-}
-
-static void test_hashmap_get(void) {
-        Hashmap *m;
-        char *r;
-        char *val;
-
-        val = strdup("my val");
-        assert_se(val);
-
-        r = hashmap_get(NULL, "Key 1");
-        assert_se(r == NULL);
-
-        m = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, "Key 1", val);
-
-        r = hashmap_get(m, "Key 1");
-        assert_se(streq(r, val));
-
-        r = hashmap_get(m, "no such key");
-        assert_se(r == NULL);
-
-        assert_se(m);
-        hashmap_free_free(m);
-}
-
-static void test_hashmap_get2(void) {
-        Hashmap *m;
-        char *r;
-        char *val;
-        char key_orig[] = "Key 1";
-        void *key_copy;
-
-        val = strdup("my val");
-        assert_se(val);
-
-        key_copy = strdup(key_orig);
-        assert_se(key_copy);
-
-        r = hashmap_get2(NULL, key_orig, &key_copy);
-        assert_se(r == NULL);
-
-        m = hashmap_new(&string_hash_ops);
-
-        hashmap_put(m, key_copy, val);
-        key_copy = NULL;
-
-        r = hashmap_get2(m, key_orig, &key_copy);
-        assert_se(streq(r, val));
-        assert_se(key_orig != key_copy);
-        assert_se(streq(key_orig, key_orig));
-
-        r = hashmap_get2(m, "no such key", NULL);
-        assert_se(r == NULL);
-
-        assert_se(m);
-        hashmap_free_free_free(m);
-}
-
-static unsigned long crippled_hashmap_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
-        return trivial_hash_func(p, hash_key) & 0xff;
-}
-
-static const struct hash_ops crippled_hashmap_ops = {
-        .hash = crippled_hashmap_func,
-        .compare = trivial_compare_func,
-};
-
-static void test_hashmap_many(void) {
-        Hashmap *h;
-        unsigned i, j;
-        void *v, *k;
-        static const struct {
-                const struct hash_ops *ops;
-                unsigned n_entries;
-        } tests[] = {
-                { .ops = NULL,                  .n_entries = 1 << 20 },
-                { .ops = &crippled_hashmap_ops, .n_entries = 1 << 11 },
-        };
-
-
-        for (j = 0; j < ELEMENTSOF(tests); j++) {
-                assert_se(h = hashmap_new(tests[j].ops));
-
-                for (i = 1; i < tests[j].n_entries*3; i+=3) {
-                        assert_se(hashmap_put(h, UINT_TO_PTR(i), UINT_TO_PTR(i)) >= 0);
-                        assert_se(PTR_TO_UINT(hashmap_get(h, UINT_TO_PTR(i))) == i);
-                }
-
-                for (i = 1; i < tests[j].n_entries*3; i++)
-                        assert_se(hashmap_contains(h, UINT_TO_PTR(i)) == (i % 3 == 1));
-
-                log_info("%u <= %u * 0.8 = %g", hashmap_size(h), hashmap_buckets(h), hashmap_buckets(h) * 0.8);
-
-                assert_se(hashmap_size(h) <= hashmap_buckets(h) * 0.8);
-                assert_se(hashmap_size(h) == tests[j].n_entries);
-
-                while (!hashmap_isempty(h)) {
-                        k = hashmap_first_key(h);
-                        v = hashmap_remove(h, k);
-                        assert_se(v == k);
-                }
-
-                hashmap_free(h);
-        }
-}
-
-static void test_hashmap_first(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        assert_se(!hashmap_first(m));
-        assert_se(hashmap_put(m, "key 1", (void*) "val 1") == 1);
-        assert_se(streq(hashmap_first(m), "val 1"));
-        assert_se(hashmap_put(m, "key 2", (void*) "val 2") == 1);
-#ifdef ORDERED
-        assert_se(streq(hashmap_first(m), "val 1"));
-        assert_se(hashmap_remove(m, "key 1"));
-        assert_se(streq(hashmap_first(m), "val 2"));
-#endif
-}
-
-static void test_hashmap_first_key(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        assert_se(!hashmap_first_key(m));
-        assert_se(hashmap_put(m, "key 1", NULL) == 1);
-        assert_se(streq(hashmap_first_key(m), "key 1"));
-        assert_se(hashmap_put(m, "key 2", NULL) == 1);
-#ifdef ORDERED
-        assert_se(streq(hashmap_first_key(m), "key 1"));
-        assert_se(hashmap_remove(m, "key 1") == NULL);
-        assert_se(streq(hashmap_first_key(m), "key 2"));
-#endif
-}
-
-static void test_hashmap_steal_first_key(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        assert_se(!hashmap_steal_first_key(m));
-        assert_se(hashmap_put(m, "key 1", NULL) == 1);
-        assert_se(streq(hashmap_steal_first_key(m), "key 1"));
-
-        assert_se(hashmap_isempty(m));
-}
-
-static void test_hashmap_steal_first(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-        int seen[3] = {};
-        char *val;
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        assert_se(hashmap_put(m, "key 1", (void*) "1") == 1);
-        assert_se(hashmap_put(m, "key 2", (void*) "22") == 1);
-        assert_se(hashmap_put(m, "key 3", (void*) "333") == 1);
-
-        while ((val = hashmap_steal_first(m)))
-                seen[strlen(val) - 1]++;
-
-        assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
-
-        assert_se(hashmap_isempty(m));
-}
-
-static void test_hashmap_clear_free_free(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-
-        m = hashmap_new(&string_hash_ops);
-        assert_se(m);
-
-        assert_se(hashmap_put(m, strdup("key 1"), NULL) == 1);
-        assert_se(hashmap_put(m, strdup("key 2"), NULL) == 1);
-        assert_se(hashmap_put(m, strdup("key 3"), NULL) == 1);
-
-        hashmap_clear_free_free(m);
-        assert_se(hashmap_isempty(m));
-}
-
-static void test_hashmap_reserve(void) {
-        _cleanup_hashmap_free_ Hashmap *m = NULL;
-
-        m = hashmap_new(&string_hash_ops);
-
-        assert_se(hashmap_reserve(m, 1) == 0);
-        assert_se(hashmap_buckets(m) < 1000);
-        assert_se(hashmap_reserve(m, 1000) == 0);
-        assert_se(hashmap_buckets(m) >= 1000);
-        assert_se(hashmap_isempty(m));
-
-        assert_se(hashmap_put(m, "key 1", (void*) "val 1") == 1);
-
-        assert_se(hashmap_reserve(m, UINT_MAX) == -ENOMEM);
-        assert_se(hashmap_reserve(m, UINT_MAX - 1) == -ENOMEM);
-}
-
-void test_hashmap_funcs(void) {
-        test_hashmap_copy();
-        test_hashmap_get_strv();
-        test_hashmap_move_one();
-        test_hashmap_move();
-        test_hashmap_replace();
-        test_hashmap_update();
-        test_hashmap_put();
-        test_hashmap_remove();
-        test_hashmap_remove2();
-        test_hashmap_remove_value();
-        test_hashmap_remove_and_put();
-        test_hashmap_remove_and_replace();
-        test_hashmap_ensure_allocated();
-        test_hashmap_foreach();
-        test_hashmap_foreach_key();
-        test_hashmap_contains();
-        test_hashmap_merge();
-        test_hashmap_isempty();
-        test_hashmap_get();
-        test_hashmap_get2();
-        test_hashmap_size();
-        test_hashmap_many();
-        test_hashmap_first();
-        test_hashmap_first_key();
-        test_hashmap_steal_first_key();
-        test_hashmap_steal_first();
-        test_hashmap_clear_free_free();
-        test_hashmap_reserve();
-}
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
deleted file mode 100644 (file)
index 767cbd9..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2013 Daniel Buch
-
-  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 "util.h"
-#include "hashmap.h"
-
-void test_hashmap_funcs(void);
-void test_ordered_hashmap_funcs(void);
-
-static void test_ordered_hashmap_next(void) {
-        OrderedHashmap *m;
-        char *val1, *val2, *val3, *val4, *r;
-
-        m = ordered_hashmap_new(&string_hash_ops);
-        val1 = strdup("val1");
-        assert_se(val1);
-        val2 = strdup("val2");
-        assert_se(val2);
-        val3 = strdup("val3");
-        assert_se(val3);
-        val4 = strdup("val4");
-        assert_se(val4);
-
-        ordered_hashmap_put(m, "key 1", val1);
-        ordered_hashmap_put(m, "key 2", val2);
-        ordered_hashmap_put(m, "key 3", val3);
-        ordered_hashmap_put(m, "key 4", val4);
-
-        r = ordered_hashmap_next(m, "key 1");
-        assert_se(streq(r, val2));
-        r = ordered_hashmap_next(m, "key 2");
-        assert_se(streq(r, val3));
-        r = ordered_hashmap_next(m, "key 3");
-        assert_se(streq(r, val4));
-        r = ordered_hashmap_next(m, "key 4");
-        assert_se(!r);
-        r = ordered_hashmap_next(NULL, "key 1");
-        assert_se(!r);
-        r = ordered_hashmap_next(m, "key 5");
-        assert_se(!r);
-
-        ordered_hashmap_free_free(m);
-}
-
-static void test_uint64_compare_func(void) {
-        const uint64_t a = 0x100, b = 0x101;
-
-        assert_se(uint64_compare_func(&a, &a) == 0);
-        assert_se(uint64_compare_func(&a, &b) == -1);
-        assert_se(uint64_compare_func(&b, &a) == 1);
-}
-
-static void test_trivial_compare_func(void) {
-        assert_se(trivial_compare_func(INT_TO_PTR('a'), INT_TO_PTR('a')) == 0);
-        assert_se(trivial_compare_func(INT_TO_PTR('a'), INT_TO_PTR('b')) == -1);
-        assert_se(trivial_compare_func(INT_TO_PTR('b'), INT_TO_PTR('a')) == 1);
-}
-
-static void test_string_compare_func(void) {
-        assert_se(string_compare_func("fred", "wilma") != 0);
-        assert_se(string_compare_func("fred", "fred") == 0);
-}
-
-int main(int argc, const char *argv[]) {
-        test_hashmap_funcs();
-        test_ordered_hashmap_funcs();
-
-        test_ordered_hashmap_next();
-        test_uint64_compare_func();
-        test_trivial_compare_func();
-        test_string_compare_func();
-}
diff --git a/src/test/test-helper.h b/src/test/test-helper.h
deleted file mode 100644 (file)
index f75dd33..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Holger Hans Peter Freyther
-
-  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 "sd-daemon.h"
-
-#define TEST_REQ_RUNNING_SYSTEMD(x)                                 \
-        if (sd_booted() > 0) {                                      \
-                x;                                                  \
-        } else {                                                    \
-                printf("systemd not booted skipping '%s'\n", #x);   \
-        }
diff --git a/src/test/test-hostname.c b/src/test/test-hostname.c
deleted file mode 100644 (file)
index c7e5de8..0000000
+++ /dev/null
@@ -1,34 +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 "hostname-setup.h"
-#include "util.h"
-
-int main(int argc, char* argv[]) {
-        int r;
-
-        r = hostname_setup();
-        if (r < 0)
-                log_error_errno(r, "hostname: %m");
-
-        return 0;
-}
diff --git a/src/test/test-id128.c b/src/test/test-id128.c
deleted file mode 100644 (file)
index a6a0cd7..0000000
+++ /dev/null
@@ -1,78 +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"
-#include "sd-daemon.h"
-
-#define ID128_WALDI SD_ID128_MAKE(01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0c, 0d, 0e, 0f, 10)
-#define STR_WALDI "0102030405060708090a0b0c0d0e0f10"
-#define UUID_WALDI "01020304-0506-0708-090a-0b0c0d0e0f10"
-
-int main(int argc, char *argv[]) {
-        sd_id128_t id, id2;
-        char t[33];
-        _cleanup_free_ char *b = NULL;
-
-        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));
-
-        if (sd_booted() > 0) {
-                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));
-        assert_se(streq(t, STR_WALDI));
-
-        assert_se(asprintf(&b, SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(ID128_WALDI)) == 32);
-        printf("waldi2: %s\n", b);
-        assert_se(streq(t, b));
-
-        assert_se(sd_id128_from_string(UUID_WALDI, &id) >= 0);
-        assert_se(sd_id128_equal(id, ID128_WALDI));
-
-        assert_se(sd_id128_from_string("", &id) < 0);
-        assert_se(sd_id128_from_string("01020304-0506-0708-090a-0b0c0d0e0f101", &id) < 0);
-        assert_se(sd_id128_from_string("01020304-0506-0708-090a-0b0c0d0e0f10-", &id) < 0);
-        assert_se(sd_id128_from_string("01020304-0506-0708-090a0b0c0d0e0f10", &id) < 0);
-        assert_se(sd_id128_from_string("010203040506-0708-090a-0b0c0d0e0f10", &id) < 0);
-
-        assert_se(id128_is_valid(STR_WALDI));
-        assert_se(id128_is_valid(UUID_WALDI));
-        assert_se(!id128_is_valid(""));
-        assert_se(!id128_is_valid("01020304-0506-0708-090a-0b0c0d0e0f101"));
-        assert_se(!id128_is_valid("01020304-0506-0708-090a-0b0c0d0e0f10-"));
-        assert_se(!id128_is_valid("01020304-0506-0708-090a0b0c0d0e0f10"));
-        assert_se(!id128_is_valid("010203040506-0708-090a-0b0c0d0e0f10"));
-
-        return 0;
-}
diff --git a/src/test/test-install.c b/src/test/test-install.c
deleted file mode 100644 (file)
index 5ee52e6..0000000
+++ /dev/null
@@ -1,261 +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 <stdio.h>
-
-#include "install.h"
-
-static void dump_changes(UnitFileChange *c, unsigned n) {
-        unsigned i;
-
-        assert_se(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_ops);
-        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, basename(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, basename(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, basename(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, basename(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, basename(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, basename(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, basename(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, basename(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, UNIT_FILE_PRESET_FULL, 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, basename(files[0])) == UNIT_FILE_ENABLED);
-
-        return 0;
-}
diff --git a/src/test/test-ipcrm.c b/src/test/test-ipcrm.c
deleted file mode 100644 (file)
index 4944bf6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 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 "util.h"
-#include "clean-ipc.h"
-
-int main(int argc, char *argv[]) {
-        uid_t uid;
-
-        assert_se(argc == 2);
-        assert_se(parse_uid(argv[1], &uid) >= 0);
-
-        return clean_ipc(uid) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-}
diff --git a/src/test/test-job-type.c b/src/test/test-job-type.c
deleted file mode 100644 (file)
index af0d76e..0000000
+++ /dev/null
@@ -1,102 +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 "job.h"
-#include "unit.h"
-#include "service.h"
-
-int main(int argc, char*argv[]) {
-        JobType a, b, c, ab, bc, ab_c, bc_a, a_bc;
-        const ServiceState test_states[] = { SERVICE_DEAD, SERVICE_RUNNING };
-        unsigned i;
-        bool merged_ab;
-
-        /* fake a unit */
-        static Service s = {
-                .meta.load_state = UNIT_LOADED,
-                .type = SERVICE_SIMPLE,
-        };
-        Unit *u = UNIT(&s);
-
-        for (i = 0; i < ELEMENTSOF(test_states); i++) {
-                s.state = test_states[i];
-                printf("\nWith collapsing for service state %s\n"
-                       "=========================================\n", service_state_to_string(s.state));
-                for (a = 0; a < _JOB_TYPE_MAX_MERGING; a++) {
-                        for (b = 0; b < _JOB_TYPE_MAX_MERGING; b++) {
-
-                                ab = a;
-                                merged_ab = (job_type_merge_and_collapse(&ab, b, u) >= 0);
-
-                                if (!job_type_is_mergeable(a, b)) {
-                                        assert_se(!merged_ab);
-                                        printf("Not mergeable: %s + %s\n", job_type_to_string(a), job_type_to_string(b));
-                                        continue;
-                                }
-
-                                assert_se(merged_ab);
-                                printf("%s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(ab));
-
-                                for (c = 0; c < _JOB_TYPE_MAX_MERGING; c++) {
-
-                                        /* Verify transitivity of mergeability of job types */
-                                        assert_se(!job_type_is_mergeable(a, b) ||
-                                               !job_type_is_mergeable(b, c) ||
-                                               job_type_is_mergeable(a, c));
-
-                                        /* Verify that merged entries can be merged with the same entries
-                                         * they can be merged with separately */
-                                        assert_se(!job_type_is_mergeable(a, c) || job_type_is_mergeable(ab, c));
-                                        assert_se(!job_type_is_mergeable(b, c) || job_type_is_mergeable(ab, 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_se(job_type_is_mergeable(ab, c) || !job_type_is_mergeable(a, c) || !job_type_is_mergeable(b, c));
-
-                                        bc = b;
-                                        if (job_type_merge_and_collapse(&bc, c, u) >= 0) {
-
-                                                /* Verify associativity */
-
-                                                ab_c = ab;
-                                                assert_se(job_type_merge_and_collapse(&ab_c, c, u) == 0);
-
-                                                bc_a = bc;
-                                                assert_se(job_type_merge_and_collapse(&bc_a, a, u) == 0);
-
-                                                a_bc = a;
-                                                assert_se(job_type_merge_and_collapse(&a_bc, bc, u) == 0);
-
-                                                assert_se(ab_c == bc_a);
-                                                assert_se(ab_c == a_bc);
-
-                                                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(ab_c));
-                                        }
-                                }
-                        }
-                }
-        }
-
-
-        return 0;
-}
diff --git a/src/test/test-json.c b/src/test/test-json.c
deleted file mode 100644 (file)
index 24dc700..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 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 <math.h>
-
-#include "util.h"
-#include "json.h"
-
-static void test_one(const char *data, ...) {
-        void *state = NULL;
-        va_list ap;
-
-        va_start(ap, data);
-
-        for (;;) {
-                _cleanup_free_ char *str = NULL;
-                union json_value v = {};
-                int t, tt;
-
-                t = json_tokenize(&data, &str, &v, &state, NULL);
-                tt = va_arg(ap, int);
-
-                assert_se(t == tt);
-
-                if (t == JSON_END || t < 0)
-                        break;
-
-                else if (t == JSON_STRING) {
-                        const char *nn;
-
-                        nn = va_arg(ap, const char *);
-                        assert_se(streq_ptr(nn, str));
-
-                } else if (t == JSON_REAL) {
-                        double d;
-
-                        d = va_arg(ap, double);
-                        assert_se(fabs(d - v.real) < 0.001);
-
-                } else if (t == JSON_INTEGER) {
-                        intmax_t i;
-
-                        i = va_arg(ap, intmax_t);
-                        assert_se(i == v.integer);
-
-                } else if (t == JSON_BOOLEAN) {
-                        bool b;
-
-                        b = va_arg(ap, int);
-                        assert_se(b == v.boolean);
-                }
-        }
-
-        va_end(ap);
-}
-
-int main(int argc, char *argv[]) {
-
-        test_one("x", -EINVAL);
-        test_one("", JSON_END);
-        test_one(" ", JSON_END);
-        test_one("0", JSON_INTEGER, (intmax_t) 0, JSON_END);
-        test_one("1234", JSON_INTEGER, (intmax_t) 1234, JSON_END);
-        test_one("3.141", JSON_REAL, 3.141, JSON_END);
-        test_one("0.0", JSON_REAL, 0.0, JSON_END);
-        test_one("7e3", JSON_REAL, 7e3, JSON_END);
-        test_one("-7e-3", JSON_REAL, -7e-3, JSON_END);
-        test_one("true", JSON_BOOLEAN, true, JSON_END);
-        test_one("false", JSON_BOOLEAN, false, JSON_END);
-        test_one("null", JSON_NULL, JSON_END);
-        test_one("{}", JSON_OBJECT_OPEN, JSON_OBJECT_CLOSE, JSON_END);
-        test_one("\t {\n} \n", JSON_OBJECT_OPEN, JSON_OBJECT_CLOSE, JSON_END);
-        test_one("[]", JSON_ARRAY_OPEN, JSON_ARRAY_CLOSE, JSON_END);
-        test_one("\t [] \n\n", JSON_ARRAY_OPEN, JSON_ARRAY_CLOSE, JSON_END);
-        test_one("\"\"", JSON_STRING, "", JSON_END);
-        test_one("\"foo\"", JSON_STRING, "foo", JSON_END);
-        test_one("\"foo\\nfoo\"", JSON_STRING, "foo\nfoo", JSON_END);
-        test_one("{\"foo\" : \"bar\"}", JSON_OBJECT_OPEN, JSON_STRING, "foo", JSON_COLON, JSON_STRING, "bar", JSON_OBJECT_CLOSE, JSON_END);
-        test_one("{\"foo\" : [true, false]}", JSON_OBJECT_OPEN, JSON_STRING, "foo", JSON_COLON, JSON_ARRAY_OPEN, JSON_BOOLEAN, true, JSON_COMMA, JSON_BOOLEAN, false, JSON_ARRAY_CLOSE, JSON_OBJECT_CLOSE, JSON_END);
-        test_one("\"\xef\xbf\xbd\"", JSON_STRING, "\xef\xbf\xbd", JSON_END);
-        test_one("\"\\ufffd\"", JSON_STRING, "\xef\xbf\xbd", JSON_END);
-        test_one("\"\\uf\"", -EINVAL);
-        test_one("\"\\ud800a\"", -EINVAL);
-        test_one("\"\\udc00\\udc00\"", -EINVAL);
-        test_one("\"\\ud801\\udc37\"", JSON_STRING, "\xf0\x90\x90\xb7", JSON_END);
-
-        return 0;
-}
diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c
deleted file mode 100644 (file)
index 2b004fd..0000000
+++ /dev/null
@@ -1,475 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-/***
-  This file is part of systemd.
-
-  Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
-
-  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 <unistd.h>
-#include <getopt.h>
-#include <sys/epoll.h>
-
-#include "libudev.h"
-#include "udev-util.h"
-#include "util.h"
-
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
-static void print_device(struct udev_device *device) {
-        const char *str;
-        dev_t devnum;
-        int count;
-        struct udev_list_entry *list_entry;
-
-        printf("*** device: %p ***\n", device);
-        str = udev_device_get_action(device);
-        if (str != NULL)
-                printf("action:    '%s'\n", str);
-
-        str = udev_device_get_syspath(device);
-        printf("syspath:   '%s'\n", str);
-
-        str = udev_device_get_sysname(device);
-        printf("sysname:   '%s'\n", str);
-
-        str = udev_device_get_sysnum(device);
-        if (str != NULL)
-                printf("sysnum:    '%s'\n", str);
-
-        str = udev_device_get_devpath(device);
-        printf("devpath:   '%s'\n", str);
-
-        str = udev_device_get_subsystem(device);
-        if (str != NULL)
-                printf("subsystem: '%s'\n", str);
-
-        str = udev_device_get_devtype(device);
-        if (str != NULL)
-                printf("devtype:   '%s'\n", str);
-
-        str = udev_device_get_driver(device);
-        if (str != NULL)
-                printf("driver:    '%s'\n", str);
-
-        str = udev_device_get_devnode(device);
-        if (str != NULL)
-                printf("devname:   '%s'\n", str);
-
-        devnum = udev_device_get_devnum(device);
-        if (major(devnum) > 0)
-                printf("devnum:    %u:%u\n", major(devnum), minor(devnum));
-
-        count = 0;
-        udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
-                printf("link:      '%s'\n", udev_list_entry_get_name(list_entry));
-                count++;
-        }
-        if (count > 0)
-                printf("found %i links\n", count);
-
-        count = 0;
-        udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(device)) {
-                printf("property:  '%s=%s'\n",
-                       udev_list_entry_get_name(list_entry),
-                       udev_list_entry_get_value(list_entry));
-                count++;
-        }
-        if (count > 0)
-                printf("found %i properties\n", count);
-
-        str = udev_device_get_property_value(device, "MAJOR");
-        if (str != NULL)
-                printf("MAJOR: '%s'\n", str);
-
-        str = udev_device_get_sysattr_value(device, "dev");
-        if (str != NULL)
-                printf("attr{dev}: '%s'\n", str);
-
-        printf("\n");
-}
-
-static int test_device(struct udev *udev, const char *syspath) {
-        _cleanup_udev_device_unref_ struct udev_device *device;
-
-        printf("looking at device: %s\n", syspath);
-        device = udev_device_new_from_syspath(udev, syspath);
-        if (device == NULL) {
-                printf("no device found\n");
-                return -1;
-        }
-        print_device(device);
-
-        return 0;
-}
-
-static int test_device_parents(struct udev *udev, const char *syspath) {
-        _cleanup_udev_device_unref_ struct udev_device *device;
-        struct udev_device *device_parent;
-
-        printf("looking at device: %s\n", syspath);
-        device = udev_device_new_from_syspath(udev, syspath);
-        if (device == NULL)
-                return -1;
-
-        printf("looking at parents\n");
-        device_parent = device;
-        do {
-                print_device(device_parent);
-                device_parent = udev_device_get_parent(device_parent);
-        } while (device_parent != NULL);
-
-        printf("looking at parents again\n");
-        device_parent = device;
-        do {
-                print_device(device_parent);
-                device_parent = udev_device_get_parent(device_parent);
-        } while (device_parent != NULL);
-
-        return 0;
-}
-
-static int test_device_devnum(struct udev *udev) {
-        dev_t devnum = makedev(1, 3);
-        struct udev_device *device;
-
-        printf("looking up device: %u:%u\n", major(devnum), minor(devnum));
-        device = udev_device_new_from_devnum(udev, 'c', devnum);
-        if (device == NULL)
-                return -1;
-        print_device(device);
-        udev_device_unref(device);
-        return 0;
-}
-
-static int test_device_subsys_name(struct udev *udev) {
-        struct udev_device *device;
-
-        printf("looking up device: 'block':'sda'\n");
-        device = udev_device_new_from_subsystem_sysname(udev, "block", "sda");
-        if (device == NULL)
-                return -1;
-        print_device(device);
-        udev_device_unref(device);
-
-        printf("looking up device: 'subsystem':'pci'\n");
-        device = udev_device_new_from_subsystem_sysname(udev, "subsystem", "pci");
-        if (device == NULL)
-                return -1;
-        print_device(device);
-        udev_device_unref(device);
-
-        printf("looking up device: 'drivers':'scsi:sd'\n");
-        device = udev_device_new_from_subsystem_sysname(udev, "drivers", "scsi:sd");
-        if (device == NULL)
-                return -1;
-        print_device(device);
-        udev_device_unref(device);
-
-        printf("looking up device: 'module':'printk'\n");
-        device = udev_device_new_from_subsystem_sysname(udev, "module", "printk");
-        if (device == NULL)
-                return -1;
-        print_device(device);
-        udev_device_unref(device);
-        return 0;
-}
-
-static int test_enumerate_print_list(struct udev_enumerate *enumerate) {
-        struct udev_list_entry *list_entry;
-        int count = 0;
-
-        udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(enumerate)) {
-                struct udev_device *device;
-
-                device = udev_device_new_from_syspath(udev_enumerate_get_udev(enumerate),
-                                                      udev_list_entry_get_name(list_entry));
-                if (device != NULL) {
-                        printf("device: '%s' (%s)\n",
-                               udev_device_get_syspath(device),
-                               udev_device_get_subsystem(device));
-                        udev_device_unref(device);
-                        count++;
-                }
-        }
-        printf("found %i devices\n\n", count);
-        return count;
-}
-
-static int test_monitor(struct udev *udev) {
-        struct udev_monitor *udev_monitor = NULL;
-        int fd_ep;
-        int fd_udev = -1;
-        struct epoll_event ep_udev, ep_stdin;
-
-        fd_ep = epoll_create1(EPOLL_CLOEXEC);
-        if (fd_ep < 0) {
-                printf("error creating epoll fd: %m\n");
-                goto out;
-        }
-
-        udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
-        if (udev_monitor == NULL) {
-                printf("no socket\n");
-                goto out;
-        }
-        fd_udev = udev_monitor_get_fd(udev_monitor);
-
-        if (udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "block", NULL) < 0 ||
-            udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL) < 0 ||
-            udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "usb", "usb_device") < 0) {
-                printf("filter failed\n");
-                goto out;
-        }
-
-        if (udev_monitor_enable_receiving(udev_monitor) < 0) {
-                printf("bind failed\n");
-                goto out;
-        }
-
-        memzero(&ep_udev, sizeof(struct epoll_event));
-        ep_udev.events = EPOLLIN;
-        ep_udev.data.fd = fd_udev;
-        if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) {
-                printf("fail to add fd to epoll: %m\n");
-                goto out;
-        }
-
-        memzero(&ep_stdin, sizeof(struct epoll_event));
-        ep_stdin.events = EPOLLIN;
-        ep_stdin.data.fd = STDIN_FILENO;
-        if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, STDIN_FILENO, &ep_stdin) < 0) {
-                printf("fail to add fd to epoll: %m\n");
-                goto out;
-        }
-
-        for (;;) {
-                int fdcount;
-                struct epoll_event ev[4];
-                struct udev_device *device;
-                int i;
-
-                printf("waiting for events from udev, press ENTER to exit\n");
-                fdcount = epoll_wait(fd_ep, ev, ARRAY_SIZE(ev), -1);
-                printf("epoll fd count: %i\n", fdcount);
-
-                for (i = 0; i < fdcount; i++) {
-                        if (ev[i].data.fd == fd_udev && ev[i].events & EPOLLIN) {
-                                device = udev_monitor_receive_device(udev_monitor);
-                                if (device == NULL) {
-                                        printf("no device from socket\n");
-                                        continue;
-                                }
-                                print_device(device);
-                                udev_device_unref(device);
-                        } else if (ev[i].data.fd == STDIN_FILENO && ev[i].events & EPOLLIN) {
-                                printf("exiting loop\n");
-                                goto out;
-                        }
-                }
-        }
-out:
-        if (fd_ep >= 0)
-                close(fd_ep);
-        udev_monitor_unref(udev_monitor);
-        return 0;
-}
-
-static int test_queue(struct udev *udev) {
-        struct udev_queue *udev_queue;
-
-        udev_queue = udev_queue_new(udev);
-        if (udev_queue == NULL)
-                return -1;
-
-        if (udev_queue_get_queue_is_empty(udev_queue))
-                printf("queue is empty\n");
-
-        udev_queue_unref(udev_queue);
-        return 0;
-}
-
-static int test_enumerate(struct udev *udev, const char *subsystem) {
-        struct udev_enumerate *udev_enumerate;
-
-        printf("enumerate '%s'\n", subsystem == NULL ? "<all>" : subsystem);
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_add_match_subsystem(udev_enumerate, subsystem);
-        udev_enumerate_scan_devices(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-
-        printf("enumerate 'net' + duplicated scan + null + zero\n");
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_add_match_subsystem(udev_enumerate, "net");
-        udev_enumerate_scan_devices(udev_enumerate);
-        udev_enumerate_scan_devices(udev_enumerate);
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
-        udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
-        udev_enumerate_scan_devices(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-
-        printf("enumerate 'block'\n");
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_add_match_subsystem(udev_enumerate,"block");
-        udev_enumerate_add_match_is_initialized(udev_enumerate);
-        udev_enumerate_scan_devices(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-
-        printf("enumerate 'not block'\n");
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_add_nomatch_subsystem(udev_enumerate, "block");
-        udev_enumerate_scan_devices(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-
-        printf("enumerate 'pci, mem, vc'\n");
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_add_match_subsystem(udev_enumerate, "pci");
-        udev_enumerate_add_match_subsystem(udev_enumerate, "mem");
-        udev_enumerate_add_match_subsystem(udev_enumerate, "vc");
-        udev_enumerate_scan_devices(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-
-        printf("enumerate 'subsystem'\n");
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_scan_subsystems(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-
-        printf("enumerate 'property IF_FS_*=filesystem'\n");
-        udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL)
-                return -1;
-        udev_enumerate_add_match_property(udev_enumerate, "ID_FS*", "filesystem");
-        udev_enumerate_scan_devices(udev_enumerate);
-        test_enumerate_print_list(udev_enumerate);
-        udev_enumerate_unref(udev_enumerate);
-        return 0;
-}
-
-static void test_hwdb(struct udev *udev, const char *modalias) {
-        struct udev_hwdb *hwdb;
-        struct udev_list_entry *entry;
-
-        hwdb = udev_hwdb_new(udev);
-
-        udev_list_entry_foreach(entry, udev_hwdb_get_properties_list_entry(hwdb, modalias, 0))
-                printf("'%s'='%s'\n", udev_list_entry_get_name(entry), udev_list_entry_get_value(entry));
-        printf("\n");
-
-        hwdb = udev_hwdb_unref(hwdb);
-        assert_se(hwdb == NULL);
-}
-
-int main(int argc, char *argv[]) {
-        struct udev *udev = NULL;
-        static const struct option options[] = {
-                { "syspath", required_argument, NULL, 'p' },
-                { "subsystem", required_argument, NULL, 's' },
-                { "debug", no_argument, NULL, 'd' },
-                { "help", no_argument, NULL, 'h' },
-                { "version", no_argument, NULL, 'V' },
-                {}
-        };
-        const char *syspath = "/devices/virtual/mem/null";
-        const char *subsystem = NULL;
-        char path[1024];
-        int c;
-
-        udev = udev_new();
-        printf("context: %p\n", udev);
-        if (udev == NULL) {
-                printf("no context\n");
-                return 1;
-        }
-
-        while ((c = getopt_long(argc, argv, "p:s:dhV", options, NULL)) >= 0)
-                switch (c) {
-
-                case 'p':
-                        syspath = optarg;
-                        break;
-
-                case 's':
-                        subsystem = optarg;
-                        break;
-
-                case 'd':
-                        if (log_get_max_level() < LOG_INFO)
-                                log_set_max_level(LOG_INFO);
-                        break;
-
-                case 'h':
-                        printf("--debug --syspath= --subsystem= --help\n");
-                        goto out;
-
-                case 'V':
-                        printf("%s\n", VERSION);
-                        goto out;
-
-                case '?':
-                        goto out;
-
-                default:
-                        assert_not_reached("Unhandled option code.");
-                }
-
-
-        /* add sys path if needed */
-        if (!startswith(syspath, "/sys")) {
-                snprintf(path, sizeof(path), "/sys/%s", syspath);
-                syspath = path;
-        }
-
-        test_device(udev, syspath);
-        test_device_devnum(udev);
-        test_device_subsys_name(udev);
-        test_device_parents(udev, syspath);
-
-        test_enumerate(udev, subsystem);
-
-        test_queue(udev);
-
-        test_hwdb(udev, "usb:v0D50p0011*");
-
-        test_monitor(udev);
-out:
-        udev_unref(udev);
-        return 0;
-}
diff --git a/src/test/test-list.c b/src/test/test-list.c
deleted file mode 100644 (file)
index f6da1a7..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2013 Jan Janssen
-
-  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 "list.h"
-#include "util.h"
-
-int main(int argc, const char *argv[]) {
-        size_t i;
-        typedef struct list_item {
-                LIST_FIELDS(struct list_item, item);
-        } list_item;
-        LIST_HEAD(list_item, head);
-        list_item items[4];
-        list_item *cursor;
-
-        LIST_HEAD_INIT(head);
-        assert_se(head == NULL);
-
-        for (i = 0; i < ELEMENTSOF(items); i++) {
-                LIST_INIT(item, &items[i]);
-                assert_se(LIST_JUST_US(item, &items[i]));
-                LIST_PREPEND(item, head, &items[i]);
-        }
-
-        i = 0;
-        LIST_FOREACH_OTHERS(item, cursor, &items[2]) {
-                i++;
-                assert_se(cursor != &items[2]);
-        }
-        assert_se(i == ELEMENTSOF(items)-1);
-
-        i = 0;
-        LIST_FOREACH_OTHERS(item, cursor, &items[0]) {
-                i++;
-                assert_se(cursor != &items[0]);
-        }
-        assert_se(i == ELEMENTSOF(items)-1);
-
-        i = 0;
-        LIST_FOREACH_OTHERS(item, cursor, &items[3]) {
-                i++;
-                assert_se(cursor != &items[3]);
-        }
-        assert_se(i == ELEMENTSOF(items)-1);
-
-        assert_se(!LIST_JUST_US(item, head));
-
-        assert_se(items[0].item_next == NULL);
-        assert_se(items[1].item_next == &items[0]);
-        assert_se(items[2].item_next == &items[1]);
-        assert_se(items[3].item_next == &items[2]);
-
-        assert_se(items[0].item_prev == &items[1]);
-        assert_se(items[1].item_prev == &items[2]);
-        assert_se(items[2].item_prev == &items[3]);
-        assert_se(items[3].item_prev == NULL);
-
-        LIST_FIND_HEAD(item, &items[0], cursor);
-        assert_se(cursor == &items[3]);
-
-        LIST_FIND_TAIL(item, &items[3], cursor);
-        assert_se(cursor == &items[0]);
-
-        LIST_REMOVE(item, head, &items[1]);
-        assert_se(LIST_JUST_US(item, &items[1]));
-
-        assert_se(items[0].item_next == NULL);
-        assert_se(items[2].item_next == &items[0]);
-        assert_se(items[3].item_next == &items[2]);
-
-        assert_se(items[0].item_prev == &items[2]);
-        assert_se(items[2].item_prev == &items[3]);
-        assert_se(items[3].item_prev == NULL);
-
-        LIST_INSERT_AFTER(item, head, &items[3], &items[1]);
-        assert_se(items[0].item_next == NULL);
-        assert_se(items[2].item_next == &items[0]);
-        assert_se(items[1].item_next == &items[2]);
-        assert_se(items[3].item_next == &items[1]);
-
-        assert_se(items[0].item_prev == &items[2]);
-        assert_se(items[2].item_prev == &items[1]);
-        assert_se(items[1].item_prev == &items[3]);
-        assert_se(items[3].item_prev == NULL);
-
-        LIST_REMOVE(item, head, &items[0]);
-        assert_se(LIST_JUST_US(item, &items[0]));
-
-        assert_se(items[2].item_next == NULL);
-        assert_se(items[1].item_next == &items[2]);
-        assert_se(items[3].item_next == &items[1]);
-
-        assert_se(items[2].item_prev == &items[1]);
-        assert_se(items[1].item_prev == &items[3]);
-        assert_se(items[3].item_prev == NULL);
-
-        LIST_REMOVE(item, head, &items[1]);
-        assert_se(LIST_JUST_US(item, &items[1]));
-
-        assert_se(items[2].item_next == NULL);
-        assert_se(items[3].item_next == &items[2]);
-
-        assert_se(items[2].item_prev == &items[3]);
-        assert_se(items[3].item_prev == NULL);
-
-        LIST_REMOVE(item, head, &items[2]);
-        assert_se(LIST_JUST_US(item, &items[2]));
-        assert_se(LIST_JUST_US(item, head));
-
-        LIST_REMOVE(item, head, &items[3]);
-        assert_se(LIST_JUST_US(item, &items[3]));
-
-        assert_se(head == NULL);
-
-        for (i = 0; i < ELEMENTSOF(items); i++) {
-                assert_se(LIST_JUST_US(item, &items[i]));
-                LIST_APPEND(item, head, &items[i]);
-        }
-
-        assert_se(!LIST_JUST_US(item, head));
-
-        assert_se(items[0].item_next == &items[1]);
-        assert_se(items[1].item_next == &items[2]);
-        assert_se(items[2].item_next == &items[3]);
-        assert_se(items[3].item_next == NULL);
-
-        assert_se(items[0].item_prev == NULL);
-        assert_se(items[1].item_prev == &items[0]);
-        assert_se(items[2].item_prev == &items[1]);
-        assert_se(items[3].item_prev == &items[2]);
-
-        for (i = 0; i < ELEMENTSOF(items); i++)
-                LIST_REMOVE(item, head, &items[i]);
-
-        assert_se(head == NULL);
-
-        return 0;
-}
diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c
deleted file mode 100644 (file)
index 9765075..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "locale-util.h"
-#include "strv.h"
-#include "macro.h"
-
-static void test_get_locales(void) {
-        _cleanup_strv_free_ char **locales = NULL;
-        char **p;
-        int r;
-
-        r = get_locales(&locales);
-        assert_se(r >= 0);
-        assert_se(locales);
-
-        STRV_FOREACH(p, locales) {
-                puts(*p);
-                assert_se(locale_is_valid(*p));
-        }
-}
-
-static void test_locale_is_valid(void) {
-        assert_se(locale_is_valid("en_EN.utf8"));
-        assert_se(locale_is_valid("fr_FR.utf8"));
-        assert_se(locale_is_valid("fr_FR@euro"));
-        assert_se(locale_is_valid("fi_FI"));
-        assert_se(locale_is_valid("POSIX"));
-        assert_se(locale_is_valid("C"));
-
-        assert_se(!locale_is_valid(""));
-        assert_se(!locale_is_valid("/usr/bin/foo"));
-        assert_se(!locale_is_valid("\x01gar\x02 bage\x03"));
-}
-
-int main(int argc, char *argv[]) {
-        test_get_locales();
-        test_locale_is_valid();
-
-        return 0;
-}
diff --git a/src/test/test-log.c b/src/test/test-log.c
deleted file mode 100644 (file)
index ca64004..0000000
+++ /dev/null
@@ -1,54 +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 <stddef.h>
-#include <unistd.h>
-
-#include "log.h"
-#include "util.h"
-
-int main(int argc, char* argv[]) {
-
-        log_set_target(LOG_TARGET_CONSOLE);
-        log_open();
-
-        log_struct(LOG_INFO,
-                   "MESSAGE=Waldo PID="PID_FMT, getpid(),
-                   "SERVICE=piepapo",
-                   NULL);
-
-        log_set_target(LOG_TARGET_JOURNAL);
-        log_open();
-
-        log_struct(LOG_INFO,
-                   "MESSAGE=Foobar PID="PID_FMT, getpid(),
-                   "SERVICE=foobar",
-                   NULL);
-
-        log_struct(LOG_INFO,
-                   "MESSAGE=Foobar PID="PID_FMT, getpid(),
-                   "FORMAT_STR_TEST=1=%i A=%c 2=%hi 3=%li 4=%lli 1=%p foo=%s 2.5=%g 3.5=%g 4.5=%Lg",
-                   (int) 1, 'A', (short) 2, (long int) 3, (long long int) 4, (void*) 1, "foo", (float) 2.5f, (double) 3.5, (long double) 4.5,
-                   "SUFFIX=GOT IT",
-                   NULL);
-
-        return 0;
-}
diff --git a/src/test/test-loopback.c b/src/test/test-loopback.c
deleted file mode 100644 (file)
index c03bda4..0000000
+++ /dev/null
@@ -1,38 +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 <stdio.h>
-
-#include "loopback-setup.h"
-#include "log.h"
-
-int main(int argc, char* argv[]) {
-        int r;
-
-        log_open();
-        log_parse_environment();
-
-        if ((r = loopback_setup()) < 0)
-                fprintf(stderr, "loopback: %s\n", strerror(-r));
-
-        return 0;
-}
diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c
deleted file mode 100644 (file)
index 2397db5..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Zbigniew Jędrzejewski-Szmek
-
-  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 <sys/socket.h>
-
-#include "namespace.h"
-#include "util.h"
-
-static void test_tmpdir(const char *id, const char *A, const char *B) {
-        _cleanup_free_ char *a, *b;
-        struct stat x, y;
-        char *c, *d;
-
-        assert_se(setup_tmp_dirs(id, &a, &b) == 0);
-        assert_se(startswith(a, A));
-        assert_se(startswith(b, B));
-
-        assert_se(stat(a, &x) >= 0);
-        assert_se(stat(b, &y) >= 0);
-
-        assert_se(S_ISDIR(x.st_mode));
-        assert_se(S_ISDIR(y.st_mode));
-
-        assert_se((x.st_mode & 01777) == 0700);
-        assert_se((y.st_mode & 01777) == 0700);
-
-        c = strjoina(a, "/tmp");
-        d = strjoina(b, "/tmp");
-
-        assert_se(stat(c, &x) >= 0);
-        assert_se(stat(d, &y) >= 0);
-
-        assert_se(S_ISDIR(x.st_mode));
-        assert_se(S_ISDIR(y.st_mode));
-
-        assert_se((x.st_mode & 01777) == 01777);
-        assert_se((y.st_mode & 01777) == 01777);
-
-        assert_se(rmdir(c) >= 0);
-        assert_se(rmdir(d) >= 0);
-
-        assert_se(rmdir(a) >= 0);
-        assert_se(rmdir(b) >= 0);
-}
-
-static void test_netns(void) {
-        _cleanup_close_pair_ int s[2] = { -1, -1 };
-        pid_t pid1, pid2, pid3;
-        int r, n = 0;
-        siginfo_t si;
-
-        if (geteuid() > 0)
-                return;
-
-        assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, s) >= 0);
-
-        pid1 = fork();
-        assert_se(pid1 >= 0);
-
-        if (pid1 == 0) {
-                r = setup_netns(s);
-                assert_se(r >= 0);
-                _exit(r);
-        }
-
-        pid2 = fork();
-        assert_se(pid2 >= 0);
-
-        if (pid2 == 0) {
-                r = setup_netns(s);
-                assert_se(r >= 0);
-                exit(r);
-        }
-
-        pid3 = fork();
-        assert_se(pid3 >= 0);
-
-        if (pid3 == 0) {
-                r = setup_netns(s);
-                assert_se(r >= 0);
-                exit(r);
-        }
-
-        r = wait_for_terminate(pid1, &si);
-        assert_se(r >= 0);
-        assert_se(si.si_code == CLD_EXITED);
-        n += si.si_status;
-
-        r = wait_for_terminate(pid2, &si);
-        assert_se(r >= 0);
-        assert_se(si.si_code == CLD_EXITED);
-        n += si.si_status;
-
-        r = wait_for_terminate(pid3, &si);
-        assert_se(r >= 0);
-        assert_se(si.si_code == CLD_EXITED);
-        n += si.si_status;
-
-        assert_se(n == 1);
-}
-
-int main(int argc, char *argv[]) {
-        sd_id128_t bid;
-        char boot_id[SD_ID128_STRING_MAX];
-        _cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL;
-
-        assert_se(sd_id128_get_boot(&bid) >= 0);
-        sd_id128_to_string(bid, boot_id);
-
-        x = strjoin("/tmp/systemd-private-", boot_id, "-abcd.service-", NULL);
-        y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-", NULL);
-        assert_se(x && y);
-
-        test_tmpdir("abcd.service", x, y);
-
-        z = strjoin("/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", NULL);
-        zz = strjoin("/var/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", NULL);
-
-        assert_se(z && zz);
-
-        test_tmpdir("sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device", z, zz);
-
-        test_netns();
-
-        return 0;
-}
diff --git a/src/test/test-ns.c b/src/test/test-ns.c
deleted file mode 100644 (file)
index 76b131c..0000000
+++ /dev/null
@@ -1,72 +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 <unistd.h>
-
-#include "namespace.h"
-#include "log.h"
-
-int main(int argc, char *argv[]) {
-        const char * const writable[] = {
-                "/home",
-                NULL
-        };
-
-        const char * const readonly[] = {
-                "/",
-                "/usr",
-                "/boot",
-                NULL
-        };
-
-        const char * const inaccessible[] = {
-                "/home/lennart/projects",
-                NULL
-        };
-
-        int r;
-        char tmp_dir[] = "/tmp/systemd-private-XXXXXX",
-             var_tmp_dir[] = "/var/tmp/systemd-private-XXXXXX";
-
-        assert_se(mkdtemp(tmp_dir));
-        assert_se(mkdtemp(var_tmp_dir));
-
-        r = setup_namespace((char **) writable,
-                            (char **) readonly,
-                            (char **) inaccessible,
-                            tmp_dir,
-                            var_tmp_dir,
-                            NULL,
-                            true,
-                            PROTECT_HOME_NO,
-                            PROTECT_SYSTEM_NO,
-                            0);
-        if (r < 0) {
-                log_error_errno(r, "Failed to setup namespace: %m");
-                return 1;
-        }
-
-        execl("/bin/sh", "/bin/sh", NULL);
-        log_error_errno(errno, "execl(): %m");
-
-        return 1;
-}
diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c
deleted file mode 100644 (file)
index a951b01..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Zbigniew Jędrzejewski-Szmek
-
-  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 <sys/stat.h>
-
-#include "path-lookup.h"
-#include "log.h"
-#include "strv.h"
-
-static void test_paths(SystemdRunningAs running_as, bool personal) {
-        char template[] = "/tmp/test-path-lookup.XXXXXXX";
-
-        _cleanup_lookup_paths_free_ LookupPaths lp = {};
-        char *exists, *not;
-
-        assert_se(mkdtemp(template));
-        exists = strjoina(template, "/exists");
-        assert_se(mkdir(exists, 0755) == 0);
-        not = strjoina(template, "/not");
-
-        assert_se(lookup_paths_init(&lp, running_as, personal, NULL, exists, not, not) == 0);
-
-        assert_se(!strv_isempty(lp.unit_path));
-        assert_se(strv_contains(lp.unit_path, exists));
-        assert_se(strv_contains(lp.unit_path, not));
-
-        assert_se(rm_rf_dangerous(template, false, true, false) >= 0);
-}
-
-static void print_generator_paths(SystemdRunningAs running_as) {
-        _cleanup_strv_free_ char **paths;
-        char **dir;
-
-        log_info("Generators dirs (%s):", running_as == SYSTEMD_SYSTEM ? "system" : "user");
-
-        paths = generator_paths(running_as);
-        STRV_FOREACH(dir, paths)
-                log_info("        %s", *dir);
-}
-
-int main(int argc, char **argv) {
-        log_set_max_level(LOG_DEBUG);
-        log_parse_environment();
-        log_open();
-
-        test_paths(SYSTEMD_SYSTEM, false);
-        test_paths(SYSTEMD_SYSTEM, true);
-        test_paths(SYSTEMD_USER, false);
-        test_paths(SYSTEMD_USER, true);
-
-        print_generator_paths(SYSTEMD_SYSTEM);
-        print_generator_paths(SYSTEMD_USER);
-
-        return EXIT_SUCCESS;
-}
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
deleted file mode 100644 (file)
index 6396fcb..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Zbigniew Jędrzejewski-Szmek
-
-  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 <unistd.h>
-
-#include "path-util.h"
-#include "util.h"
-#include "macro.h"
-#include "strv.h"
-
-#define test_path_compare(a, b, result) {                 \
-                assert_se(path_compare(a, b) == result);  \
-                assert_se(path_compare(b, a) == -result); \
-                assert_se(path_equal(a, b) == !result);   \
-                assert_se(path_equal(b, a) == !result);   \
-        }
-
-static void test_path(void) {
-        test_path_compare("/goo", "/goo", 0);
-        test_path_compare("/goo", "/goo", 0);
-        test_path_compare("//goo", "/goo", 0);
-        test_path_compare("//goo/////", "/goo", 0);
-        test_path_compare("goo/////", "goo", 0);
-
-        test_path_compare("/goo/boo", "/goo//boo", 0);
-        test_path_compare("//goo/boo", "/goo/boo//", 0);
-
-        test_path_compare("/", "///", 0);
-
-        test_path_compare("/x", "x/", 1);
-        test_path_compare("x/", "/", -1);
-
-        test_path_compare("/x/./y", "x/y", 1);
-        test_path_compare("x/.y", "x/y", -1);
-
-        test_path_compare("foo", "/foo", -1);
-        test_path_compare("/foo", "/foo/bar", -1);
-        test_path_compare("/foo/aaa", "/foo/b", -1);
-        test_path_compare("/foo/aaa", "/foo/b/a", -1);
-        test_path_compare("/foo/a", "/foo/aaa", -1);
-        test_path_compare("/foo/a/b", "/foo/aaa", -1);
-
-        assert_se(path_is_absolute("/"));
-        assert_se(!path_is_absolute("./"));
-
-        assert_se(is_path("/dir"));
-        assert_se(is_path("a/b"));
-        assert_se(!is_path("."));
-
-        assert_se(streq(basename("./aa/bb/../file.da."), "file.da."));
-        assert_se(streq(basename("/aa///.file"), ".file"));
-        assert_se(streq(basename("/aa///file..."), "file..."));
-        assert_se(streq(basename("file.../"), ""));
-
-#define test_parent(x, y) {                                \
-                _cleanup_free_ char *z = NULL;             \
-                int r = path_get_parent(x, &z);            \
-                printf("expected: %s\n", y ? y : "error"); \
-                printf("actual: %s\n", r<0 ? "error" : z); \
-                assert_se((y==NULL) ^ (r==0));             \
-                assert_se(y==NULL || path_equal(z, y));    \
-        }
-
-        test_parent("./aa/bb/../file.da.", "./aa/bb/..");
-        test_parent("/aa///.file", "/aa///");
-        test_parent("/aa///file...", "/aa///");
-        test_parent("file.../", NULL);
-
-        assert_se(path_is_mount_point("/", true));
-        assert_se(path_is_mount_point("/", false));
-
-        {
-                char p1[] = "aaa/bbb////ccc";
-                char p2[] = "//aaa/.////ccc";
-                char p3[] = "/./";
-
-                assert_se(path_equal(path_kill_slashes(p1), "aaa/bbb/ccc"));
-                assert_se(path_equal(path_kill_slashes(p2), "/aaa/./ccc"));
-                assert_se(path_equal(path_kill_slashes(p3), "/./"));
-        }
-}
-
-static void test_find_binary(const char *self, bool local) {
-        char *p;
-
-        assert_se(find_binary("/bin/sh", local, &p) == 0);
-        puts(p);
-        assert_se(streq(p, "/bin/sh"));
-        free(p);
-
-        assert_se(find_binary(self, local, &p) == 0);
-        puts(p);
-        assert_se(endswith(p, "/test-path-util"));
-        assert_se(path_is_absolute(p));
-        free(p);
-
-        assert_se(find_binary("sh", local, &p) == 0);
-        puts(p);
-        assert_se(endswith(p, "/sh"));
-        assert_se(path_is_absolute(p));
-        free(p);
-
-        assert_se(find_binary("xxxx-xxxx", local, &p) == -ENOENT);
-
-        assert_se(find_binary("/some/dir/xxxx-xxxx", local, &p) ==
-                  (local ? -ENOENT : 0));
-        if (!local)
-                free(p);
-}
-
-static void test_prefixes(void) {
-        static const char* values[] = { "/a/b/c/d", "/a/b/c", "/a/b", "/a", "", NULL};
-        unsigned i;
-        char s[PATH_MAX];
-        bool b;
-
-        i = 0;
-        PATH_FOREACH_PREFIX_MORE(s, "/a/b/c/d") {
-                log_error("---%s---", s);
-                assert_se(streq(s, values[i++]));
-        }
-        assert_se(values[i] == NULL);
-
-        i = 1;
-        PATH_FOREACH_PREFIX(s, "/a/b/c/d") {
-                log_error("---%s---", s);
-                assert_se(streq(s, values[i++]));
-        }
-        assert_se(values[i] == NULL);
-
-        i = 0;
-        PATH_FOREACH_PREFIX_MORE(s, "////a////b////c///d///////")
-                assert_se(streq(s, values[i++]));
-        assert_se(values[i] == NULL);
-
-        i = 1;
-        PATH_FOREACH_PREFIX(s, "////a////b////c///d///////")
-                assert_se(streq(s, values[i++]));
-        assert_se(values[i] == NULL);
-
-        PATH_FOREACH_PREFIX(s, "////")
-                assert_not_reached("Wut?");
-
-        b = false;
-        PATH_FOREACH_PREFIX_MORE(s, "////") {
-                assert_se(!b);
-                assert_se(streq(s, ""));
-                b = true;
-        }
-        assert_se(b);
-
-        PATH_FOREACH_PREFIX(s, "")
-                assert_not_reached("wut?");
-
-        b = false;
-        PATH_FOREACH_PREFIX_MORE(s, "") {
-                assert_se(!b);
-                assert_se(streq(s, ""));
-                b = true;
-        }
-}
-
-static void test_path_join(void) {
-
-#define test_join(root, path, rest, expected) {  \
-                _cleanup_free_ char *z = NULL;   \
-                z = path_join(root, path, rest); \
-                assert_se(streq(z, expected));   \
-        }
-
-        test_join("/root", "/a/b", "/c", "/root/a/b/c");
-        test_join("/root", "a/b", "c", "/root/a/b/c");
-        test_join("/root", "/a/b", "c", "/root/a/b/c");
-        test_join("/root", "/", "c", "/root/c");
-        test_join("/root", "/", NULL, "/root/");
-
-        test_join(NULL, "/a/b", "/c", "/a/b/c");
-        test_join(NULL, "a/b", "c", "a/b/c");
-        test_join(NULL, "/a/b", "c", "/a/b/c");
-        test_join(NULL, "/", "c", "/c");
-        test_join(NULL, "/", NULL, "/");
-}
-
-static void test_fsck_exists(void) {
-        /* Ensure we use a sane default for PATH. */
-        unsetenv("PATH");
-
-        /* fsck.minix is provided by util-linux and will probably exist. */
-        assert_se(fsck_exists("minix") == 0);
-
-        assert_se(fsck_exists("AbCdE") == -ENOENT);
-}
-
-static void test_make_relative(void) {
-        char *result;
-
-        assert_se(path_make_relative("some/relative/path", "/some/path", &result) < 0);
-        assert_se(path_make_relative("/some/path", "some/relative/path", &result) < 0);
-
-#define test(from_dir, to_path, expected) {                \
-                _cleanup_free_ char *z = NULL;             \
-                path_make_relative(from_dir, to_path, &z); \
-                assert_se(streq(z, expected));             \
-        }
-
-        test("/", "/", ".");
-        test("/", "/some/path", "some/path");
-        test("/some/path", "/some/path", ".");
-        test("/some/path", "/some/path/in/subdir", "in/subdir");
-        test("/some/path", "/", "../..");
-        test("/some/path", "/some/other/path", "../other/path");
-        test("//extra/////slashes///won't////fool///anybody//", "////extra///slashes////are/just///fine///", "../../../are/just/fine");
-}
-
-static void test_strv_resolve(void) {
-        char tmp_dir[] = "/tmp/test-path-util-XXXXXX";
-        _cleanup_strv_free_ char **search_dirs = NULL;
-        _cleanup_strv_free_ char **absolute_dirs = NULL;
-        char **d;
-
-        assert_se(mkdtemp(tmp_dir) != NULL);
-
-        search_dirs = strv_new("/dir1", "/dir2", "/dir3", NULL);
-        assert_se(search_dirs);
-        STRV_FOREACH(d, search_dirs) {
-                char *p = strappend(tmp_dir, *d);
-                assert_se(p);
-                assert_se(strv_push(&absolute_dirs, p) == 0);
-        }
-
-        assert_se(mkdir(absolute_dirs[0], 0700) == 0);
-        assert_se(mkdir(absolute_dirs[1], 0700) == 0);
-        assert_se(symlink("dir2", absolute_dirs[2]) == 0);
-
-        path_strv_resolve(search_dirs, tmp_dir);
-        assert_se(streq(search_dirs[0], "/dir1"));
-        assert_se(streq(search_dirs[1], "/dir2"));
-        assert_se(streq(search_dirs[2], "/dir2"));
-
-        assert_se(rm_rf_dangerous(tmp_dir, false, true, false) == 0);
-}
-
-static void test_path_startswith(void) {
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo/"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "////"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo//bar/////barfoo///"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo////"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo/bar///barfoo/"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo////bar/barfoo/"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "////foo/bar/barfoo/"));
-        assert_se(path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo"));
-
-        assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa/"));
-        assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa"));
-        assert_se(!path_startswith("/foo/bar/barfoo/", ""));
-        assert_se(!path_startswith("/foo/bar/barfoo/", "/bar/foo"));
-        assert_se(!path_startswith("/foo/bar/barfoo/", "/f/b/b/"));
-}
-
-int main(int argc, char **argv) {
-        test_path();
-        test_find_binary(argv[0], true);
-        test_find_binary(argv[0], false);
-        test_prefixes();
-        test_path_join();
-        test_fsck_exists();
-        test_make_relative();
-        test_strv_resolve();
-        test_path_startswith();
-
-        return 0;
-}
diff --git a/src/test/test-path.c b/src/test/test-path.c
deleted file mode 100644 (file)
index a3295aa..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Ronny Chevalier
-
-  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 <stdbool.h>
-
-#include "unit.h"
-#include "manager.h"
-#include "util.h"
-#include "macro.h"
-#include "strv.h"
-#include "mkdir.h"
-
-typedef void (*test_function_t)(Manager *m);
-
-static int setup_test(Manager **m) {
-        char **tests_path = STRV_MAKE("exists", "existsglobFOOBAR", "changed", "modified", "unit",
-                                      "directorynotempty", "makedirectory");
-        char **test_path;
-        Manager *tmp = NULL;
-        int r;
-
-        assert_se(m);
-
-        r = manager_new(SYSTEMD_USER, true, &tmp);
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
-                printf("Skipping test: manager_new: %s", strerror(-r));
-                return -EXIT_TEST_SKIP;
-        }
-        assert_se(r >= 0);
-        assert_se(manager_startup(tmp, NULL, NULL) >= 0);
-
-        STRV_FOREACH(test_path, tests_path) {
-               rm_rf_dangerous(strjoina("/tmp/test-path_", *test_path), false, true, false);
-        }
-
-        *m = tmp;
-
-        return 0;
-}
-
-static void shutdown_test(Manager *m) {
-        assert_se(m);
-
-        manager_free(m);
-}
-
-static void check_stop_unlink(Manager *m, Unit *unit, const char *test_path, const char *service_name) {
-        _cleanup_free_ char *tmp = NULL;
-        Unit *service_unit = NULL;
-        Service *service = NULL;
-        usec_t ts;
-        usec_t timeout = 2 * USEC_PER_SEC;
-
-        assert_se(m);
-        assert_se(unit);
-        assert_se(test_path);
-
-        if (!service_name) {
-                assert_se(tmp = strreplace(unit->id, ".path", ".service"));
-                service_unit = manager_get_unit(m, tmp);
-        } else
-                service_unit = manager_get_unit(m, service_name);
-        assert_se(service_unit);
-        service = SERVICE(service_unit);
-
-        ts = now(CLOCK_MONOTONIC);
-        /* We process events until the service related to the path has been successfully started */
-        while(service->result != SERVICE_SUCCESS || service->state != SERVICE_START) {
-                usec_t n;
-                int r;
-
-                r = sd_event_run(m->event, 100 * USEC_PER_MSEC);
-                assert_se(r >= 0);
-
-                printf("%s: state = %s; result = %s \n",
-                                service_unit->id,
-                                service_state_to_string(service->state),
-                                service_result_to_string(service->result));
-
-
-                /* But we timeout if the service has not been started in the allocated time */
-                n = now(CLOCK_MONOTONIC);
-                if (ts + timeout < n) {
-                        log_error("Test timeout when testing %s", unit->id);
-                        exit(EXIT_FAILURE);
-                }
-        }
-
-        assert_se(UNIT_VTABLE(unit)->stop(unit) >= 0);
-        rm_rf_dangerous(test_path, false, true, false);
-}
-
-static void test_path_exists(Manager *m) {
-        const char *test_path = "/tmp/test-path_exists";
-        Unit *unit = NULL;
-
-        assert_se(m);
-
-        assert_se(manager_load_unit(m, "path-exists.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        assert_se(touch(test_path) >= 0);
-
-        check_stop_unlink(m, unit, test_path, NULL);
-}
-
-static void test_path_existsglob(Manager *m) {
-        const char *test_path = "/tmp/test-path_existsglobFOOBAR";
-        Unit *unit = NULL;
-
-        assert_se(m);
-        assert_se(manager_load_unit(m, "path-existsglob.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        assert_se(touch(test_path) >= 0);
-
-        check_stop_unlink(m, unit, test_path, NULL);
-}
-
-static void test_path_changed(Manager *m) {
-        const char *test_path = "/tmp/test-path_changed";
-        FILE *f;
-        Unit *unit = NULL;
-
-        assert_se(m);
-
-        assert_se(touch(test_path) >= 0);
-
-        assert_se(manager_load_unit(m, "path-changed.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        f = fopen(test_path, "w");
-        assert_se(f);
-        fclose(f);
-
-        check_stop_unlink(m, unit, test_path, NULL);
-}
-
-static void test_path_modified(Manager *m) {
-        _cleanup_fclose_ FILE *f = NULL;
-        const char *test_path = "/tmp/test-path_modified";
-        Unit *unit = NULL;
-
-        assert_se(m);
-
-        assert_se(touch(test_path) >= 0);
-
-        assert_se(manager_load_unit(m, "path-modified.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        f = fopen(test_path, "w");
-        assert_se(f);
-        fputs("test", f);
-
-        check_stop_unlink(m, unit, test_path, NULL);
-}
-
-static void test_path_unit(Manager *m) {
-        const char *test_path = "/tmp/test-path_unit";
-        Unit *unit = NULL;
-
-        assert_se(m);
-
-        assert_se(manager_load_unit(m, "path-unit.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        assert_se(touch(test_path) >= 0);
-
-        check_stop_unlink(m, unit, test_path, "path-mycustomunit.service");
-}
-
-static void test_path_directorynotempty(Manager *m) {
-        const char *test_path = "/tmp/test-path_directorynotempty/";
-        Unit *unit = NULL;
-
-        assert_se(m);
-
-        assert_se(access(test_path, F_OK) < 0);
-
-        assert_se(manager_load_unit(m, "path-directorynotempty.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        /* MakeDirectory default to no */
-        assert_se(access(test_path, F_OK) < 0);
-
-        assert_se(mkdir_p(test_path, 0755) >= 0);
-        assert_se(touch(strjoina(test_path, "test_file")) >= 0);
-
-        check_stop_unlink(m, unit, test_path, NULL);
-}
-
-static void test_path_makedirectory_directorymode(Manager *m) {
-        const char *test_path = "/tmp/test-path_makedirectory/";
-        Unit *unit = NULL;
-        struct stat s;
-
-        assert_se(m);
-
-        assert_se(access(test_path, F_OK) < 0);
-
-        assert_se(manager_load_unit(m, "path-makedirectory.path", NULL, NULL, &unit) >= 0);
-        assert_se(UNIT_VTABLE(unit)->start(unit) >= 0);
-
-        /* Check if the directory has been created */
-        assert_se(access(test_path, F_OK) >= 0);
-
-        /* Check the mode we specified with DirectoryMode=0744 */
-        assert_se(stat(test_path, &s) >= 0);
-        assert_se((s.st_mode & S_IRWXU) == 0700);
-        assert_se((s.st_mode & S_IRWXG) == 0040);
-        assert_se((s.st_mode & S_IRWXO) == 0004);
-
-        assert_se(UNIT_VTABLE(unit)->stop(unit) >= 0);
-        rm_rf_dangerous(test_path, false, true, false);
-}
-
-int main(int argc, char *argv[]) {
-        test_function_t tests[] = {
-                test_path_exists,
-                test_path_existsglob,
-                test_path_changed,
-                test_path_modified,
-                test_path_unit,
-                test_path_directorynotempty,
-                test_path_makedirectory_directorymode,
-                NULL,
-        };
-        test_function_t *test = NULL;
-        Manager *m = NULL;
-
-        log_parse_environment();
-        log_open();
-
-        assert_se(set_unit_path(TEST_DIR ":") >= 0);
-
-        for (test = tests; test && *test; test++) {
-                int r;
-
-                /* We create a clean environment for each test */
-                r = setup_test(&m);
-                if (r < 0)
-                        return -r;
-
-                (*test)(m);
-
-                shutdown_test(m);
-        }
-
-        return 0;
-}
diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c
deleted file mode 100644 (file)
index dfedc9b..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 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 "util.h"
-#include "set.h"
-#include "prioq.h"
-#include "siphash24.h"
-
-#define SET_SIZE 1024*4
-
-static int unsigned_compare(const void *a, const void *b) {
-        const unsigned *x = a, *y = b;
-
-        if (*x < *y)
-                return -1;
-
-        if (*x > *y)
-                return 1;
-
-        return 0;
-}
-
-static void test_unsigned(void) {
-        unsigned buffer[SET_SIZE], i;
-        Prioq *q;
-
-        srand(0);
-
-        q = prioq_new(trivial_compare_func);
-        assert_se(q);
-
-        for (i = 0; i < ELEMENTSOF(buffer); i++) {
-                unsigned u;
-
-                u = (unsigned) rand();
-                buffer[i] = u;
-                assert_se(prioq_put(q, UINT_TO_PTR(u), NULL) >= 0);
-        }
-
-        qsort(buffer, ELEMENTSOF(buffer), sizeof(buffer[0]), unsigned_compare);
-
-        for (i = 0; i < ELEMENTSOF(buffer); i++) {
-                unsigned u;
-
-                assert_se(prioq_size(q) == ELEMENTSOF(buffer) - i);
-
-                u = PTR_TO_UINT(prioq_pop(q));
-                assert_se(buffer[i] == u);
-        }
-
-        assert_se(prioq_isempty(q));
-        prioq_free(q);
-}
-
-struct test {
-        unsigned value;
-        unsigned idx;
-};
-
-static int test_compare(const void *a, const void *b) {
-        const struct test *x = a, *y = b;
-
-        if (x->value < y->value)
-                return -1;
-
-        if (x->value > y->value)
-                return 1;
-
-        return 0;
-}
-
-static unsigned long test_hash(const void *a, const uint8_t hash_key[HASH_KEY_SIZE]) {
-        const struct test *x = a;
-        uint64_t u;
-
-        siphash24((uint8_t*) &u, &x->value, sizeof(x->value), hash_key);
-
-        return (unsigned long) u;
-}
-
-static const struct hash_ops test_hash_ops = {
-        .hash = test_hash,
-        .compare = test_compare
-};
-
-static void test_struct(void) {
-        Prioq *q;
-        Set *s;
-        unsigned previous = 0, i;
-        int r;
-
-        srand(0);
-
-        q = prioq_new(test_compare);
-        assert_se(q);
-
-        s = set_new(&test_hash_ops);
-        assert_se(s);
-
-        for (i = 0; i < SET_SIZE; i++) {
-                struct test *t;
-
-                t = new0(struct test, 1);
-                assert_se(t);
-                t->value = (unsigned) rand();
-
-                r = prioq_put(q, t, &t->idx);
-                assert_se(r >= 0);
-
-                if (i % 4 == 0) {
-                        r = set_consume(s, t);
-                        assert_se(r >= 0);
-                }
-        }
-
-        for (;;) {
-                struct test *t;
-
-                t = set_steal_first(s);
-                if (!t)
-                        break;
-
-                r = prioq_remove(q, t, &t->idx);
-                assert_se(r > 0);
-
-                free(t);
-        }
-
-        for (i = 0; i < SET_SIZE * 3 / 4; i++) {
-                struct test *t;
-
-                assert_se(prioq_size(q) == (SET_SIZE * 3 / 4) - i);
-
-                t = prioq_pop(q);
-                assert_se(t);
-
-                assert_se(previous <= t->value);
-                previous = t->value;
-                free(t);
-        }
-
-        assert_se(prioq_isempty(q));
-        prioq_free(q);
-
-        assert_se(set_isempty(s));
-        set_free(s);
-}
-
-int main(int argc, char* argv[]) {
-
-        test_unsigned();
-        test_struct();
-
-        return 0;
-}
diff --git a/src/test/test-pty.c b/src/test/test-pty.c
deleted file mode 100644 (file)
index b5f4d4f..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
-  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 <locale.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include "pty.h"
-#include "util.h"
-
-static const char sndmsg[] = "message\n";
-static const char rcvmsg[] = "message\r\n";
-static char rcvbuf[128];
-static size_t rcvsiz = 0;
-static sd_event *event;
-
-static void run_child(Pty *pty) {
-        ssize_t r, l;
-        char buf[512];
-
-        r = read(0, buf, sizeof(buf));
-        assert_se((size_t)r == strlen(sndmsg));
-        assert_se(!strncmp(buf, sndmsg, r));
-
-        l = write(1, buf, r);
-        assert_se(l == r);
-}
-
-static int pty_fn(Pty *pty, void *userdata, unsigned int ev, const void *ptr, size_t size) {
-        switch (ev) {
-        case PTY_DATA:
-                assert_se(rcvsiz < strlen(rcvmsg) * 2);
-                assert_se(rcvsiz + size < sizeof(rcvbuf));
-
-                memcpy(&rcvbuf[rcvsiz], ptr, size);
-                rcvsiz += size;
-
-                if (rcvsiz >= strlen(rcvmsg) * 2) {
-                        assert_se(rcvsiz == strlen(rcvmsg) * 2);
-                        assert_se(!memcmp(rcvbuf, rcvmsg, strlen(rcvmsg)));
-                        assert_se(!memcmp(&rcvbuf[strlen(rcvmsg)], rcvmsg, strlen(rcvmsg)));
-                }
-
-                break;
-        case PTY_HUP:
-                /* This is guaranteed to appear _after_ the input queues are
-                 * drained! */
-                assert_se(rcvsiz == strlen(rcvmsg) * 2);
-                break;
-        case PTY_CHILD:
-                /* this may appear at any time */
-                break;
-        default:
-                assert_se(0);
-                break;
-        }
-
-        /* if we got HUP _and_ CHILD, exit */
-        if (pty_get_fd(pty) < 0 && pty_get_child(pty) < 0)
-                sd_event_exit(event, 0);
-
-        return 0;
-}
-
-static void run_parent(Pty *pty) {
-        int r;
-
-        /* write message to pty, ECHO mode guarantees that we get it back
-         * twice: once via ECHO, once from the run_child() fn */
-        assert_se(pty_write(pty, sndmsg, strlen(sndmsg)) >= 0);
-
-        r = sd_event_loop(event);
-        assert_se(r >= 0);
-}
-
-static void test_pty(void) {
-        pid_t pid;
-        Pty *pty = NULL;
-
-        rcvsiz = 0;
-        zero(rcvbuf);
-
-        assert_se(sd_event_default(&event) >= 0);
-
-        pid = pty_fork(&pty, event, pty_fn, NULL, 80, 25);
-        assert_se(pid >= 0);
-
-        if (pid == 0) {
-                /* child */
-                run_child(pty);
-                exit(0);
-        }
-
-        /* parent */
-        run_parent(pty);
-
-        /* Make sure the PTY recycled the child; yeah, this is racy if the
-         * PID was already reused; but that seems fine for a test. */
-        assert_se(waitpid(pid, NULL, WNOHANG) < 0 && errno == ECHILD);
-
-        pty_unref(pty);
-        sd_event_unref(event);
-}
-
-int main(int argc, char *argv[]) {
-        unsigned int i;
-
-        log_parse_environment();
-        log_open();
-
-        assert_se(sigprocmask_many(SIG_BLOCK, SIGCHLD, -1) >= 0);
-
-        /* Oh, there're ugly races in the TTY layer regarding HUP vs IN. Turns
-         * out they appear only 10% of the time. I fixed all of them and
-         * don't see them, anymore. But lets be safe and run this 1000 times
-         * so we catch any new ones, in case they appear again. */
-        for (i = 0; i < 1000; ++i)
-                test_pty();
-
-        return 0;
-}
diff --git a/src/test/test-ratelimit.c b/src/test/test-ratelimit.c
deleted file mode 100644 (file)
index b7f6dfe..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "ratelimit.h"
-#include "time-util.h"
-#include "macro.h"
-
-static void test_ratelimit_test(void) {
-        int i;
-        RATELIMIT_DEFINE(ratelimit, 1 * USEC_PER_SEC, 10);
-
-        for (i = 0; i < 10; i++) {
-                assert_se(ratelimit_test(&ratelimit));
-        }
-        assert_se(!ratelimit_test(&ratelimit));
-        sleep(1);
-        for (i = 0; i < 10; i++) {
-                assert_se(ratelimit_test(&ratelimit));
-        }
-
-        RATELIMIT_INIT(ratelimit, 0, 10);
-        for (i = 0; i < 10000; i++) {
-                assert_se(ratelimit_test(&ratelimit));
-        }
-}
-
-int main(int argc, char *argv[]) {
-        test_ratelimit_test();
-
-        return 0;
-}
diff --git a/src/test/test-replace-var.c b/src/test/test-replace-var.c
deleted file mode 100644 (file)
index b1d42d7..0000000
+++ /dev/null
@@ -1,46 +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 <string.h>
-
-#include "util.h"
-#include "macro.h"
-#include "replace-var.h"
-
-static char *lookup(const char *variable, void *userdata) {
-        return strjoin("<<<", variable, ">>>", NULL);
-}
-
-int main(int argc, char *argv[]) {
-        char *r;
-
-        assert_se(r = replace_var("@@@foobar@xyz@HALLO@foobar@test@@testtest@TEST@...@@@", lookup, NULL));
-        puts(r);
-        assert_se(streq(r, "@@@foobar@xyz<<<HALLO>>>foobar@test@@testtest<<<TEST>>>...@@@"));
-        free(r);
-
-        assert_se(r = strreplace("XYZFFFFXYZFFFFXYZ", "XYZ", "ABC"));
-        puts(r);
-        assert_se(streq(r, "ABCFFFFABCFFFFABC"));
-        free(r);
-
-        return 0;
-}
diff --git a/src/test/test-ring.c b/src/test/test-ring.c
deleted file mode 100644 (file)
index cb8a5d4..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
-  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 "def.h"
-#include "ring.h"
-
-static void test_ring(void) {
-        static const char buf[8192];
-        Ring r;
-        size_t l;
-        struct iovec vec[2];
-        int s;
-
-        zero(r);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 0);
-
-        s = ring_push(&r, buf, 2048);
-        assert_se(!s);
-        assert_se(ring_get_size(&r) == 2048);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 1);
-        assert_se(vec[0].iov_len == 2048);
-        assert_se(!memcmp(vec[0].iov_base, buf, vec[0].iov_len));
-        assert_se(ring_get_size(&r) == 2048);
-
-        ring_pull(&r, 2048);
-        assert_se(ring_get_size(&r) == 0);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 0);
-        assert_se(ring_get_size(&r) == 0);
-
-        s = ring_push(&r, buf, 2048);
-        assert_se(!s);
-        assert_se(ring_get_size(&r) == 2048);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 1);
-        assert_se(vec[0].iov_len == 2048);
-        assert_se(!memcmp(vec[0].iov_base, buf, vec[0].iov_len));
-        assert_se(ring_get_size(&r) == 2048);
-
-        s = ring_push(&r, buf, 1);
-        assert_se(!s);
-        assert_se(ring_get_size(&r) == 2049);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 2);
-        assert_se(vec[0].iov_len == 2048);
-        assert_se(vec[1].iov_len == 1);
-        assert_se(!memcmp(vec[0].iov_base, buf, vec[0].iov_len));
-        assert_se(!memcmp(vec[1].iov_base, buf, vec[1].iov_len));
-        assert_se(ring_get_size(&r) == 2049);
-
-        ring_pull(&r, 2048);
-        assert_se(ring_get_size(&r) == 1);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 1);
-        assert_se(vec[0].iov_len == 1);
-        assert_se(!memcmp(vec[0].iov_base, buf, vec[0].iov_len));
-        assert_se(ring_get_size(&r) == 1);
-
-        ring_pull(&r, 1);
-        assert_se(ring_get_size(&r) == 0);
-
-        s = ring_push(&r, buf, 2048);
-        assert_se(!s);
-        assert_se(ring_get_size(&r) == 2048);
-
-        s = ring_push(&r, buf, 2049);
-        assert_se(!s);
-        assert_se(ring_get_size(&r) == 4097);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 1);
-        assert_se(vec[0].iov_len == 4097);
-        assert_se(!memcmp(vec[0].iov_base, buf, vec[0].iov_len));
-        assert_se(ring_get_size(&r) == 4097);
-
-        ring_pull(&r, 1);
-        assert_se(ring_get_size(&r) == 4096);
-
-        s = ring_push(&r, buf, 4096);
-        assert_se(!s);
-        assert_se(ring_get_size(&r) == 8192);
-
-        l = ring_peek(&r, vec);
-        assert_se(l == 2);
-        assert_se(vec[0].iov_len == 8191);
-        assert_se(vec[1].iov_len == 1);
-        assert_se(!memcmp(vec[0].iov_base, buf, vec[0].iov_len));
-        assert_se(!memcmp(vec[1].iov_base, buf, vec[1].iov_len));
-        assert_se(ring_get_size(&r) == 8192);
-
-        ring_clear(&r);
-        assert_se(ring_get_size(&r) == 0);
-}
-
-int main(int argc, char *argv[]) {
-        log_parse_environment();
-        log_open();
-
-        test_ring();
-
-        return 0;
-}
diff --git a/src/test/test-rtnl-manual.c b/src/test/test-rtnl-manual.c
deleted file mode 100644 (file)
index c406454..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Susant Sahani
-
-  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 <arpa/inet.h>
-#include <net/if.h>
-#include <linux/ip.h>
-#include <linux/if_tunnel.h>
-#include <libkmod.h>
-
-#include "util.h"
-#include "macro.h"
-#include "sd-rtnl.h"
-
-static int load_module(const char *mod_name) {
-        struct kmod_ctx *ctx;
-        struct kmod_list *list = NULL, *l;
-        int r;
-
-        ctx = kmod_new(NULL, NULL);
-        if (!ctx) {
-                kmod_unref(ctx);
-                return -ENOMEM;
-        }
-
-        r = kmod_module_new_from_lookup(ctx, mod_name, &list);
-        if (r < 0)
-                return -1;
-
-        kmod_list_foreach(l, list) {
-                struct kmod_module *mod = kmod_module_get_module(l);
-
-                r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
-                if (r >= 0)
-                        r = 0;
-                else
-                        r = -1;
-
-                kmod_module_unref(mod);
-        }
-
-        kmod_module_unref_list(list);
-        kmod_unref(ctx);
-
-        return r;
-}
-
-static int test_tunnel_configure(sd_rtnl *rtnl) {
-        int r;
-        sd_rtnl_message *m, *n;
-        struct in_addr local, remote;
-
-        /* skip test if module cannot be loaded */
-        r = load_module("ipip");
-        if(r < 0)
-                return EXIT_TEST_SKIP;
-
-        if(getuid() != 0)
-                return EXIT_TEST_SKIP;
-
-        /* IPIP tunnel */
-        assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0);
-        assert_se(m);
-
-        assert_se(sd_rtnl_message_append_string(m, IFLA_IFNAME, "ipip-tunnel") >= 0);
-        assert_se(sd_rtnl_message_append_u32(m, IFLA_MTU, 1234)>= 0);
-
-        assert_se(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
-
-        assert_se(sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "ipip") >= 0);
-
-        inet_pton(AF_INET, "192.168.21.1", &local.s_addr);
-        assert_se(sd_rtnl_message_append_u32(m, IFLA_IPTUN_LOCAL, local.s_addr) >= 0);
-
-        inet_pton(AF_INET, "192.168.21.2", &remote.s_addr);
-        assert_se(sd_rtnl_message_append_u32(m, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0);
-
-        assert_se(sd_rtnl_message_close_container(m) >= 0);
-        assert_se(sd_rtnl_message_close_container(m) >= 0);
-
-        assert_se(sd_rtnl_call(rtnl, m, -1, 0) == 1);
-
-        assert_se((m = sd_rtnl_message_unref(m)) == NULL);
-
-        r = load_module("sit");
-        if(r < 0)
-                return EXIT_TEST_SKIP;
-
-        /* sit */
-        assert_se(sd_rtnl_message_new_link(rtnl, &n, RTM_NEWLINK, 0) >= 0);
-        assert_se(n);
-
-        assert_se(sd_rtnl_message_append_string(n, IFLA_IFNAME, "sit-tunnel") >= 0);
-        assert_se(sd_rtnl_message_append_u32(n, IFLA_MTU, 1234)>= 0);
-
-        assert_se(sd_rtnl_message_open_container(n, IFLA_LINKINFO) >= 0);
-
-        assert_se(sd_rtnl_message_open_container_union(n, IFLA_INFO_DATA, "sit") >= 0);
-
-        assert_se(sd_rtnl_message_append_u8(n, IFLA_IPTUN_PROTO, IPPROTO_IPIP) >= 0);
-
-        inet_pton(AF_INET, "192.168.21.3", &local.s_addr);
-        assert_se(sd_rtnl_message_append_u32(n, IFLA_IPTUN_LOCAL, local.s_addr) >= 0);
-
-        inet_pton(AF_INET, "192.168.21.4", &remote.s_addr);
-        assert_se(sd_rtnl_message_append_u32(n, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0);
-
-        assert_se(sd_rtnl_message_close_container(n) >= 0);
-        assert_se(sd_rtnl_message_close_container(n) >= 0);
-
-        assert_se(sd_rtnl_call(rtnl, n, -1, 0) == 1);
-
-        assert_se((m = sd_rtnl_message_unref(n)) == NULL);
-
-        return EXIT_SUCCESS;
-}
-
-int main(int argc, char *argv[]) {
-        sd_rtnl *rtnl;
-        int r;
-
-        assert_se(sd_rtnl_open(&rtnl, 0) >= 0);
-        assert_se(rtnl);
-
-        r = test_tunnel_configure(rtnl);
-
-        assert_se((rtnl = sd_rtnl_unref(rtnl)) == NULL);
-
-        return r;
-}
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
deleted file mode 100644 (file)
index 6b3128d..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2012 Holger Hans Peter Freyther
-
-  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 <sched.h>
-
-#include "manager.h"
-#include "macro.h"
-
-int main(int argc, char *argv[]) {
-        Manager *m = NULL;
-        Unit *idle_ok, *idle_bad, *rr_ok, *rr_bad, *rr_sched;
-        Service *ser;
-        FILE *serial = NULL;
-        FDSet *fdset = NULL;
-        int r;
-
-        /* prepare the test */
-        assert_se(set_unit_path(TEST_DIR) >= 0);
-        r = manager_new(SYSTEMD_USER, true, &m);
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
-                printf("Skipping test: manager_new: %s", strerror(-r));
-                return EXIT_TEST_SKIP;
-        }
-        assert_se(r >= 0);
-        assert_se(manager_startup(m, serial, fdset) >= 0);
-
-        /* load idle ok */
-        assert_se(manager_load_unit(m, "sched_idle_ok.service", NULL, NULL, &idle_ok) >= 0);
-        assert_se(idle_ok->load_state == UNIT_LOADED);
-        ser = SERVICE(idle_ok);
-        assert_se(ser->exec_context.cpu_sched_policy == SCHED_OTHER);
-        assert_se(ser->exec_context.cpu_sched_priority == 0);
-
-        /*
-         * load idle bad. This should print a warning but we have no way to look at it.
-         */
-        assert_se(manager_load_unit(m, "sched_idle_bad.service", NULL, NULL, &idle_bad) >= 0);
-        assert_se(idle_bad->load_state == UNIT_LOADED);
-        ser = SERVICE(idle_ok);
-        assert_se(ser->exec_context.cpu_sched_policy == SCHED_OTHER);
-        assert_se(ser->exec_context.cpu_sched_priority == 0);
-
-        /*
-         * load rr ok.
-         * Test that the default priority is moving from 0 to 1.
-         */
-        assert_se(manager_load_unit(m, "sched_rr_ok.service", NULL, NULL, &rr_ok) >= 0);
-        assert_se(rr_ok->load_state == UNIT_LOADED);
-        ser = SERVICE(rr_ok);
-        assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR);
-        assert_se(ser->exec_context.cpu_sched_priority == 1);
-
-        /*
-         * load rr bad.
-         * Test that the value of 0 and 100 is ignored.
-         */
-        assert_se(manager_load_unit(m, "sched_rr_bad.service", NULL, NULL, &rr_bad) >= 0);
-        assert_se(rr_bad->load_state == UNIT_LOADED);
-        ser = SERVICE(rr_bad);
-        assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR);
-        assert_se(ser->exec_context.cpu_sched_priority == 1);
-
-        /*
-         * load rr change.
-         * Test that anything between 1 and 99 can be set.
-         */
-        assert_se(manager_load_unit(m, "sched_rr_change.service", NULL, NULL, &rr_sched) >= 0);
-        assert_se(rr_sched->load_state == UNIT_LOADED);
-        ser = SERVICE(rr_sched);
-        assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR);
-        assert_se(ser->exec_context.cpu_sched_priority == 99);
-
-        manager_free(m);
-
-        return EXIT_SUCCESS;
-}
diff --git a/src/test/test-set.c b/src/test/test-set.c
deleted file mode 100644 (file)
index ac292ed..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Zbigniew Jędrzejewski-Szmek
-
-  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 "set.h"
-
-static void test_set_steal_first(void) {
-        _cleanup_set_free_ Set *m = NULL;
-        int seen[3] = {};
-        char *val;
-
-        m = set_new(&string_hash_ops);
-        assert_se(m);
-
-        assert_se(set_put(m, (void*) "1") == 1);
-        assert_se(set_put(m, (void*) "22") == 1);
-        assert_se(set_put(m, (void*) "333") == 1);
-
-        while ((val = set_steal_first(m)))
-                seen[strlen(val) - 1]++;
-
-        assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
-
-        assert_se(set_isempty(m));
-}
-
-int main(int argc, const char *argv[]) {
-        test_set_steal_first();
-
-        return 0;
-}
diff --git a/src/test/test-sigbus.c b/src/test/test-sigbus.c
deleted file mode 100644 (file)
index f5bae65..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 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 <sys/mman.h>
-
-#include "util.h"
-#include "sigbus.h"
-
-int main(int argc, char *argv[]) {
-        _cleanup_close_ int fd = -1;
-        char template[] = "/tmp/sigbus-test-XXXXXX";
-        void *addr = NULL;
-        uint8_t *p;
-
-        sigbus_install();
-
-        assert_se(sigbus_pop(&addr) == 0);
-
-        assert_se((fd = mkostemp(template, O_RDWR|O_CREAT|O_EXCL)) >= 0);
-        assert_se(unlink(template) >= 0);
-        assert_se(fallocate(fd, 0, 0, page_size() * 8) >= 0);
-
-        p = mmap(NULL, page_size() * 16, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
-        assert_se(p != MAP_FAILED);
-
-        assert_se(sigbus_pop(&addr) == 0);
-
-        p[0] = 0xFF;
-        assert_se(sigbus_pop(&addr) == 0);
-
-        p[page_size()] = 0xFF;
-        assert_se(sigbus_pop(&addr) == 0);
-
-        p[page_size()*8] = 0xFF;
-        p[page_size()*8+1] = 0xFF;
-        p[page_size()*10] = 0xFF;
-        assert_se(sigbus_pop(&addr) > 0);
-        assert_se(addr == p + page_size() * 8);
-        assert_se(sigbus_pop(&addr) > 0);
-        assert_se(addr == p + page_size() * 10);
-        assert_se(sigbus_pop(&addr) == 0);
-
-        sigbus_reset();
-}
diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c
deleted file mode 100644 (file)
index 1d75d05..0000000
+++ /dev/null
@@ -1,64 +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 <stdio.h>
-
-#include "util.h"
-#include "log.h"
-#include "sleep-config.h"
-#include "strv.h"
-
-static void test_sleep(void) {
-        _cleanup_strv_free_ char
-                **standby = strv_new("standby", NULL),
-                **mem = strv_new("mem", NULL),
-                **disk = strv_new("disk", NULL),
-                **suspend = strv_new("suspend", NULL),
-                **reboot = strv_new("reboot", NULL),
-                **platform = strv_new("platform", NULL),
-                **shutdown = strv_new("shutdown", NULL),
-                **freez = strv_new("freeze", NULL);
-
-        log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0));
-        log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0));
-        log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0));
-        log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0));
-        log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0));
-        log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0));
-        log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0));
-        log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0));
-
-        log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0));
-        log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0));
-        log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0));
-}
-
-int main(int argc, char* argv[]) {
-        log_parse_environment();
-        log_open();
-
-        if (getuid() != 0)
-                log_warning("This program is unlikely to work for unpriviledged users");
-
-        test_sleep();
-
-        return 0;
-}
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
deleted file mode 100644 (file)
index 6fb4a40..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/***
-  This file is part of systemd
-
-  Copyright 2014 Ronny Chevalier
-
-  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 "socket-util.h"
-#include "in-addr-util.h"
-#include "util.h"
-#include "macro.h"
-#include "log.h"
-#include "async.h"
-
-static void test_socket_address_parse(void) {
-        SocketAddress a;
-
-        assert_se(socket_address_parse(&a, "junk") < 0);
-        assert_se(socket_address_parse(&a, "192.168.1.1") < 0);
-        assert_se(socket_address_parse(&a, ".168.1.1") < 0);
-        assert_se(socket_address_parse(&a, "989.168.1.1") < 0);
-        assert_se(socket_address_parse(&a, "192.168.1.1:65536") < 0);
-        assert_se(socket_address_parse(&a, "192.168.1.1:0") < 0);
-        assert_se(socket_address_parse(&a, "0") < 0);
-        assert_se(socket_address_parse(&a, "65536") < 0);
-
-        assert_se(socket_address_parse(&a, "65535") >= 0);
-
-        if (socket_ipv6_is_supported()) {
-                assert_se(socket_address_parse(&a, "[::1]") < 0);
-                assert_se(socket_address_parse(&a, "[::1]8888") < 0);
-                assert_se(socket_address_parse(&a, "::1") < 0);
-                assert_se(socket_address_parse(&a, "[::1]:0") < 0);
-                assert_se(socket_address_parse(&a, "[::1]:65536") < 0);
-                assert_se(socket_address_parse(&a, "[a:b:1]:8888") < 0);
-
-                assert_se(socket_address_parse(&a, "8888") >= 0);
-                assert_se(a.sockaddr.sa.sa_family == AF_INET6);
-
-                assert_se(socket_address_parse(&a, "[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:8888") >= 0);
-                assert_se(a.sockaddr.sa.sa_family == AF_INET6);
-
-                assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
-                assert_se(a.sockaddr.sa.sa_family == AF_INET6);
-        } else {
-                assert_se(socket_address_parse(&a, "[::1]:8888") < 0);
-
-                assert_se(socket_address_parse(&a, "8888") >= 0);
-                assert_se(a.sockaddr.sa.sa_family == AF_INET);
-        }
-
-        assert_se(socket_address_parse(&a, "192.168.1.254:8888") >= 0);
-        assert_se(a.sockaddr.sa.sa_family == AF_INET);
-
-        assert_se(socket_address_parse(&a, "/foo/bar") >= 0);
-        assert_se(a.sockaddr.sa.sa_family == AF_UNIX);
-
-        assert_se(socket_address_parse(&a, "@abstract") >= 0);
-        assert_se(a.sockaddr.sa.sa_family == AF_UNIX);
-}
-
-static void test_socket_address_parse_netlink(void) {
-        SocketAddress a;
-
-        assert_se(socket_address_parse_netlink(&a, "junk") < 0);
-        assert_se(socket_address_parse_netlink(&a, "") < 0);
-
-        assert_se(socket_address_parse_netlink(&a, "route") >= 0);
-        assert_se(socket_address_parse_netlink(&a, "route 10") >= 0);
-        assert_se(a.sockaddr.sa.sa_family == AF_NETLINK);
-        assert_se(a.protocol == NETLINK_ROUTE);
-}
-
-static void test_socket_address_equal(void) {
-        SocketAddress a;
-        SocketAddress b;
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_parse(&b, "192.168.1.1:888") >= 0);
-        assert_se(!socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_parse(&b, "192.16.1.1:8888") >= 0);
-        assert_se(!socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_parse(&b, "8888") >= 0);
-        assert_se(!socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_parse(&b, "/foo/bar/") >= 0);
-        assert_se(!socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_parse(&b, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "/foo/bar") >= 0);
-        assert_se(socket_address_parse(&b, "/foo/bar") >= 0);
-        assert_se(socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
-        assert_se(socket_address_parse(&b, "[::1]:8888") >= 0);
-        assert_se(socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse(&a, "@abstract") >= 0);
-        assert_se(socket_address_parse(&b, "@abstract") >= 0);
-        assert_se(socket_address_equal(&a, &b));
-
-        assert_se(socket_address_parse_netlink(&a, "firewall") >= 0);
-        assert_se(socket_address_parse_netlink(&b, "firewall") >= 0);
-        assert_se(socket_address_equal(&a, &b));
-}
-
-static void test_socket_address_get_path(void) {
-        SocketAddress a;
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(!socket_address_get_path(&a));
-
-        assert_se(socket_address_parse(&a, "@abstract") >= 0);
-        assert_se(!socket_address_get_path(&a));
-
-        assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
-        assert_se(!socket_address_get_path(&a));
-
-        assert_se(socket_address_parse(&a, "/foo/bar") >= 0);
-        assert_se(streq(socket_address_get_path(&a), "/foo/bar"));
-}
-
-static void test_socket_address_is(void) {
-        SocketAddress a;
-
-        assert_se(socket_address_parse(&a, "192.168.1.1:8888") >= 0);
-        assert_se(socket_address_is(&a, "192.168.1.1:8888", SOCK_STREAM));
-        assert_se(!socket_address_is(&a, "route", SOCK_STREAM));
-        assert_se(!socket_address_is(&a, "192.168.1.1:8888", SOCK_RAW));
-}
-
-static void test_socket_address_is_netlink(void) {
-        SocketAddress a;
-
-        assert_se(socket_address_parse_netlink(&a, "route 10") >= 0);
-        assert_se(socket_address_is_netlink(&a, "route 10"));
-        assert_se(!socket_address_is_netlink(&a, "192.168.1.1:8888"));
-        assert_se(!socket_address_is_netlink(&a, "route 1"));
-}
-
-static void test_in_addr_prefix_intersect_one(unsigned f, const char *a, unsigned apl, const char *b, unsigned bpl, int result) {
-        union in_addr_union ua, ub;
-
-        assert_se(in_addr_from_string(f, a, &ua) >= 0);
-        assert_se(in_addr_from_string(f, b, &ub) >= 0);
-
-        assert_se(in_addr_prefix_intersect(f, &ua, apl, &ub, bpl) == result);
-}
-
-static void test_in_addr_prefix_intersect(void) {
-
-        test_in_addr_prefix_intersect_one(AF_INET, "255.255.255.255", 32, "255.255.255.254", 32, 0);
-        test_in_addr_prefix_intersect_one(AF_INET, "255.255.255.255", 0, "255.255.255.255", 32, 1);
-        test_in_addr_prefix_intersect_one(AF_INET, "0.0.0.0", 0, "47.11.8.15", 32, 1);
-
-        test_in_addr_prefix_intersect_one(AF_INET, "1.1.1.1", 24, "1.1.1.1", 24, 1);
-        test_in_addr_prefix_intersect_one(AF_INET, "2.2.2.2", 24, "1.1.1.1", 24, 0);
-
-        test_in_addr_prefix_intersect_one(AF_INET, "1.1.1.1", 24, "1.1.1.127", 25, 1);
-        test_in_addr_prefix_intersect_one(AF_INET, "1.1.1.1", 24, "1.1.1.127", 26, 1);
-        test_in_addr_prefix_intersect_one(AF_INET, "1.1.1.1", 25, "1.1.1.127", 25, 1);
-        test_in_addr_prefix_intersect_one(AF_INET, "1.1.1.1", 25, "1.1.1.255", 25, 0);
-
-        test_in_addr_prefix_intersect_one(AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 128, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe", 128, 0);
-        test_in_addr_prefix_intersect_one(AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 0, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 128, 1);
-        test_in_addr_prefix_intersect_one(AF_INET6, "::", 0, "beef:beef:beef:beef:beef:beef:beef:beef", 128, 1);
-
-        test_in_addr_prefix_intersect_one(AF_INET6, "1::2", 64, "1::2", 64, 1);
-        test_in_addr_prefix_intersect_one(AF_INET6, "2::2", 64, "1::2", 64, 0);
-
-        test_in_addr_prefix_intersect_one(AF_INET6, "1::1", 120, "1::007f", 121, 1);
-        test_in_addr_prefix_intersect_one(AF_INET6, "1::1", 120, "1::007f", 122, 1);
-        test_in_addr_prefix_intersect_one(AF_INET6, "1::1", 121, "1::007f", 121, 1);
-        test_in_addr_prefix_intersect_one(AF_INET6, "1::1", 121, "1::00ff", 121, 0);
-}
-
-static void test_in_addr_prefix_next_one(unsigned f, const char *before, unsigned pl, const char *after) {
-        union in_addr_union ubefore, uafter, t;
-
-        assert_se(in_addr_from_string(f, before, &ubefore) >= 0);
-
-        t = ubefore;
-        assert_se((in_addr_prefix_next(f, &t, pl) > 0) == !!after);
-
-        if (after) {
-                assert_se(in_addr_from_string(f, after, &uafter) >= 0);
-                assert_se(in_addr_equal(f, &t, &uafter) > 0);
-        }
-}
-
-static void test_in_addr_prefix_next(void) {
-
-        test_in_addr_prefix_next_one(AF_INET, "192.168.0.0", 24, "192.168.1.0");
-        test_in_addr_prefix_next_one(AF_INET, "192.168.0.0", 16, "192.169.0.0");
-        test_in_addr_prefix_next_one(AF_INET, "192.168.0.0", 20, "192.168.16.0");
-
-        test_in_addr_prefix_next_one(AF_INET, "0.0.0.0", 32, "0.0.0.1");
-        test_in_addr_prefix_next_one(AF_INET, "255.255.255.255", 32, NULL);
-        test_in_addr_prefix_next_one(AF_INET, "255.255.255.0", 24, NULL);
-
-        test_in_addr_prefix_next_one(AF_INET6, "4400::", 128, "4400::0001");
-        test_in_addr_prefix_next_one(AF_INET6, "4400::", 120, "4400::0100");
-        test_in_addr_prefix_next_one(AF_INET6, "4400::", 127, "4400::0002");
-        test_in_addr_prefix_next_one(AF_INET6, "4400::", 8, "4500::");
-        test_in_addr_prefix_next_one(AF_INET6, "4400::", 7, "4600::");
-
-        test_in_addr_prefix_next_one(AF_INET6, "::", 128, "::1");
-
-        test_in_addr_prefix_next_one(AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 128, NULL);
-        test_in_addr_prefix_next_one(AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00", 120, NULL);
-
-}
-
-static void *connect_thread(void *arg) {
-        union sockaddr_union *sa = arg;
-        _cleanup_close_ int fd = -1;
-
-        fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
-        assert_se(fd >= 0);
-
-        assert_se(connect(fd, &sa->sa, sizeof(sa->in)) == 0);
-
-        return NULL;
-}
-
-static void test_nameinfo_pretty(void) {
-        _cleanup_free_ char *stdin_name = NULL, *localhost = NULL;
-
-        union sockaddr_union s = {
-                .in.sin_family = AF_INET,
-                .in.sin_port = 0,
-                .in.sin_addr.s_addr = htonl(INADDR_ANY),
-        };
-        int r;
-
-        union sockaddr_union c = {};
-        socklen_t slen = sizeof(c.in), clen = sizeof(c.in);
-
-        _cleanup_close_ int sfd = -1, cfd = -1;
-        r = getnameinfo_pretty(STDIN_FILENO, &stdin_name);
-        log_info_errno(r, "No connection remote: %m");
-
-        assert_se(r < 0);
-
-        sfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
-        assert_se(sfd >= 0);
-
-        assert_se(bind(sfd, &s.sa, sizeof(s.in)) == 0);
-
-        /* find out the port number */
-        assert_se(getsockname(sfd, &s.sa, &slen) == 0);
-
-        assert_se(listen(sfd, 1) == 0);
-
-        assert_se(asynchronous_job(connect_thread, &s) == 0);
-
-        log_debug("Accepting new connection on fd:%d", sfd);
-        cfd = accept4(sfd, &c.sa, &clen, SOCK_CLOEXEC);
-        assert_se(cfd >= 0);
-
-        r = getnameinfo_pretty(cfd, &localhost);
-        log_info("Connection from %s", localhost);
-        assert_se(r == 0);
-}
-
-static void test_sockaddr_equal(void) {
-        union sockaddr_union a = {
-                .in.sin_family = AF_INET,
-                .in.sin_port = 0,
-                .in.sin_addr.s_addr = htonl(INADDR_ANY),
-        };
-        union sockaddr_union b = {
-                .in.sin_family = AF_INET,
-                .in.sin_port = 0,
-                .in.sin_addr.s_addr = htonl(INADDR_ANY),
-        };
-        union sockaddr_union c = {
-                .in.sin_family = AF_INET,
-                .in.sin_port = 0,
-                .in.sin_addr.s_addr = htonl(1234),
-        };
-        union sockaddr_union d = {
-                .in6.sin6_family = AF_INET6,
-                .in6.sin6_port = 0,
-                .in6.sin6_addr = IN6ADDR_ANY_INIT,
-        };
-        assert_se(sockaddr_equal(&a, &a));
-        assert_se(sockaddr_equal(&a, &b));
-        assert_se(sockaddr_equal(&d, &d));
-        assert_se(!sockaddr_equal(&a, &c));
-        assert_se(!sockaddr_equal(&b, &c));
-}
-
-int main(int argc, char *argv[]) {
-
-        log_set_max_level(LOG_DEBUG);
-
-        test_socket_address_parse();
-        test_socket_address_parse_netlink();
-        test_socket_address_equal();
-        test_socket_address_get_path();
-        test_socket_address_is();
-        test_socket_address_is_netlink();
-
-        test_in_addr_prefix_intersect();
-        test_in_addr_prefix_next();
-
-        test_nameinfo_pretty();
-
-        test_sockaddr_equal();
-
-        return 0;
-}
diff --git a/src/test/test-strbuf.c b/src/test/test-strbuf.c
deleted file mode 100644 (file)
index 4ec648a..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Thomas H.P. Andersen
-
-  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 "strbuf.h"
-#include "strv.h"
-#include "util.h"
-
-static ssize_t add_string(struct strbuf *sb, const char *s) {
-        return strbuf_add_string(sb, s, strlen(s));
-}
-
-static void test_strbuf(void) {
-        struct strbuf *sb;
-        _cleanup_strv_free_ char **l;
-        ssize_t a, b, c, d, e, f, g;
-
-        sb = strbuf_new();
-
-        a = add_string(sb, "waldo");
-        b = add_string(sb, "foo");
-        c = add_string(sb, "bar");
-        d = add_string(sb, "waldo");   /* duplicate */
-        e = add_string(sb, "aldo");    /* duplicate */
-        f = add_string(sb, "do");      /* duplicate */
-        g = add_string(sb, "waldorf"); /* not a duplicate: matches from tail */
-
-        /* check the content of the buffer directly */
-        l = strv_parse_nulstr(sb->buf, sb->len);
-
-        assert_se(streq(l[0], "")); /* root */
-        assert_se(streq(l[1], "waldo"));
-        assert_se(streq(l[2], "foo"));
-        assert_se(streq(l[3], "bar"));
-        assert_se(streq(l[4], "waldorf"));
-
-        assert_se(sb->nodes_count == 5); /* root + 4 non-duplicates */
-        assert_se(sb->dedup_count == 3);
-        assert_se(sb->in_count == 7);
-
-        assert_se(sb->in_len == 29);    /* length of all strings added */
-        assert_se(sb->dedup_len == 11); /* length of all strings duplicated */
-        assert_se(sb->len == 23);       /* buffer length: in - dedup + \0 for each node */
-
-        /* check the returned offsets and the respective content in the buffer */
-        assert_se(a == 1);
-        assert_se(b == 7);
-        assert_se(c == 11);
-        assert_se(d == 1);
-        assert_se(e == 2);
-        assert_se(f == 4);
-        assert_se(g == 15);
-
-        assert_se(streq(sb->buf + a, "waldo"));
-        assert_se(streq(sb->buf + b, "foo"));
-        assert_se(streq(sb->buf + c, "bar"));
-        assert_se(streq(sb->buf + d, "waldo"));
-        assert_se(streq(sb->buf + e, "aldo"));
-        assert_se(streq(sb->buf + f, "do"));
-        assert_se(streq(sb->buf + g, "waldorf"));
-
-        strbuf_complete(sb);
-        assert_se(sb->root == NULL);
-
-        strbuf_cleanup(sb);
-}
-
-int main(int argc, const char *argv[]) {
-        test_strbuf();
-
-        return 0;
-}
diff --git a/src/test/test-strip-tab-ansi.c b/src/test/test-strip-tab-ansi.c
deleted file mode 100644 (file)
index 5016906..0000000
+++ /dev/null
@@ -1,52 +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 <stdio.h>
-
-#include "util.h"
-
-int main(int argc, char *argv[]) {
-        char *p;
-
-        assert_se(p = strdup("\tFoobar\tbar\twaldo\t"));
-        assert_se(strip_tab_ansi(&p, NULL));
-        fprintf(stdout, "<%s>\n", p);
-        assert_se(streq(p, "        Foobar        bar        waldo        "));
-        free(p);
-
-        assert_se(p = strdup(ANSI_HIGHLIGHT_ON "Hello" ANSI_HIGHLIGHT_OFF ANSI_HIGHLIGHT_RED_ON " world!" ANSI_HIGHLIGHT_OFF));
-        assert_se(strip_tab_ansi(&p, NULL));
-        fprintf(stdout, "<%s>\n", p);
-        assert_se(streq(p, "Hello world!"));
-        free(p);
-
-        assert_se(p = strdup("\x1B[\x1B[\t\x1B[" ANSI_HIGHLIGHT_ON "\x1B[" "Hello" ANSI_HIGHLIGHT_OFF ANSI_HIGHLIGHT_RED_ON " world!" ANSI_HIGHLIGHT_OFF));
-        assert_se(strip_tab_ansi(&p, NULL));
-        assert_se(streq(p, "\x1B[\x1B[        \x1B[\x1B[Hello world!"));
-        free(p);
-
-        assert_se(p = strdup("\x1B[waldo"));
-        assert_se(strip_tab_ansi(&p, NULL));
-        assert_se(streq(p, "\x1B[waldo"));
-        free(p);
-
-        return 0;
-}
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
deleted file mode 100644 (file)
index d5ea2b3..0000000
+++ /dev/null
@@ -1,603 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-  Copyright 2013 Thomas H.P. Andersen
-
-  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"
-#include "strv.h"
-
-static void test_specifier_printf(void) {
-        static const Specifier table[] = {
-                { 'a', specifier_string, (char*) "AAAA" },
-                { 'b', specifier_string, (char*) "BBBB" },
-                { 'm', specifier_machine_id, NULL },
-                { 'B', specifier_boot_id, NULL },
-                { 'H', specifier_host_name, NULL },
-                { 'v', specifier_kernel_release, NULL },
-                {}
-        };
-
-        _cleanup_free_ char *w = NULL;
-        int r;
-
-        r = specifier_printf("xxx a=%a b=%b yyy", table, NULL, &w);
-        assert_se(r >= 0);
-        assert_se(w);
-
-        puts(w);
-        assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
-
-        free(w);
-        r = specifier_printf("machine=%m, boot=%B, host=%H, version=%v", table, NULL, &w);
-        assert_se(r >= 0);
-        assert_se(w);
-        puts(w);
-}
-
-static const char* const input_table_multiple[] = {
-        "one",
-        "two",
-        "three",
-        NULL,
-};
-
-static const char* const input_table_one[] = {
-        "one",
-        NULL,
-};
-
-static const char* const input_table_none[] = {
-        NULL,
-};
-
-static const char* const input_table_quotes[] = {
-        "\"",
-        "'",
-        "\"\"",
-        "\\",
-        "\\\\",
-        NULL,
-};
-#define QUOTES_STRING                            \
-        "\"\\\"\" "                              \
-        "\"\\\'\" "                              \
-        "\"\\\"\\\"\" "                          \
-        "\"\\\\\" "                              \
-        "\"\\\\\\\\\""
-
-static const char * const input_table_spaces[] = {
-        " ",
-        "' '",
-        "\" ",
-        " \"",
-        " \\\\ ",
-        NULL,
-};
-#define SPACES_STRING                           \
-        "\" \" "                                \
-        "\"\\' \\'\" "                          \
-        "\"\\\" \" "                            \
-        "\" \\\"\" "                            \
-        "\" \\\\\\\\ \""
-
-static void test_strv_find(void) {
-        assert_se(strv_find((char **)input_table_multiple, "three"));
-        assert_se(!strv_find((char **)input_table_multiple, "four"));
-}
-
-static void test_strv_find_prefix(void) {
-        assert_se(strv_find_prefix((char **)input_table_multiple, "o"));
-        assert_se(strv_find_prefix((char **)input_table_multiple, "one"));
-        assert_se(strv_find_prefix((char **)input_table_multiple, ""));
-        assert_se(!strv_find_prefix((char **)input_table_multiple, "xxx"));
-        assert_se(!strv_find_prefix((char **)input_table_multiple, "onee"));
-}
-
-static void test_strv_find_startswith(void) {
-        char *r;
-
-        r = strv_find_startswith((char **)input_table_multiple, "o");
-        assert_se(r && streq(r, "ne"));
-
-        r = strv_find_startswith((char **)input_table_multiple, "one");
-        assert_se(r && streq(r, ""));
-
-        r = strv_find_startswith((char **)input_table_multiple, "");
-        assert_se(r && streq(r, "one"));
-
-        assert_se(!strv_find_startswith((char **)input_table_multiple, "xxx"));
-        assert_se(!strv_find_startswith((char **)input_table_multiple, "onee"));
-}
-
-static void test_strv_join(void) {
-        _cleanup_free_ char *p = NULL, *q = NULL, *r = NULL, *s = NULL, *t = NULL;
-
-        p = strv_join((char **)input_table_multiple, ", ");
-        assert_se(p);
-        assert_se(streq(p, "one, two, three"));
-
-        q = strv_join((char **)input_table_multiple, ";");
-        assert_se(q);
-        assert_se(streq(q, "one;two;three"));
-
-        r = strv_join((char **)input_table_multiple, NULL);
-        assert_se(r);
-        assert_se(streq(r, "one two three"));
-
-        s = strv_join((char **)input_table_one, ", ");
-        assert_se(s);
-        assert_se(streq(s, "one"));
-
-        t = strv_join((char **)input_table_none, ", ");
-        assert_se(t);
-        assert_se(streq(t, ""));
-}
-
-static void test_strv_quote_unquote(const char* const *split, const char *quoted) {
-        _cleanup_free_ char *p;
-        _cleanup_strv_free_ char **s;
-        char **t;
-        int r;
-
-        p = strv_join_quoted((char **)split);
-        assert_se(p);
-        printf("-%s- --- -%s-\n", p, quoted); /* fprintf deals with NULL, puts does not */
-        assert_se(p);
-        assert_se(streq(p, quoted));
-
-        r = strv_split_quoted(&s, quoted, 0);
-        assert_se(r == 0);
-        assert_se(s);
-        STRV_FOREACH(t, s) {
-                assert_se(*t);
-                assert_se(streq(*t, *split));
-                split++;
-        }
-}
-
-static void test_strv_unquote(const char *quoted, char **list) {
-        _cleanup_strv_free_ char **s;
-        _cleanup_free_ char *j;
-        unsigned i = 0;
-        char **t;
-        int r;
-
-        r = strv_split_quoted(&s, quoted, 0);
-        assert_se(r == 0);
-        assert_se(s);
-        j = strv_join(s, " | ");
-        assert_se(j);
-        puts(j);
-
-        STRV_FOREACH(t, s)
-                assert_se(streq(list[i++], *t));
-
-        assert_se(list[i] == NULL);
-}
-
-static void test_invalid_unquote(const char *quoted) {
-        char **s = NULL;
-        int r;
-
-        r = strv_split_quoted(&s, quoted, 0);
-        assert_se(s == NULL);
-        assert_se(r == -EINVAL);
-}
-
-static void test_strv_split(void) {
-        char **s;
-        unsigned i = 0;
-        _cleanup_strv_free_ char **l = NULL;
-        const char str[] = "one,two,three";
-
-        l = strv_split(str, ",");
-
-        assert_se(l);
-
-        STRV_FOREACH(s, l) {
-                assert_se(streq(*s, input_table_multiple[i++]));
-        }
-}
-
-static void test_strv_split_newlines(void) {
-        unsigned i = 0;
-        char **s;
-        _cleanup_strv_free_ char **l = NULL;
-        const char str[] = "one\ntwo\nthree";
-
-        l = strv_split_newlines(str);
-
-        assert_se(l);
-
-        STRV_FOREACH(s, l) {
-                assert_se(streq(*s, input_table_multiple[i++]));
-        }
-}
-
-static void test_strv_split_nulstr(void) {
-        _cleanup_strv_free_ char **l = NULL;
-        const char nulstr[] = "str0\0str1\0str2\0str3\0";
-
-        l = strv_split_nulstr (nulstr);
-        assert_se(l);
-
-        assert_se(streq(l[0], "str0"));
-        assert_se(streq(l[1], "str1"));
-        assert_se(streq(l[2], "str2"));
-        assert_se(streq(l[3], "str3"));
-}
-
-static void test_strv_parse_nulstr(void) {
-        _cleanup_strv_free_ char **l = NULL;
-        const char nulstr[] = "fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx";
-
-        l = strv_parse_nulstr(nulstr, sizeof(nulstr)-1);
-        assert_se(l);
-        puts("Parse nulstr:");
-        strv_print(l);
-
-        assert_se(streq(l[0], "fuck"));
-        assert_se(streq(l[1], "fuck2"));
-        assert_se(streq(l[2], "fuck3"));
-        assert_se(streq(l[3], ""));
-        assert_se(streq(l[4], "fuck5"));
-        assert_se(streq(l[5], ""));
-        assert_se(streq(l[6], "xxx"));
-}
-
-static void test_strv_overlap(void) {
-        const char * const input_table[] = {
-                "one",
-                "two",
-                "three",
-                NULL
-        };
-        const char * const input_table_overlap[] = {
-                "two",
-                NULL
-        };
-        const char * const input_table_unique[] = {
-                "four",
-                "five",
-                "six",
-                NULL
-        };
-
-        assert_se(strv_overlap((char **)input_table, (char**)input_table_overlap));
-        assert_se(!strv_overlap((char **)input_table, (char**)input_table_unique));
-}
-
-static void test_strv_sort(void) {
-        const char* input_table[] = {
-                "durian",
-                "apple",
-                "citrus",
-                 "CAPITAL LETTERS FIRST",
-                "banana",
-                NULL
-        };
-
-        strv_sort((char **)input_table);
-
-        assert_se(streq(input_table[0], "CAPITAL LETTERS FIRST"));
-