summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan N. Marchenko <me@ruff.mobi>2020-09-13 15:55:37 +0200
committerRuslan N. Marchenko <me@ruff.mobi>2020-09-23 17:54:43 +0200
commitf4edec086666e759d97093c42422bee754262d3a (patch)
tree060dd2b5f89aaa6cd9e943b2ec308073ef1ef2dd
parent431ce45f3ccfc603fd84392255e52be8cf0d06bc (diff)
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.
-rw-r--r--tests/wocky-connector-test.c15
-rw-r--r--tests/wocky-test-connector-server.c13
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);
}