From 42b6dff2b410a9fd5b1eb08e7da9308d0e74132e Mon Sep 17 00:00:00 2001 From: Slawomir Milczarek Date: Sun, 29 Nov 2020 21:26:33 +0100 Subject: [PATCH] Move unit test for VA sharing to separate module built with libva Signed-off-by: Slawomir Milczarek --- .../os_interface/linux/CMakeLists.txt | 5 +++ .../linux/drm_memory_manager_tests.cpp | 22 ----------- .../linux/drm_va_sharing_tests.cpp | 38 +++++++++++++++++++ 3 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 opencl/test/unit_test/os_interface/linux/drm_va_sharing_tests.cpp diff --git a/opencl/test/unit_test/os_interface/linux/CMakeLists.txt b/opencl/test/unit_test/os_interface/linux/CMakeLists.txt index a3a54418bd..31d11213b3 100644 --- a/opencl/test/unit_test/os_interface/linux/CMakeLists.txt +++ b/opencl/test/unit_test/os_interface/linux/CMakeLists.txt @@ -51,6 +51,11 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_memory_manager_allocate_in_device_pool_tests.cpp ) endif() +if(NEO__LIBVA_FOUND) + list(APPEND IGDRCL_SRCS_tests_os_interface_linux + ${CMAKE_CURRENT_SOURCE_DIR}/drm_va_sharing_tests.cpp + ) +endif() if(UNIX) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_os_interface_linux}) endif() diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index d13beb4bbe..33eab01d79 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -32,7 +32,6 @@ #include "opencl/source/mem_obj/buffer.h" #include "opencl/source/mem_obj/image.h" #include "opencl/source/os_interface/linux/drm_command_stream.h" -#include "opencl/source/sharings/va/va_surface.h" #include "opencl/test/unit_test/helpers/unit_test_helper.h" #include "opencl/test/unit_test/mocks/linux/mock_drm_allocation.h" #include "opencl/test/unit_test/mocks/mock_allocation_properties.h" @@ -41,7 +40,6 @@ #include "opencl/test/unit_test/mocks/mock_gmm.h" #include "opencl/test/unit_test/mocks/mock_platform.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock.h" -#include "opencl/test/unit_test/sharings/va/mock_va_sharing.h" #include "test.h" #include "drm/i915_drm.h" @@ -4134,24 +4132,4 @@ TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenIsaIsRegisteredThenC allocation.freeRegisteredBOBindExtHandles(&drm); EXPECT_EQ(2u, drm.unregisterCalledCount); } - -TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedVaSurfaceIsImportedWithDrmPrimeFdToHandleThenDrmPrimeFdCanBeClosed) { - mock->ioctl_expected.total = -1; - - MockContext context(device); - MockVaSharing vaSharing; - VASurfaceID vaSurfaceId = 0u; - - vaSharing.updateAcquiredHandle(1); - std::unique_ptr sharedImage1(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions, - CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr)); - EXPECT_EQ(1, closeCalledCount); - EXPECT_EQ(1, closeInputFd); - - vaSharing.updateAcquiredHandle(2); - std::unique_ptr sharedImage2(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions, - CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr)); - EXPECT_EQ(2, closeCalledCount); - EXPECT_EQ(2, closeInputFd); -} } // namespace NEO diff --git a/opencl/test/unit_test/os_interface/linux/drm_va_sharing_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_va_sharing_tests.cpp new file mode 100644 index 0000000000..07d6403676 --- /dev/null +++ b/opencl/test/unit_test/os_interface/linux/drm_va_sharing_tests.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "opencl/source/mem_obj/image.h" +#include "opencl/source/sharings/va/va_surface.h" +#include "opencl/test/unit_test/mocks/mock_context.h" +#include "opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h" +#include "opencl/test/unit_test/sharings/va/mock_va_sharing.h" +#include "test.h" + +namespace NEO { + +using DrmVaSharingTest = Test; + +TEST_F(DrmVaSharingTest, givenDrmMemoryManagerWhenSharedVaSurfaceIsImportedWithDrmPrimeFdToHandleThenDrmPrimeFdCanBeClosed) { + mock->ioctl_expected.total = -1; + + MockContext context(device); + MockVaSharing vaSharing; + VASurfaceID vaSurfaceId = 0u; + + vaSharing.updateAcquiredHandle(1); + std::unique_ptr sharedImage1(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions, + CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr)); + EXPECT_EQ(1, closeCalledCount); + EXPECT_EQ(1, closeInputFd); + + vaSharing.updateAcquiredHandle(2); + std::unique_ptr sharedImage2(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions, + CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr)); + EXPECT_EQ(2, closeCalledCount); + EXPECT_EQ(2, closeInputFd); +} +} // namespace NEO