mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-14 19:55:12 +01:00
Merge branch 'test-failures' into 'main'
tests: Fix timeout sources in gdbus-auth and gapplication tests See merge request GNOME/glib!3323
This commit is contained in:
commit
8fbb8dc442
@ -1071,6 +1071,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
gboolean allow_replacement;
|
gboolean allow_replacement;
|
||||||
GSubprocess *subprocess;
|
GSubprocess *subprocess;
|
||||||
|
GApplication *app; /* (not owned) */
|
||||||
|
guint timeout_id;
|
||||||
} TestReplaceData;
|
} TestReplaceData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1116,11 +1118,12 @@ activate (gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
quit_already (gpointer data)
|
quit_already (gpointer user_data)
|
||||||
{
|
{
|
||||||
GApplication *app = data;
|
TestReplaceData *data = user_data;
|
||||||
|
|
||||||
g_application_quit (app);
|
g_application_quit (data->app);
|
||||||
|
data->timeout_id = 0;
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
@ -1159,22 +1162,22 @@ test_replace (gconstpointer data)
|
|||||||
gboolean name_lost = FALSE;
|
gboolean name_lost = FALSE;
|
||||||
TestReplaceData data;
|
TestReplaceData data;
|
||||||
GTestDBus *bus;
|
GTestDBus *bus;
|
||||||
guint timeout_id = 0;
|
|
||||||
|
|
||||||
data.allow_replacement = allow;
|
data.allow_replacement = allow;
|
||||||
data.subprocess = NULL;
|
data.subprocess = NULL;
|
||||||
|
data.timeout_id = 0;
|
||||||
|
|
||||||
bus = g_test_dbus_new (0);
|
bus = g_test_dbus_new (0);
|
||||||
g_test_dbus_up (bus);
|
g_test_dbus_up (bus);
|
||||||
|
|
||||||
app = g_application_new ("org.gtk.TestApplication.Replace", allow ? G_APPLICATION_ALLOW_REPLACEMENT : G_APPLICATION_DEFAULT_FLAGS);
|
app = data.app = g_application_new ("org.gtk.TestApplication.Replace", allow ? G_APPLICATION_ALLOW_REPLACEMENT : G_APPLICATION_DEFAULT_FLAGS);
|
||||||
g_application_set_inactivity_timeout (app, 500);
|
g_application_set_inactivity_timeout (app, 500);
|
||||||
g_signal_connect (app, "name-lost", G_CALLBACK (name_was_lost), &name_lost);
|
g_signal_connect (app, "name-lost", G_CALLBACK (name_was_lost), &name_lost);
|
||||||
g_signal_connect (app, "startup", G_CALLBACK (startup_cb), &data);
|
g_signal_connect (app, "startup", G_CALLBACK (startup_cb), &data);
|
||||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||||
|
|
||||||
if (!allow)
|
if (!allow)
|
||||||
timeout_id = g_timeout_add_seconds (1, quit_already, app);
|
data.timeout_id = g_timeout_add_seconds (1, quit_already, &data);
|
||||||
|
|
||||||
g_application_run (app, G_N_ELEMENTS (argv) - 1, argv);
|
g_application_run (app, G_N_ELEMENTS (argv) - 1, argv);
|
||||||
|
|
||||||
@ -1184,7 +1187,7 @@ test_replace (gconstpointer data)
|
|||||||
else
|
else
|
||||||
g_assert_false (name_lost);
|
g_assert_false (name_lost);
|
||||||
|
|
||||||
g_clear_handle_id (&timeout_id, g_source_remove);
|
g_clear_handle_id (&data.timeout_id, g_source_remove);
|
||||||
g_object_unref (app);
|
g_object_unref (app);
|
||||||
g_free (binpath);
|
g_free (binpath);
|
||||||
|
|
||||||
|
@ -111,15 +111,6 @@ test_auth_on_new_connection (GDBusServer *server,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
test_auth_on_timeout (gpointer user_data)
|
|
||||||
{
|
|
||||||
g_error ("Timeout waiting for client");
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const gchar *address;
|
const gchar *address;
|
||||||
@ -162,7 +153,6 @@ test_auth_mechanism (const gchar *allowed_client_mechanism,
|
|||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
GThread *client_thread;
|
GThread *client_thread;
|
||||||
TestAuthData data;
|
TestAuthData data;
|
||||||
guint timeout_id;
|
|
||||||
|
|
||||||
server = server_new_for_mechanism (allowed_server_mechanism);
|
server = server_new_for_mechanism (allowed_server_mechanism);
|
||||||
|
|
||||||
@ -173,13 +163,12 @@ test_auth_mechanism (const gchar *allowed_client_mechanism,
|
|||||||
G_CALLBACK (test_auth_on_new_connection),
|
G_CALLBACK (test_auth_on_new_connection),
|
||||||
loop);
|
loop);
|
||||||
|
|
||||||
timeout_id = g_timeout_add_seconds (5, test_auth_on_timeout, NULL);
|
|
||||||
|
|
||||||
data.allowed_client_mechanism = allowed_client_mechanism;
|
data.allowed_client_mechanism = allowed_client_mechanism;
|
||||||
data.allowed_server_mechanism = allowed_server_mechanism;
|
data.allowed_server_mechanism = allowed_server_mechanism;
|
||||||
data.address = g_dbus_server_get_client_address (server);
|
data.address = g_dbus_server_get_client_address (server);
|
||||||
|
|
||||||
/* run the D-Bus client in a thread */
|
/* Run the D-Bus client in a thread. If this hangs forever, the test harness
|
||||||
|
* (typically Meson) will eventually kill the test. */
|
||||||
client_thread = g_thread_new ("gdbus-client-thread",
|
client_thread = g_thread_new ("gdbus-client-thread",
|
||||||
test_auth_client_thread_func,
|
test_auth_client_thread_func,
|
||||||
&data);
|
&data);
|
||||||
@ -191,7 +180,6 @@ test_auth_mechanism (const gchar *allowed_client_mechanism,
|
|||||||
g_dbus_server_stop (server);
|
g_dbus_server_stop (server);
|
||||||
|
|
||||||
g_thread_join (client_thread);
|
g_thread_join (client_thread);
|
||||||
g_source_remove (timeout_id);
|
|
||||||
|
|
||||||
while (g_main_context_iteration (NULL, FALSE));
|
while (g_main_context_iteration (NULL, FALSE));
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user