Use TestedDrmCommandStreamReceiver in DrmMemoryManager tests

Related-To: NEO-4512
Change-Id: If8ee746d11ffaf8c2b95a13289e15bf1064b4588
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-03-30 10:01:32 +02:00
committed by sys_ocldev
parent 1e6337c61e
commit d38ae0e07a
3 changed files with 10 additions and 18 deletions

View File

@ -33,7 +33,6 @@
#include "opencl/source/mem_obj/image.h"
#include "opencl/source/os_interface/linux/drm_command_stream.h"
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
#include "opencl/test/unit_test/mocks/linux/mock_drm_command_stream_receiver.h"
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_gfx_partition.h"
@ -1257,11 +1256,10 @@ TEST_F(DrmMemoryManagerTest, givenDrmBufferWhenItIsQueriedForInternalAllocationT
clReleaseMemObject(buffer);
}
TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIsExhaustedAndNewAllocationsIsMadeThenNullIsReturned) {
TEST_F(DrmMemoryManagerTest, GivenExhaustedInternalHeapWhenAllocate32BitIsCalledThenNullIsReturned) {
DebugManagerStateRestore dbgStateRestore;
DebugManager.flags.Force32bitAddressing.set(true);
memoryManager->setForce32BitAllocations(true);
std::unique_ptr<Device> pDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
size_t size = MemoryConstants::pageSize64k;
auto alloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, size);
@ -1270,7 +1268,6 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs
size_t allocationSize = 4 * GB;
auto graphicsAllocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, allocationSize, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP);
EXPECT_EQ(nullptr, graphicsAllocation);
EXPECT_TRUE(pDevice->getDeviceInfo().force32BitAddressess);
}
TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateGraphicsMemoryForImageIsCalledThenProperIoctlsAreCalledAndUnmapSizeIsNonZero) {
@ -1445,6 +1442,7 @@ HWTEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreated
mock->ioctl_expected.gemWait = 2;
mock->ioctl_expected.gemClose = 2;
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.execbuffer2 = 1;
// builtins kernels
mock->ioctl_expected.gemUserptr += 5;
@ -2050,10 +2048,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
}
TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferObjectWhenTheyAreMadeResidentThenOnlyOneBoIsPassedToExec) {
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, rootDeviceIndex);
device->resetCommandStreamReceiver(testedCsr);
mock->reset();
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(device->getDefaultEngine().commandStreamReceiver);
mock->ioctl_expected.primeFdToHandle = 2;
mock->ioctl_expected.gemClose = 1;
mock->ioctl_expected.gemWait = 2;
@ -2076,7 +2071,10 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb
}
TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBufferObjectWhenTheyAreMadeResidentThenTwoBoIsPassedToExec) {
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(device->getDefaultEngine().commandStreamReceiver);
mock->ioctl_expected.primeFdToHandle = 2;
mock->ioctl_expected.gemClose = 2;
mock->ioctl_expected.gemWait = 2;
osHandle sharedHandle = 1u;
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
@ -2084,15 +2082,6 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
mock->outputHandle++;
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
mock->testIoctls();
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, rootDeviceIndex);
device->resetCommandStreamReceiver(testedCsr);
mock->reset();
mock->ioctl_expected.gemClose = 2;
mock->ioctl_expected.gemWait = 2;
testedCsr->makeResident(*graphicsAllocation);
testedCsr->makeResident(*graphicsAllocation2);
EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size());

View File

@ -10,6 +10,7 @@
#include "shared/source/os_interface/linux/os_interface.h"
#include "opencl/test/unit_test/fixtures/memory_management_fixture.h"
#include "opencl/test/unit_test/mocks/linux/mock_drm_command_stream_receiver.h"
#include "opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_device.h"
@ -51,6 +52,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
}
void SetUp(DrmMockCustom *mock, bool localMemoryEnabled) {
environmentWrapper.setCsrType<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>>();
allocationData.rootDeviceIndex = rootDeviceIndex;
this->mock = mock;
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), false, numRootDevices);
@ -100,6 +102,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
DrmMockCustom::IoctlResExt ioctlResExt = {0, 0};
AllocationData allocationData{};
DrmMockCustom::Ioctls additionalDestroyDeviceIoctls{};
EnvironmentWithCsrWrapper environmentWrapper;
};
class DrmMemoryManagerWithLocalMemoryFixture : public DrmMemoryManagerFixture {