Skip to content

Commit 16e1a05

Browse files
Test for DrmMemoryManager allocateGraphicsMemoryInDevicePool
Change-Id: If04321fc1045d01c0001e27eed8b2a128b830f25 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
1 parent 38aa884 commit 16e1a05

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ endif()
136136
if(LIBDRM_DIR)
137137
get_filename_component(I915_INCLUDES_DIR "${LIBDRM_DIR}/include" ABSOLUTE)
138138
else()
139-
get_filename_component(I915_INCLUDES_DIR "${IGDRCL_SOURCE_DIR}/third_party/uapi" ABSOLUTE)
139+
get_filename_component(I915_INCLUDES_DIR "${IGDRCL_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/uapi" ABSOLUTE)
140140
endif()
141141
message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}")
142142

unit_tests/mocks/linux/mock_drm_memory_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#pragma once
89
#include "runtime/os_interface/linux/drm_memory_manager.h"
910
#include "unit_tests/mocks/mock_allocation_properties.h"
1011
#include "unit_tests/mocks/mock_host_ptr_manager.h"

unit_tests/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,21 @@ TEST_F(DrmMemoryManagerTest, givenImageOrSharedResourceCopyWhenGraphicsAllocatio
30103010
}
30113011
}
30123012

3013+
TEST(DrmMemoryManagerSimpleTest, givenLocalMemoryDisabledWhenAllocateInDevicePoolIsCalledThenNullptrAndStatusRetryIsReturned) {
3014+
ExecutionEnvironment executionEnvironment;
3015+
const bool localMemoryEnabled = false;
3016+
TestedDrmMemoryManager memoryManager(Drm::get(0), localMemoryEnabled, false, false, executionEnvironment);
3017+
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
3018+
AllocationData allocData;
3019+
allocData.size = MemoryConstants::pageSize;
3020+
allocData.flags.useSystemMemory = false;
3021+
allocData.flags.allocateMemory = true;
3022+
3023+
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
3024+
EXPECT_EQ(nullptr, allocation);
3025+
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
3026+
}
3027+
30133028
TEST(DrmAllocationTest, givenAllocationTypeWhenPassedToDrmAllocationConstructorThenAllocationTypeIsStored) {
30143029
DrmAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, static_cast<size_t>(0), 0u, MemoryPool::MemoryNull, false};
30153030
EXPECT_EQ(GraphicsAllocation::AllocationType::COMMAND_BUFFER, allocation.getAllocationType());

unit_tests/os_interface/linux/drm_mock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ class DrmMock : public Drm {
174174
aperture->aper_available_size = gpuMemSize;
175175
aperture->aper_size = gpuMemSize;
176176
}
177+
if (request == DRM_IOCTL_I915_GEM_MMAP) {
178+
auto mmap_arg = static_cast<drm_i915_gem_mmap *>(arg);
179+
mmap_arg->addr_ptr = reinterpret_cast<__u64>(lockedPtr);
180+
}
177181

178182
handleRemainingRequests(request, arg);
179183
return 0;
@@ -250,6 +254,8 @@ class DrmMock : public Drm {
250254
//DRM_IOCTL_I915_GEM_USERPTR
251255
__u32 returnHandle = 0;
252256
__u64 gpuMemSize = 3u * MemoryConstants::gigaByte;
257+
//DRM_IOCTL_I915_GEM_MMAP
258+
uint64_t lockedPtr[4];
253259

254260
virtual void handleRemainingRequests(unsigned long request, void *arg){};
255261

0 commit comments

Comments
 (0)