tests: Fix a potential race condition in pollable test

This may have been causing an intermittent failure of the pollable test
on BSD, where updating the readable status of a socket takes a bit
longer than on Linux.

```
GLib-GIO-DEBUG: 16:06:41.235: GSocketClient: Starting application layer connection
GLib-GIO-DEBUG: 16:06:41.235: GSocketClient: Connection successful!
Bail out! GLib-GIO:ERROR:../gio/tests/pollable.c:73:check_source_readability_callback: assertion failed (readable == expected): (0 == 1)
```

I have not debugged the test on BSD, though, so this is only a guess.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/2022087

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-05-31 13:14:15 +01:00
parent 4daa3ca33e
commit 95c1d656e2

View File

@ -90,10 +90,8 @@ write_callback (gpointer user_data)
g_assert_cmpint (nwrote, ==, 2);
g_assert_true (g_pollable_output_stream_is_writable (G_POLLABLE_OUTPUT_STREAM (streams->out)));
/* Give the pipe a few ticks to propagate the write for sockets. On my
* iMac i7, 40 works, 30 doesn't. */
g_usleep (80L);
/* Wait for the pipe to propagate the write for sockets. */
while (!g_pollable_input_stream_is_readable (streams->in));
g_assert_true (g_pollable_input_stream_is_readable (streams->in));
return G_SOURCE_REMOVE;