[Piglit] [PATCH 1/5] egl: Change each test to initialize egl_test with common function

Chad Versace chad at chad-versace.us
Wed Oct 19 18:37:46 PDT 2011


Define egl_test_init(struct egl_test*), which initializes the test to
default values. Modify each test to use that function.

This is in preparation for allowing an EGL test to specify its window
dimensions.

Signed-off-by: Chad Versace <chad at chad-versace.us>
---
 tests/egl/egl-create-surface.c          |   23 +++++------------------
 tests/egl/egl-nok-swap-region.c         |   22 ++++++----------------
 tests/egl/egl-nok-texture-from-pixmap.c |   22 ++++++----------------
 tests/egl/egl-util.c                    |   10 ++++++++++
 tests/egl/egl-util.h                    |   17 +++++++++++++++++
 5 files changed, 44 insertions(+), 50 deletions(-)

diff --git a/tests/egl/egl-create-surface.c b/tests/egl/egl-create-surface.c
index 4481446..c58d0f1 100644
--- a/tests/egl/egl-create-surface.c
+++ b/tests/egl/egl-create-surface.c
@@ -43,16 +43,6 @@ static const EGLint pixmap_attribs[] = {
 	EGL_NONE
 };
 
-static const EGLint attribs[] = {
-	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
-	EGL_RED_SIZE, 1,
-	EGL_GREEN_SIZE, 1,
-	EGL_BLUE_SIZE, 1,
-	EGL_DEPTH_SIZE, 1,
-	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
-	EGL_NONE
-};
-
 static enum piglit_result
 draw(struct egl_state *state)
 {
@@ -77,16 +67,13 @@ draw(struct egl_state *state)
 	return PIGLIT_PASS;
 }
 
-static const char *extensions[] = { NULL };
-
-static const struct egl_test test = {
-	.config_attribs = attribs,
-	.extensions = extensions,
-	.draw = draw
-};
-
 int
 main(int argc, char *argv[])
 {
+	struct egl_test test;
+
+	egl_init_test(&test);
+	test.draw = draw;
+
 	return egl_util_run(&test, argc, argv);
 }
diff --git a/tests/egl/egl-nok-swap-region.c b/tests/egl/egl-nok-swap-region.c
index 993a407..9493d4d 100644
--- a/tests/egl/egl-nok-swap-region.c
+++ b/tests/egl/egl-nok-swap-region.c
@@ -35,16 +35,6 @@
 
 const char *extensions[] = { "EGL_NOK_swap_region", NULL };
 
-static const EGLint attribs[] = {
-	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
-	EGL_RED_SIZE, 1,
-	EGL_GREEN_SIZE, 1,
-	EGL_BLUE_SIZE, 1,
-	EGL_DEPTH_SIZE, 1,
-	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
-	EGL_NONE
-};
-
 static enum piglit_result
 draw(struct egl_state *state)
 {
@@ -82,15 +72,15 @@ draw(struct egl_state *state)
 	return PIGLIT_PASS;
 }
 
-static const struct egl_test test = {
-	.config_attribs = attribs,
-	.extensions = extensions,
-	.draw = draw
-};
-
 int
 main(int argc, char *argv[])
 {
+	struct egl_test test;
+
+	egl_init_test(&test);
+	test.extensions = extensions;
+	test.draw = draw;
+
 	return egl_util_run(&test, argc, argv);
 }
 
diff --git a/tests/egl/egl-nok-texture-from-pixmap.c b/tests/egl/egl-nok-texture-from-pixmap.c
index 337da1a..95ecbf3 100644
--- a/tests/egl/egl-nok-texture-from-pixmap.c
+++ b/tests/egl/egl-nok-texture-from-pixmap.c
@@ -41,16 +41,6 @@ static const EGLint pixmap_attribs[] = {
 	EGL_NONE
 };
 
-static const EGLint attribs[] = {
-	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
-	EGL_RED_SIZE, 1,
-	EGL_GREEN_SIZE, 1,
-	EGL_BLUE_SIZE, 1,
-	EGL_DEPTH_SIZE, 1,
-	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
-	EGL_NONE
-};
-
 static enum piglit_result
 draw(struct egl_state *state)
 {
@@ -110,15 +100,15 @@ draw(struct egl_state *state)
 	return PIGLIT_PASS;
 }
 
-static const struct egl_test test = {
-	.config_attribs = attribs,
-	.extensions = extensions,
-	.draw = draw
-};
-
 int
 main(int argc, char *argv[])
 {
+	struct egl_test test;
+
+	egl_init_test(&test);
+	test.extensions = extensions;
+	test.draw = draw;
+
 	return egl_util_run(&test, argc, argv);
 }
 
diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
index 4f96818..519c09f 100644
--- a/tests/egl/egl-util.c
+++ b/tests/egl/egl-util.c
@@ -37,6 +37,16 @@ static int automatic;
 
 int depth;
 
+void
+egl_init_test(struct egl_test *test)
+{
+	static const char *no_extensions[] = { NULL };
+
+	test->config_attribs = egl_default_attribs;
+	test->draw = NULL;
+	test->extensions = no_extensions;
+}
+
 EGLSurface
 egl_util_create_pixmap(struct egl_state *state,
 		       int width, int height, const EGLint *attribs)
diff --git a/tests/egl/egl-util.h b/tests/egl/egl-util.h
index 7ef7216..e796cd7 100644
--- a/tests/egl/egl-util.h
+++ b/tests/egl/egl-util.h
@@ -35,6 +35,23 @@ struct egl_test {
 	enum piglit_result (*draw)(struct egl_state *state);
 };
 
+
+static const EGLint egl_default_attribs[] = {
+	EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
+	EGL_RED_SIZE, 1,
+	EGL_GREEN_SIZE, 1,
+	EGL_BLUE_SIZE, 1,
+	EGL_DEPTH_SIZE, 1,
+	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+	EGL_NONE
+};
+
+/**
+ * \brief Initialize test to default values.
+ */
+void
+egl_init_test(struct egl_test *test);
+
 EGLSurface
 egl_util_create_pixmap(struct egl_state *state,
 		       int width, int height, const EGLint *attribs);
-- 
1.7.6.4



More information about the Piglit mailing list