Commit 1cad169b authored by Simon McVittie's avatar Simon McVittie

tests/agents: Put a finite timeout on agent start/stop

This prevents the test from hanging forever on failure.
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: Frédéric Dalleau's avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D7107
parent 5c815140
......@@ -214,8 +214,14 @@ install_bundle_and_wait_for_agent (Fixture *f)
/* The agent is not initially running. GDBus represents this by reporting
* it as having vanished. */
while (f->agent_vanished_count == 0)
g_main_context_iteration (NULL, TRUE);
{
g_auto (TestsScopedTimeout) timeout = 0;
tests_scoped_timeout_start (&timeout, 10);
while (f->agent_vanished_count == 0)
g_main_context_iteration (NULL, TRUE);
}
g_assert_cmpstr (f->agent_unique_name, ==, NULL);
g_assert_cmpuint (f->agent_appeared_count, ==, 0);
......@@ -228,9 +234,17 @@ install_bundle_and_wait_for_agent (Fixture *f)
tests_app_bundle_install_bundle (&f->bundle, NULL, version);
/* Now that we have implemented T2711, the agent should start as a
* side-effect of the installation of the bundle. */
while (f->agent_unique_name == NULL)
g_main_context_iteration (NULL, TRUE);
* side-effect of the installation of the bundle. Be a bit generous
* with the timing, since for simplicity tests_app_bundle_install_bundle()
* doesn't actually wait for the transaction to finish. */
{
g_auto (TestsScopedTimeout) timeout = 0;
tests_scoped_timeout_start (&timeout, 30);
while (f->agent_unique_name == NULL)
g_main_context_iteration (NULL, TRUE);
}
g_assert_cmpstr (f->agent_unique_name, !=, NULL);
g_assert_cmpuint (f->agent_appeared_count, ==, 1);
......@@ -244,6 +258,7 @@ install_bundle_and_wait_for_agent (Fixture *f)
static void
terminate_agent_and_wait (Fixture *f)
{
g_auto (TestsScopedTimeout) timeout = 0;
g_autoptr (GError) error = NULL;
/* Make sure any automated restart processing implemented for
......@@ -256,6 +271,8 @@ terminate_agent_and_wait (Fixture *f)
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
g_assert_no_error (error);
tests_scoped_timeout_start (&timeout, 10);
while (f->agent_unique_name != NULL)
g_main_context_iteration (NULL, TRUE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment