chiark / gitweb /
Prep v233.3: Unmask various functions for future coverage tests.
authorSven Eden <yamakuzure@gmx.net>
Tue, 18 Jul 2017 22:56:25 +0000 (00:56 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 19 Jul 2017 11:04:57 +0000 (13:04 +0200)
These functions, although not used by elogind itself, are mostly tiny
and crucial for important tests to work.

34 files changed:
man/sd_booted.xml [new file with mode: 0644]
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/conf-files.c
src/basic/conf-files.h
src/basic/fs-util.c
src/basic/fs-util.h
src/basic/hashmap.c
src/basic/hashmap.h
src/basic/parse-util.c
src/basic/parse-util.h
src/basic/path-util.c
src/basic/path-util.h
src/basic/selinux-util.c
src/basic/selinux-util.h
src/basic/signal-util.c
src/basic/signal-util.h
src/basic/strv.c
src/basic/strv.h
src/core/mount-setup.c
src/libelogind/libelogind.sym
src/libelogind/sd-bus/bus-kernel.c
src/libelogind/sd-bus/bus-kernel.h
src/libelogind/sd-bus/bus-message.c
src/libelogind/sd-bus/sd-bus.c
src/libelogind/sd-daemon/sd-daemon.c
src/libelogind/sd-event/sd-event.c
src/libelogind/sd-id128/id128-util.c
src/libelogind/sd-id128/id128-util.h
src/shared/tests.c [new file with mode: 0644]
src/shared/tests.h [new file with mode: 0644]
src/systemd/sd-bus.h
src/systemd/sd-daemon.h
src/systemd/sd-event.h

diff --git a/man/sd_booted.xml b/man/sd_booted.xml
new file mode 100644 (file)
index 0000000..d9c4013
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<!--
+  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/>.
+-->
+
+<refentry id="sd_booted"
+  xmlns:xi="http://www.w3.org/2001/XInclude">
+
+  <refentryinfo>
+    <title>sd_booted</title>
+    <productname>systemd</productname>
+
+    <authorgroup>
+      <author>
+        <contrib>Developer</contrib>
+        <firstname>Lennart</firstname>
+        <surname>Poettering</surname>
+        <email>lennart@poettering.net</email>
+      </author>
+    </authorgroup>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>sd_booted</refentrytitle>
+    <manvolnum>3</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>sd_booted</refname>
+    <refpurpose>Test whether the system is running the systemd init system</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
+
+      <funcprototype>
+        <funcdef>int <function>sd_booted</function></funcdef>
+        <paramdef>void</paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+    <para><function>sd_booted()</function> checks whether the system
+    was booted up using the systemd init system.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>Return Value</title>
+
+    <para>On failure, this call returns a negative errno-style error
+    code. If the system was booted up with systemd as init system,
+    this call returns a positive return value, zero otherwise.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>Notes</title>
+
+    <xi:include href="libelogind-pkgconfig.xml" xpointer="pkgconfig-text"/>
+
+    <para>Internally, this function checks whether the directory
+    <filename>/run/systemd/system/</filename> exists. A simple check
+    like this can also be implemented trivially in shell or any other
+    language.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>See Also</title>
+    <para>
+      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    </para>
+  </refsect1>
+
+</refentry>
index b5b669c0e3d7ed51cf690208c3ae9b6f811aa2e6..d30edd41bb8a10c0f7279ad41ce1819f8e876982 100644 (file)
@@ -2610,9 +2610,15 @@ bool cg_is_hybrid_wanted(void) {
         return (wanted = r > 0 ? !b : is_default);
 }
 #else
+bool cg_is_unified_wanted(void) {
+        return false;
+}
 bool cg_is_legacy_wanted(void) {
         return true;
 }
+bool cg_is_hybrid_wanted(void) {
+        return false;
+}
 #endif // 0
 
 #if 0 /// UNNEEDED by elogind
index ac115b4b75c06fcb2f610f4f432e9541f93c90ad..ea74df4e63ed9be28889d00cd896c456271e8b6a 100644 (file)
@@ -258,13 +258,9 @@ int cg_hybrid_unified(void);
 int cg_unified_controller(const char *controller);
 int cg_unified_flush(void);
 
-#if 0 /// UNNEEDED by elogind
 bool cg_is_unified_wanted(void);
-#endif // 0
 bool cg_is_legacy_wanted(void);
-#if 0 /// UNNEEDED by elogind
 bool cg_is_hybrid_wanted(void);
-#endif // 0
 
 const char* cgroup_controller_to_string(CGroupController c) _const_;
 CGroupController cgroup_controller_from_string(const char *s) _pure_;
index 1cd0d9dfc6967b32b544063bf9590216684a4855..b8f0f5d03d227e370d0db4b6a5aa07e152b89016 100644 (file)
@@ -132,7 +132,6 @@ int conf_files_list_strv(char ***strv, const char *suffix, const char *root, con
         return conf_files_list_strv_internal(strv, suffix, root, copy);
 }
 
-#if 0 /// UNNEEDED by elogind
 int conf_files_list(char ***strv, const char *suffix, const char *root, const char *dir, ...) {
         _cleanup_strv_free_ char **dirs = NULL;
         va_list ap;
@@ -148,7 +147,6 @@ int conf_files_list(char ***strv, const char *suffix, const char *root, const ch
 
         return conf_files_list_strv_internal(strv, suffix, root, dirs);
 }
-#endif // 0
 
 int conf_files_list_nulstr(char ***strv, const char *suffix, const char *root, const char *d) {
         _cleanup_strv_free_ char **dirs = NULL;
index 3e684364c03adabdd159c303da1ad160ee5e4826..e00e0e81fbd3713e5a5d8d49f1285e2227c6a6a5 100644 (file)
@@ -20,8 +20,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#if 0 /// UNNEEDED by elogind
 int conf_files_list(char ***ret, const char *suffix, const char *root, const char *dir, ...);
-#endif // 0
 int conf_files_list_strv(char ***ret, const char *suffix, const char *root, const char* const* dirs);
 int conf_files_list_nulstr(char ***ret, const char *suffix, const char *root, const char *dirs);
index eefdbb52d84243c9f6c3d4a091d4a88df2e621c2..33624354f57dc4675366c3e4a2e188ac632cf0ad 100644 (file)
@@ -204,6 +204,7 @@ int readlink_value(const char *p, char **ret) {
 
         return 0;
 }
+#endif // 0
 
 int readlink_and_make_absolute(const char *p, char **r) {
         _cleanup_free_ char *target = NULL;
@@ -225,6 +226,7 @@ int readlink_and_make_absolute(const char *p, char **r) {
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 int readlink_and_canonicalize(const char *p, const char *root, char **ret) {
         char *t, *s;
         int r;
index b139619913a5574d7b808018012917e2ab69d39e..4c6bb659afa6014d7e7a0b4be22f96b21dec400f 100644 (file)
@@ -41,7 +41,9 @@ int readlinkat_malloc(int fd, const char *p, char **ret);
 int readlink_malloc(const char *p, char **r);
 #if 0 /// UNNEEDED by elogind
 int readlink_value(const char *p, char **ret);
+#endif // 0
 int readlink_and_make_absolute(const char *p, char **r);
+#if 0 /// UNNEEDED by elogind
 int readlink_and_canonicalize(const char *p, const char *root, char **r);
 int readlink_and_make_absolute_root(const char *root, const char *path, char **ret);
 #endif // 0
index 250fed5345fc47befcf09df9ea952626f1f956d2..86d648df0052c570db222aac2112cba0f6b4f449 100644 (file)
@@ -1745,7 +1745,6 @@ char **internal_hashmap_get_strv(HashmapBase *h) {
         return sv;
 }
 
-#if 0 /// UNNEEDED by elogind
 void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
         struct ordered_hashmap_entry *e;
         unsigned hash, idx;
@@ -1763,7 +1762,6 @@ void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
                 return NULL;
         return ordered_bucket_at(h, e->iterate_next)->p.value;
 }
-#endif // 0
 
 int set_consume(Set *s, void *value) {
         int r;
index 0fda53e111bc81f7d80b4fb67f54c7c95adbd153..6d1ae48b213b76fbe4da1b4c01fc5ebb3d8e13e9 100644 (file)
@@ -328,10 +328,8 @@ static inline void *ordered_hashmap_first(OrderedHashmap *h) {
         return internal_hashmap_first(HASHMAP_BASE(h));
 }
 
-#if 0 /// UNNEEDED by elogind
 /* no hashmap_next */
 void *ordered_hashmap_next(OrderedHashmap *h, const void *key);
-#endif // 0
 
 char **internal_hashmap_get_strv(HashmapBase *h);
 static inline char **hashmap_get_strv(Hashmap *h) {
index e294f25cf2717f9e4f333652eda26a41b4a6b474..cfdb29aba0a4f538a6d63358e7014fdab3793c3c 100644 (file)
@@ -273,6 +273,7 @@ int parse_range(const char *t, unsigned *lower, unsigned *upper) {
         *upper = u;
         return 0;
 }
+#endif // 0
 
 char *format_bytes(char *buf, size_t l, uint64_t t) {
         unsigned i;
@@ -314,7 +315,6 @@ finish:
         return buf;
 
 }
-#endif // 0
 
 int safe_atou(const char *s, unsigned *ret_u) {
         char *x = NULL;
index 1c1ee40963969713055605eec8d571dba7b30c58..3555aa1eaa23dda82b3ec22ec8a812c879754caa 100644 (file)
@@ -37,10 +37,10 @@ int parse_ifindex(const char *s, int *ret);
 int parse_size(const char *t, uint64_t base, uint64_t *size);
 #if 0 /// UNNEEDED by elogind
 int parse_range(const char *t, unsigned *lower, unsigned *upper);
+#endif // 0
 
 #define FORMAT_BYTES_MAX 8
 char *format_bytes(char *buf, size_t l, uint64_t t);
-#endif // 0
 
 int safe_atou(const char *s, unsigned *ret_u);
 int safe_atoi(const char *s, int *ret_i);
index 6c47620299842b7191ed32ebf643e839770a3249..0e4e76dc42e5ae82e071559cb9c9dc55f48a4068 100644 (file)
@@ -448,7 +448,6 @@ bool path_equal_or_files_same(const char *a, const char *b) {
         return path_equal(a, b) || files_same(a, b) > 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 char* path_join(const char *root, const char *path, const char *rest) {
         assert(path);
 
@@ -525,6 +524,7 @@ int find_binary(const char *name, char **ret) {
         return last_error;
 }
 
+#if 0 /// UNNEEDED by elogind
 bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
         bool changed = false;
         const char* const* i;
index 3e1519efe4f5629d37e2e2fc9d109f5af3d14352..487ae139622ee6f6d71051a4ce96ff6a3e429616 100644 (file)
@@ -53,13 +53,11 @@ char* path_startswith(const char *path, const char *prefix) _pure_;
 int path_compare(const char *a, const char *b) _pure_;
 bool path_equal(const char *a, const char *b) _pure_;
 bool path_equal_or_files_same(const char *a, const char *b);
-#if 0 /// UNNEEDED by elogind
 char* path_join(const char *root, const char *path, const char *rest);
 
 static inline bool path_equal_ptr(const char *a, const char *b) {
         return !!a == !!b && (!a || path_equal(a, b));
 }
-#endif // 0
 
 /* Note: the search terminates on the first NULL item. */
 #define PATH_IN_SET(p, ...)                                     \
@@ -92,9 +90,9 @@ int path_strv_make_absolute_cwd(char **l);
 char** path_strv_resolve(char **l, const char *root);
 char** path_strv_resolve_uniq(char **l, const char *root);
 
-#if 0 /// UNNEEDED by elogind
 int find_binary(const char *name, char **filename);
 
+#if 0 /// UNNEEDED by elogind
 bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
 
 int fsck_exists(const char *fstype);
index 021041cbdccd195558bebe2111b9b1b6cb5850a6..2a9dd7c8c47bb943974ebc003f6f99e2333391aa 100644 (file)
@@ -74,13 +74,11 @@ bool mac_selinux_use(void) {
         return getuid() == 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 void mac_selinux_retest(void) {
 #ifdef HAVE_SELINUX
         cached_use = -1;
 #endif
 }
-#endif // 0
 
 int mac_selinux_init(void) {
         int r = 0;
@@ -120,7 +118,6 @@ int mac_selinux_init(void) {
         return r;
 }
 
-#if 0 /// UNNEEDED by elogind
 void mac_selinux_finish(void) {
 
 #ifdef HAVE_SELINUX
@@ -131,7 +128,6 @@ void mac_selinux_finish(void) {
         label_hnd = NULL;
 #endif
 }
-#endif // 0
 
 int mac_selinux_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
 
index 0528b77592371dd5d5cd2d43e70aadfc93dc40b3..fa41a65f864fa2b8148999973bcad6072afb9a09 100644 (file)
 
 bool mac_selinux_use(void);
 bool mac_selinux_have(void);
-#if 0 /// UNNEEDED by elogind
 void mac_selinux_retest(void);
-#endif // 0
 
 int mac_selinux_init(void);
-#if 0 /// UNNEEDED by elogind
 void mac_selinux_finish(void);
-#endif // 0
 
 int mac_selinux_fix(const char *path, bool ignore_enoent, bool ignore_erofs);
 #if 0 /// UNNEEDED by elogind
index 0be2ec0c708ee983a8abdefcf8430407d3f3d078..8e83bfcf0d960c433406fc9717bc49c8604a8d72 100644 (file)
@@ -120,7 +120,6 @@ int ignore_signals(int sig, ...) {
         return r;
 }
 
-#if 0 /// UNNEEDED by elogind
 int default_signals(int sig, ...) {
 
         static const struct sigaction sa = {
@@ -137,7 +136,6 @@ int default_signals(int sig, ...) {
 
         return r;
 }
-#endif // 0
 
 static int sigset_add_many_ap(sigset_t *ss, va_list ap) {
         int sig, r = 0;
index ee37e2726e14e686cad101ea0b0946f6eb9567e1..8dc9e3aea517992f81a3ec3cf5b02769be06774f 100644 (file)
@@ -27,8 +27,8 @@ int reset_all_signal_handlers(void);
 int reset_signal_mask(void);
 
 int ignore_signals(int sig, ...);
-#if 0 /// UNNEEDED by elogind
 int default_signals(int sig, ...);
+#if 0 /// UNNEEDED by elogind
 int sigaction_many(const struct sigaction *sa, ...);
 #endif // 0
 
index fc0b2c4af58af9d3feb89863ca0c903bc36d764e..c2defbe970149cc8a0423f70362e44ce4f691d68 100644 (file)
@@ -790,7 +790,6 @@ char **strv_sort(char **l) {
         return l;
 }
 
-#if 0 /// UNNEEDED by elogind
 bool strv_equal(char **a, char **b) {
 
         if (strv_isempty(a))
@@ -813,6 +812,7 @@ void strv_print(char **l) {
                 puts(*s);
 }
 
+#if 0 /// UNNEEDED by elogind
 int strv_extendf(char ***l, const char *format, ...) {
         va_list ap;
         char *x;
index dafb4fdc1ba2fee161496bc9153d5232faa55360..1433e896daf939745fdb7178ab55f5943435e215 100644 (file)
@@ -68,9 +68,9 @@ char **strv_remove(char **l, const char *s);
 char **strv_uniq(char **l);
 #if 0 /// UNNEEDED by elogind
 bool strv_is_uniq(char **l);
+#endif // 0
 
 bool strv_equal(char **a, char **b);
-#endif // 0
 
 #define strv_contains(l, s) (!!strv_find((l), (s)))
 
@@ -122,9 +122,7 @@ bool strv_overlap(char **a, char **b) _pure_;
         for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
 
 char **strv_sort(char **l);
-#if 0 /// UNNEEDED by elogind
 void strv_print(char **l);
-#endif // 0
 
 #define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL }))
 
index 6c6669af17dbc4bfbdbb9626e5ce0dbc433a7f58..d056a9f2e81db13af7f7c765a6c038ee83ea695b 100644 (file)
@@ -422,7 +422,9 @@ int mount_setup(bool loaded_policy) {
          * this mkdir really needs to stay for good, otherwise software that copied sd-daemon.c into their sources will
          * misdetect systemd. */
         (void) mkdir_label("/run/systemd", 0755);
+#if 0 /// Yeah, but elogind is not used with systemd, so this directory would be toxic.
         (void) mkdir_label("/run/systemd/system", 0755);
+#endif // 0
 
         /* Set up inaccessible items */
         (void) mkdir_label("/run/systemd/inaccessible", 0000);
index a7c42eacf48453844e922dad3e07d494dc712f73..167f08ef3ccf004681887b89826c4609510a64bf 100644 (file)
@@ -64,7 +64,7 @@ global:
         /* sd_journal_open_container; */
 
         /* sd-daemon */
-        /* sd_booted; */
+        sd_booted;
         /* sd_is_fifo; */
         /* sd_is_mq; */
         sd_is_socket;
@@ -188,11 +188,11 @@ global:
         sd_bus_set_fd;
         /* sd_bus_set_exec; */
         /* sd_bus_get_address; */
-        /* sd_bus_set_bus_client; */
+        sd_bus_set_bus_client;
         /* sd_bus_is_bus_client; */
-        /* sd_bus_set_server; */
+        sd_bus_set_server;
         /* sd_bus_is_server; */
-        /* sd_bus_set_anonymous; */
+        sd_bus_set_anonymous;
         /* sd_bus_is_anonymous; */
         /* sd_bus_set_trusted; */
         /* sd_bus_is_trusted; */
@@ -202,7 +202,7 @@ global:
         /* sd_bus_get_description; */
         /* sd_bus_negotiate_creds; */
         /* sd_bus_negotiate_timestamp; */
-        /* sd_bus_negotiate_fds; */
+        sd_bus_negotiate_fds;
         sd_bus_can_send;
         /* sd_bus_get_creds_mask; */
         sd_bus_set_allow_interactive_authorization;
@@ -282,7 +282,7 @@ global:
         /* sd_bus_message_get_seqnum; */
         sd_bus_message_get_bus;
         sd_bus_message_get_creds;
-        /* sd_bus_message_is_signal; */
+        sd_bus_message_is_signal;
         sd_bus_message_is_method_call;
         sd_bus_message_is_method_error;
         /* sd_bus_message_is_empty; */
@@ -295,7 +295,7 @@ global:
         sd_bus_message_append;
         sd_bus_message_append_basic;
         /* sd_bus_message_append_array; */
-        /* sd_bus_message_append_array_space; */
+        sd_bus_message_append_array_space;
         /* sd_bus_message_append_array_iovec; */
         /* sd_bus_message_append_array_memfd; */
         /* sd_bus_message_append_string_space; */
@@ -419,17 +419,17 @@ global:
         sd_event_add_io;
         sd_event_add_time;
         sd_event_add_signal;
-        /* sd_event_add_child; */
-        /* sd_event_add_defer; */
+        sd_event_add_child;
+        sd_event_add_defer;
         sd_event_add_post;
         sd_event_add_exit;
         sd_event_prepare;
         sd_event_wait;
         sd_event_dispatch;
         sd_event_run;
-        /* sd_event_loop; */
+        sd_event_loop;
         sd_event_exit;
-        /* sd_event_now; */
+        sd_event_now;
         /* sd_event_get_fd; */
         sd_event_get_state;
         /* sd_event_get_tid; */
@@ -445,7 +445,7 @@ global:
         /* sd_event_source_get_description; */
         sd_event_source_set_prepare;
         /* sd_event_source_get_pending; */
-        /* sd_event_source_get_priority; */
+        sd_event_source_get_priority;
         sd_event_source_set_priority;
         /* sd_event_source_get_enabled; */
         sd_event_source_set_enabled;
index dce9b9b5d4ec058a7a0f89401f8cae78638a182f..c7a47813930cba64e595c570748a1b839fe4254e 100644 (file)
@@ -1583,7 +1583,6 @@ uint64_t attach_flags_to_kdbus(uint64_t mask) {
         return m;
 }
 
-#if 0 /// UNNEEDED by elogind
 int bus_kernel_create_bus(const char *name, bool world, char **s) {
         struct kdbus_cmd *make;
         struct kdbus_item *n;
@@ -1659,7 +1658,6 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
 
         return fd;
 }
-#endif // 0
 
 int bus_kernel_open_bus_fd(const char *bus, char **path) {
         char *p;
index 83109784b1496263bda884cb0560ba63db8cfa87..eac75253c4b624ce64e902b5d69ac90e8b613347 100644 (file)
@@ -69,8 +69,8 @@ int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority);
 
 int bus_kernel_open_bus_fd(const char *bus, char **path);
 
-#if 0 /// UNNEEDED by elogind
 int bus_kernel_create_bus(const char *name, bool world, char **s);
+#if 0 /// UNNEEDED by elogind
 int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char **path);
 #endif // 0
 
index 129c612ecd2df126163b2d0fafd292d24dc7077a..1c5f885e147692ddf18aff41d10718b68fcf17c9 100644 (file)
@@ -1082,7 +1082,6 @@ _public_ sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m) {
         return &m->creds;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_message_is_signal(
                 sd_bus_message *m,
                 const char *interface,
@@ -1101,7 +1100,6 @@ _public_ int sd_bus_message_is_signal(
 
         return 1;
 }
-#endif // 0
 
 _public_ int sd_bus_message_is_method_call(
                 sd_bus_message *m,
@@ -2573,7 +2571,6 @@ _public_ int sd_bus_message_append(sd_bus_message *m, const char *types, ...) {
         return r;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_message_append_array_space(
                 sd_bus_message *m,
                 char type,
@@ -2617,6 +2614,7 @@ _public_ int sd_bus_message_append_array_space(
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_message_append_array(
                 sd_bus_message *m,
                 char type,
index 4173ecde66904808fa1ae5a371cbabf94ba76887..a4f20ca1eabf4c02c384460872b60f720a9a785b 100644 (file)
@@ -262,6 +262,7 @@ _public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[])
 
         return 0;
 }
+#endif // 0
 
 _public_ int sd_bus_set_bus_client(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
@@ -272,6 +273,7 @@ _public_ int sd_bus_set_bus_client(sd_bus *bus, int b) {
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
@@ -280,6 +282,7 @@ _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
         SET_FLAG(bus->hello_flags, KDBUS_HELLO_MONITOR, b);
         return 0;
 }
+#endif // 0
 
 _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
@@ -290,6 +293,7 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
         uint64_t new_flags;
         assert_return(bus, -EINVAL);
@@ -333,6 +337,7 @@ _public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
 
         return 0;
 }
+#endif // 0
 
 _public_ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
         assert_return(bus, -EINVAL);
@@ -354,6 +359,7 @@ _public_ int sd_bus_set_anonymous(sd_bus *bus, int b) {
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_set_trusted(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
index 3e66092b110b907f003191b903c3de55050cddef..26a0a7e522eee21e31750bcf7f55788e3b5ab86f 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "alloc-util.h"
 #include "fd-util.h"
-//#include "fs-util.h"
+#include "fs-util.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "socket-util.h"
@@ -631,6 +631,7 @@ _public_ int sd_notifyf(int unset_environment, const char *format, ...) {
 
         return sd_pid_notify(0, unset_environment, p);
 }
+#endif // 0
 
 _public_ int sd_booted(void) {
         /* We test whether the runtime unit file directory has been
@@ -639,7 +640,6 @@ _public_ int sd_booted(void) {
 
         return laccess("/run/systemd/system/", F_OK) >= 0;
 }
-#endif // 0
 
 _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {
         const char *s, *p = ""; /* p is set to dummy value to do unsetting */
index 019d411c43ae65a5113009695ffeb3aee6ccf26f..0f7a0ca7be2bde153730fba22772fb88b6e4216c 100644 (file)
@@ -1196,7 +1196,6 @@ _public_ int sd_event_add_signal(
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_event_add_child(
                 sd_event *e,
                 sd_event_source **ret,
@@ -1289,7 +1288,6 @@ _public_ int sd_event_add_defer(
 
         return 0;
 }
-#endif // 0
 
 _public_ int sd_event_add_post(
                 sd_event *e,
@@ -1546,6 +1544,7 @@ _public_ int sd_event_source_get_signal(sd_event_source *s) {
 
         return s->signal.sig;
 }
+#endif // 0
 
 _public_ int sd_event_source_get_priority(sd_event_source *s, int64_t *priority) {
         assert_return(s, -EINVAL);
@@ -1554,7 +1553,6 @@ _public_ int sd_event_source_get_priority(sd_event_source *s, int64_t *priority)
         *priority = s->priority;
         return 0;
 }
-#endif // 0
 
 _public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority) {
         int r;
@@ -2717,7 +2715,6 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
         return r;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_event_loop(sd_event *e) {
         int r;
 
@@ -2740,6 +2737,7 @@ finish:
         return r;
 }
 
+#if 0 /// UNNEEDED by elogind
 _public_ int sd_event_get_fd(sd_event *e) {
 
         assert_return(e, -EINVAL);
@@ -2781,7 +2779,6 @@ _public_ int sd_event_exit(sd_event *e, int code) {
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
         assert_return(e, -EINVAL);
         assert_return(usec, -EINVAL);
@@ -2806,7 +2803,6 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
         *usec = triple_timestamp_by_clock(&e->timestamp, clock);
         return 0;
 }
-#endif // 0
 
 _public_ int sd_event_default(sd_event **ret) {
 
index 6c1c7f02d7ed8dcc02ade2e1d74e8d4b89836c5f..ce8a6aad09f80d60dff6140c1d9aa4345a1f3125 100644 (file)
@@ -153,7 +153,6 @@ int id128_read(const char *p, Id128Format f, sd_id128_t *ret) {
         return id128_read_fd(fd, f, ret);
 }
 
-#if 0 /// UNNEEDED by elogind
 int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) {
         char buffer[36 + 2];
         size_t sz;
@@ -184,6 +183,7 @@ int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) {
         return r;
 }
 
+#if 0 /// UNNEEDED by elogind
 int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync) {
         _cleanup_close_ int fd = -1;
 
index e5262cdcda200c956c8442caff1df5df03467f91..d435b976d98767a7657c8f80e5acc9aa610e7cfc 100644 (file)
@@ -43,8 +43,8 @@ typedef enum Id128Format {
 int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret);
 int id128_read(const char *p, Id128Format f, sd_id128_t *ret);
 
-#if 0 /// UNNEEDED by elogind
 int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync);
+#if 0 /// UNNEEDED by elogind
 int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync);
 
 void id128_hash_func(const void *p, struct siphash *state);
diff --git a/src/shared/tests.c b/src/shared/tests.c
new file mode 100644 (file)
index 0000000..f300bbc
--- /dev/null
@@ -0,0 +1,73 @@
+/***
+  This file is part of systemd.
+
+  Copyright 2016 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 <alloc-util.h>
+#include <fs-util.h>
+#include <libgen.h>
+#include <stdlib.h>
+#include <util.h>
+
+#include "tests.h"
+#include "path-util.h"
+
+char* setup_fake_runtime_dir(void) {
+        char t[] = "/tmp/fake-xdg-runtime-XXXXXX", *p;
+
+        assert_se(mkdtemp(t));
+        assert_se(setenv("XDG_RUNTIME_DIR", t, 1) >= 0);
+        assert_se(p = strdup(t));
+
+        return p;
+}
+
+const char* get_testdata_dir(const char *suffix) {
+        const char *env;
+        /* convenience: caller does not need to free result */
+        static char testdir[PATH_MAX];
+
+        /* if the env var is set, use that */
+        env = getenv("SYSTEMD_TEST_DATA");
+        testdir[sizeof(testdir) - 1] = '\0';
+        if (env) {
+                if (access(env, F_OK) < 0) {
+                        fputs("ERROR: $SYSTEMD_TEST_DATA directory does not exist\n", stderr);
+                        exit(1);
+                }
+                strncpy(testdir, env, sizeof(testdir) - 1);
+        } else {
+                _cleanup_free_ char *exedir = NULL;
+                assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0);
+
+                /* Check if we're running from the builddir. If so, use the compiled in path. */
+                if (path_startswith(exedir, ABS_BUILD_DIR))
+                        assert_se(snprintf(testdir, sizeof(testdir), "%s/test", ABS_SRC_DIR) > 0);
+                else
+                        /* Try relative path, according to the install-test layout */
+                        assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0);
+
+                /* test this without the suffix, as it may contain a glob */
+                if (access(testdir, F_OK) < 0) {
+                        fputs("ERROR: Cannot find testdata directory, set $SYSTEMD_TEST_DATA\n", stderr);
+                        exit(1);
+                }
+        }
+
+        strncpy(testdir + strlen(testdir), suffix, sizeof(testdir) - strlen(testdir) - 1);
+        return testdir;
+}
diff --git a/src/shared/tests.h b/src/shared/tests.h
new file mode 100644 (file)
index 0000000..7055124
--- /dev/null
@@ -0,0 +1,23 @@
+#pragma once
+
+/***
+  This file is part of systemd.
+
+  Copyright 2016 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/>.
+***/
+
+char* setup_fake_runtime_dir(void);
+const char* get_testdata_dir(const char *suffix);
index 997cf9f00bca1ab3677067fd30b1ac18d6b59c27..009cffea92822e8f71674aff638766a7b5c2f1f3 100644 (file)
@@ -129,11 +129,17 @@ int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd);
 #if 0 /// UNNEEDED by elogind
 int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
 int sd_bus_get_address(sd_bus *bus, const char **address);
+#endif // 0
 int sd_bus_set_bus_client(sd_bus *bus, int b);
+#if 0 /// UNNEEDED by elogind
 int sd_bus_is_bus_client(sd_bus *bus);
+#endif // 0
 int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t bus_id);
+#if 0 /// UNNEEDED by elogind
 int sd_bus_is_server(sd_bus *bus);
+#endif // 0
 int sd_bus_set_anonymous(sd_bus *bus, int b);
+#if 0 /// UNNEEDED by elogind
 int sd_bus_is_anonymous(sd_bus *bus);
 int sd_bus_set_trusted(sd_bus *bus, int b);
 int sd_bus_is_trusted(sd_bus *bus);
@@ -143,8 +149,8 @@ int sd_bus_set_description(sd_bus *bus, const char *description);
 int sd_bus_get_description(sd_bus *bus, const char **description);
 int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t creds_mask);
 int sd_bus_negotiate_timestamp(sd_bus *bus, int b);
-int sd_bus_negotiate_fds(sd_bus *bus, int b);
 #endif // 0
+int sd_bus_negotiate_fds(sd_bus *bus, int b);
 int sd_bus_can_send(sd_bus *bus, char type);
 #if 0 /// UNNEEDED by elogind
 int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *creds_mask);
@@ -282,9 +288,7 @@ int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t* seqnum);
 sd_bus* sd_bus_message_get_bus(sd_bus_message *m);
 sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m); /* do not unref the result */
 
-#if 0 /// UNNEEDED by elogind
 int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
-#endif // 0
 int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);
 int sd_bus_message_is_method_error(sd_bus_message *m, const char *name);
 #if 0 /// UNNEEDED by elogind
@@ -305,7 +309,9 @@ int sd_bus_message_append(sd_bus_message *m, const char *types, ...);
 int sd_bus_message_append_basic(sd_bus_message *m, char type, const void *p);
 #if 0 /// UNNEEDED by elogind
 int sd_bus_message_append_array(sd_bus_message *m, char type, const void *ptr, size_t size);
+#endif // 0
 int sd_bus_message_append_array_space(sd_bus_message *m, char type, size_t size, void **ptr);
+#if 0 /// UNNEEDED by elogind
 int sd_bus_message_append_array_iovec(sd_bus_message *m, char type, const struct iovec *iov, unsigned n);
 int sd_bus_message_append_array_memfd(sd_bus_message *m, char type, int memfd, uint64_t offset, uint64_t size);
 int sd_bus_message_append_string_space(sd_bus_message *m, size_t size, char **s);
index bee4043940a38245072ea208d2d3bfeb87fc672d..ac31df94b46df62c16a2103c6991167e8bb1a821 100644 (file)
@@ -278,7 +278,6 @@ int sd_pid_notifyf(pid_t pid, int unset_environment, const char *format, ...) _s
 */
 int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char *state, const int *fds, unsigned n_fds);
 
-#if 0 /// UNNEEDED by elogind
 /*
   Returns > 0 if the system was booted with systemd. Returns < 0 on
   error. Returns 0 if the system was not booted with systemd. Note
@@ -291,7 +290,6 @@ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char *state,
   See sd_booted(3) for more information.
 */
 int sd_booted(void);
-#endif // 0
 
 /*
   Returns > 0 if the service manager expects watchdog keep-alive
index d17c68d51bc47a4d470aef22e79b172e16949b4c..020e7457460ee60a6b5829d23b2ddfb8285b9a95 100644 (file)
@@ -91,10 +91,8 @@ sd_event* sd_event_unref(sd_event *e);
 int sd_event_add_io(sd_event *e, sd_event_source **s, int fd, uint32_t events, sd_event_io_handler_t callback, void *userdata);
 int sd_event_add_time(sd_event *e, sd_event_source **s, clockid_t clock, uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback, void *userdata);
 int sd_event_add_signal(sd_event *e, sd_event_source **s, int sig, sd_event_signal_handler_t callback, void *userdata);
-#if 0 /// UNNEEDED by elogind
 int sd_event_add_child(sd_event *e, sd_event_source **s, pid_t pid, int options, sd_event_child_handler_t callback, void *userdata);
 int sd_event_add_defer(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
-#endif // 0
 int sd_event_add_post(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
 int sd_event_add_exit(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
 
@@ -102,14 +100,12 @@ int sd_event_prepare(sd_event *e);
 int sd_event_wait(sd_event *e, uint64_t usec);
 int sd_event_dispatch(sd_event *e);
 int sd_event_run(sd_event *e, uint64_t usec);
-#if 0 /// UNNEEDED by elogind
 int sd_event_loop(sd_event *e);
-#endif // 0
 int sd_event_exit(sd_event *e, int code);
 
-#if 0 /// UNNEEDED by elogind
 int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec);
 
+#if 0 /// UNNEEDED by elogind
 int sd_event_get_fd(sd_event *e);
 #endif // 0
 int sd_event_get_state(sd_event *e);
@@ -141,8 +137,8 @@ int sd_event_source_get_description(sd_event_source *s, const char **description
 int sd_event_source_set_prepare(sd_event_source *s, sd_event_handler_t callback);
 #if 0 /// UNNEEDED by elogind
 int sd_event_source_get_pending(sd_event_source *s);
-int sd_event_source_get_priority(sd_event_source *s, int64_t *priority);
 #endif // 0
+int sd_event_source_get_priority(sd_event_source *s, int64_t *priority);
 int sd_event_source_set_priority(sd_event_source *s, int64_t priority);
 #if 0 /// UNNEEDED by elogind
 int sd_event_source_get_enabled(sd_event_source *s, int *enabled);