[Spice-devel] [PATCH spice-server 09/16] tests: Allow to quit the message loop

Frediano Ziglio fziglio at redhat.com
Mon Sep 4 10:57:17 UTC 2017


This allows to end the loop to end some tests.
Currently different tests enter the loop but never exit from
them.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/tests/basic-event-loop.c | 11 ++++++++++-
 server/tests/basic-event-loop.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/server/tests/basic-event-loop.c b/server/tests/basic-event-loop.c
index 4cc797bf..46cf3877 100644
--- a/server/tests/basic-event-loop.c
+++ b/server/tests/basic-event-loop.c
@@ -38,6 +38,7 @@ int debug = 0;
 
 static SpiceCoreInterfaceInternal base_core_interface;
 static GMainContext *main_context = NULL;
+static GMainLoop *loop = NULL;
 
 GMainContext *basic_event_loop_get_context(void)
 {
@@ -52,10 +53,18 @@ static void event_loop_channel_event(int event, SpiceChannelEventInfo *info)
 
 void basic_event_loop_mainloop(void)
 {
-    GMainLoop *loop = g_main_loop_new(main_context, FALSE);
+    loop = g_main_loop_new(main_context, FALSE);
 
     g_main_loop_run(loop);
     g_main_loop_unref(loop);
+    loop = NULL;
+}
+
+void basic_event_loop_quit(void)
+{
+    if (loop) {
+        g_main_loop_quit(loop);
+    }
 }
 
 static void ignore_sigpipe(void)
diff --git a/server/tests/basic-event-loop.h b/server/tests/basic-event-loop.h
index 593532b6..097f4433 100644
--- a/server/tests/basic-event-loop.h
+++ b/server/tests/basic-event-loop.h
@@ -25,5 +25,6 @@ GMainContext *basic_event_loop_get_context(void);
 SpiceCoreInterface *basic_event_loop_init(void);
 void basic_event_loop_destroy(void);
 void basic_event_loop_mainloop(void);
+void basic_event_loop_quit(void);
 
 #endif // __BASIC_EVENT_LOOP_H__
-- 
2.13.5



More information about the Spice-devel mailing list