[gupnp: 22/25] tests: Disconnect timeout for delayed shutdown




commit 88419ce7df41ed25cd5d4a972dbe5fca8a86e0d5
Author: Jens Georg <mail jensge org>
Date:   Wed Dec 29 16:58:05 2021 +0100

    tests: Disconnect timeout for delayed shutdown

 tests/test-acl.c     | 9 ++++++++-
 tests/test-context.c | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-acl.c b/tests/test-acl.c
index 1c96a37..321171a 100644
--- a/tests/test-acl.c
+++ b/tests/test-acl.c
@@ -60,6 +60,13 @@ test_fixture_setup (ContextTestFixture *tf, gconstpointer user_data)
         g_slist_free_full (uris, (GDestroyNotify) g_uri_unref);
 }
 
+static gboolean
+delayed_loop_quitter (gpointer user_data)
+{
+        g_main_loop_quit (user_data);
+        return G_SOURCE_REMOVE;
+}
+
 static void
 test_fixture_teardown (ContextTestFixture *tf, gconstpointer user_data)
 {
@@ -67,7 +74,7 @@ test_fixture_teardown (ContextTestFixture *tf, gconstpointer user_data)
         g_object_unref (tf->context);
 
         // Make sure the source teardown handlers get run so we don't confuse valgrind
-        g_timeout_add (500, (GSourceFunc) g_main_loop_quit, tf->loop);
+        g_timeout_add (500, (GSourceFunc) delayed_loop_quitter, tf->loop);
         g_main_loop_run (tf->loop);
         g_main_loop_unref (tf->loop);
         g_object_unref (tf->session);
diff --git a/tests/test-context.c b/tests/test-context.c
index 21c2656..8fefdc7 100644
--- a/tests/test-context.c
+++ b/tests/test-context.c
@@ -56,6 +56,13 @@ test_fixture_setup (ContextTestFixture* tf, gconstpointer user_data)
         g_slist_free_full (uris, (GDestroyNotify) g_uri_unref);
 }
 
+static gboolean
+delayed_loop_quitter (gpointer user_data)
+{
+        g_main_loop_quit (user_data);
+        return G_SOURCE_REMOVE;
+}
+
 static void
 test_fixture_teardown (ContextTestFixture *tf, gconstpointer user_data)
 {
@@ -63,7 +70,7 @@ test_fixture_teardown (ContextTestFixture *tf, gconstpointer user_data)
         g_object_unref (tf->context);
 
         // Make sure the source teardown handlers get run so we don't confuse valgrind
-        g_timeout_add (500, (GSourceFunc) g_main_loop_quit, tf->loop);
+        g_timeout_add (500, (GSourceFunc) delayed_loop_quitter, tf->loop);
         g_main_loop_run (tf->loop);
         g_main_loop_unref (tf->loop);
         g_object_unref (tf->session);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]