summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c7
-rw-r--r--src/libsystemd/sd-bus/test-bus-gvariant.c179
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c4
3 files changed, 94 insertions, 96 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;
}