diff options
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-chat.c | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-gvariant.c | 179 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-match.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-event/test-event.c | 19 | ||||
-rw-r--r-- | src/libsystemd/sd-resolve/test-resolve.c | 11 |
5 files changed, 109 insertions, 111 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index 06edd621e4..8625ee6d89 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -19,7 +19,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <assert.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> @@ -44,7 +43,7 @@ static int match_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int r; - assert(bus); + assert_se(bus); if (sd_bus_message_is_method_error(m, NULL)) return 0; @@ -68,7 +67,7 @@ static int server_init(sd_bus **_bus) { int r; const char *unique; - assert(_bus); + assert_se(_bus); r = sd_bus_open_user(&bus); if (r < 0) { @@ -299,7 +298,7 @@ static void* client1(void*p) { goto finish; } - assert(streq(hello, "hello")); + assert_se(streq(hello, "hello")); if (pipe2(pp, O_CLOEXEC|O_NONBLOCK) < 0) { log_error_errno(errno, "Failed to allocate pipe: %m"); diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c index d700a35b0c..6992ec44de 100644 --- a/src/libsystemd/sd-bus/test-bus-gvariant.c +++ b/src/libsystemd/sd-bus/test-bus-gvariant.c @@ -24,6 +24,7 @@ #endif #include "util.h" +#include "macro.h" #include "sd-bus.h" #include "bus-gvariant.h" #include "bus-util.h" @@ -32,101 +33,101 @@ #include "bus-dump.h" static void test_bus_gvariant_is_fixed_size(void) { - assert(bus_gvariant_is_fixed_size("") > 0); - assert(bus_gvariant_is_fixed_size("()") > 0); - assert(bus_gvariant_is_fixed_size("y") > 0); - assert(bus_gvariant_is_fixed_size("u") > 0); - assert(bus_gvariant_is_fixed_size("b") > 0); - assert(bus_gvariant_is_fixed_size("n") > 0); - assert(bus_gvariant_is_fixed_size("q") > 0); - assert(bus_gvariant_is_fixed_size("i") > 0); - assert(bus_gvariant_is_fixed_size("t") > 0); - assert(bus_gvariant_is_fixed_size("d") > 0); - assert(bus_gvariant_is_fixed_size("s") == 0); - assert(bus_gvariant_is_fixed_size("o") == 0); - assert(bus_gvariant_is_fixed_size("g") == 0); - assert(bus_gvariant_is_fixed_size("h") > 0); - assert(bus_gvariant_is_fixed_size("ay") == 0); - assert(bus_gvariant_is_fixed_size("v") == 0); - assert(bus_gvariant_is_fixed_size("(u)") > 0); - assert(bus_gvariant_is_fixed_size("(uuuuy)") > 0); - assert(bus_gvariant_is_fixed_size("(uusuuy)") == 0); - assert(bus_gvariant_is_fixed_size("a{ss}") == 0); - assert(bus_gvariant_is_fixed_size("((u)yyy(b(iiii)))") > 0); - assert(bus_gvariant_is_fixed_size("((u)yyy(b(iiivi)))") == 0); + assert_se(bus_gvariant_is_fixed_size("") > 0); + assert_se(bus_gvariant_is_fixed_size("()") > 0); + assert_se(bus_gvariant_is_fixed_size("y") > 0); + assert_se(bus_gvariant_is_fixed_size("u") > 0); + assert_se(bus_gvariant_is_fixed_size("b") > 0); + assert_se(bus_gvariant_is_fixed_size("n") > 0); + assert_se(bus_gvariant_is_fixed_size("q") > 0); + assert_se(bus_gvariant_is_fixed_size("i") > 0); + assert_se(bus_gvariant_is_fixed_size("t") > 0); + assert_se(bus_gvariant_is_fixed_size("d") > 0); + assert_se(bus_gvariant_is_fixed_size("s") == 0); + assert_se(bus_gvariant_is_fixed_size("o") == 0); + assert_se(bus_gvariant_is_fixed_size("g") == 0); + assert_se(bus_gvariant_is_fixed_size("h") > 0); + assert_se(bus_gvariant_is_fixed_size("ay") == 0); + assert_se(bus_gvariant_is_fixed_size("v") == 0); + assert_se(bus_gvariant_is_fixed_size("(u)") > 0); + assert_se(bus_gvariant_is_fixed_size("(uuuuy)") > 0); + assert_se(bus_gvariant_is_fixed_size("(uusuuy)") == 0); + assert_se(bus_gvariant_is_fixed_size("a{ss}") == 0); + assert_se(bus_gvariant_is_fixed_size("((u)yyy(b(iiii)))") > 0); + assert_se(bus_gvariant_is_fixed_size("((u)yyy(b(iiivi)))") == 0); } static void test_bus_gvariant_get_size(void) { - assert(bus_gvariant_get_size("") == 0); - assert(bus_gvariant_get_size("()") == 0); - assert(bus_gvariant_get_size("y") == 1); - assert(bus_gvariant_get_size("u") == 4); - assert(bus_gvariant_get_size("b") == 1); - assert(bus_gvariant_get_size("n") == 2); - assert(bus_gvariant_get_size("q") == 2); - assert(bus_gvariant_get_size("i") == 4); - assert(bus_gvariant_get_size("t") == 8); - assert(bus_gvariant_get_size("d") == 8); - assert(bus_gvariant_get_size("s") < 0); - assert(bus_gvariant_get_size("o") < 0); - assert(bus_gvariant_get_size("g") < 0); - assert(bus_gvariant_get_size("h") == 4); - assert(bus_gvariant_get_size("ay") < 0); - assert(bus_gvariant_get_size("v") < 0); - assert(bus_gvariant_get_size("(u)") == 4); - assert(bus_gvariant_get_size("(uuuuy)") == 20); - assert(bus_gvariant_get_size("(uusuuy)") < 0); - assert(bus_gvariant_get_size("a{ss}") < 0); - assert(bus_gvariant_get_size("((u)yyy(b(iiii)))") == 28); - assert(bus_gvariant_get_size("((u)yyy(b(iiivi)))") < 0); - assert(bus_gvariant_get_size("((b)(t))") == 16); - assert(bus_gvariant_get_size("((b)(b)(t))") == 16); - assert(bus_gvariant_get_size("(bt)") == 16); - assert(bus_gvariant_get_size("((t)(b))") == 16); - assert(bus_gvariant_get_size("(tb)") == 16); - assert(bus_gvariant_get_size("((b)(b))") == 2); - assert(bus_gvariant_get_size("((t)(t))") == 16); + assert_se(bus_gvariant_get_size("") == 0); + assert_se(bus_gvariant_get_size("()") == 0); + assert_se(bus_gvariant_get_size("y") == 1); + assert_se(bus_gvariant_get_size("u") == 4); + assert_se(bus_gvariant_get_size("b") == 1); + assert_se(bus_gvariant_get_size("n") == 2); + assert_se(bus_gvariant_get_size("q") == 2); + assert_se(bus_gvariant_get_size("i") == 4); + assert_se(bus_gvariant_get_size("t") == 8); + assert_se(bus_gvariant_get_size("d") == 8); + assert_se(bus_gvariant_get_size("s") < 0); + assert_se(bus_gvariant_get_size("o") < 0); + assert_se(bus_gvariant_get_size("g") < 0); + assert_se(bus_gvariant_get_size("h") == 4); + assert_se(bus_gvariant_get_size("ay") < 0); + assert_se(bus_gvariant_get_size("v") < 0); + assert_se(bus_gvariant_get_size("(u)") == 4); + assert_se(bus_gvariant_get_size("(uuuuy)") == 20); + assert_se(bus_gvariant_get_size("(uusuuy)") < 0); + assert_se(bus_gvariant_get_size("a{ss}") < 0); + assert_se(bus_gvariant_get_size("((u)yyy(b(iiii)))") == 28); + assert_se(bus_gvariant_get_size("((u)yyy(b(iiivi)))") < 0); + assert_se(bus_gvariant_get_size("((b)(t))") == 16); + assert_se(bus_gvariant_get_size("((b)(b)(t))") == 16); + assert_se(bus_gvariant_get_size("(bt)") == 16); + assert_se(bus_gvariant_get_size("((t)(b))") == 16); + assert_se(bus_gvariant_get_size("(tb)") == 16); + assert_se(bus_gvariant_get_size("((b)(b))") == 2); + assert_se(bus_gvariant_get_size("((t)(t))") == 16); } static void test_bus_gvariant_get_alignment(void) { - assert(bus_gvariant_get_alignment("") == 1); - assert(bus_gvariant_get_alignment("()") == 1); - assert(bus_gvariant_get_alignment("y") == 1); - assert(bus_gvariant_get_alignment("b") == 1); - assert(bus_gvariant_get_alignment("u") == 4); - assert(bus_gvariant_get_alignment("s") == 1); - assert(bus_gvariant_get_alignment("o") == 1); - assert(bus_gvariant_get_alignment("g") == 1); - assert(bus_gvariant_get_alignment("v") == 8); - assert(bus_gvariant_get_alignment("h") == 4); - assert(bus_gvariant_get_alignment("i") == 4); - assert(bus_gvariant_get_alignment("t") == 8); - assert(bus_gvariant_get_alignment("x") == 8); - assert(bus_gvariant_get_alignment("q") == 2); - assert(bus_gvariant_get_alignment("n") == 2); - assert(bus_gvariant_get_alignment("d") == 8); - assert(bus_gvariant_get_alignment("ay") == 1); - assert(bus_gvariant_get_alignment("as") == 1); - assert(bus_gvariant_get_alignment("au") == 4); - assert(bus_gvariant_get_alignment("an") == 2); - assert(bus_gvariant_get_alignment("ans") == 2); - assert(bus_gvariant_get_alignment("ant") == 8); - assert(bus_gvariant_get_alignment("(ss)") == 1); - assert(bus_gvariant_get_alignment("(ssu)") == 4); - assert(bus_gvariant_get_alignment("a(ssu)") == 4); - assert(bus_gvariant_get_alignment("(u)") == 4); - assert(bus_gvariant_get_alignment("(uuuuy)") == 4); - assert(bus_gvariant_get_alignment("(uusuuy)") == 4); - assert(bus_gvariant_get_alignment("a{ss}") == 1); - assert(bus_gvariant_get_alignment("((u)yyy(b(iiii)))") == 4); - assert(bus_gvariant_get_alignment("((u)yyy(b(iiivi)))") == 8); - assert(bus_gvariant_get_alignment("((b)(t))") == 8); - assert(bus_gvariant_get_alignment("((b)(b)(t))") == 8); - assert(bus_gvariant_get_alignment("(bt)") == 8); - assert(bus_gvariant_get_alignment("((t)(b))") == 8); - assert(bus_gvariant_get_alignment("(tb)") == 8); - assert(bus_gvariant_get_alignment("((b)(b))") == 1); - assert(bus_gvariant_get_alignment("((t)(t))") == 8); + assert_se(bus_gvariant_get_alignment("") == 1); + assert_se(bus_gvariant_get_alignment("()") == 1); + assert_se(bus_gvariant_get_alignment("y") == 1); + assert_se(bus_gvariant_get_alignment("b") == 1); + assert_se(bus_gvariant_get_alignment("u") == 4); + assert_se(bus_gvariant_get_alignment("s") == 1); + assert_se(bus_gvariant_get_alignment("o") == 1); + assert_se(bus_gvariant_get_alignment("g") == 1); + assert_se(bus_gvariant_get_alignment("v") == 8); + assert_se(bus_gvariant_get_alignment("h") == 4); + assert_se(bus_gvariant_get_alignment("i") == 4); + assert_se(bus_gvariant_get_alignment("t") == 8); + assert_se(bus_gvariant_get_alignment("x") == 8); + assert_se(bus_gvariant_get_alignment("q") == 2); + assert_se(bus_gvariant_get_alignment("n") == 2); + assert_se(bus_gvariant_get_alignment("d") == 8); + assert_se(bus_gvariant_get_alignment("ay") == 1); + assert_se(bus_gvariant_get_alignment("as") == 1); + assert_se(bus_gvariant_get_alignment("au") == 4); + assert_se(bus_gvariant_get_alignment("an") == 2); + assert_se(bus_gvariant_get_alignment("ans") == 2); + assert_se(bus_gvariant_get_alignment("ant") == 8); + assert_se(bus_gvariant_get_alignment("(ss)") == 1); + assert_se(bus_gvariant_get_alignment("(ssu)") == 4); + assert_se(bus_gvariant_get_alignment("a(ssu)") == 4); + assert_se(bus_gvariant_get_alignment("(u)") == 4); + assert_se(bus_gvariant_get_alignment("(uuuuy)") == 4); + assert_se(bus_gvariant_get_alignment("(uusuuy)") == 4); + assert_se(bus_gvariant_get_alignment("a{ss}") == 1); + assert_se(bus_gvariant_get_alignment("((u)yyy(b(iiii)))") == 4); + assert_se(bus_gvariant_get_alignment("((u)yyy(b(iiivi)))") == 8); + assert_se(bus_gvariant_get_alignment("((b)(t))") == 8); + assert_se(bus_gvariant_get_alignment("((b)(b)(t))") == 8); + assert_se(bus_gvariant_get_alignment("(bt)") == 8); + assert_se(bus_gvariant_get_alignment("((t)(b))") == 8); + assert_se(bus_gvariant_get_alignment("(tb)") == 8); + assert_se(bus_gvariant_get_alignment("((b)(b))") == 1); + assert_se(bus_gvariant_get_alignment("((t)(t))") == 8); } static void test_marshal(void) { diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c index 7133117038..76ca0b6bf3 100644 --- a/src/libsystemd/sd-bus/test-bus-match.c +++ b/src/libsystemd/sd-bus/test-bus-match.c @@ -19,8 +19,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <assert.h> - #include "log.h" #include "util.h" #include "macro.h" @@ -34,7 +32,7 @@ static bool mask[32]; static int filter(sd_bus *b, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { log_info("Ran %u", PTR_TO_UINT(userdata)); - assert(PTR_TO_UINT(userdata) < ELEMENTSOF(mask)); + assert_se(PTR_TO_UINT(userdata) < ELEMENTSOF(mask)); mask[PTR_TO_UINT(userdata)] = true; return 0; } diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c index ffefb14b74..721700be7b 100644 --- a/src/libsystemd/sd-event/test-event.c +++ b/src/libsystemd/sd-event/test-event.c @@ -22,6 +22,7 @@ #include "sd-event.h" #include "log.h" #include "util.h" +#include "macro.h" static int prepare_handler(sd_event_source *s, void *userdata) { log_info("preparing %c", PTR_TO_INT(userdata)); @@ -62,12 +63,12 @@ static int io_handler(sd_event_source *s, int fd, uint32_t revents, void *userda static int child_handler(sd_event_source *s, const siginfo_t *si, void *userdata) { - assert(s); - assert(si); + assert_se(s); + assert_se(si); log_info("got child on %c", PTR_TO_INT(userdata)); - assert(userdata == INT_TO_PTR('f')); + assert_se(userdata == INT_TO_PTR('f')); assert_se(sd_event_exit(sd_event_source_get_event(s), 0) >= 0); sd_event_source_unref(s); @@ -80,12 +81,12 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, sigset_t ss; pid_t pid; - assert(s); - assert(si); + assert_se(s); + assert_se(si); log_info("got signal on %c", PTR_TO_INT(userdata)); - assert(userdata == INT_TO_PTR('e')); + assert_se(userdata == INT_TO_PTR('e')); assert_se(sigemptyset(&ss) >= 0); assert_se(sigaddset(&ss, SIGCHLD) >= 0); @@ -109,11 +110,11 @@ static int defer_handler(sd_event_source *s, void *userdata) { sd_event_source *p = NULL; sigset_t ss; - assert(s); + assert_se(s); log_info("got defer on %c", PTR_TO_INT(userdata)); - assert(userdata == INT_TO_PTR('d')); + assert_se(userdata == INT_TO_PTR('d')); assert_se(sigemptyset(&ss) >= 0); assert_se(sigaddset(&ss, SIGUSR1) >= 0); @@ -140,7 +141,7 @@ static int time_handler(sd_event_source *s, uint64_t usec, void *userdata) { assert_se(sd_event_add_defer(sd_event_source_get_event(s), &p, defer_handler, INT_TO_PTR('d')) >= 0); assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0); } else { - assert(!got_c); + assert_se(!got_c); got_c = true; } } else diff --git a/src/libsystemd/sd-resolve/test-resolve.c b/src/libsystemd/sd-resolve/test-resolve.c index a9dc9313a6..d08e1b5a05 100644 --- a/src/libsystemd/sd-resolve/test-resolve.c +++ b/src/libsystemd/sd-resolve/test-resolve.c @@ -28,7 +28,6 @@ #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> -#include <assert.h> #include <signal.h> #include <errno.h> @@ -40,7 +39,7 @@ static int getaddrinfo_handler(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata) { const struct addrinfo *i; - assert(q); + assert_se(q); if (ret != 0) { log_error("getaddrinfo error: %s %i", gai_strerror(ret), ret); @@ -60,7 +59,7 @@ static int getaddrinfo_handler(sd_resolve_query *q, int ret, const struct addrin } static int getnameinfo_handler(sd_resolve_query *q, int ret, const char *host, const char *serv, void *userdata) { - assert(q); + assert_se(q); if (ret != 0) { log_error("getnameinfo error: %s %i", gai_strerror(ret), ret); @@ -77,7 +76,7 @@ static int res_handler(sd_resolve_query *q, int ret, unsigned char *answer, void unsigned char *end = answer + ret; HEADER *head = (HEADER *) answer; char name[256]; - assert(q); + assert_se(q); if (ret < 0) { log_error("res_query() error: %s %i", strerror(errno), errno); @@ -96,7 +95,7 @@ static int res_handler(sd_resolve_query *q, int ret, unsigned char *answer, void /* Ignore the questions */ while (qdcount-- > 0 && (len = dn_expand(answer, end, pos, name, 255)) >= 0) { - assert(len >= 0); + assert_se(len >= 0); pos += len + QFIXEDSZ; } @@ -104,7 +103,7 @@ static int res_handler(sd_resolve_query *q, int ret, unsigned char *answer, void while (ancount-- > 0 && (len = dn_expand(answer, end, pos, name, 255)) >= 0) { /* Ignore the initial string */ uint16_t pref, weight, port; - assert(len >= 0); + assert_se(len >= 0); pos += len; /* Ignore type, ttl, class and dlen */ pos += 10; |