[PATCH v2 2/3] tests: add frame_callback_wait_nofail

Marek Chalupa mchqwerty at gmail.com
Wed Jul 16 02:32:50 PDT 2014


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)))
 
 int
 get_n_egl_buffers(struct client *client);
-- 
2.0.1



More information about the wayland-devel mailing list