[PATCH v2 2/3] tests: add frame_callback_wait_nofail

Pekka Paalanen ppaalanen at gmail.com
Tue Jul 22 09:22:39 PDT 2014


On Wed, 16 Jul 2014 11:32:50 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> With expect_protocol_error, we need a possibility to wait for a frame
> without aborting the test when wl_display_dispatch returns -1;
> This patch adds function frame_callback_wait_nofail that only
> returns 1 or 0 (instead of aborting on error).
> ---
>  tests/weston-test-client-helper.c | 9 ++++++---
>  tests/weston-test-client-helper.h | 6 ++++--
>  2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
> index 92cee9f..79097fa 100644
> --- a/tests/weston-test-client-helper.c
> +++ b/tests/weston-test-client-helper.c
> @@ -80,12 +80,15 @@ frame_callback_set(struct wl_surface *surface, int *done)
>  	return callback;
>  }
>  
> -void
> -frame_callback_wait(struct client *client, int *done)
> +int
> +frame_callback_wait_nofail(struct client *client, int *done)
>  {
>  	while (!*done) {
> -		assert(wl_display_dispatch(client->wl_display) >= 0);
> +		if (wl_display_dispatch(client->wl_display) < 0)
> +			return 0;
>  	}
> +
> +	return 1;
>  }
>  
>  void
> diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
> index f154661..684afc6 100644
> --- a/tests/weston-test-client-helper.h
> +++ b/tests/weston-test-client-helper.h
> @@ -120,8 +120,10 @@ move_client(struct client *client, int x, int y);
>  struct wl_callback *
>  frame_callback_set(struct wl_surface *surface, int *done);
>  
> -void
> -frame_callback_wait(struct client *client, int *done);
> +int
> +frame_callback_wait_nofail(struct client *client, int *done);
> +
> +#define frame_callback_wait(c, d) assert(frame_callback_wait_nofail((c), (d)))

I would have liked a real function better, but this works. Pushed.


Thanks,
pq


More information about the wayland-devel mailing list