tests: Add missing wakeup calls to gdbus-names.c

Following on from the previous commit, some explicit
`g_main_context_wakeup()` calls were missing from the test code which
only uses `GMainContext`.

Add them, and also add some assertions to check that these functions are
being called in the expected thread (as the code comments say).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-06-15 13:00:20 +01:00
parent 8530a6a8e4
commit bd8d139a77

View File

@ -513,6 +513,7 @@ typedef struct
gboolean unwatch_early;
GMutex mutex;
guint watch_id;
GMainContext *thread_context; /* (unowned), only accessed from watcher_thread() */
} WatchNameThreadData;
static void
@ -892,6 +893,9 @@ static void
t_watch_name_data_free_func (WatchNameThreadData *thread_data)
{
thread_data->data.num_free_func++;
g_assert_true (g_main_context_is_owner (thread_data->thread_context));
g_main_context_wakeup (thread_data->thread_context);
}
/* Called in the same thread as watcher_thread() */
@ -903,6 +907,9 @@ t_name_appeared_handler (GDBusConnection *connection,
{
WatchNameThreadData *thread_data = user_data;
thread_data->data.num_appeared += 1;
g_assert_true (g_main_context_is_owner (thread_data->thread_context));
g_main_context_wakeup (thread_data->thread_context);
}
/* Called in the same thread as watcher_thread() */
@ -913,6 +920,9 @@ t_name_vanished_handler (GDBusConnection *connection,
{
WatchNameThreadData *thread_data = user_data;
thread_data->data.num_vanished += 1;
g_assert_true (g_main_context_is_owner (thread_data->thread_context));
g_main_context_wakeup (thread_data->thread_context);
}
/* Called in the thread which constructed the GDBusConnection */
@ -940,6 +950,7 @@ watcher_thread (gpointer user_data)
GMainContext *thread_context;
thread_context = g_main_context_new ();
thread_data->thread_context = thread_context;
g_main_context_push_thread_default (thread_context);
// Notify that the thread has started