Add unit tests for completion fence

Related-To: NEO-6575

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2022-01-20 11:07:57 +00:00
committed by Compute-Runtime-Automation
parent 6968bfdb33
commit ec40b6562e
13 changed files with 252 additions and 74 deletions

View File

@@ -5,77 +5,20 @@
*
*/
#include "shared/source/os_interface/linux/drm_buffer_object.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_gmm_helper.h"
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
#include "shared/test/common/os_interface/linux/drm_buffer_object_fixture.h"
#include "shared/test/common/test_macros/test.h"
#include "drm/i915_drm.h"
#include <memory>
using namespace NEO;
class TestedBufferObject : public BufferObject {
public:
TestedBufferObject(Drm *drm) : BufferObject(drm, 1, 0, 1) {
}
void tileBy(uint32_t mode) {
this->tiling_mode = mode;
}
void fillExecObject(drm_i915_gem_exec_object2 &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId) override {
BufferObject::fillExecObject(execObject, osContext, vmHandleId, drmContextId);
execObjectPointerFilled = &execObject;
}
void setSize(size_t size) {
this->size = size;
}
drm_i915_gem_exec_object2 *execObjectPointerFilled = nullptr;
};
class DrmBufferObjectFixture {
public:
std::unique_ptr<DrmMockCustom> mock;
TestedBufferObject *bo;
drm_i915_gem_exec_object2 execObjectsStorage[256];
std::unique_ptr<OsContextLinux> osContext;
void SetUp() {
this->mock = std::make_unique<DrmMockCustom>(*executionEnvironment.rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, this->mock);
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u);
osContext.reset(new OsContextLinux(*this->mock, 0u, EngineDescriptorHelper::getDefaultDescriptor()));
this->mock->reset();
bo = new TestedBufferObject(this->mock.get());
ASSERT_NE(nullptr, bo);
}
void TearDown() {
delete bo;
if (this->mock->ioctl_expected.total >= 0) {
EXPECT_EQ(this->mock->ioctl_expected.total, this->mock->ioctl_cnt.total);
}
mock->reset();
osContext.reset(nullptr);
mock.reset(nullptr);
}
MockExecutionEnvironment executionEnvironment;
};
typedef Test<DrmBufferObjectFixture> DrmBufferObjectTest;
using DrmMockBufferObjectFixture = DrmBufferObjectFixture<DrmMockCustom>;
using DrmBufferObjectTest = Test<DrmMockBufferObjectFixture>;
TEST_F(DrmBufferObjectTest, WhenCallingExecThenReturnIsCorrect) {
mock->ioctl_expected.total = 1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -84,12 +84,12 @@ class DrmCommandStreamTest : public ::testing::Test {
std::unique_ptr<OsContextLinux> osContext;
};
template <typename T>
template <typename DrmType>
class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
public:
std::unique_ptr<DebugManagerStateRestore> dbgState;
MockExecutionEnvironment *executionEnvironment;
T *mock;
DrmType *mock;
CommandStreamReceiver *csr = nullptr;
const uint32_t rootDeviceIndex = 0u;
@@ -105,7 +105,7 @@ class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
//make sure this is disabled, we don't want to test this now
DebugManager.flags.EnableForcePin.set(false);
mock = new T(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
mock = new DrmType(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, rootDeviceIndex);
@@ -149,7 +149,7 @@ class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
protected:
class MockBufferObject : public BufferObject {
friend DrmCommandStreamEnhancedTemplate<T>;
friend DrmCommandStreamEnhancedTemplate<DrmType>;
protected:
MockBufferObject(Drm *drm, size_t size) : BufferObject(drm, 1, 0, 16u) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,16 +11,29 @@
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
#include "shared/test/common/os_interface/linux/drm_buffer_object_fixture.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/source/platform/platform.h"
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"
using namespace NEO;
class DrmCommandStreamMMTest : public ::testing::Test {
using DrmCommandStreamMMTest = ::testing::Test;
struct DrmCommandStreamMemExecTest : public DrmCommandStreamEnhancedTemplate<DrmMockCustom> {
void SetUp() override {
DrmCommandStreamEnhancedTemplate::SetUp();
}
void TearDown() override {
DrmCommandStreamEnhancedTemplate::TearDown();
}
};
HWTEST_F(DrmCommandStreamMMTest, GivenForcePinThenMemoryManagerCreatesPinBb) {
@@ -81,3 +94,35 @@ HWTEST_F(DrmCommandStreamMMTest, givenExecutionEnvironmentWithMoreThanOneRootDev
EXPECT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
}
}
HWTEST_TEMPLATED_F(DrmCommandStreamMemExecTest, GivenDrmSupportsCompletionFenceWhenCallingCsrExecThenTagAllocationIsPassed) {
mock->completionFenceSupported = true;
TestedBufferObject bo(mock, 128);
MockDrmAllocation cmdBuffer(GraphicsAllocation::AllocationType::COMMAND_BUFFER, MemoryPool::System4KBPages);
cmdBuffer.bufferObjects[0] = &bo;
uint8_t buff[128];
LinearStream cs(&cmdBuffer, buff, 128);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
csr->makeResident(cmdBuffer);
csr->makeResident(*allocation);
csr->makeResident(*csr->getTagAllocation());
uint64_t expectedCompletionGpuAddress = csr->getTagAllocation()->getGpuAddress() + Drm::completionFenceOffset;
auto *testCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
testCsr->latestSentTaskCount = 2;
int ret = testCsr->exec(batchBuffer, 1, 2);
EXPECT_EQ(0, ret);
EXPECT_EQ(expectedCompletionGpuAddress, bo.receivedCompletionGpuAddress);
EXPECT_EQ(testCsr->latestSentTaskCount, bo.receivedCompletionValue);
mm->freeGraphicsMemory(allocation);
}

View File

@@ -5796,4 +5796,85 @@ TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorre
EXPECT_EQ(0u, memoryInfo->getMemoryRegionSize(4));
}
TEST_F(DrmMemoryManagerTest, GivenEligbleAllocationTypeWhenCheckingAllocationEligbleForCompletionFenceThenReturnTrue) {
GraphicsAllocation::AllocationType validAllocations[] = {
GraphicsAllocation::AllocationType::COMMAND_BUFFER,
GraphicsAllocation::AllocationType::RING_BUFFER,
GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER,
GraphicsAllocation::AllocationType::TAG_BUFFER};
for (size_t i = 0; i < 4; i++) {
EXPECT_TRUE(memoryManager->allocationTypeForCompletionFence(validAllocations[i]));
}
}
TEST_F(DrmMemoryManagerTest, GivenNotEligbleAllocationTypeWhenCheckingAllocationEligbleForCompletionFenceThenReturnFalse) {
GraphicsAllocation::AllocationType validAllocations[] = {
GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY,
GraphicsAllocation::AllocationType::CONSTANT_SURFACE,
GraphicsAllocation::AllocationType::FILL_PATTERN,
GraphicsAllocation::AllocationType::GLOBAL_SURFACE};
for (size_t i = 0; i < 4; i++) {
EXPECT_FALSE(memoryManager->allocationTypeForCompletionFence(validAllocations[i]));
}
}
TEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionOfUsedAndEligbleAllocationThenCallWaitUserFence) {
mock->ioctl_expected.total = -1;
VariableBackup<bool> backupFenceSupported{&mock->completionFenceSupported, true};
VariableBackup<bool> backupVmBindCallParent{&mock->isVmBindAvailableCall.callParent, false};
VariableBackup<bool> backupVmBindReturnValue{&mock->isVmBindAvailableCall.returnValue, true};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, 1024, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
auto engine = memoryManager->getRegisteredEngines()[0];
allocation->updateTaskCount(2, engine.osContext->getContextId());
uint64_t expectedFenceAddress = castToUint64(const_cast<uint32_t *>(engine.commandStreamReceiver->getTagAddress())) + Drm::completionFenceOffset;
constexpr uint64_t expectedValue = 2;
memoryManager->handleFenceCompletion(allocation);
EXPECT_EQ(1u, mock->waitUserFenceCall.called);
EXPECT_EQ(expectedFenceAddress, mock->waitUserFenceCall.address);
EXPECT_EQ(expectedValue, mock->waitUserFenceCall.value);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionOfNotUsedAndEligbleAllocationThenDoNotCallWaitUserFence) {
mock->ioctl_expected.total = -1;
VariableBackup<bool> backupFenceSupported{&mock->completionFenceSupported, true};
VariableBackup<bool> backupVmBindCallParent{&mock->isVmBindAvailableCall.callParent, false};
VariableBackup<bool> backupVmBindReturnValue{&mock->isVmBindAvailableCall.returnValue, true};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, 1024, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
memoryManager->handleFenceCompletion(allocation);
EXPECT_EQ(0u, mock->waitUserFenceCall.called);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionOfUsedAndNotEligbleAllocationThenDoNotCallWaitUserFence) {
mock->ioctl_expected.total = -1;
VariableBackup<bool> backupFenceSupported{&mock->completionFenceSupported, true};
VariableBackup<bool> backupVmBindCallParent{&mock->isVmBindAvailableCall.callParent, false};
VariableBackup<bool> backupVmBindReturnValue{&mock->isVmBindAvailableCall.returnValue, true};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, 1024, GraphicsAllocation::AllocationType::GLOBAL_SURFACE});
auto engine = memoryManager->getRegisteredEngines()[0];
allocation->updateTaskCount(2, engine.osContext->getContextId());
memoryManager->handleFenceCompletion(allocation);
EXPECT_EQ(0u, mock->waitUserFenceCall.called);
memoryManager->freeGraphicsMemory(allocation);
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -938,3 +938,20 @@ TEST(DrmQueryTest, givenUapiPrelimVersionWithInvalidPathThenReturnEmptyString) {
EXPECT_TRUE(prelimVersion.empty());
}
TEST(DrmTest, GivenCompletionFenceDebugFlagWhenCreatingDrmObjectThenExpectCorrectSetting) {
DebugManagerStateRestore restore;
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drmDefault{*executionEnvironment->rootDeviceEnvironments[0]};
EXPECT_FALSE(drmDefault.completionFenceSupported);
DebugManager.flags.EnableDrmCompletionFence.set(1);
DrmMock drmEnabled{*executionEnvironment->rootDeviceEnvironments[0]};
EXPECT_TRUE(drmEnabled.completionFenceSupported);
DebugManager.flags.EnableDrmCompletionFence.set(0);
DrmMock drmDisabled{*executionEnvironment->rootDeviceEnvironments[0]};
EXPECT_FALSE(drmDisabled.completionFenceSupported);
}

View File

@@ -46,7 +46,7 @@ class BufferObject {
int pin(BufferObject *const boToPin[], size_t numberOfBos, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId);
MOCKABLE_VIRTUAL int validateHostPtr(BufferObject *const boToPin[], size_t numberOfBos, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId);
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId,
MOCKABLE_VIRTUAL int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId,
BufferObject *const residency[], size_t residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage, uint64_t completionGpuAddress, uint32_t completionValue);
int bind(OsContext *osContext, uint32_t vmHandleId);

View File

@@ -146,6 +146,7 @@ set(neo_libult_common_SRCS_LIB_ULT_LINUX
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/linux/memory_allocator_multi_device_fixture_linux.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/device_command_stream_fixture.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/device_command_stream_fixture.h
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/drm_buffer_object_fixture.h
)
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_LIB_ULT_LINUX ${neo_libult_common_SRCS_LIB_ULT_LINUX})

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -28,6 +28,7 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
using CommandStreamReceiver::useGpuIdleImplicitFlush;
using CommandStreamReceiver::useNewResourceImplicitFlush;
using CommandStreamReceiver::useNotifyEnableForPostSync;
using DrmCommandStreamReceiver<GfxFamily>::exec;
using DrmCommandStreamReceiver<GfxFamily>::residency;
using DrmCommandStreamReceiver<GfxFamily>::useContextForUserFenceWait;
using DrmCommandStreamReceiver<GfxFamily>::useUserFenceWait;

View File

@@ -69,6 +69,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
using DrmMemoryManager::allocateGraphicsMemoryWithAlignment;
using DrmMemoryManager::allocateGraphicsMemoryWithHostPtr;
using DrmMemoryManager::allocateMemoryByKMD;
using DrmMemoryManager::allocationTypeForCompletionFence;
using DrmMemoryManager::allocUserptr;
using DrmMemoryManager::createAllocWithAlignment;
using DrmMemoryManager::createAllocWithAlignmentFromUserptr;
@@ -80,6 +81,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
using DrmMemoryManager::getRootDeviceIndex;
using DrmMemoryManager::getUserptrAlignment;
using DrmMemoryManager::gfxPartitions;
using DrmMemoryManager::handleFenceCompletion;
using DrmMemoryManager::lockResourceInLocalMemoryImpl;
using DrmMemoryManager::memoryForPinBBs;
using DrmMemoryManager::mmapFunction;
@@ -94,6 +96,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
using DrmMemoryManager::sharingBufferObjects;
using DrmMemoryManager::supportsMultiStorageResources;
using DrmMemoryManager::unlockResourceInLocalMemoryImpl;
using DrmMemoryManager::waitOnCompletionFence;
using MemoryManager::allocateGraphicsMemoryInDevicePool;
using MemoryManager::heapAssigner;
using MemoryManager::registeredEngines;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,6 +12,7 @@
namespace NEO {
struct MockAllocationProperties : public AllocationProperties {
MockAllocationProperties(uint32_t rootDeviceIndex, size_t size) : AllocationProperties(rootDeviceIndex, true, size, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, false, mockDeviceBitfield) {}
MockAllocationProperties(uint32_t rootDeviceIndex, size_t size, GraphicsAllocation::AllocationType type) : AllocationProperties(rootDeviceIndex, true, size, type, false, mockDeviceBitfield) {}
MockAllocationProperties(uint32_t rootDeviceIndex, size_t size, DeviceBitfield deviceBitfield) : AllocationProperties(rootDeviceIndex, true, size, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, false, deviceBitfield) {}
MockAllocationProperties(uint32_t rootDeviceIndex, bool allocateMemory, size_t size) : AllocationProperties(rootDeviceIndex, allocateMemory, size, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, false, mockDeviceBitfield) {}
MockAllocationProperties(uint32_t rootDeviceIndex, bool allocateMemory, size_t size, DeviceBitfield deviceBitfield) : AllocationProperties(rootDeviceIndex, allocateMemory, size, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, false, deviceBitfield) {}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -70,6 +70,7 @@ int DrmMockCustom::ioctl(unsigned long request, void *arg) {
this->execBufferBufferObjects =
*reinterpret_cast<drm_i915_gem_exec_object2 *>(this->execBuffer.buffers_ptr);
ioctl_cnt.execbuffer2++;
execBufferExtensions(execbuf);
} break;
case DRM_IOCTL_I915_GEM_USERPTR: {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -68,6 +68,7 @@ class DrmMockCustom : public Drm {
public:
using Drm::bindAvailable;
using Drm::cacheInfo;
using Drm::completionFenceSupported;
using Drm::memoryInfo;
struct IoctlResExt {
@@ -143,6 +144,9 @@ class DrmMockCustom : public Drm {
ioctl_res_ext = &NONE;
}
virtual void execBufferExtensions(drm_i915_gem_execbuffer2 *execbuf) {
}
Ioctls ioctl_cnt;
Ioctls ioctl_expected;

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/os_interface/linux/drm_buffer_object.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "drm/i915_drm.h"
#include <memory>
class TestedBufferObject : public BufferObject {
public:
using BufferObject::handle;
TestedBufferObject(Drm *drm) : BufferObject(drm, 1, 0, 1) {
}
TestedBufferObject(Drm *drm, size_t size) : BufferObject(drm, 1, size, 1) {
}
void tileBy(uint32_t mode) {
this->tiling_mode = mode;
}
void fillExecObject(drm_i915_gem_exec_object2 &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId) override {
BufferObject::fillExecObject(execObject, osContext, vmHandleId, drmContextId);
execObjectPointerFilled = &execObject;
}
void setSize(size_t size) {
this->size = size;
}
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId,
BufferObject *const residency[], size_t residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage, uint64_t completionGpuAddress, uint32_t completionValue) override {
this->receivedCompletionGpuAddress = completionGpuAddress;
this->receivedCompletionValue = completionValue;
return BufferObject::exec(used, startOffset, flags, requiresCoherency, osContext, vmHandleId, drmContextId, residency, residencyCount, execObjectsStorage, completionGpuAddress, completionValue);
}
uint64_t receivedCompletionGpuAddress = 0;
drm_i915_gem_exec_object2 *execObjectPointerFilled = nullptr;
uint32_t receivedCompletionValue = 0;
};
template <typename DrmClass>
class DrmBufferObjectFixture {
public:
std::unique_ptr<DrmClass> mock;
TestedBufferObject *bo;
drm_i915_gem_exec_object2 execObjectsStorage[256];
std::unique_ptr<OsContextLinux> osContext;
void SetUp() {
this->mock = std::make_unique<DrmClass>(*executionEnvironment.rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, this->mock);
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u);
osContext.reset(new OsContextLinux(*this->mock, 0u, EngineDescriptorHelper::getDefaultDescriptor()));
this->mock->reset();
bo = new TestedBufferObject(this->mock.get());
ASSERT_NE(nullptr, bo);
}
void TearDown() {
delete bo;
if (this->mock->ioctl_expected.total >= 0) {
EXPECT_EQ(this->mock->ioctl_expected.total, this->mock->ioctl_cnt.total);
}
mock->reset();
osContext.reset(nullptr);
mock.reset(nullptr);
}
MockExecutionEnvironment executionEnvironment;
};