mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
Test for DrmMemoryManager allocateGraphicsMemoryInDevicePool
Change-Id: If04321fc1045d01c0001e27eed8b2a128b830f25 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
38aa884edd
commit
16e1a05375
@@ -136,7 +136,7 @@ endif()
|
||||
if(LIBDRM_DIR)
|
||||
get_filename_component(I915_INCLUDES_DIR "${LIBDRM_DIR}/include" ABSOLUTE)
|
||||
else()
|
||||
get_filename_component(I915_INCLUDES_DIR "${IGDRCL_SOURCE_DIR}/third_party/uapi" ABSOLUTE)
|
||||
get_filename_component(I915_INCLUDES_DIR "${IGDRCL_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/uapi" ABSOLUTE)
|
||||
endif()
|
||||
message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}")
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_allocation_properties.h"
|
||||
#include "unit_tests/mocks/mock_host_ptr_manager.h"
|
||||
|
||||
@@ -3010,6 +3010,21 @@ TEST_F(DrmMemoryManagerTest, givenImageOrSharedResourceCopyWhenGraphicsAllocatio
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmMemoryManagerSimpleTest, givenLocalMemoryDisabledWhenAllocateInDevicePoolIsCalledThenNullptrAndStatusRetryIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
const bool localMemoryEnabled = false;
|
||||
TestedDrmMemoryManager memoryManager(Drm::get(0), localMemoryEnabled, false, false, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.useSystemMemory = false;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
}
|
||||
|
||||
TEST(DrmAllocationTest, givenAllocationTypeWhenPassedToDrmAllocationConstructorThenAllocationTypeIsStored) {
|
||||
DrmAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, static_cast<size_t>(0), 0u, MemoryPool::MemoryNull, false};
|
||||
EXPECT_EQ(GraphicsAllocation::AllocationType::COMMAND_BUFFER, allocation.getAllocationType());
|
||||
|
||||
@@ -174,6 +174,10 @@ class DrmMock : public Drm {
|
||||
aperture->aper_available_size = gpuMemSize;
|
||||
aperture->aper_size = gpuMemSize;
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GEM_MMAP) {
|
||||
auto mmap_arg = static_cast<drm_i915_gem_mmap *>(arg);
|
||||
mmap_arg->addr_ptr = reinterpret_cast<__u64>(lockedPtr);
|
||||
}
|
||||
|
||||
handleRemainingRequests(request, arg);
|
||||
return 0;
|
||||
@@ -250,6 +254,8 @@ class DrmMock : public Drm {
|
||||
//DRM_IOCTL_I915_GEM_USERPTR
|
||||
__u32 returnHandle = 0;
|
||||
__u64 gpuMemSize = 3u * MemoryConstants::gigaByte;
|
||||
//DRM_IOCTL_I915_GEM_MMAP
|
||||
uint64_t lockedPtr[4];
|
||||
|
||||
virtual void handleRemainingRequests(unsigned long request, void *arg){};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user