Correct usage of rootDeviceIndex in DrmMemoryManager::populateOsHandles

Related-To: NEO-3691
Change-Id: Id7ac60fd8f4f1949508f1ac000de40f58e1878c0
Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
Jablonski, Mateusz
2020-03-25 09:50:46 +01:00
committed by sys_ocldev
parent 42cc9e3563
commit fdde7232fd
3 changed files with 18 additions and 7 deletions

View File

@ -594,19 +594,23 @@ TEST_F(DrmMemoryManagerTest, BoWaitFailure) {
}
TEST_F(DrmMemoryManagerTest, NullOsHandleStorageAskedForPopulationReturnsFilledPointer) {
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemWait = 1;
mock->ioctl_expected.gemClose = 1;
mock->ioctl_expected.gemUserptr = 0;
mock->ioctl_expected.gemWait = 0;
mock->ioctl_expected.gemClose = 0;
nonDefaultDrm->ioctl_expected.gemUserptr = 1;
nonDefaultDrm->ioctl_expected.gemWait = 1;
nonDefaultDrm->ioctl_expected.gemClose = 1;
OsHandleStorage storage;
storage.fragmentStorageData[0].cpuPtr = reinterpret_cast<void *>(0x1000);
storage.fragmentStorageData[0].fragmentSize = 1;
memoryManager->populateOsHandles(storage, 0u);
memoryManager->populateOsHandles(storage, nonDefaultRootDeviceIndex);
EXPECT_NE(nullptr, storage.fragmentStorageData[0].osHandleStorage);
EXPECT_EQ(nullptr, storage.fragmentStorageData[1].osHandleStorage);
EXPECT_EQ(nullptr, storage.fragmentStorageData[2].osHandleStorage);
storage.fragmentStorageData[0].freeTheFragment = true;
memoryManager->cleanOsHandles(storage, 0);
memoryManager->cleanOsHandles(storage, nonDefaultRootDeviceIndex);
}
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValidationWhenReadOnlyPointerCausesPinningFailWithEfaultThenPopulateOsHandlesReturnsInvalidHostPointerError) {

View File

@ -37,6 +37,8 @@ class DrmMemoryManagerBasic : public ::testing::Test {
class DrmMemoryManagerFixture : public MemoryManagementFixture {
public:
DrmMockCustom *mock;
DrmMockCustom *nonDefaultDrm = nullptr;
const uint32_t nonDefaultRootDeviceIndex = 1u;
TestedDrmMemoryManager *memoryManager = nullptr;
MockClDevice *device = nullptr;
@ -47,12 +49,17 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
void SetUp(DrmMockCustom *mock, bool localMemoryEnabled) {
this->mock = mock;
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get());
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), false, nonDefaultRootDeviceIndex + 1);
executionEnvironment->incRefInternal();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setDrm(mock);
nonDefaultDrm = new DrmMockCustom();
auto nonDefaultRootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[nonDefaultRootDeviceIndex].get();
nonDefaultRootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
nonDefaultRootDeviceEnvironment->osInterface->get()->setDrm(nonDefaultDrm);
memoryManager = new (std::nothrow) TestedDrmMemoryManager(localMemoryEnabled, false, false, *executionEnvironment);
//assert we have memory manager
ASSERT_NE(nullptr, memoryManager);