From 95cd35028fec0239cfe05ece3f571d055ff6e501 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 16 Dec 2010 18:42:08 +0000 Subject: tests/dbus/dbus: cancel_watch_during_dispatch: assert that user_data is freed --- tests/dbus/dbus.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/dbus/dbus.c b/tests/dbus/dbus.c index 2eccec858..842b47ad1 100644 --- a/tests/dbus/dbus.c +++ b/tests/dbus/dbus.c @@ -255,6 +255,20 @@ test_watch_name_owner (void) #define N_CALLBACK_PAIRS 5 gboolean callbacks_fired[N_CALLBACK_PAIRS] = { FALSE, FALSE, FALSE, FALSE, FALSE }; +/* Overwritten with "-" when "freed" */ +gchar user_data_flags[N_CALLBACK_PAIRS * 2 + 1] = "0123456789"; + +static void +free_fake_user_data (gpointer user_data) +{ + guint i = GPOINTER_TO_UINT (user_data); + + if (user_data_flags[i] == '.') + g_error ("Double 'free' of user-data %u. Still to free: %s", i, + user_data_flags); + + user_data_flags[i] = '.'; +} static void bbf3_performed_cb ( @@ -297,12 +311,15 @@ cancel_watch_during_dispatch (void) for (i = 0; i < N_CALLBACK_PAIRS * 2; i++) tp_dbus_daemon_watch_name_owner (bus, "ca.bbf3", bbf3_performed_cb, - GUINT_TO_POINTER (i), NULL); + GUINT_TO_POINTER (i), free_fake_user_data); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); g_main_loop_unref (mainloop); g_object_unref (bus); + + /* everything should have been "freed" */ + g_assert_cmpstr (user_data_flags, ==, ".........."); } int -- cgit v1.2.3