mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
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:
committed by
Compute-Runtime-Automation
parent
84f3d44968
commit
42b6dff2b4
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user