[Piglit] [PATCH piglit] egl: add test for EGL_MESA_query_driver
Eric Engestrom
eric.engestrom at intel.com
Tue Jan 22 12:42:25 UTC 2019
Cc: Veluri Mithun <velurimithun38 at gmail.com>
Cc: Emil Velikov <emil.l.velikov at gmail.com>
Cc: Rob Clark <robdclark at gmail.com>
Cc: Nicolai Hähnle <nicolai.haehnle at amd.com>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
---
The extension is currently in development in this MR:
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/47
Veluri will send updated versions of this test if the spec changes.
---
tests/egl/spec/CMakeLists.txt | 1 +
.../CMakeLists.no_api.txt | 7 +
.../spec/egl_mesa_query_driver/CMakeLists.txt | 1 +
.../egl_mesa_query_driver.c | 121 ++++++++++++++++++
tests/opengl.py | 6 +
5 files changed, 136 insertions(+)
create mode 100644 tests/egl/spec/egl_mesa_query_driver/CMakeLists.no_api.txt
create mode 100644 tests/egl/spec/egl_mesa_query_driver/CMakeLists.txt
create mode 100644 tests/egl/spec/egl_mesa_query_driver/egl_mesa_query_driver.c
diff --git a/tests/egl/spec/CMakeLists.txt b/tests/egl/spec/CMakeLists.txt
index f38a4f62b6d4139719fb..378c8d7257518a4cc773 100644
--- a/tests/egl/spec/CMakeLists.txt
+++ b/tests/egl/spec/CMakeLists.txt
@@ -12,6 +12,7 @@ add_subdirectory (egl_khr_fence_sync)
add_subdirectory (egl_khr_surfaceless_context)
add_subdirectory (egl_mesa_device_software)
add_subdirectory (egl_mesa_platform_surfaceless)
+add_subdirectory (egl_mesa_query_driver)
if (PIGLIT_HAS_X11)
add_subdirectory (egl_chromium_sync_control)
diff --git a/tests/egl/spec/egl_mesa_query_driver/CMakeLists.no_api.txt b/tests/egl/spec/egl_mesa_query_driver/CMakeLists.no_api.txt
new file mode 100644
index 00000000000000000000..d6f97ba5d294e930d050
--- /dev/null
+++ b/tests/egl/spec/egl_mesa_query_driver/CMakeLists.no_api.txt
@@ -0,0 +1,7 @@
+link_libraries(
+ piglitutil
+)
+
+piglit_add_executable(egl_mesa_query_driver egl_mesa_query_driver.c)
+
+# vim: ft=cmake:
diff --git a/tests/egl/spec/egl_mesa_query_driver/CMakeLists.txt b/tests/egl/spec/egl_mesa_query_driver/CMakeLists.txt
new file mode 100644
index 00000000000000000000..144a306f4e7d38ba7da8
--- /dev/null
+++ b/tests/egl/spec/egl_mesa_query_driver/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/egl/spec/egl_mesa_query_driver/egl_mesa_query_driver.c b/tests/egl/spec/egl_mesa_query_driver/egl_mesa_query_driver.c
new file mode 100644
index 00000000000000000000..db93e56cd308658a1beb
--- /dev/null
+++ b/tests/egl/spec/egl_mesa_query_driver/egl_mesa_query_driver.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2016 Red Hat, Inc.
+ * Copyright 2015 Intel Corporation
+ * Copyright 2018 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util.h"
+#include "piglit-util-egl.h"
+
+#ifndef EGL_MESA_query_driver
+typedef char *PFNEGLGETDISPLAYDRIVERCONFIGPROC(EGLDisplay disp);
+typedef const char *PFNEGLGETDISPLAYDRIVERNAMEPROC(EGLDisplay disp);
+#endif
+
+int
+main(void)
+{
+ EGLDisplay egl_display = EGL_NO_DISPLAY;
+ EGLint egl_major, egl_minor;
+ EGLint egl_error;
+ const char *driver_name;
+ char *driver_config;
+
+ piglit_require_egl_extension(EGL_NO_DISPLAY, "EGL_MESA_query_driver");
+
+ PFNEGLGETDISPLAYDRIVERNAMEPROC *GetDisplayDriverName =
+ (void *)eglGetProcAddress("eglGetDisplayDriverName");
+ PFNEGLGETDISPLAYDRIVERCONFIGPROC *GetDisplayDriverconfig =
+ (void *)eglGetProcAddress("eglGetDisplayDriverconfig");
+
+ if (!GetDisplayDriverName || !GetDisplayDriverconfig) {
+ printf("Query driver entrypoints missing\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ driver_name = GetDisplayDriverName(egl_display);
+ egl_error = eglGetError();
+ if (driver_name || egl_error != EGL_BAD_DISPLAY) {
+ printf("eglGetDisplayDriverName() should have failed with EGL_BAD_DISPLAY\n");
+ printf("Instead, it returned %s and with error %s\n",
+ driver_name, piglit_get_egl_error_name(egl_error));
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ driver_config = GetDisplayDriverconfig(egl_display);
+ egl_error = eglGetError();
+ if (driver_config || egl_error != EGL_BAD_DISPLAY) {
+ printf("eglGetDisplayDriverConfig() should have failed with EGL_BAD_DISPLAY\n");
+ printf("Instead, it returned %s and with error %s\n",
+ driver_config, piglit_get_egl_error_name(egl_error));
+ free(driver_config);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+
+ driver_name = GetDisplayDriverName(egl_display);
+ egl_error = eglGetError();
+ if (driver_name || egl_error != EGL_NOT_INITIALIZED) {
+ printf("eglGetDisplayDriverName() should have failed with EGL_NOT_INITIALIZED\n");
+ printf("Instead, it returned %s and with error %s\n",
+ driver_name, piglit_get_egl_error_name(egl_error));
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ driver_config = GetDisplayDriverconfig(egl_display);
+ egl_error = eglGetError();
+ if (driver_config || egl_error != EGL_NOT_INITIALIZED) {
+ printf("eglGetDisplayDriverConfig() should have failed with EGL_NOT_INITIALIZED\n");
+ printf("Instead, it returned %s and with error %s\n",
+ driver_config, piglit_get_egl_error_name(egl_error));
+ free(driver_config);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (!eglInitialize(egl_display, &egl_major, &egl_minor)) {
+ printf("eglInitialize() failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ driver_name = GetDisplayDriverName(egl_display);
+ egl_error = eglGetError();
+ if (!driver_name || egl_error != EGL_SUCCESS) {
+ printf("eglGetDisplayDriverName() failed with %s\n",
+ piglit_get_egl_error_name(egl_error));
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ driver_config = GetDisplayDriverconfig(egl_display);
+ egl_error = eglGetError();
+ if (!driver_config || egl_error != EGL_SUCCESS) {
+ printf("eglGetDisplayDriverConfig() failed with %s\n",
+ piglit_get_egl_error_name(egl_error));
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ printf("Driver name: %s\n", driver_name);
+ printf("Driver config: %s\n", driver_config);
+ free(driver_config);
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/opengl.py b/tests/opengl.py
index af68560bf2f5c211f750..39a4cb2ca876526297d5 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -4617,6 +4617,12 @@ def f(name, format, p1=None, p2=None):
exclude_platforms=['glx']) as g:
g(['egl_mesa_device_software'], 'conformance')
+with profile.test_list.group_manager(
+ PiglitGLTest,
+ grouptools.join('spec', 'egl_mesa_query_driver'),
+ exclude_platforms=['glx']) as g:
+ g(['egl_mesa_query_driver'], 'conformance')
+
with profile.test_list.group_manager(
PiglitGLTest,
grouptools.join('spec', 'egl_mesa_platform_surfaceless'),
--
Cheers,
Eric
More information about the Piglit
mailing list