diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test-service.c | 26 | ||||
-rw-r--r-- | test/test-utils.c | 20 | ||||
-rw-r--r-- | test/test-utils.h | 3 |
3 files changed, 45 insertions, 4 deletions
diff --git a/test/test-service.c b/test/test-service.c index a1f2ae34..a9a960a1 100644 --- a/test/test-service.c +++ b/test/test-service.c @@ -2,6 +2,17 @@ #include "test-utils.h" static DBusLoop *loop; +static dbus_bool_t already_quit; + +static void +quit (void) +{ + if (!already_quit) + { + _dbus_loop_quit (loop); + already_quit = TRUE; + } +} static void die (const char *message) @@ -62,12 +73,14 @@ filter_func (DBusMessageHandler *handler, DBusConnection *connection, DBusMessage *message, void *user_data) -{ +{ if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteEcho")) return handle_echo (connection, message); - else if (dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT)) + else if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteExit") || + dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT)) { - _dbus_loop_quit (loop); + dbus_connection_disconnect (connection); + quit (); return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS; } else @@ -85,6 +98,7 @@ main (int argc, DBusMessageHandler *handler; const char *to_handle[] = { "org.freedesktop.DBus.TestSuiteEcho", + "org.freedesktop.DBus.TestSuiteExit", DBUS_MESSAGE_LOCAL_DISCONNECT, }; int result; @@ -121,11 +135,13 @@ main (int argc, fprintf (stderr, "Failed to acquire service: %s\n", error.message); dbus_error_free (&error); - return 1; + exit (1); } _dbus_loop_run (loop); + test_connection_shutdown (loop, connection); + dbus_connection_unref (connection); dbus_message_handler_unref (handler); @@ -134,6 +150,8 @@ main (int argc, loop = NULL; dbus_shutdown (); + + printf ("*** Test service exiting\n"); return 0; } diff --git a/test/test-utils.c b/test/test-utils.c index d7ccd931..62963f38 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -176,3 +176,23 @@ test_connection_setup (DBusLoop *loop, cdata_free (cd); return FALSE; } + +void +test_connection_shutdown (DBusLoop *loop, + DBusConnection *connection) +{ + if (!dbus_connection_set_watch_functions (connection, + NULL, + NULL, + NULL, + NULL, NULL)) + _dbus_assert_not_reached ("setting watch functions to NULL failed"); + + if (!dbus_connection_set_timeout_functions (connection, + NULL, + NULL, + NULL, + NULL, NULL)) + _dbus_assert_not_reached ("setting timeout functions to NULL failed"); + +} diff --git a/test/test-utils.h b/test/test-utils.h index 2f115c7f..f00a7181 100644 --- a/test/test-utils.h +++ b/test/test-utils.h @@ -11,7 +11,10 @@ dbus_bool_t test_connection_setup (DBusLoop *loop, DBusConnection *connection); +void test_connection_shutdown (DBusLoop *loop, + DBusConnection *connection); void test_connection_dispatch_all_messages (DBusConnection *connection); dbus_bool_t test_connection_dispatch_one_message (DBusConnection *connection); + #endif |