[Piglit] [PATCH 05/29] util: Add egl version and extension helpers
Pauli Nieminen
pauli.nieminen at linux.intel.com
Mon May 21 11:08:40 PDT 2012
The helpers functions are based on glx helper functions already provided
for glx tests.
Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
---
tests/util/piglit-util-egl.c | 57 ++++++++++++++++++++++++++++++++++++++++++
tests/util/piglit-util-egl.h | 15 +++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/tests/util/piglit-util-egl.c b/tests/util/piglit-util-egl.c
index b286ee5..0078962 100644
--- a/tests/util/piglit-util-egl.c
+++ b/tests/util/piglit-util-egl.c
@@ -23,6 +23,9 @@
#include "piglit-util-egl.h"
+#include <EGL/egl.h>
+#include <stdio.h>
+
const char* piglit_get_egl_error_name(EGLint error) {
#define CASE(x) case x: return #x;
switch (error) {
@@ -74,3 +77,57 @@ void piglit_expect_egl_error(EGLint expected_error, enum piglit_result result)
piglit_report_result(result);
}
+
+bool
+piglit_is_egl_extension_supported(const char *name)
+{
+ const char * egl_extension_list;
+ EGLDisplay dpy;
+
+ dpy = eglGetCurrentDisplay();
+
+ egl_extension_list = eglQueryString(dpy, EGL_EXTENSIONS);
+
+ return piglit_is_extension_in_string(egl_extension_list, name);
+}
+
+void
+piglit_require_egl_extension(const char *name)
+{
+ if (!piglit_is_egl_extension_supported(name)) {
+ fprintf(stderr, "Test requires %s\n", name);
+ piglit_report_result(PIGLIT_SKIP);
+ }
+}
+
+
+bool
+piglit_check_egl_version(int major, int minor)
+{
+ int eglMajor;
+ int eglMinor;
+ const char *egl_version;
+ EGLDisplay dpy;
+
+ dpy = eglGetCurrentDisplay();
+ egl_version = eglQueryString(dpy, EGL_VERSION);
+
+ if (sscanf(egl_version, "%d.%d", &eglMajor, &eglMinor) != 2) {
+ fprintf(stderr, "Failed to parse EGL version\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (eglMajor != major || eglMinor < minor) {
+ fprintf(stderr, "Test requires EGL %d.%d. Got %d.%d.\n",
+ major, minor, eglMajor, eglMinor);
+ return false;
+ }
+ return true;
+}
+
+void
+piglit_require_egl_version(int major, int minor)
+{
+ if (!piglit_check_egl_version(major, minor))
+ piglit_report_result(PIGLIT_SKIP);
+}
diff --git a/tests/util/piglit-util-egl.h b/tests/util/piglit-util-egl.h
index 1fa68e5..59f4e27 100644
--- a/tests/util/piglit-util-egl.h
+++ b/tests/util/piglit-util-egl.h
@@ -50,6 +50,21 @@ const char* piglit_get_egl_error_name(EGLint error);
*/
void piglit_expect_egl_error(EGLint expected_error, enum piglit_result result);
+/**
+ * Check if specified EGL version in supported.
+ */
+bool piglit_check_egl_version(int major, int minor);
+
+/**
+ * Skip test if required EGL version isn't supported.
+ */
+void piglit_require_egl_version(int major, int minor);
+
+/**
+ * Check if egl extension is supported.
+ */
+bool piglit_is_egl_extension_supported(const char *name);
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
--
1.7.5.4
More information about the Piglit
mailing list