mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
refactor: use virtualFileSystem in ULTs
reducing the number of tests that have interactions with filesystem. writeDataToFile() saves filename and content in std::map. fileExistsHasSize() checks if file was previously written to virtualFileSystem loadDataFromVirtualFile() fetches data from std::map based on filename Related-To: NEO-7006 Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9f23867d30
commit
e27a6dc280
@@ -13,6 +13,7 @@
|
||||
#include "shared/test/common/debug_settings/debug_settings_manager_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/helpers/mock_file_io.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||
@@ -402,21 +403,25 @@ TEST(DebugSettingsManager, GivenLogsEnabledAndDumpToFileWhenPrintDebuggerLogCall
|
||||
|
||||
auto logFile = NEO::fileLoggerInstance().getLogFileName();
|
||||
|
||||
std::remove(logFile);
|
||||
if (virtualFileExists(logFile)) {
|
||||
removeVirtualFile(logFile);
|
||||
}
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
PRINT_DEBUGGER_LOG(stdout, "test %s", "log");
|
||||
auto output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(0u, output.size());
|
||||
|
||||
auto logFileExists = fileExists(logFile);
|
||||
auto logFileExists = virtualFileExists(logFile);
|
||||
EXPECT_TRUE(logFileExists);
|
||||
|
||||
size_t retSize;
|
||||
auto data = loadDataFromFile(logFile, retSize);
|
||||
auto data = loadDataFromVirtualFile(logFile, retSize);
|
||||
|
||||
EXPECT_STREQ("test log", data.get());
|
||||
std::remove(logFile);
|
||||
if (virtualFileExists(logFile)) {
|
||||
removeVirtualFile(logFile);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, GivenLogsDisabledAndDumpToFileWhenPrintDebuggerLogCalledThenStringIsNotPrintedToFile) {
|
||||
|
||||
Reference in New Issue
Block a user