[Piglit] [PATCH 1/4] cmake, dma_buf: Refactor decisions to build dma_buf tests

Chad Versace chad.versace at linux.intel.com
Tue Sep 10 11:07:51 PDT 2013


This patch unifies the logic for deciding (1) to build dma_buf support
into libpiglitutil and (2) to build the ext_image_dma_buf_import tests.
In doing so, the patch creates a new CMake option,
PIGLIT_BUILD_DMA_BUF_TESTS.

It doesn't make sense to do (1) without (2) because the tests would all
skip. There does exist some logic in the ext_image_dma_buf_import
CMakeLists to prevent the tests from getting built without (1), but the
logic is incopmlete. This patch's unification fixes the incompleteness.

During Piglit's initial configuration, CMake chooses a default value of
PIGLIT_BUILD_DMA_BUF_TESTS based on what packages are present on the
system.

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 CMakeLists.txt                                     | 27 ++++++++++++++++++++++
 .../ext_image_dma_buf_import/CMakeLists.gles1.txt  |  4 ++--
 .../ext_image_dma_buf_import/CMakeLists.gles2.txt  |  5 ++--
 tests/util/CMakeLists.txt                          |  5 +---
 4 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a39d9df..2aba844 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -89,11 +89,38 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
         add_definitions(-DPIGLIT_HAS_GLX)
 
 	pkg_check_modules(LIBDRM QUIET libdrm)
+	pkg_check_modules(LIBDRM_INTEL QUIET libdrm_intel)
+	pkg_check_modules(XCB_DRI2 QUIET xcb-dri2)
 
 	option(PIGLIT_BUILD_GLX_TESTS "Build tests that require GLX" ON)
 ELSE()
 	option(PIGLIT_BUILD_GLX_TESTS "Build tests that require GLX" OFF)
 ENDIF()
+
+# Choose to build tests that use dma_buf.
+#
+# The presence of libdrm is not sufficient. At least one libdrm_${hardware}
+# library is also needed.
+#
+if(LIBDRM_FOUND AND LIBDRM_INTEL_FOUND)
+	set(PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID true)
+else()
+	set(PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID false)
+endif()
+
+if(PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID)
+	option(PIGLIT_BUILD_DMA_BUF_TESTS "Build tests that use dma_buf" ON)
+else()
+	option(PIGLIT_BUILD_DMA_BUF_TESTS "Build tests that use dma_buf" OFF)
+endif()
+
+# If the users has updated PIGLIT_BUILD_DMA_BUF_TESTS in the CMakeCache, then
+# we need to validate it.
+if(PIGLIT_BUILD_DMA_BUF_TESTS AND NOT PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID)
+	message(FATAL_ERROR
+		"PIGLIT_BUILD_DMA_BUF_TESTS require libdrm and libdrm_intel")
+endif()
+
 IF(PIGLIT_BUILD_GLX_TESTS)
 	pkg_check_modules(GLPROTO REQUIRED glproto)
 ENDIF()
diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
index f514c53..b60e507 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
@@ -11,7 +11,7 @@ link_libraries(
 	)
 
 # These tests rely on drm and are hence compiled only on linux/drm platforms
-if(LIBDRM_FOUND)
+if(PIGLIT_BUILD_DMA_BUF_TESTS)
 	add_definitions(-DHAVE_LIBDRM)
 
 	include_directories(
@@ -24,6 +24,6 @@ if(LIBDRM_FOUND)
 	piglit_add_executable(ext_image_dma_buf_import-ownership_transfer ownership_transfer.c image_common.c)
 	piglit_add_executable(ext_image_dma_buf_import-intel_unsupported_format intel_unsupported_format.c image_common.c)
 	piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_only intel_external_sampler_only.c image_common.c)
-endif(LIBDRM_FOUND)
+endif()
 
 # vim: ft=cmake:
diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
index d4bcba6..f8ebd21 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
@@ -9,8 +9,7 @@ link_libraries(
 	piglitutil_gles2
 	)
 
-# These tests rely on drm and are hence compiled only on linux/drm platforms
-if(LIBDRM_FOUND)
+if(PIGLIT_BUILD_DMA_BUF_TESTS)
 	add_definitions(-DHAVE_LIBDRM)
 
 	include_directories(
@@ -19,6 +18,6 @@ if(LIBDRM_FOUND)
 
 	piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c image_common.c)
 	piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c image_common.c)
-endif(LIBDRM_FOUND)
+endif()
 
 # vim: ft=cmake:
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 8f1420c..6bfe451 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -51,12 +51,9 @@ set(UTIL_GL_LIBS
 	)
 
 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-	pkg_check_modules(LIBDRM_INTEL QUIET libdrm_intel)
-	pkg_check_modules(XCB_DRI2 QUIET xcb-dri2)
-
 	# One needs to have at least one hardware driver present, otherwise
 	# there is no point compiling just the dispatcher.
-	if(LIBDRM_FOUND AND LIBDRM_INTEL_FOUND)
+	if(PIGLIT_BUILD_DMA_BUF_TESTS)
 		add_definitions(-DHAVE_LIBDRM)
 
 		list(APPEND UTIL_GL_SOURCES
-- 
1.8.3.1



More information about the Piglit mailing list