mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
tests: Fix race condition on cancellation in unix-streams test
The cancellable may be cancelled just after the operation succeeds in a different thread. So instead of checking whether the cancellable is cancelled, check whether the operation returned a `CANCELLED` error, and *then* assert that the cancellable is cancelled. This should fix https://pwithnall.pages.gitlab.gnome.org/-/glib/-/jobs/2338552/artifacts/_build/meson-logs/testlog.txt: ``` ok 1 /unix-streams/basic Bail out! GLib-GIO:ERROR:../gio/tests/unix-streams.c:149:main_thread_skipped: assertion failed (err == (g-io-error-quark, 19)): err is NULL stderr: ``` Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
b7f2b09c30
commit
0c1fa95827
@ -144,9 +144,9 @@ main_thread_skipped (GObject *source, GAsyncResult *res, gpointer user_data)
|
||||
|
||||
nskipped = g_input_stream_skip_finish (in, res, &err);
|
||||
|
||||
if (g_cancellable_is_cancelled (main_cancel))
|
||||
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
g_assert_error (err, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
||||
g_assert_true (g_cancellable_is_cancelled (main_cancel));
|
||||
do_main_cancel (out);
|
||||
g_clear_error (&err);
|
||||
return;
|
||||
@ -180,9 +180,9 @@ main_thread_read (GObject *source, GAsyncResult *res, gpointer user_data)
|
||||
|
||||
nread = g_input_stream_read_finish (in, res, &err);
|
||||
|
||||
if (g_cancellable_is_cancelled (main_cancel))
|
||||
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
g_assert_error (err, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
||||
g_assert_true (g_cancellable_is_cancelled (main_cancel));
|
||||
do_main_cancel (out);
|
||||
g_clear_error (&err);
|
||||
return;
|
||||
@ -218,9 +218,9 @@ main_thread_wrote (GObject *source, GAsyncResult *res, gpointer user_data)
|
||||
|
||||
nwrote = g_output_stream_write_finish (out, res, &err);
|
||||
|
||||
if (g_cancellable_is_cancelled (main_cancel))
|
||||
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
g_assert_error (err, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
||||
g_assert_true (g_cancellable_is_cancelled (main_cancel));
|
||||
do_main_cancel (out);
|
||||
g_clear_error (&err);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user