From f154bb7b2bea372fe694abb20492d411dcedce61 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 5 Nov 2015 05:44:19 +0100 Subject: [PATCH] Fix test cases running client and server dispatch design issue. DBus test cases running the server *and* client loop in the same process assumed that all messages send from the server has to be received in one client dispatch, which is not the case in all environments. https://bugs.freedesktop.org/show_bug.cgi?id=92721 --- bus/dispatch.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/bus/dispatch.c b/bus/dispatch.c index 3ea944a..52459c6 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -653,6 +653,7 @@ typedef struct const char *expected_service_name; dbus_bool_t failed; DBusConnection *skip_connection; + BusContext *context; } CheckServiceOwnerChangedData; static dbus_bool_t @@ -674,9 +675,16 @@ check_service_owner_changed_foreach (DBusConnection *connection, message = pop_message_waiting_for_memory (connection); if (message == NULL) { - _dbus_warn ("Did not receive a message on %p, expecting %s\n", - connection, "NameOwnerChanged"); - goto out; + dbus_connection_ref (connection); + block_connection_until_message_from_bus (d->context, connection, "NameOwnerChanged"); + dbus_connection_unref (connection); + message = pop_message_waiting_for_memory (connection); + if (message == NULL) + { + _dbus_warn ("Did not receive a message on %p, expecting %s\n", + connection, "NameOwnerChanged"); + goto out; + } } else if (!dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, @@ -789,6 +797,7 @@ kill_client_connection (BusContext *context, socd.expected_service_name = base_service; socd.failed = FALSE; socd.skip_connection = NULL; + socd.context = context; bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -1019,6 +1028,8 @@ check_hello_message (BusContext *context, socd.expected_service_name = name; socd.failed = FALSE; socd.skip_connection = connection; /* we haven't done AddMatch so won't get it ourselves */ + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -1031,9 +1042,16 @@ check_hello_message (BusContext *context, message = pop_message_waiting_for_memory (connection); if (message == NULL) { - _dbus_warn ("Expecting %s, got nothing\n", + dbus_connection_ref (connection); + block_connection_until_message_from_bus (context, connection, "signal NameAcquired"); + dbus_connection_unref (connection); + message = pop_message_waiting_for_memory (connection); + if (message == NULL) + { + _dbus_warn ("Expecting %s, got nothing\n", "NameAcquired"); - goto out; + goto out; + } } if (! dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameAcquired")) @@ -2086,6 +2104,8 @@ check_base_service_activated (BusContext *context, socd.expected_service_name = base_service; socd.failed = FALSE; socd.skip_connection = connection; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -2190,6 +2210,8 @@ check_service_activated (BusContext *context, socd.skip_connection = connection; socd.failed = FALSE; socd.expected_service_name = service_name; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -2327,6 +2349,8 @@ check_service_auto_activated (BusContext *context, socd.expected_service_name = service_name; socd.failed = FALSE; socd.skip_connection = connection; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -2376,6 +2400,8 @@ check_service_deactivated (BusContext *context, socd.expected_service_name = activated_name; socd.failed = FALSE; socd.skip_connection = NULL; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -2386,6 +2412,8 @@ check_service_deactivated (BusContext *context, socd.expected_service_name = base_service; socd.failed = FALSE; socd.skip_connection = NULL; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -2833,6 +2861,7 @@ check_existent_service_no_auto_start (BusContext *context, socd.expected_service_name = base_service; socd.failed = FALSE; socd.skip_connection = NULL; + socd.context = context; bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -3453,6 +3482,8 @@ check_existent_service_auto_start (BusContext *context, socd.expected_service_name = base_service; socd.failed = FALSE; socd.skip_connection = NULL; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); @@ -4141,6 +4172,8 @@ check_shell_service_success_auto_start (BusContext *context, socd.expected_service_name = base_service; socd.failed = FALSE; socd.skip_connection = NULL; + socd.context = context; + bus_test_clients_foreach (check_service_owner_changed_foreach, &socd); -- 1.8.4.5