[Piglit] [PATCH] piglit framework: add gbm support

Jordan Justen jordan.l.justen at intel.com
Mon Oct 1 15:47:11 PDT 2012


Chad,

Does this look close to the correct way to add GBM support
following your recent piglit framework refactor series?

-Jordan

--

Use gbm for testing if the PIGLIT_PLATFORM environment variable
is set to gbm.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 CMakeLists.txt                                     |    3 +
 tests/util/CMakeLists.txt                          |    1 +
 .../piglit-framework-gl/piglit_gbm_framework.c     |   78 ++++++++++++++++++++
 .../piglit-framework-gl/piglit_gbm_framework.h     |   29 ++++++++
 .../piglit-framework-gl/piglit_wfl_framework.c     |   10 +++
 .../piglit-framework-gl/piglit_winsys_framework.c  |    6 ++
 6 files changed, 127 insertions(+)
 create mode 100644 tests/util/piglit-framework-gl/piglit_gbm_framework.c
 create mode 100644 tests/util/piglit-framework-gl/piglit_gbm_framework.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b51e16f..76f9464 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,9 @@ if(PIGLIT_BUILD_CL_TESTS)
 endif(PIGLIT_BUILD_CL_TESTS)
 
 IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+        set(PIGLIT_HAS_GBM True)
+        add_definitions(-DPIGLIT_HAS_GBM)
+
 	set(PIGLIT_HAS_X11 True)
 	add_definitions(-DPIGLIT_HAS_X11)
 
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 836e437..8a145c6 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -27,6 +27,7 @@ set(UTIL_GL_SOURCES
 
 if(PIGLIT_USE_WAFFLE)
 	list(APPEND UTIL_GL_SOURCES
+		piglit-framework-gl/piglit_gbm_framework.c
 		piglit-framework-gl/piglit_fbo_framework.c
 		piglit-framework-gl/piglit_wfl_framework.c
 		piglit-framework-gl/piglit_winsys_framework.c
diff --git a/tests/util/piglit-framework-gl/piglit_gbm_framework.c b/tests/util/piglit-framework-gl/piglit_gbm_framework.c
new file mode 100644
index 0000000..4d82190
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_gbm_framework.c
@@ -0,0 +1,78 @@
+/*
+ * 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-common.h"
+#include "piglit_gbm_framework.h"
+
+static void
+enter_event_loop(struct piglit_winsys_framework *winsys_fw)
+{
+}
+
+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_gbm_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 = piglit_calloc(sizeof(*winsys_fw));
+	gl_fw = &winsys_fw->wfl_fw.gl_fw;
+
+	ok = piglit_winsys_framework_init(winsys_fw, test_config,
+	                           WAFFLE_PLATFORM_GBM);
+	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_gbm_framework.h b/tests/util/piglit-framework-gl/piglit_gbm_framework.h
new file mode 100644
index 0000000..2fd9779
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_gbm_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_gbm_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 29f09e8..259d07f 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -56,6 +56,16 @@ piglit_wfl_framework_choose_platform(void)
 #endif
 	}
 
+	else if (strcmp(env, "gbm") == 0) {
+#ifdef PIGLIT_HAS_GBM
+		return WAFFLE_PLATFORM_GBM;
+#else
+		fprintf(stderr, "environment var PIGLIT_PLATFORM=gbm, but "
+		        "piglit was built without GBM support\n");
+		piglit_report_result(PIGLIT_FAIL);
+#endif
+	}
+
 	else if (strcmp(env, "glx") == 0) {
 #ifdef PIGLIT_HAS_GLX
 		return WAFFLE_PLATFORM_GLX;
diff --git a/tests/util/piglit-framework-gl/piglit_winsys_framework.c b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
index fc08bbc..12de108 100644
--- a/tests/util/piglit-framework-gl/piglit_winsys_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
@@ -27,6 +27,7 @@
 #include "piglit-util-gl-common.h"
 #include "piglit-util-waffle.h"
 
+#include "piglit_gbm_framework.h"
 #include "piglit_gl_framework.h"
 #include "piglit_winsys_framework.h"
 #include "piglit_wl_framework.h"
@@ -132,6 +133,11 @@ piglit_winsys_framework_factory(const struct piglit_gl_test_config *test_config)
 		return piglit_x11_framework_create(test_config, platform);
 #endif
 
+#ifdef PIGLIT_HAS_GBM
+	case WAFFLE_PLATFORM_GBM:
+		return piglit_gbm_framework_create(test_config);
+#endif
+
 /* There is no need to #ifdef out Piglit support for Wayland yet
  * because Piglit calls no Wayland functions.
  */
-- 
1.7.9.5



More information about the Piglit mailing list