mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
refactor: capability to print mmap and munmap calls
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4b5d5f235a
commit
fcd57f94cf
@@ -187,6 +187,8 @@ struct MockDrmGemCloseWorker : DrmGemCloseWorker {
|
||||
struct MockDrmMemoryManager : DrmMemoryManager {
|
||||
using DrmMemoryManager::DrmMemoryManager;
|
||||
using DrmMemoryManager::gemCloseWorker;
|
||||
using DrmMemoryManager::mmapFunction;
|
||||
using DrmMemoryManager::munmapFunction;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -588,4 +588,5 @@ OverridePatIndexForUncachedTypes = -1
|
||||
OverridePatIndexForCachedTypes = -1
|
||||
FlushTlbBeforeCopy = -1
|
||||
UseGemCreateExtInAllocateMemoryByKMD = -1
|
||||
PrintMmapAndMunMapCalls = -1
|
||||
# Please don't edit below this line
|
||||
|
||||
@@ -205,6 +205,36 @@ TEST_F(DrmMemoryManagerTest, givenEnableDirectSubmissionWhenCreateDrmMemoryManag
|
||||
EXPECT_EQ(memoryManager.peekGemCloseWorker(), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDebugFlagSetWhenUsingMmapFunctionsThenPrintContent) {
|
||||
DebugManagerStateRestore dbgState;
|
||||
debugManager.flags.PrintMmapAndMunMapCalls.set(1);
|
||||
|
||||
MockDrmMemoryManager memoryManager(GemCloseWorkerMode::gemCloseWorkerInactive, false, false, *executionEnvironment);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
size_t len = 2;
|
||||
off_t offset = 6;
|
||||
void *ptr = reinterpret_cast<void *>(0x1234);
|
||||
void *retPtr = memoryManager.mmapFunction(ptr, len, 3, 4, 5, offset);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
char expected1[256] = {};
|
||||
|
||||
sprintf(expected1, "mmap(%p, %zu, %d, %d, %d, %ld) = %p", ptr, len, 3, 4, 5, offset, retPtr);
|
||||
|
||||
EXPECT_NE(std::string::npos, output.find(expected1));
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
int retVal = memoryManager.munmapFunction(ptr, len);
|
||||
|
||||
output = testing::internal::GetCapturedStdout();
|
||||
char expected2[256] = {};
|
||||
|
||||
sprintf(expected2, "munmap(%p, %zu) = %d", ptr, len, retVal);
|
||||
|
||||
EXPECT_NE(std::string::npos, output.find(expected2));
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDebugVariableWhenCreatingDrmMemoryManagerThenSetSupportForMultiStorageResources) {
|
||||
DebugManagerStateRestore dbgState;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user