Move unit test for VA sharing to separate module built with libva

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2020-11-29 21:26:33 +01:00
committed by Compute-Runtime-Automation
parent 84f3d44968
commit 42b6dff2b4
3 changed files with 43 additions and 22 deletions

View File

@@ -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()

View File

@@ -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<Image> 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<Image> sharedImage2(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions,
CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr));
EXPECT_EQ(2, closeCalledCount);
EXPECT_EQ(2, closeInputFd);
}
} // namespace NEO

View File

@@ -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<DrmMemoryManagerFixture>;
TEST_F(DrmVaSharingTest, givenDrmMemoryManagerWhenSharedVaSurfaceIsImportedWithDrmPrimeFdToHandleThenDrmPrimeFdCanBeClosed) {
mock->ioctl_expected.total = -1;
MockContext context(device);
MockVaSharing vaSharing;
VASurfaceID vaSurfaceId = 0u;
vaSharing.updateAcquiredHandle(1);
std::unique_ptr<Image> 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<Image> sharedImage2(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions,
CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr));
EXPECT_EQ(2, closeCalledCount);
EXPECT_EQ(2, closeInputFd);
}
} // namespace NEO