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

Christophe Fergeau cfergeau at redhat.com
Wed Sep 6 15:41:02 UTC 2017


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Mon, Sep 04, 2017 at 11:57:17AM +0100, Frediano Ziglio wrote:
> 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
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list