[Piglit] [PATCH] Implement support for headless EGL through waffle.
Ryan Houdek
sonicadvance1 at gmail.com
Thu Feb 18 03:19:38 UTC 2016
---
CMakeLists.txt | 11 ++-
tests/util/CMakeLists.txt | 5 ++
.../piglit_headless_framework.c | 93 ++++++++++++++++++++++
.../piglit_headless_framework.h | 29 +++++++
.../piglit-framework-gl/piglit_wfl_framework.c | 10 ++-
.../piglit-framework-gl/piglit_winsys_framework.c | 6 ++
6 files changed, 152 insertions(+), 2 deletions(-)
create mode 100644 tests/util/piglit-framework-gl/piglit_headless_framework.c
create mode 100644 tests/util/piglit-framework-gl/piglit_headless_framework.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 493cece..e993de7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -200,7 +200,6 @@ endif()
IF(PIGLIT_BUILD_GLX_TESTS)
pkg_check_modules(GLPROTO REQUIRED glproto)
ENDIF()
-
find_package(PythonInterp 2.7 REQUIRED)
find_package(PythonNumpy 1.6.2 REQUIRED)
find_package(PythonMako 0.8.0 REQUIRED)
@@ -400,6 +399,16 @@ endif()
if(EGL_FOUND)
add_definitions(-DPIGLIT_HAS_EGL)
include_directories(${EGL_INCLUDE_DIRS})
+ check_c_source_compiles(
+ "
+ #include <waffle-1/waffle.h>
+ int main() { return WAFFLE_PLATFORM_HEADLESS_EGL; }
+ "
+ PIGLIT_HAS_HEADLESS_EGL
+ )
+ if(PIGLIT_HAS_HEADLESS_EGL)
+ add_definitions(-DPIGLIT_HAS_HEADLESS_EGL)
+ endif()
endif()
if(PIGLIT_BUILD_GLES1_TESTS AND NOT EGL_FOUND)
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index fb22ffa..3ac5115 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -90,6 +90,11 @@ if(PIGLIT_USE_WAFFLE)
piglit-framework-gl/piglit_x11_framework.c
)
endif()
+ if(PIGLIT_HAS_HEADLESS_EGL)
+ list(APPEND UTIL_GL_SOURCES
+ piglit-framework-gl/piglit_headless_framework.c
+ )
+ endif()
list(APPEND UTIL_GL_LIBS
${Waffle_LDFLAGS}
diff --git a/tests/util/piglit-framework-gl/piglit_headless_framework.c b/tests/util/piglit-framework-gl/piglit_headless_framework.c
new file mode 100644
index 0000000..70e29bc
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_headless_framework.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * 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 <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "piglit-util-gl.h"
+#include "piglit_gbm_framework.h"
+
+static void
+enter_event_loop(struct piglit_winsys_framework *winsys_fw)
+{
+ const struct piglit_gl_test_config *test_config = winsys_fw->wfl_fw.gl_fw.test_config;
+
+ enum piglit_result result = PIGLIT_PASS;
+
+ if (test_config->display)
+ result = test_config->display();
+
+ if (piglit_automatic)
+ piglit_report_result(result);
+
+ /* headless has no input, so we exit immediately, as if the user
+ * had pressed escape.
+ */
+ exit(0);
+}
+
+static void
+show_window(struct piglit_winsys_framework *winsys_fw)
+{
+ waffle_window_show(winsys_fw->wfl_fw.window);
+}
+
+static void
+destroy(struct piglit_gl_framework *gl_fw)
+{
+ struct piglit_winsys_framework *winsys_fw= piglit_winsys_framework(gl_fw);
+
+ if (winsys_fw == NULL)
+ return;
+
+ piglit_winsys_framework_teardown(winsys_fw);
+ free(winsys_fw);
+}
+
+struct piglit_gl_framework*
+piglit_headless_framework_create(const struct piglit_gl_test_config *test_config)
+{
+ struct piglit_winsys_framework *winsys_fw = NULL;
+ struct piglit_gl_framework *gl_fw = NULL;
+ bool ok = true;
+
+ winsys_fw = calloc(1, sizeof(*winsys_fw));
+ gl_fw = &winsys_fw->wfl_fw.gl_fw;
+
+ ok = piglit_winsys_framework_init(winsys_fw, test_config,
+ WAFFLE_PLATFORM_HEADLESS_EGL);
+ if (!ok)
+ goto fail;
+
+ winsys_fw->show_window = show_window;
+ winsys_fw->enter_event_loop = enter_event_loop;
+ gl_fw->destroy = destroy;
+
+ return gl_fw;
+
+fail:
+ destroy(gl_fw);
+ return NULL;
+}
+
diff --git a/tests/util/piglit-framework-gl/piglit_headless_framework.h b/tests/util/piglit-framework-gl/piglit_headless_framework.h
new file mode 100644
index 0000000..0c4d368
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_headless_framework.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include "piglit_winsys_framework.h"
+
+struct piglit_gl_framework*
+piglit_headless_framework_create(const struct piglit_gl_test_config *test_config);
diff --git a/tests/util/piglit-framework-gl/piglit_wfl_framework.c b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
index faf758b..59ebbb2 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -120,7 +120,15 @@ piglit_wfl_framework_choose_platform(const struct piglit_gl_test_config *test_co
piglit_report_result(PIGLIT_FAIL);
#endif
}
-
+ else if (strcmp(env, "headless_egl") == 0) {
+#ifdef PIGLIT_HAS_HEADLESS_EGL
+ return WAFFLE_PLATFORM_HEADLESS_EGL;
+#else
+ fprintf(stderr, "environment var PIGLIT_PLATFORM=headless_egl, "
+ "but piglit was built without headless EGL support\n");
+ piglit_report_result(PIGLIT_FAIL);
+#endif
+ }
else {
fprintf(stderr, "environment var PIGLIT_PLATFORM has bad "
"value \"%s\"\n", env);
diff --git a/tests/util/piglit-framework-gl/piglit_winsys_framework.c b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
index ff3428a..587f9c0 100644
--- a/tests/util/piglit-framework-gl/piglit_winsys_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
@@ -31,6 +31,7 @@
#include "piglit_gbm_framework.h"
#include "piglit_gl_framework.h"
+#include "piglit_headless_framework.h"
#include "piglit_wgl_framework.h"
#include "piglit_winsys_framework.h"
#include "piglit_wl_framework.h"
@@ -183,6 +184,11 @@ piglit_winsys_framework_factory(const struct piglit_gl_test_config *test_config)
return piglit_wgl_framework_create(test_config);
#endif
+#ifdef PIGLIT_HAS_HEADLESS_EGL
+ case WAFFLE_PLATFORM_HEADLESS_EGL:
+ return piglit_headless_framework_create(test_config);
+#endif
+
default:
assert(0);
return NULL;
--
2.5.0
More information about the Piglit
mailing list