From f42d2c1b54541cf8d4e399f5c6d27d3ac40fc1a9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 21 Apr 2015 20:46:47 +0100 Subject: [PATCH] gdbus-serialization: use check_serialization() instead of dbus-daemon This test originally did not connect to the bus, which meant it was omitted from commits like 415a8d81 that made sure none of GLib tests rely on the presence of an existing session bus. (In particular, Debian autobuilders don't have a session bus.) When test_double_array() was added, environments like the Debian autobuilders didn't catch the fact that this test relied on having a session bus, because it is often skipped in minimal environments due to its libdbus-1 dependency. We don't actually need to connect to a dbus-daemon here: it's enough to convert the message from GVariant to D-Bus serialization, and back into an in-memory representation through libdbus. That's what check_serialization() does, and I've verified that when I re-introduce bug #732754 by reverting commits 627b49b and 2268628 locally, this test still fails. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=744895 Signed-off-by: Simon McVittie Reviewed-by: Colin Walters --- gio/tests/gdbus-serialization.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c index d01ab1f9e..a40518964 100644 --- a/gio/tests/gdbus-serialization.c +++ b/gio/tests/gdbus-serialization.c @@ -1060,33 +1060,23 @@ message_parse_empty_arrays_of_arrays (void) static void test_double_array (void) { - GDBusConnection *conn; - GError *error = NULL; GVariantBuilder builder; + GVariant *body; g_test_bug ("732754"); - conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); - g_assert_no_error (error); - g_variant_builder_init (&builder, G_VARIANT_TYPE ("ad")); g_variant_builder_add (&builder, "d", (gdouble)0.0); g_variant_builder_add (&builder, "d", (gdouble)8.0); g_variant_builder_add (&builder, "d", (gdouble)22.0); g_variant_builder_add (&builder, "d", (gdouble)0.0); - - /* - * Some versions of glib encoded arrays of doubles wrong. Here we send such - * a message and check that we didn't get bumped from the connection. - */ - g_dbus_connection_call_sync (conn, "org.freedesktop.DBus", "/path", - "org.freedesktop.DBus", "InvalidNonExistantMethod", - g_variant_new ("(@ad)", g_variant_builder_end (&builder)), - NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &error); - g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); - g_error_free (error); - - g_object_unref (conn); + body = g_variant_new ("(@ad)", g_variant_builder_end (&builder)); + check_serialization (body, + "value 0: array:\n" + " double: 0.000000\n" + " double: 8.000000\n" + " double: 22.000000\n" + " double: 0.000000\n"); } /* ---------------------------------------------------------------------------------------------------- */