summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/test-bus-marshal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-05-09 20:00:51 +0200
committerLennart Poettering <lennart@poettering.net>2013-05-09 20:01:21 +0200
commitb3af9646f8ac23e73fe1d7af3b69e35b1547b13e (patch)
tree810dddfd6f2c679ad3ae9983a81653d8e07b23e7 /src/libsystemd-bus/test-bus-marshal.c
parent9541fe6adff9941e487084c718ff2d46ed2929c6 (diff)
bus: add API for appending/reading fixed arrays
Diffstat (limited to 'src/libsystemd-bus/test-bus-marshal.c')
-rw-r--r--src/libsystemd-bus/test-bus-marshal.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsystemd-bus/test-bus-marshal.c b/src/libsystemd-bus/test-bus-marshal.c
index 20ae723fbe..ac519531f7 100644
--- a/src/libsystemd-bus/test-bus-marshal.c
+++ b/src/libsystemd-bus/test-bus-marshal.c
@@ -43,6 +43,7 @@ int main(int argc, char *argv[]) {
void *buffer = NULL;
size_t sz;
char *h;
+ const int32_t integer_array[] = { -1, -2, 0, 1, 2 }, *return_array;
r = sd_bus_message_new_method_call(NULL, "foobar.waldo", "/", "foobar.waldo", "Piep", &m);
assert_se(r >= 0);
@@ -77,6 +78,9 @@ int main(int argc, char *argv[]) {
r = sd_bus_message_close_container(m);
assert_se(r >= 0);
+ r = sd_bus_message_append_array(m, 'i', integer_array, sizeof(integer_array));
+ assert_se(r >= 0);
+
r = bus_message_seal(m, 4711);
assert_se(r >= 0);
@@ -168,6 +172,11 @@ int main(int argc, char *argv[]) {
assert_se(streq(x, "foobar"));
assert_se(streq(y, "waldo"));
+ r = sd_bus_message_read_array(m, 'i', (const void**) &return_array, &sz);
+ assert_se(r > 0);
+ assert_se(sz == sizeof(integer_array));
+ assert_se(memcmp(integer_array, return_array, sz) == 0);
+
r = sd_bus_message_peek_type(m, NULL, NULL);
assert_se(r == 0);