mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
[1/n] Log allocation placement.
Change-Id: I9ab61e10dcb0fcbbaf859c077a64ce7a4f2c213c
This commit is contained in:
committed by
sys_ocldev
parent
e987d41dd6
commit
75a635fdc5
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018 Intel Corporation
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -8,6 +8,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.h
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
#include "unit_tests/os_interface/debug_settings_manager_fixture.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
|
||||
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCorrectInfo) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
|
||||
// Log file not created
|
||||
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
|
||||
debugManager.flags.LogAllocationMemoryPool.set(true);
|
||||
|
||||
MockGraphicsAllocation allocation;
|
||||
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||
allocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
|
||||
debugManager.logAllocation(&allocation);
|
||||
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
std::stringstream threadIDCheck;
|
||||
threadIDCheck << " ThreadID: " << thisThread;
|
||||
|
||||
std::stringstream memoryPoolCheck;
|
||||
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||
|
||||
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
|
||||
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
||||
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithoutLogAllocationsThenAllocationIsNotLogged) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
|
||||
// Log file not created
|
||||
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
|
||||
debugManager.flags.LogAllocationMemoryPool.set(false);
|
||||
|
||||
MockGraphicsAllocation allocation;
|
||||
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||
allocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
|
||||
debugManager.logAllocation(&allocation);
|
||||
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
std::stringstream threadIDCheck;
|
||||
threadIDCheck << " ThreadID: " << thisThread;
|
||||
|
||||
std::stringstream memoryPoolCheck;
|
||||
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||
|
||||
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||
EXPECT_FALSE(str.find(threadIDCheck.str()) != std::string::npos);
|
||||
EXPECT_FALSE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
||||
EXPECT_FALSE(str.find("AllocationType: BUFFER") != std::string::npos);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user