unit_test for the previous change

realAllocationSize for keeping actual GPU allocation Size

Change-Id: Id414adccae4c4a88e7ec071bc976ff77e76fd7fb
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
This commit is contained in:
Dongwon Kim
2019-04-02 14:22:17 -07:00
committed by sys_ocldev
parent b13bd16665
commit 52f51866eb

View File

@@ -2799,6 +2799,32 @@ TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryFor
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrObjectAlignedSizeIsUsedByAllocUserPtrWhenBiggerSizeAllocatedInHeap) {
AllocationData allocationData;
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
allocationData.size = 4llu * 1024 * 1024 + 16 * 1024;
allocationData.hostPtr = reinterpret_cast<const void *>(0x10000000);
auto allocation0 = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
allocationData.hostPtr = reinterpret_cast<const void *>(0x20000000);
auto allocation1 = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
memoryManager->freeGraphicsMemory(allocation0);
allocationData.size = 4llu * 1024 * 1024 + 12 * 1024;
allocationData.hostPtr = reinterpret_cast<const void *>(0x30000000);
allocation0 = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
EXPECT_EQ((uint64_t)(allocation0->getBO()->peekUnmapSize()), 4llu * 1024 * 1024 + 16 * 1024);
EXPECT_EQ((uint64_t)(allocation0->getBO()->peekSize()), 4llu * 1024 * 1024 + 12 * 1024);
memoryManager->freeGraphicsMemory(allocation0);
memoryManager->freeGraphicsMemory(allocation1);
}
TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledButAllocationFailedThenNullPtrReturned) {
AllocationData allocationData;
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));