[PATCH weston 7/8] tests/buffer-count-test: teardown after the test

Emil Velikov emil.l.velikov at gmail.com
Mon Nov 14 17:08:18 UTC 2016


From: Emil Velikov <emil.velikov at collabora.com>

Might be a bit of an overkill, but still. One should cleanup after
themselves.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 tests/buffer-count-test.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/buffer-count-test.c b/tests/buffer-count-test.c
index e7d8ca7..0df9774 100644
--- a/tests/buffer-count-test.c
+++ b/tests/buffer-count-test.c
@@ -39,6 +39,7 @@
 
 struct test_data {
 	struct client *client;
+	struct wl_egl_window *native_window;
 
 	EGLDisplay egl_dpy;
 	EGLContext egl_ctx;
@@ -49,7 +50,6 @@ struct test_data {
 static int
 init_egl(struct test_data *test_data)
 {
-	struct wl_egl_window *native_window;
 	struct surface *surface = test_data->client->surface;
 	const char *str, *mesa;
 
@@ -94,14 +94,15 @@ init_egl(struct test_data *test_data)
 	if (!test_data->egl_ctx)
 		fail("eglCreateContext");
 
-	native_window =
+	test_data->native_window =
 		wl_egl_window_create(surface->wl_surface,
 				     surface->width,
 				     surface->height);
 	test_data->egl_surface =
 		weston_platform_create_egl_surface(test_data->egl_dpy,
 						   test_data->egl_conf,
-						   native_window, NULL);
+						   test_data->native_window,
+						   NULL);
 
 	ret = eglMakeCurrent(test_data->egl_dpy, test_data->egl_surface,
 			     test_data->egl_surface, test_data->egl_ctx);
@@ -122,6 +123,17 @@ init_egl(struct test_data *test_data)
 	return 0;
 }
 
+static void
+fini_egl(struct test_data *test_data)
+{
+	eglMakeCurrent(test_data->egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
+		       EGL_NO_CONTEXT);
+	weston_platform_destroy_egl_surface(test_data->egl_dpy,
+					    test_data->egl_surface);
+	wl_egl_window_destroy(test_data->native_window);
+	eglTerminate(test_data->egl_dpy);
+}
+
 TEST(test_buffer_count)
 {
 	struct test_data test_data;
@@ -155,4 +167,6 @@ TEST(test_buffer_count)
 	/* The implementation should only end up creating two buffers
 	 * and cycling between them */
 	assert(buffer_count == 2);
+
+	fini_egl(&test_data);
 }
-- 
2.9.3



More information about the wayland-devel mailing list