From d30d68dbb9e013cd002923608d34b8af3e1fe522 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 11 Mar 2014 18:32:22 +0000 Subject: tests: relax assertion that user_data is freed immediately In GDBus, every call back to user code comes through an idle, to improve thread-safety. --- tests/dbus/disconnection.c | 38 +++++++++++++++++++++++++++++--------- tests/dbus/unsupported-interface.c | 5 ++++- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c index 5f3ff5247..edf2dfe44 100644 --- a/tests/dbus/disconnection.c +++ b/tests/dbus/disconnection.c @@ -364,15 +364,29 @@ main (int argc, g_error_free (error_out); error_out = NULL; - /* Now that the main loop has run, cancelled signal connections have been - * freed */ - MYASSERT (tp_intset_is_member (freed_user_data, TEST_B), ""); - MYASSERT (tp_intset_is_member (freed_user_data, TEST_C), ""); - MYASSERT (tp_intset_is_member (freed_user_data, TEST_D), ""); - MYASSERT (tp_intset_is_member (freed_user_data, TEST_E), ""); - MYASSERT (tp_intset_is_member (freed_user_data, TEST_F), ""); - MYASSERT (tp_intset_is_member (freed_user_data, TEST_G), ""); - MYASSERT (tp_intset_is_member (freed_user_data, TEST_H), ""); + /* It might take a little longer to free all the user-data, because it + * happens in an idle */ + + while (!tp_intset_is_member (freed_user_data, TEST_B)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_C)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_D)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_E)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_F)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_G)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_H)) + g_main_context_iteration (NULL, TRUE); /* both A and Z are still listening for signals, so their user data is * still held */ @@ -390,6 +404,12 @@ main (int argc, tp_tests_assert_last_unref (&f->proxies[TEST_H]); tp_tests_assert_last_unref (&f->proxies[TEST_Z]); + while (!tp_intset_is_member (freed_user_data, TEST_A)) + g_main_context_iteration (NULL, TRUE); + + while (!tp_intset_is_member (freed_user_data, TEST_Z)) + g_main_context_iteration (NULL, TRUE); + /* we should already have checked each of these at least once, but just to * make sure we have a systematic test that all user data is freed... */ MYASSERT (tp_intset_is_member (freed_user_data, TEST_A), ""); diff --git a/tests/dbus/unsupported-interface.c b/tests/dbus/unsupported-interface.c index 818e40f2e..7ff94d777 100644 --- a/tests/dbus/unsupported-interface.c +++ b/tests/dbus/unsupported-interface.c @@ -196,7 +196,10 @@ test_supported_signal (Fixture *f, g_assert (!f->freed); tp_proxy_signal_connection_disconnect (sc); - g_assert (f->freed); + + /* GDBus invokes destructors in an idle */ + while (!f->freed) + g_main_context_iteration (NULL, TRUE); } static void -- cgit v1.2.3