diff options
author | Sven Eden <yamakuzure@gmx.net> | 2017-07-19 00:56:25 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-07-19 13:04:57 +0200 |
commit | a97a730270418e53e9400de5dce7b07c7dacd19a (patch) | |
tree | bac97ceff71bef555a8612f90d2a746189592791 /src | |
parent | b6e675bcef8c3dca1292269795c795195ea6d1e7 (diff) |
Prep v233.3: Unmask various functions for future coverage tests.
These functions, although not used by elogind itself, are mostly tiny
and crucial for important tests to work.
Diffstat (limited to 'src')
33 files changed, 152 insertions, 72 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index b5b669c0e..d30edd41b 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -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 diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index ac115b4b7..ea74df4e6 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -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_; diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 1cd0d9dfc..b8f0f5d03 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -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; diff --git a/src/basic/conf-files.h b/src/basic/conf-files.h index 3e684364c..e00e0e81f 100644 --- a/src/basic/conf-files.h +++ b/src/basic/conf-files.h @@ -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); diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index eefdbb52d..33624354f 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -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; diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index b13961991..4c6bb659a 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -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 diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 250fed534..86d648df0 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -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; diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h index 0fda53e11..6d1ae48b2 100644 --- a/src/basic/hashmap.h +++ b/src/basic/hashmap.h @@ -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) { diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index e294f25cf..cfdb29aba 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -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; diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h index 1c1ee4096..3555aa1ea 100644 --- a/src/basic/parse-util.h +++ b/src/basic/parse-util.h @@ -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); diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 6c4762029..0e4e76dc4 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -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; diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 3e1519efe..487ae1396 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -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); diff --git a/src/basic/selinux-util.c b/src/basic/selinux-util.c index 021041cbd..2a9dd7c8c 100644 --- a/src/basic/selinux-util.c +++ b/src/basic/selinux-util.c @@ -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) { diff --git a/src/basic/selinux-util.h b/src/basic/selinux-util.h index 0528b7759..fa41a65f8 100644 --- a/src/basic/selinux-util.h +++ b/src/basic/selinux-util.h @@ -27,14 +27,10 @@ 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 diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 0be2ec0c7..8e83bfcf0 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -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; diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h index ee37e2726..8dc9e3aea 100644 --- a/src/basic/signal-util.h +++ b/src/basic/signal-util.h @@ -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 diff --git a/src/basic/strv.c b/src/basic/strv.c index fc0b2c4af..c2defbe97 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -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; diff --git a/src/basic/strv.h b/src/basic/strv.h index dafb4fdc1..1433e896d 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -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 })) diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index 6c6669af1..d056a9f2e 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -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); diff --git a/src/libelogind/libelogind.sym b/src/libelogind/libelogind.sym index a7c42eacf..167f08ef3 100644 --- a/src/libelogind/libelogind.sym +++ b/src/libelogind/libelogind.sym @@ -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; diff --git a/src/libelogind/sd-bus/bus-kernel.c b/src/libelogind/sd-bus/bus-kernel.c index dce9b9b5d..c7a478139 100644 --- a/src/libelogind/sd-bus/bus-kernel.c +++ b/src/libelogind/sd-bus/bus-kernel.c @@ -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; diff --git a/src/libelogind/sd-bus/bus-kernel.h b/src/libelogind/sd-bus/bus-kernel.h index 83109784b..eac75253c 100644 --- a/src/libelogind/sd-bus/bus-kernel.h +++ b/src/libelogind/sd-bus/bus-kernel.h @@ -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 diff --git a/src/libelogind/sd-bus/bus-message.c b/src/libelogind/sd-bus/bus-message.c index 129c612ec..1c5f885e1 100644 --- a/src/libelogind/sd-bus/bus-message.c +++ b/src/libelogind/sd-bus/bus-message.c @@ -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, diff --git a/src/libelogind/sd-bus/sd-bus.c b/src/libelogind/sd-bus/sd-bus.c index 4173ecde6..a4f20ca1e 100644 --- a/src/libelogind/sd-bus/sd-bus.c +++ b/src/libelogind/sd-bus/sd-bus.c @@ -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); diff --git a/src/libelogind/sd-daemon/sd-daemon.c b/src/libelogind/sd-daemon/sd-daemon.c index 3e66092b1..26a0a7e52 100644 --- a/src/libelogind/sd-daemon/sd-daemon.c +++ b/src/libelogind/sd-daemon/sd-daemon.c @@ -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 */ diff --git a/src/libelogind/sd-event/sd-event.c b/src/libelogind/sd-event/sd-event.c index 019d411c4..0f7a0ca7b 100644 --- a/src/libelogind/sd-event/sd-event.c +++ b/src/libelogind/sd-event/sd-event.c @@ -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) { diff --git a/src/libelogind/sd-id128/id128-util.c b/src/libelogind/sd-id128/id128-util.c index 6c1c7f02d..ce8a6aad0 100644 --- a/src/libelogind/sd-id128/id128-util.c +++ b/src/libelogind/sd-id128/id128-util.c @@ -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; diff --git a/src/libelogind/sd-id128/id128-util.h b/src/libelogind/sd-id128/id128-util.h index e5262cdcd..d435b976d 100644 --- a/src/libelogind/sd-id128/id128-util.h +++ b/src/libelogind/sd-id128/id128-util.h @@ -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 index 000000000..f300bbc66 --- /dev/null +++ b/src/shared/tests.c @@ -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 index 000000000..705512499 --- /dev/null +++ b/src/shared/tests.h @@ -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); diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 997cf9f00..009cffea9 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -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); diff --git a/src/systemd/sd-daemon.h b/src/systemd/sd-daemon.h index bee404394..ac31df94b 100644 --- a/src/systemd/sd-daemon.h +++ b/src/systemd/sd-daemon.h @@ -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 diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h index d17c68d51..020e74574 100644 --- a/src/systemd/sd-event.h +++ b/src/systemd/sd-event.h @@ -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); |