On Wed, 29 Oct 2014 14:44:33 -0400
Frederic Plourde <[email protected]> wrote:

> Currently, once we've reached our main's wl_display_run(), we always
> return ret=EXIT_SUCCESS when weston terminates through wl_display_terminate.
> 
> This patch makes it possible to specify another return value by setting
> prior to terminating Weston. This is useful for automated tests that want
> to report test failures to the overlying testing infrastructure.
> 
> Signed-off-by: Frederic Plourde <[email protected]>
> ---
>  src/compositor.c | 17 +++++++++++++++++
>  src/compositor.h |  5 +++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 29731c7..a08b53d 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4101,6 +4101,14 @@ weston_compositor_shutdown(struct weston_compositor 
> *ec)
>  }
>  
>  WL_EXPORT void
> +weston_compositor_exit_with_code(struct weston_compositor *compositor,
> +                                                              int exit_code)
> +{
> +     compositor->exit_code = exit_code;
> +     wl_display_terminate(compositor->wl_display);
> +}
> +
> +WL_EXPORT void
>  weston_compositor_set_default_pointer_grab(struct weston_compositor *ec,
>                       const struct weston_pointer_grab_interface *interface)
>  {
> @@ -4689,6 +4697,7 @@ int main(int argc, char *argv[])
>  
>       ec->idle_time = idle_time;
>       ec->default_pointer_grab = NULL;
> +     ec->exit_code = EXIT_SUCCESS;
>  
>       for (i = 1; i < argc; i++)
>               weston_log("fatal: unhandled option: %s\n", argv[i]);
> @@ -4754,6 +4763,14 @@ int main(int argc, char *argv[])
>  
>       wl_display_run(display);
>  
> +     /* Allow for setting return exit code after
> +      * wl_display_run returns normally. This is
> +      * useful for devs/testers and automated tests
> +      * that want to indicate failure status to
> +      * testing infrastructure above
> +      */
> +     ret = ec->exit_code;
> +
>  out:
>       /* prevent further rendering while shutting down */
>       ec->state = WESTON_COMPOSITOR_OFFSCREEN;
> diff --git a/src/compositor.h b/src/compositor.h
> index 44379fe..f65ef1a 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -668,6 +668,8 @@ struct weston_compositor {
>       int32_t kb_repeat_delay;
>  
>       clockid_t presentation_clock;
> +
> +     int exit_code;
>  };
>  
>  struct weston_buffer {
> @@ -1253,6 +1255,9 @@ weston_compositor_set_presentation_clock_software(
>  void
>  weston_compositor_shutdown(struct weston_compositor *ec);
>  void
> +weston_compositor_exit_with_code(struct weston_compositor *compositor,
> +                                                              int exit_code);
> +void
>  weston_output_init_zoom(struct weston_output *output);
>  void
>  weston_output_update_zoom(struct weston_output *output);

Hi Fred,

your tab width setting is off, but I fixed that. Pushed this one.

A nice follow-up would be to search for wl_display_terminate() calls,
and convert them to weston_compositor_exit_with_code() as appropriate,
and check if there are exit() calls to replace too.

I pushed another patch on top of this to not overwrite exit_code unless
it is EXIT_SUCCESS. That way if several things want to exit, we get the
code from the first error one.


Thanks,
pq
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to