[glib] gio/tests/cancellable: fix to still work when running slowly
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio/tests/cancellable: fix to still work when running slowly
- Date: Mon, 3 Sep 2012 12:57:05 +0000 (UTC)
commit 17bb9d542cea2eeb3cb54cb583f671cf5e005631
Author: Dan Winship <danw gnome org>
Date: Fri Aug 24 17:11:38 2012 -0400
gio/tests/cancellable: fix to still work when running slowly
The test was assuming that all cancelled ops would finish within a
certain amount of time, but this often failed under valgrind. Instead,
just run the loop until all of the ops have actually finished.
https://bugzilla.gnome.org/show_bug.cgi?id=682560
gio/tests/cancellable.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/cancellable.c b/gio/tests/cancellable.c
index e4fd098..7c960c7 100644
--- a/gio/tests/cancellable.c
+++ b/gio/tests/cancellable.c
@@ -149,6 +149,8 @@ mock_operation_finish (GAsyncResult *result,
return data->iterations_done;
}
+GMainLoop *loop;
+
static void
on_mock_operation_ready (GObject *source,
GAsyncResult *result,
@@ -166,6 +168,9 @@ on_mock_operation_ready (GObject *source,
g_assert_cmpint (iterations_requested, >, iterations_done);
num_async_operations--;
+
+ if (!num_async_operations)
+ g_main_loop_quit (loop);
}
static gboolean
@@ -181,7 +186,6 @@ test_cancel_multiple_concurrent (void)
{
GCancellable *cancellable;
guint i, iterations;
- GMainLoop *loop;
cancellable = g_cancellable_new ();
loop = g_main_loop_new (NULL, FALSE);
@@ -203,8 +207,7 @@ test_cancel_multiple_concurrent (void)
g_cancellable_cancel (cancellable);
g_assert (g_cancellable_is_cancelled (cancellable));
- /* Wait for two more iterations, and all threads should be cancelled */
- g_timeout_add (WAIT_ITERATION * 2, on_main_loop_timeout_quit, loop);
+ /* Wait for all operations to be cancelled */
g_main_loop_run (loop);
g_assert_cmpint (num_async_operations, ==, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]