2018-12-20 17:38:38 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2019-12-13 16:48:57 +01:00
|
|
|
#include "core/debug_settings/debug_settings_manager.h"
|
2019-01-17 13:55:49 +01:00
|
|
|
#include "runtime/gmm_helper/gmm.h"
|
2019-12-30 14:14:27 +01:00
|
|
|
#include "runtime/platform/platform.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "test.h"
|
2018-12-20 17:38:38 +01:00
|
|
|
#include "unit_tests/os_interface/windows/mock_wddm_allocation.h"
|
2019-12-10 16:26:35 +01:00
|
|
|
#include "unit_tests/utilities/file_logger_tests.h"
|
2018-12-20 17:38:38 +01:00
|
|
|
|
2019-12-10 16:26:35 +01:00
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
|
|
TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
|
|
|
|
|
std::string testFile = "testfile";
|
|
|
|
|
DebugVariables flags;
|
|
|
|
|
flags.LogAllocationMemoryPool.set(true);
|
|
|
|
|
FullyEnabledFileLogger fileLogger(testFile, flags);
|
2018-12-20 17:38:38 +01:00
|
|
|
|
|
|
|
|
// Log file not created
|
2019-12-10 16:26:35 +01:00
|
|
|
bool logFileCreated = fileExists(fileLogger.getLogFileName());
|
2018-12-20 17:38:38 +01:00
|
|
|
EXPECT_FALSE(logFileCreated);
|
|
|
|
|
|
|
|
|
|
MockWddmAllocation allocation;
|
|
|
|
|
allocation.handle = 4;
|
|
|
|
|
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
2019-03-05 14:21:57 +01:00
|
|
|
allocation.memoryPool = MemoryPool::System64KBPages;
|
2019-12-30 14:14:27 +01:00
|
|
|
auto gmm = std::make_unique<Gmm>(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false);
|
2019-03-12 13:24:58 +01:00
|
|
|
allocation.setDefaultGmm(gmm.get());
|
|
|
|
|
allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0;
|
2018-12-20 17:38:38 +01:00
|
|
|
|
2019-12-10 16:26:35 +01:00
|
|
|
fileLogger.logAllocation(&allocation);
|
2018-12-20 17:38:38 +01:00
|
|
|
|
|
|
|
|
std::thread::id thisThread = std::this_thread::get_id();
|
|
|
|
|
|
|
|
|
|
std::stringstream threadIDCheck;
|
|
|
|
|
threadIDCheck << " ThreadID: " << thisThread;
|
|
|
|
|
|
|
|
|
|
std::stringstream memoryPoolCheck;
|
|
|
|
|
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
|
|
|
|
|
2019-12-10 16:26:35 +01:00
|
|
|
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
|
|
|
|
|
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
|
2018-12-20 17:38:38 +01:00
|
|
|
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
|
|
|
|
|
EXPECT_TRUE(str.find("Handle: 4") != std::string::npos);
|
|
|
|
|
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
|
|
|
|
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 16:26:35 +01:00
|
|
|
TEST(FileLogger, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIsNotLogged) {
|
|
|
|
|
std::string testFile = "testfile";
|
|
|
|
|
DebugVariables flags;
|
|
|
|
|
flags.LogAllocationMemoryPool.set(false);
|
|
|
|
|
FullyEnabledFileLogger fileLogger(testFile, flags);
|
2018-12-20 17:38:38 +01:00
|
|
|
|
|
|
|
|
// Log file not created
|
2019-12-10 16:26:35 +01:00
|
|
|
bool logFileCreated = fileExists(fileLogger.getLogFileName());
|
2018-12-20 17:38:38 +01:00
|
|
|
EXPECT_FALSE(logFileCreated);
|
|
|
|
|
|
|
|
|
|
MockWddmAllocation allocation;
|
|
|
|
|
allocation.handle = 4;
|
|
|
|
|
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
2019-03-05 14:21:57 +01:00
|
|
|
allocation.memoryPool = MemoryPool::System64KBPages;
|
2019-12-30 14:14:27 +01:00
|
|
|
auto gmm = std::make_unique<Gmm>(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false);
|
2019-03-12 13:24:58 +01:00
|
|
|
allocation.setDefaultGmm(gmm.get());
|
|
|
|
|
allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0;
|
2018-12-20 17:38:38 +01:00
|
|
|
|
2019-12-10 16:26:35 +01:00
|
|
|
fileLogger.logAllocation(&allocation);
|
2018-12-20 17:38:38 +01:00
|
|
|
|
|
|
|
|
std::thread::id thisThread = std::this_thread::get_id();
|
|
|
|
|
|
|
|
|
|
std::stringstream threadIDCheck;
|
|
|
|
|
threadIDCheck << " ThreadID: " << thisThread;
|
|
|
|
|
|
|
|
|
|
std::stringstream memoryPoolCheck;
|
|
|
|
|
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
|
|
|
|
|
2019-12-10 16:26:35 +01:00
|
|
|
if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) {
|
|
|
|
|
auto str = fileLogger.getFileString(fileLogger.getLogFileName());
|
2018-12-20 17:38:38 +01:00
|
|
|
EXPECT_FALSE(str.find(threadIDCheck.str()) != std::string::npos);
|
|
|
|
|
EXPECT_FALSE(str.find("Handle: 4") != std::string::npos);
|
|
|
|
|
EXPECT_FALSE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
|
|
|
|
EXPECT_FALSE(str.find("AllocationType: BUFFER") != std::string::npos);
|
|
|
|
|
EXPECT_FALSE(str.find("NonLocalOnly: 0") != std::string::npos);
|
|
|
|
|
}
|
2019-01-17 13:55:49 +01:00
|
|
|
}
|