mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Extract logging logic from DebugSettingsManager
Change-Id: I0ccc68216c1c3bb23d0389bec17124e09e4f98e1 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
d135944ae0
commit
5685b285f3
@@ -8,7 +8,6 @@ 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
|
||||
@@ -30,6 +29,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_logger_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux_create_command_queue_with_properties_tests.cpp
|
||||
|
||||
@@ -8,17 +8,20 @@
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_allocation.h"
|
||||
#include "unit_tests/os_interface/debug_settings_manager_fixture.h"
|
||||
#include "unit_tests/utilities/file_logger_tests.h"
|
||||
|
||||
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCorrectInfo) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
using namespace NEO;
|
||||
|
||||
TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
|
||||
std::string testFile = "testfile";
|
||||
DebugVariables flags;
|
||||
flags.LogAllocationMemoryPool.set(true);
|
||||
FullyEnabledFileLogger fileLogger(testFile, flags);
|
||||
|
||||
// Log file not created
|
||||
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||
bool logFileCreated = fileExists(fileLogger.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
|
||||
debugManager.flags.LogAllocationMemoryPool.set(true);
|
||||
|
||||
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages);
|
||||
|
||||
MockBufferObject bo;
|
||||
@@ -26,7 +29,7 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCo
|
||||
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
|
||||
debugManager.logAllocation(&allocation);
|
||||
fileLogger.logAllocation(&allocation);
|
||||
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
@@ -36,8 +39,8 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCo
|
||||
std::stringstream memoryPoolCheck;
|
||||
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||
|
||||
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
|
||||
auto str = fileLogger.getFileString(fileLogger.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);
|
||||
@@ -45,18 +48,18 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCo
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithDrmAllocationWithoutBOThenNoHandleLogged) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
TEST(FileLogger, GivenDrmAllocationWithoutBOThenNoHandleLogged) {
|
||||
std::string testFile = "testfile";
|
||||
DebugVariables flags;
|
||||
flags.LogAllocationMemoryPool.set(true);
|
||||
FullyEnabledFileLogger fileLogger(testFile, flags);
|
||||
|
||||
// Log file not created
|
||||
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||
bool logFileCreated = fileExists(fileLogger.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
|
||||
debugManager.flags.LogAllocationMemoryPool.set(true);
|
||||
|
||||
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages);
|
||||
|
||||
debugManager.logAllocation(&allocation);
|
||||
fileLogger.logAllocation(&allocation);
|
||||
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
@@ -66,8 +69,8 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithDrmAllocationWithoutBOTh
|
||||
std::stringstream memoryPoolCheck;
|
||||
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||
|
||||
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
|
||||
auto str = fileLogger.getFileString(fileLogger.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);
|
||||
@@ -75,18 +78,19 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithDrmAllocationWithoutBOTh
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithoutLogAllocationsThenAllocationIsNotLogged) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
TEST(FileLogger, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIsNotLogged) {
|
||||
std::string testFile = "testfile";
|
||||
DebugVariables flags;
|
||||
flags.LogAllocationMemoryPool.set(false);
|
||||
FullyEnabledFileLogger fileLogger(testFile, flags);
|
||||
|
||||
// Log file not created
|
||||
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||
bool logFileCreated = fileExists(fileLogger.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
|
||||
debugManager.flags.LogAllocationMemoryPool.set(false);
|
||||
|
||||
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages);
|
||||
|
||||
debugManager.logAllocation(&allocation);
|
||||
fileLogger.logAllocation(&allocation);
|
||||
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
@@ -96,8 +100,8 @@ TEST(DebugSettingsManager, GivenDebugSettingsManagerWithoutLogAllocationsThenAll
|
||||
std::stringstream memoryPoolCheck;
|
||||
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||
|
||||
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
|
||||
auto str = fileLogger.getFileString(fileLogger.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