chiark / gitweb /
Prep v238: Remove obsolete sources and add missing new ones.
authorSven Eden <yamakuzure@gmx.net>
Tue, 5 Jun 2018 17:03:51 +0000 (19:03 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 5 Jun 2018 17:08:49 +0000 (19:08 +0200)
cb/elogind.cbp
src/basic/blockdev-util.c [deleted file]
src/basic/meson.build
src/basic/raw-clone.h [new file with mode: 0644]
src/basic/special.h [new file with mode: 0644]
src/libelogind/sd-bus/test-bus-watch-bind.c [deleted file]
src/test/test-gcrypt-util.c [deleted file]
src/test/test-watch-pid.c [deleted file]

index e65d96c8e62f064518a81fdce21988caf4df4ba4..e77cdfaf05353c23d1075c32bf1976d5b925fe9d 100644 (file)
                        <Option target="all" />
                        <Option target="clean" />
                </Unit>
+               <Unit filename="../src/basic/procfs-util.c">
+                       <Option compilerVar="CC" />
+               </Unit>
+               <Unit filename="../src/basic/procfs-util.h" />
                <Unit filename="../src/basic/random-util.c">
                        <Option compilerVar="CC" />
                        <Option target="all" />
                        <Option target="all" />
                        <Option target="clean" />
                </Unit>
+               <Unit filename="../src/basic/raw-clone.h" />
                <Unit filename="../src/basic/refcnt.h">
                        <Option target="all" />
                        <Option target="clean" />
                        <Option target="all" />
                        <Option target="clean" />
                </Unit>
+               <Unit filename="../src/basic/special.h" />
                <Unit filename="../src/basic/stat-util.c">
                        <Option compilerVar="CC" />
                        <Option target="all" />
                        <Option target="all" />
                        <Option target="clean" />
                </Unit>
+               <Unit filename="../src/test/test-procfs-util.c">
+                       <Option compilerVar="CC" />
+               </Unit>
                <Unit filename="../src/test/test-random-util.c">
                        <Option compilerVar="CC" />
                        <Option target="all" />
diff --git a/src/basic/blockdev-util.c b/src/basic/blockdev-util.c
deleted file mode 100644 (file)
index b7b86ab..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  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 <sys/stat.h>
-//#include <sys/statfs.h>
-
-//#include "alloc-util.h"
-//#include "blockdev-util.h"
-//#include "btrfs-util.h"
-//#include "dirent-util.h"
-//#include "fd-util.h"
-//#include "fileio.h"
-//#include "missing.h"
-//#include "stat-util.h"
-
-int block_get_whole_disk(dev_t d, dev_t *ret) {
-        char p[SYS_BLOCK_PATH_MAX("/partition")];
-        _cleanup_free_ char *s = NULL;
-        unsigned n, m;
-        int r;
-
-        assert(ret);
-
-        /* If it has a queue this is good enough for us */
-        xsprintf_sys_block_path(p, "/queue", d);
-        if (access(p, F_OK) >= 0) {
-                *ret = d;
-                return 0;
-        }
-
-        /* If it is a partition find the originating device */
-        xsprintf_sys_block_path(p, "/partition", d);
-        if (access(p, F_OK) < 0)
-                return -ENOENT;
-
-        /* Get parent dev_t */
-        xsprintf_sys_block_path(p, "/../dev", d);
-        r = read_one_line_file(p, &s);
-        if (r < 0)
-                return r;
-
-        r = sscanf(s, "%u:%u", &m, &n);
-        if (r != 2)
-                return -EINVAL;
-
-        /* Only return this if it is really good enough for us. */
-        xsprintf_sys_block_path(p, "/queue", makedev(m, n));
-        if (access(p, F_OK) < 0)
-                return -ENOENT;
-
-        *ret = makedev(m, n);
-        return 0;
-}
-
-int get_block_device(const char *path, dev_t *dev) {
-        struct stat st;
-        struct statfs sfs;
-
-        assert(path);
-        assert(dev);
-
-        /* Get's the block device directly backing a file system. If
-         * the block device is encrypted, returns the device mapper
-         * block device. */
-
-        if (lstat(path, &st))
-                return -errno;
-
-        if (major(st.st_dev) != 0) {
-                *dev = st.st_dev;
-                return 1;
-        }
-
-        if (statfs(path, &sfs) < 0)
-                return -errno;
-
-        if (F_TYPE_EQUAL(sfs.f_type, BTRFS_SUPER_MAGIC))
-                return btrfs_get_block_device(path, dev);
-
-        return 0;
-}
-
-int get_block_device_harder(const char *path, dev_t *dev) {
-        _cleanup_closedir_ DIR *d = NULL;
-        _cleanup_free_ char *t = NULL;
-        char p[SYS_BLOCK_PATH_MAX("/slaves")];
-        struct dirent *de, *found = NULL;
-        const char *q;
-        unsigned maj, min;
-        dev_t dt;
-        int r;
-
-        assert(path);
-        assert(dev);
-
-        /* Gets the backing block device for a file system, and
-         * handles LUKS encrypted file systems, looking for its
-         * immediate parent, if there is one. */
-
-        r = get_block_device(path, &dt);
-        if (r <= 0)
-                return r;
-
-        xsprintf_sys_block_path(p, "/slaves", dt);
-        d = opendir(p);
-        if (!d) {
-                if (errno == ENOENT)
-                        goto fallback;
-
-                return -errno;
-        }
-
-        FOREACH_DIRENT_ALL(de, d, return -errno) {
-
-                if (dot_or_dot_dot(de->d_name))
-                        continue;
-
-                if (!IN_SET(de->d_type, DT_LNK, DT_UNKNOWN))
-                        continue;
-
-                if (found) {
-                        _cleanup_free_ char *u = NULL, *v = NULL, *a = NULL, *b = NULL;
-
-                        /* We found a device backed by multiple other devices. We don't really support automatic
-                         * discovery on such setups, with the exception of dm-verity partitions. In this case there are
-                         * two backing devices: the data partition and the hash partition. We are fine with such
-                         * setups, however, only if both partitions are on the same physical device. Hence, let's
-                         * verify this. */
-
-                        u = strjoin(p, "/", de->d_name, "/../dev");
-                        if (!u)
-                                return -ENOMEM;
-
-                        v = strjoin(p, "/", found->d_name, "/../dev");
-                        if (!v)
-                                return -ENOMEM;
-
-                        r = read_one_line_file(u, &a);
-                        if (r < 0) {
-                                log_debug_errno(r, "Failed to read %s: %m", u);
-                                goto fallback;
-                        }
-
-                        r = read_one_line_file(v, &b);
-                        if (r < 0) {
-                                log_debug_errno(r, "Failed to read %s: %m", v);
-                                goto fallback;
-                        }
-
-                        /* Check if the parent device is the same. If not, then the two backing devices are on
-                         * different physical devices, and we don't support that. */
-                        if (!streq(a, b))
-                                goto fallback;
-                }
-
-                found = de;
-        }
-
-        if (!found)
-                goto fallback;
-
-        q = strjoina(p, "/", found->d_name, "/dev");
-
-        r = read_one_line_file(q, &t);
-        if (r == -ENOENT)
-                goto fallback;
-        if (r < 0)
-                return r;
-
-        if (sscanf(t, "%u:%u", &maj, &min) != 2)
-                return -EINVAL;
-
-        if (maj == 0)
-                goto fallback;
-
-        *dev = makedev(maj, min);
-        return 1;
-
-fallback:
-        *dev = dt;
-        return 1;
-}
index 1f23863553b6431ad7d923e256aafe1ef43ea8fd..02cca79d731eff418f115b94c50f0c6d7c6e1991 100644 (file)
@@ -317,6 +317,8 @@ basic_sources = files('''
         prioq.h
         proc-cmdline.c
         proc-cmdline.h
+        procfs-util.c
+        procfs-util.h
         process-util.c
         process-util.h
         random-util.c
@@ -339,6 +341,7 @@ basic_sources = files('''
         socket-util.c
         socket-util.h
         sparse-endian.h
+        special.h
         stat-util.c
         stat-util.h
         stdio-util.h
@@ -386,7 +389,7 @@ generate_gperfs = find_program('generate-gperfs.py')
 #         output : 'af-list.txt',
 #         command : [generate_af_list, cpp],
 #         capture : true)
-# 
+#
 # generate_arphrd_list = find_program('generate-arphrd-list.sh')
 # arphrd_list_txt = custom_target(
 #         'arphrd-list.txt',
diff --git a/src/basic/raw-clone.h b/src/basic/raw-clone.h
new file mode 100644 (file)
index 0000000..8c95380
--- /dev/null
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+  Copyright 2016 Michael Karcher
+  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 <sys/syscall.h>
+
+#include "log.h"
+#include "macro.h"
+
+/**
+ * raw_clone() - uses clone to create a new process with clone flags
+ * @flags: Flags to pass to the clone system call
+ *
+ * Uses the clone system call to create a new process with the cloning flags and termination signal passed in the flags
+ * parameter. Opposed to glibc's clone funtion, using this function does not set up a separate stack for the child, but
+ * relies on copy-on-write semantics on the one stack at a common virtual address, just as fork does.
+ *
+ * To obtain copy-on-write semantics, flags must not contain CLONE_VM, and thus CLONE_THREAD and CLONE_SIGHAND (which
+ * require CLONE_VM) are not usable.
+ *
+ * Additionally, as this function does not pass the ptid, newtls and ctid parameters to the kernel, flags must not
+ * contain CLONE_PARENT_SETTID, CLONE_CHILD_SETTID, CLONE_CHILD_CLEARTID or CLONE_SETTLS.
+ *
+ * Returns: 0 in the child process and the child process id in the parent.
+ */
+static inline pid_t raw_clone(unsigned long flags) {
+        pid_t ret;
+
+        assert((flags & (CLONE_VM|CLONE_PARENT_SETTID|CLONE_CHILD_SETTID|
+                         CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0);
+#if defined(__s390x__) || defined(__s390__) || defined(__CRIS__)
+        /* On s390/s390x and cris the order of the first and second arguments
+         * of the raw clone() system call is reversed. */
+        ret = (pid_t) syscall(__NR_clone, NULL, flags);
+#elif defined(__sparc__) && defined(__arch64__)
+        {
+                /**
+                 * sparc64 always returns the other process id in %o0, and
+                 * a boolean flag whether this is the child or the parent in
+                 * %o1. Inline assembly is needed to get the flag returned
+                 * in %o1.
+                 */
+                int in_child, child_pid;
+
+                asm volatile("mov %2, %%g1\n\t"
+                             "mov %3, %%o0\n\t"
+                             "mov 0 , %%o1\n\t"
+                             "t 0x6d\n\t"
+                             "mov %%o1, %0\n\t"
+                             "mov %%o0, %1" :
+                             "=r"(in_child), "=r"(child_pid) :
+                             "i"(__NR_clone), "r"(flags) :
+                             "%o1", "%o0", "%g1" );
+
+                ret = in_child ? 0 : child_pid;
+        }
+#else
+        ret = (pid_t) syscall(__NR_clone, flags, NULL);
+#endif
+
+        if (ret == 0)
+                reset_cached_pid();
+
+        return ret;
+}
diff --git a/src/basic/special.h b/src/basic/special.h
new file mode 100644 (file)
index 0000000..c058b1d
--- /dev/null
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+/***
+  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/>.
+***/
+
+#define SPECIAL_DEFAULT_TARGET "default.target"
+
+/* Shutdown targets */
+#define SPECIAL_UMOUNT_TARGET "umount.target"
+/* This is not really intended to be started by directly. This is
+ * mostly so that other targets (reboot/halt/poweroff) can depend on
+ * it to bring all services down that want to be brought down on
+ * system shutdown. */
+#define SPECIAL_SHUTDOWN_TARGET "shutdown.target"
+#define SPECIAL_HALT_TARGET "halt.target"
+#define SPECIAL_POWEROFF_TARGET "poweroff.target"
+#define SPECIAL_REBOOT_TARGET "reboot.target"
+#define SPECIAL_KEXEC_TARGET "kexec.target"
+#define SPECIAL_EXIT_TARGET "exit.target"
+#define SPECIAL_SUSPEND_TARGET "suspend.target"
+#define SPECIAL_HIBERNATE_TARGET "hibernate.target"
+#define SPECIAL_HYBRID_SLEEP_TARGET "hybrid-sleep.target"
+
+/* Special boot targets */
+#define SPECIAL_RESCUE_TARGET "rescue.target"
+#define SPECIAL_EMERGENCY_TARGET "emergency.target"
+#define SPECIAL_MULTI_USER_TARGET "multi-user.target"
+#define SPECIAL_GRAPHICAL_TARGET "graphical.target"
+
+/* Early boot targets */
+#define SPECIAL_SYSINIT_TARGET "sysinit.target"
+#define SPECIAL_SOCKETS_TARGET "sockets.target"
+#define SPECIAL_TIMERS_TARGET "timers.target"
+#define SPECIAL_PATHS_TARGET "paths.target"
+#define SPECIAL_LOCAL_FS_TARGET "local-fs.target"
+#define SPECIAL_LOCAL_FS_PRE_TARGET "local-fs-pre.target"
+#define SPECIAL_INITRD_FS_TARGET "initrd-fs.target"
+#define SPECIAL_INITRD_ROOT_DEVICE_TARGET "initrd-root-device.target"
+#define SPECIAL_INITRD_ROOT_FS_TARGET "initrd-root-fs.target"
+#define SPECIAL_REMOTE_FS_TARGET "remote-fs.target"       /* LSB's $remote_fs */
+#define SPECIAL_REMOTE_FS_PRE_TARGET "remote-fs-pre.target"
+#define SPECIAL_SWAP_TARGET "swap.target"
+#define SPECIAL_NETWORK_ONLINE_TARGET "network-online.target"
+#define SPECIAL_TIME_SYNC_TARGET "time-sync.target"       /* LSB's $time */
+#define SPECIAL_BASIC_TARGET "basic.target"
+
+/* LSB compatibility */
+#define SPECIAL_NETWORK_TARGET "network.target"           /* LSB's $network */
+#define SPECIAL_NSS_LOOKUP_TARGET "nss-lookup.target"     /* LSB's $named */
+#define SPECIAL_RPCBIND_TARGET "rpcbind.target"           /* LSB's $portmap */
+
+/*
+ * Rules regarding adding further high level targets like the above:
+ *
+ * - Be conservative, only add more of these when we really need
+ *   them. We need strong usecases for further additions.
+ *
+ * - When there can be multiple implementations running side-by-side,
+ *   it needs to be a .target unit which can pull in all
+ *   implementations.
+ *
+ * - If something can be implemented with socket activation, and
+ *   without, it needs to be a .target unit, so that it can pull in
+ *   the appropriate unit.
+ *
+ * - Otherwise, it should be a .service unit.
+ *
+ * - In some cases it is OK to have both a .service and a .target
+ *   unit, i.e. if there can be multiple parallel implementations, but
+ *   only one is the "system" one. Example: syslog.
+ *
+ * Or to put this in other words: .service symlinks can be used to
+ * arbitrate between multiple implementations if there can be only one
+ * of a kind. .target units can be used to support multiple
+ * implementations that can run side-by-side.
+ */
+
+/* Magic early boot services */
+#define SPECIAL_FSCK_SERVICE "systemd-fsck@.service"
+#define SPECIAL_QUOTACHECK_SERVICE "systemd-quotacheck.service"
+#define SPECIAL_QUOTAON_SERVICE "quotaon.service"
+#define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service"
+
+/* Services systemd relies on */
+#define SPECIAL_DBUS_SERVICE "dbus.service"
+#define SPECIAL_DBUS_SOCKET "dbus.socket"
+#define SPECIAL_JOURNALD_SOCKET "systemd-journald.socket"
+#define SPECIAL_JOURNALD_SERVICE "systemd-journald.service"
+#define SPECIAL_TMPFILES_SETUP_SERVICE "systemd-tmpfiles-setup.service"
+
+/* Magic init signals */
+#define SPECIAL_KBREQUEST_TARGET "kbrequest.target"
+#define SPECIAL_SIGPWR_TARGET "sigpwr.target"
+#define SPECIAL_CTRL_ALT_DEL_TARGET "ctrl-alt-del.target"
+
+/* Where we add all our system units, users and machines by default */
+#define SPECIAL_SYSTEM_SLICE "system.slice"
+#define SPECIAL_USER_SLICE "user.slice"
+#define SPECIAL_MACHINE_SLICE "machine.slice"
+#define SPECIAL_ROOT_SLICE "-.slice"
+
+/* The scope unit systemd itself lives in. */
+#define SPECIAL_INIT_SCOPE "init.scope"
+
+/* The root directory. */
+#define SPECIAL_ROOT_MOUNT "-.mount"
diff --git a/src/libelogind/sd-bus/test-bus-watch-bind.c b/src/libelogind/sd-bus/test-bus-watch-bind.c
deleted file mode 100644 (file)
index 38c80fd..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2017 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 <pthread.h>
-
-//#include "sd-bus.h"
-//#include "sd-event.h"
-//#include "sd-id128.h"
-
-//#include "alloc-util.h"
-//#include "fd-util.h"
-//#include "fileio.h"
-//#include "fs-util.h"
-//#include "mkdir.h"
-//#include "path-util.h"
-//#include "random-util.h"
-//#include "rm-rf.h"
-//#include "socket-util.h"
-//#include "string-util.h"
-
-static int method_foobar(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
-        log_info("Got Foobar() call.");
-
-        assert_se(sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), 0) >= 0);
-        return sd_bus_reply_method_return(m, NULL);
-}
-
-static int method_exit(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
-        log_info("Got Exit() call");
-        assert_se(sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), 1) >= 0);
-        return sd_bus_reply_method_return(m, NULL);
-}
-
-static const sd_bus_vtable vtable[] = {
-        SD_BUS_VTABLE_START(0),
-        SD_BUS_METHOD("Foobar", NULL, NULL, method_foobar, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("Exit", NULL, NULL, method_exit, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_VTABLE_END,
-};
-
-static void* thread_server(void *p) {
-        _cleanup_free_ char *suffixed = NULL, *suffixed2 = NULL, *d = NULL;
-        _cleanup_close_ int fd = -1;
-        union sockaddr_union u = {
-                .un.sun_family = AF_UNIX,
-        };
-        const char *path = p;
-
-        log_debug("Initializing server");
-
-        /* Let's play some games, by slowly creating the socket directory, and renaming it in the middle */
-        (void) usleep(100 * USEC_PER_MSEC);
-
-        assert_se(mkdir_parents(path, 0755) >= 0);
-        (void) usleep(100 * USEC_PER_MSEC);
-
-        d = dirname_malloc(path);
-        assert_se(d);
-        assert_se(asprintf(&suffixed, "%s.%" PRIx64, d, random_u64()) >= 0);
-        assert_se(rename(d, suffixed) >= 0);
-        (void) usleep(100 * USEC_PER_MSEC);
-
-        assert_se(asprintf(&suffixed2, "%s.%" PRIx64, d, random_u64()) >= 0);
-        assert_se(symlink(suffixed2, d) >= 0);
-        (void) usleep(100 * USEC_PER_MSEC);
-
-        assert_se(symlink(basename(suffixed), suffixed2) >= 0);
-        (void) usleep(100 * USEC_PER_MSEC);
-
-        strncpy(u.un.sun_path, path, sizeof(u.un.sun_path));
-
-        fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
-        assert_se(fd >= 0);
-
-        assert_se(bind(fd, &u.sa, SOCKADDR_UN_LEN(u.un)) >= 0);
-        usleep(100 * USEC_PER_MSEC);
-
-        assert_se(listen(fd, SOMAXCONN) >= 0);
-        usleep(100 * USEC_PER_MSEC);
-
-        assert_se(touch(path) >= 0);
-        usleep(100 * USEC_PER_MSEC);
-
-        log_debug("Initialized server");
-
-        for (;;) {
-                _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
-                _cleanup_(sd_event_unrefp) sd_event *event = NULL;
-                sd_id128_t id;
-                int bus_fd, code;
-
-                assert_se(sd_id128_randomize(&id) >= 0);
-
-                assert_se(sd_event_new(&event) >= 0);
-
-                bus_fd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
-                assert_se(bus_fd >= 0);
-
-                log_debug("Accepted server connection");
-
-                assert_se(sd_bus_new(&bus) >= 0);
-                assert_se(sd_bus_set_description(bus, "server") >= 0);
-                assert_se(sd_bus_set_fd(bus, bus_fd, bus_fd) >= 0);
-                assert_se(sd_bus_set_server(bus, true, id) >= 0);
-                /* assert_se(sd_bus_set_anonymous(bus, true) >= 0); */
-
-                assert_se(sd_bus_attach_event(bus, event, 0) >= 0);
-
-                assert_se(sd_bus_add_object_vtable(bus, NULL, "/foo", "foo.TestInterface", vtable, NULL) >= 0);
-
-                assert_se(sd_bus_start(bus) >= 0);
-
-                assert_se(sd_event_loop(event) >= 0);
-
-                assert_se(sd_event_get_exit_code(event, &code) >= 0);
-
-                if (code > 0)
-                        break;
-        }
-
-        log_debug("Server done");
-
-        return NULL;
-}
-
-static void* thread_client1(void *p) {
-        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
-        const char *path = p, *t;
-        int r;
-
-        log_debug("Initializing client1");
-
-        assert_se(sd_bus_new(&bus) >= 0);
-        assert_se(sd_bus_set_description(bus, "client1") >= 0);
-
-        t = strjoina("unix:path=", path);
-        assert_se(sd_bus_set_address(bus, t) >= 0);
-        assert_se(sd_bus_set_watch_bind(bus, true) >= 0);
-        assert_se(sd_bus_start(bus) >= 0);
-
-        r = sd_bus_call_method(bus, "foo.bar", "/foo", "foo.TestInterface", "Foobar", &error, NULL, NULL);
-        assert_se(r >= 0);
-
-        log_debug("Client1 done");
-
-        return NULL;
-}
-
-static int client2_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
-        assert_se(sd_bus_message_is_method_error(m, NULL) == 0);
-        assert_se(sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), 0) >= 0);
-        return 0;
-}
-
-static void* thread_client2(void *p) {
-        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
-        _cleanup_(sd_event_unrefp) sd_event *event = NULL;
-        const char *path = p, *t;
-
-        log_debug("Initializing client2");
-
-        assert_se(sd_event_new(&event) >= 0);
-        assert_se(sd_bus_new(&bus) >= 0);
-        assert_se(sd_bus_set_description(bus, "client2") >= 0);
-
-        t = strjoina("unix:path=", path);
-        assert_se(sd_bus_set_address(bus, t) >= 0);
-        assert_se(sd_bus_set_watch_bind(bus, true) >= 0);
-        assert_se(sd_bus_attach_event(bus, event, 0) >= 0);
-        assert_se(sd_bus_start(bus) >= 0);
-
-        assert_se(sd_bus_call_method_async(bus, NULL, "foo.bar", "/foo", "foo.TestInterface", "Foobar", client2_callback, NULL, NULL) >= 0);
-
-        assert_se(sd_event_loop(event) >= 0);
-
-        log_debug("Client2 done");
-
-        return NULL;
-}
-
-static void request_exit(const char *path) {
-        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
-        const char *t;
-
-        assert_se(sd_bus_new(&bus) >= 0);
-
-        t = strjoina("unix:path=", path);
-        assert_se(sd_bus_set_address(bus, t) >= 0);
-        assert_se(sd_bus_set_watch_bind(bus, true) >= 0);
-        assert_se(sd_bus_set_description(bus, "request-exit") >= 0);
-        assert_se(sd_bus_start(bus) >= 0);
-
-        assert_se(sd_bus_call_method(bus, "foo.bar", "/foo", "foo.TestInterface", "Exit", NULL, NULL, NULL) >= 0);
-}
-
-int main(int argc, char *argv[]) {
-        _cleanup_(rm_rf_physical_and_freep) char *d = NULL;
-        pthread_t server, client1, client2;
-        char *path;
-
-        log_set_max_level(LOG_DEBUG);
-
-        /* We use /dev/shm here rather than /tmp, since some weird distros might set up /tmp as some weird fs that
-         * doesn't support inotify properly. */
-        assert_se(mkdtemp_malloc("/dev/shm/elogind-watch-bind-XXXXXX", &d) >= 0);
-
-        path = strjoina(d, "/this/is/a/socket");
-
-        assert_se(pthread_create(&server, NULL, thread_server, path) == 0);
-        assert_se(pthread_create(&client1, NULL, thread_client1, path) == 0);
-        assert_se(pthread_create(&client2, NULL, thread_client2, path) == 0);
-
-        assert_se(pthread_join(client1, NULL) == 0);
-        assert_se(pthread_join(client2, NULL) == 0);
-
-        request_exit(path);
-
-        assert_se(pthread_join(server, NULL) == 0);
-
-        return 0;
-}
diff --git a/src/test/test-gcrypt-util.c b/src/test/test-gcrypt-util.c
deleted file mode 100644 (file)
index 9f0ed21..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+
- * Copyright 2018 Zbigniew JÄ™drzejewski-Szmek
- */
-
-//#include "alloc-util.h"
-//#include "gcrypt-util.h"
-//#include "macro.h"
-//#include "string-util.h"
-
-static void test_string_hashsum(void) {
-        _cleanup_free_ char *out1 = NULL, *out2 = NULL, *out3 = NULL, *out4 = NULL;
-
-        assert_se(string_hashsum("asdf", 4, GCRY_MD_SHA224, &out1) == 0);
-        /* echo -n 'asdf' | sha224sum - */
-        assert_se(streq(out1, "7872a74bcbf298a1e77d507cd95d4f8d96131cbbd4cdfc571e776c8a"));
-
-        assert_se(string_hashsum("asdf", 4, GCRY_MD_SHA256, &out2) == 0);
-        /* echo -n 'asdf' | sha256sum - */
-        assert_se(streq(out2, "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"));
-
-        assert_se(string_hashsum("", 0, GCRY_MD_SHA224, &out3) == 0);
-        /* echo -n '' | sha224sum - */
-        assert_se(streq(out3, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"));
-
-        assert_se(string_hashsum("", 0, GCRY_MD_SHA256, &out4) == 0);
-        /* echo -n '' | sha256sum - */
-        assert_se(streq(out4, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
-}
-
-int main(int argc, char **argv) {
-        test_string_hashsum();
-
-        return 0;
-}
diff --git a/src/test/test-watch-pid.c b/src/test/test-watch-pid.c
deleted file mode 100644 (file)
index 37ff2e4..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-//#include "log.h"
-//#include "manager.h"
-//#include "rm-rf.h"
-//#include "test-helper.h"
-//#include "tests.h"
-
-int main(int argc, char *argv[]) {
-        _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
-        Unit *a, *b, *c, *u;
-        Manager *m;
-        int r;
-
-        log_set_max_level(LOG_DEBUG);
-        log_parse_environment();
-        log_open();
-
-        if (getuid() != 0) {
-                log_notice("Not running as root, skipping kernel related tests.");
-                return EXIT_TEST_SKIP;
-        }
-
-        r = enter_cgroup_subroot();
-        if (r == -ENOMEDIUM) {
-                log_notice("cgroupfs not available, skipping tests");
-                return EXIT_TEST_SKIP;
-        }
-
-        assert_se(set_unit_path(get_testdata_dir("")) >= 0);
-        assert_se(runtime_dir = setup_fake_runtime_dir());
-
-        assert_se(manager_new(UNIT_FILE_USER, true, &m) >= 0);
-        assert_se(manager_startup(m, NULL, NULL) >= 0);
-
-        assert_se(a = unit_new(m, sizeof(Service)));
-        assert_se(unit_add_name(a, "a.service") >= 0);
-        assert_se(set_isempty(a->pids));
-
-        assert_se(b = unit_new(m, sizeof(Service)));
-        assert_se(unit_add_name(b, "b.service") >= 0);
-        assert_se(set_isempty(b->pids));
-
-        assert_se(c = unit_new(m, sizeof(Service)));
-        assert_se(unit_add_name(c, "c.service") >= 0);
-        assert_se(set_isempty(c->pids));
-
-        assert_se(hashmap_isempty(m->watch_pids));
-        assert_se(manager_get_unit_by_pid(m, 4711) == NULL);
-
-        assert_se(unit_watch_pid(a, 4711) >= 0);
-        assert_se(manager_get_unit_by_pid(m, 4711) == a);
-
-        assert_se(unit_watch_pid(a, 4711) >= 0);
-        assert_se(manager_get_unit_by_pid(m, 4711) == a);
-
-        assert_se(unit_watch_pid(b, 4711) >= 0);
-        u = manager_get_unit_by_pid(m, 4711);
-        assert_se(u == a || u == b);
-
-        assert_se(unit_watch_pid(b, 4711) >= 0);
-        u = manager_get_unit_by_pid(m, 4711);
-        assert_se(u == a || u == b);
-
-        assert_se(unit_watch_pid(c, 4711) >= 0);
-        u = manager_get_unit_by_pid(m, 4711);
-        assert_se(u == a || u == b || u == c);
-
-        assert_se(unit_watch_pid(c, 4711) >= 0);
-        u = manager_get_unit_by_pid(m, 4711);
-        assert_se(u == a || u == b || u == c);
-
-        unit_unwatch_pid(b, 4711);
-        u = manager_get_unit_by_pid(m, 4711);
-        assert_se(u == a || u == c);
-
-        unit_unwatch_pid(b, 4711);
-        u = manager_get_unit_by_pid(m, 4711);
-        assert_se(u == a || u == c);
-
-        unit_unwatch_pid(a, 4711);
-        assert_se(manager_get_unit_by_pid(m, 4711) == c);
-
-        unit_unwatch_pid(a, 4711);
-        assert_se(manager_get_unit_by_pid(m, 4711) == c);
-
-        unit_unwatch_pid(c, 4711);
-        assert_se(manager_get_unit_by_pid(m, 4711) == NULL);
-
-        unit_unwatch_pid(c, 4711);
-        assert_se(manager_get_unit_by_pid(m, 4711) == NULL);
-
-        manager_free(m);
-
-        return 0;
-}