mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-30 19:06:38 +02:00
tests: Add a missing poll condition to socket-listener test
It’s possible for the server communications to finish one main context iteration before all of the client communications, depending on how the kernel queues socket connection messages. Fixes CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/5341950 ``` GLib-GIO:ERROR:../gio/tests/socket-listener.c:639:test_accept_multi_simultaneously: 'clients[i].result' should not be NULL not ok /socket-listener/accept/multi-simultaneously - GLib-GIO:ERROR:../gio/tests/socket-listener.c:639:test_accept_multi_simultaneously: 'clients[i].result' should not be NULL ``` Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -573,19 +573,31 @@ any_are_null (const void * const *ptr_array,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t listening_port;
|
||||
GSocketClient *client;
|
||||
GAsyncResult *result;
|
||||
GSocketConnection *connection;
|
||||
} AcceptMultiSimultaneouslyClient;
|
||||
|
||||
static gboolean
|
||||
any_client_results_are_null (const AcceptMultiSimultaneouslyClient *clients,
|
||||
size_t n_clients)
|
||||
{
|
||||
for (size_t i = 0; i < n_clients; i++)
|
||||
if (clients[i].result == NULL)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_accept_multi_simultaneously (void)
|
||||
{
|
||||
GSocketListener *listener = NULL;
|
||||
GAsyncResult *accept_results[5] = { NULL, };
|
||||
struct
|
||||
{
|
||||
uint16_t listening_port;
|
||||
GSocketClient *client;
|
||||
GAsyncResult *result;
|
||||
GSocketConnection *connection;
|
||||
}
|
||||
clients[5] = { { 0, NULL, NULL, NULL }, };
|
||||
AcceptMultiSimultaneouslyClient clients[5] = { { 0, NULL, NULL, NULL }, };
|
||||
GSocketConnection *server_connection = NULL;
|
||||
GCancellable *cancellable = NULL;
|
||||
GError *local_error = NULL;
|
||||
@@ -620,7 +632,8 @@ test_accept_multi_simultaneously (void)
|
||||
cancellable, async_result_cb, &clients[i].result);
|
||||
}
|
||||
|
||||
while (accept_results[0] == NULL)
|
||||
while (accept_results[0] == NULL ||
|
||||
any_client_results_are_null (clients, G_N_ELEMENTS (clients)))
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
/* Exactly one server connection should have been created, because we called
|
||||
|
Reference in New Issue
Block a user