[Piglit] [PATCH] egl: Use piglit_require_egl_extension

Neil Roberts neil at linux.intel.com
Thu Dec 10 04:43:24 PST 2015


Previously there were a couple of places directly searching for
extensions in EGL_EXTENSIONS via strstr. This doesn't check the
terminator for the extension name properly and there is already a
helper function for this so we might as well use it.
---
 tests/egl/egl-util.c                           | 13 ++++---------
 tests/egl/spec/egl_khr_create_context/common.c | 17 +++--------------
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
index 77d8d3f..487d6e2 100644
--- a/tests/egl/egl-util.c
+++ b/tests/egl/egl-util.c
@@ -32,6 +32,7 @@
 
 #include <X11/XKBlib.h>
 #include "piglit-util-gl.h"
+#include "piglit-util-egl.h"
 #include "egl-util.h"
 
 static int automatic;
@@ -175,17 +176,11 @@ event_loop(struct egl_state *state, const struct egl_test *test)
 static void
 check_extensions(struct egl_state *state, const struct egl_test *test)
 {
-	const char *extensions;
 	int i;
 
-	extensions = eglQueryString(state->egl_dpy, EGL_EXTENSIONS);
-	for (i = 0; test->extensions[i]; i++) {
-		if (!strstr(extensions, test->extensions[i])) {
-			fprintf(stderr, "missing extension %s\n",
-				test->extensions[i]);
-			piglit_report_result(PIGLIT_SKIP);
-		}
-	}
+	for (i = 0; test->extensions[i]; i++)
+		piglit_require_egl_extension(state->egl_dpy,
+					     test->extensions[i]);
 }
 
 enum piglit_result
diff --git a/tests/egl/spec/egl_khr_create_context/common.c b/tests/egl/spec/egl_khr_create_context/common.c
index e94d100..bd02dc1 100644
--- a/tests/egl/spec/egl_khr_create_context/common.c
+++ b/tests/egl/spec/egl_khr_create_context/common.c
@@ -22,6 +22,7 @@
 
 #include <ctype.h>
 #include <errno.h>
+#include "piglit-util-egl.h"
 #include "common.h"
 
 static Display *dpy = NULL;
@@ -69,20 +70,8 @@ parse_version_string(const char *string, int *major, int *minor)
 static void
 check_extensions(void)
 {
-	static const char *extensions[] = {
-		"EGL_KHR_create_context",
-		"EGL_KHR_surfaceless_context"
-	};
-	int i;
-
-	const char *extension_string = eglQueryString(egl_dpy, EGL_EXTENSIONS);
-	for (i = 0; i < ARRAY_SIZE(extensions); i++) {
-		if (!strstr(extension_string, extensions[i])) {
-			fprintf(stderr, "missing extension %s\n",
-				extensions[i]);
-			piglit_report_result(PIGLIT_SKIP);
-		}
-	}
+	piglit_require_egl_extension(egl_dpy, "EGL_KHR_create_context");
+	piglit_require_egl_extension(egl_dpy, "EGL_KHR_surfaceless_context");
 }
 
 bool
-- 
1.9.3



More information about the Piglit mailing list