From 1740aa8c85534c0b0a6695f808fe53a6f96f9443 Mon Sep 17 00:00:00 2001 From: Marek Chalupa Date: Wed, 16 Jul 2014 11:32:50 +0200 Subject: [PATCH] tests: add frame_callback_wait_nofail 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). Reviewed-by: Pekka Paalanen --- 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 92cee9f0..79097fa1 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 f1546611..684afc6f 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))) int get_n_egl_buffers(struct client *client);