summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/test-bus-gvariant.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-26 21:48:08 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-26 21:52:07 +0100
commitb381de4197157748ed96e469fcc372c23f842ae1 (patch)
tree5f5fa7cc7a4a703c294d92b9501772857a286fdb /src/libsystemd/sd-bus/test-bus-gvariant.c
parentee04388a54f0e045377eeaf33c17eb357fe12d69 (diff)
sd-bus: change serialization of kdbus messages to qualify in their entirety as gvariant objects
Previously, we only minimally altered the dbus1 framing for kdbus, and while the header and its fields where compliant Gvariant objects, and so was the body, the entire message together was not. As result of discussions with Ryan Lortie this is now changed, so that the messages in there entirely are fully compliant GVariants. This follows the framing description described here: https://wiki.gnome.org/Projects/GLib/GDBus/Version2 Note that this change changes the framing of *all* messages sent via kdbus, this means you have to reboot your kdbus system, after compiling and installing this new version.
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-gvariant.c')
-rw-r--r--src/libsystemd/sd-bus/test-bus-gvariant.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c
index 6992ec44de..992edacb28 100644
--- a/src/libsystemd/sd-bus/test-bus-gvariant.c
+++ b/src/libsystemd/sd-bus/test-bus-gvariant.c
@@ -132,7 +132,7 @@ static void test_bus_gvariant_get_alignment(void) {
static void test_marshal(void) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *n = NULL;
- _cleanup_bus_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_close_unref_ sd_bus *bus = NULL;
_cleanup_free_ void *blob;
size_t sz;
int r;
@@ -145,6 +145,8 @@ static void test_marshal(void) {
assert_se(sd_bus_message_new_method_call(bus, &m, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName") >= 0);
+ assert_cc(sizeof(struct bus_header) == 16);
+
assert_se(sd_bus_message_append(m,
"a(usv)", 3,
4711, "first-string-parameter", "(st)", "X", (uint64_t) 1111,
@@ -162,13 +164,15 @@ static void test_marshal(void) {
g_type_init();
#endif
- v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuuua(yv))"), m->header, sizeof(struct bus_header) + BUS_MESSAGE_FIELDS_SIZE(m), false, NULL, NULL);
+ v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuta{tv})"), m->header, sizeof(struct bus_header) + m->fields_size, false, NULL, NULL);
+ assert_se(g_variant_is_normal_form(v));
t = g_variant_print(v, TRUE);
printf("%s\n", t);
g_free(t);
g_variant_unref(v);
- v = g_variant_new_from_data(G_VARIANT_TYPE("(a(usv))"), m->body.data, BUS_MESSAGE_BODY_SIZE(m), false, NULL, NULL);
+ v = g_variant_new_from_data(G_VARIANT_TYPE("(a(usv))"), m->body.data, m->user_body_size, false, NULL, NULL);
+ assert_se(g_variant_is_normal_form(v));
t = g_variant_print(v, TRUE);
printf("%s\n", t);
g_free(t);
@@ -180,6 +184,20 @@ static void test_marshal(void) {
assert_se(bus_message_get_blob(m, &blob, &sz) >= 0);
+#ifdef HAVE_GLIB
+ {
+ GVariant *v;
+ char *t;
+
+ v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuta{tv}v)"), blob, sz, false, NULL, NULL);
+ assert_se(g_variant_is_normal_form(v));
+ t = g_variant_print(v, TRUE);
+ printf("%s\n", t);
+ g_free(t);
+ g_variant_unref(v);
+ }
+#endif
+
assert_se(bus_message_from_malloc(bus, blob, sz, NULL, 0, NULL, NULL, &n) >= 0);
blob = NULL;