[Piglit] [PATCH piglit v2] egl: add test for EGL_MESA_query_driver
Eric Engestrom
eric.engestrom at intel.com
Tue Jan 22 15:32:31 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 | 100 ++++++++++++++++++
tests/opengl.py | 6 ++
5 files changed, 115 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..63d3217607ceac2516d5
--- /dev/null
+++ b/tests/egl/spec/egl_mesa_query_driver/egl_mesa_query_driver.c
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+ egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+
+ piglit_require_egl_extension(egl_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_NO_DISPLAY);
+ if (!piglit_check_egl_error(EGL_BAD_DISPLAY))
+ piglit_report_result(PIGLIT_FAIL);
+
+ driver_config = GetDisplayDriverconfig(EGL_NO_DISPLAY);
+ if (!piglit_check_egl_error(EGL_BAD_DISPLAY)) {
+ free(driver_config);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ driver_name = GetDisplayDriverName(egl_display);
+ if (!piglit_check_egl_error(EGL_NOT_INITIALIZED))
+ piglit_report_result(PIGLIT_FAIL);
+
+ driver_config = GetDisplayDriverconfig(egl_display);
+ if (!piglit_check_egl_error(EGL_NOT_INITIALIZED)) {
+ 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);
+ if (!piglit_check_egl_error(EGL_SUCCESS))
+ piglit_report_result(PIGLIT_FAIL);
+
+ driver_config = GetDisplayDriverconfig(egl_display);
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ free(driver_config);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* TODO: validate the xml config against a DTD written from
+ * $mesa/src/util/xmlpool.h */
+
+ 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