From f4edec086666e759d97093c42422bee754262d3a Mon Sep 17 00:00:00 2001 From: "Ruslan N. Marchenko" Date: Sun, 13 Sep 2020 15:55:37 +0200 Subject: Tests: Add more retries before tearing the connection down tests/wocky-connector-test is a bit racy when it checks connection failure conditions. Partially because it races with IO events, partially because it races with internal events (test-stream). Add more retries to reduce internal race and handle cancellabe race explicitly. --- tests/wocky-connector-test.c | 15 +++++++++++++-- tests/wocky-test-connector-server.c | 13 +++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/wocky-connector-test.c b/tests/wocky-connector-test.c index 7811ea1..e08710e 100644 --- a/tests/wocky-connector-test.c +++ b/tests/wocky-connector-test.c @@ -3385,8 +3385,19 @@ test_server_teardown_cb (GObject *source, static gboolean test_server_idle_quit_loop_cb (GMainLoop *loop) { - g_main_loop_quit (loop); - return G_SOURCE_REMOVE; + static int retries = 0; + + if (retries == 5) + { + g_main_loop_quit (loop); + retries = 0; + return G_SOURCE_REMOVE; + } + else + { + retries ++; + return G_SOURCE_CONTINUE; + } } static void diff --git a/tests/wocky-test-connector-server.c b/tests/wocky-test-connector-server.c index 8221267..1796ed5 100644 --- a/tests/wocky-test-connector-server.c +++ b/tests/wocky-test-connector-server.c @@ -1390,8 +1390,17 @@ force_closed_cb (GObject *source, success = wocky_xmpp_connection_force_close_finish ( WOCKY_XMPP_CONNECTION (source), result, &error); - g_assert_no_error (error); - g_assert (success); + if (success) + { + g_assert_no_error (error); + } + else if (self->priv->teardown_task && self->priv->cancellable == NULL) + { + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); + g_error_free (error); + } + else + g_assert_not_reached (); server_dec_outstanding (self); } -- cgit v1.2.1