diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-02-13 17:32:38 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-02-16 15:03:44 +0100 |
commit | 2ac7c17f9d8eeb403b91ee5a389562edaf47fb87 (patch) | |
tree | 3b55981e7648c1b58aaf6d656e28003c53c3497c /src/libsystemd/sd-bus/test-bus-gvariant.c | |
parent | 38ab096869ad6bb39a9ef9a012abfb42ea62cd93 (diff) |
Revert "Revert "sd-bus: change serialization of kdbus messages to qualify in their entirety as gvariant objects""
This reverts commit 954871d8ba15911d014f76ed2c7a9492953cf39d.
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-gvariant.c')
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-gvariant.c | 24 |
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; |