mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +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
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -51,23 +51,27 @@ std::vector<char> readBinaryFile(const std::string &fileName) {
|
||||
}
|
||||
}
|
||||
|
||||
void readFileToVectorOfStrings(std::vector<std::string> &lines, const std::string &fileName, bool replaceTabs) {
|
||||
std::ifstream file(fileName);
|
||||
if (file.good()) {
|
||||
void istreamToVectorOfStrings(std::istream &input, std::vector<std::string> &lines, bool replaceTabs) {
|
||||
if (input.good()) {
|
||||
if (replaceTabs) {
|
||||
for (std::string line; std::getline(file, line);) {
|
||||
for (std::string line; std::getline(input, line);) {
|
||||
std::replace_if(
|
||||
line.begin(), line.end(), [](auto c) { return c == '\t'; }, ' ');
|
||||
lines.push_back(std::move(line));
|
||||
}
|
||||
} else {
|
||||
for (std::string line; std::getline(file, line);) {
|
||||
for (std::string line; std::getline(input, line);) {
|
||||
lines.push_back(std::move(line));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void readFileToVectorOfStrings(std::vector<std::string> &lines, const std::string &fileName, bool replaceTabs) {
|
||||
std::ifstream file(fileName);
|
||||
istreamToVectorOfStrings(file, lines, replaceTabs);
|
||||
}
|
||||
|
||||
size_t findPos(const std::vector<std::string> &lines, const std::string &whatToFind) {
|
||||
for (size_t i = 0; i < lines.size(); ++i) {
|
||||
auto it = lines[i].find(whatToFind);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -26,6 +26,7 @@ void addSlash(std::string &path);
|
||||
|
||||
std::vector<char> readBinaryFile(const std::string &fileName);
|
||||
|
||||
void istreamToVectorOfStrings(std::istream &input, std::vector<std::string> &lines, bool replaceTabs = false);
|
||||
void readFileToVectorOfStrings(std::vector<std::string> &lines, const std::string &fileName, bool replaceTabs = false);
|
||||
void setProductFamilyForIga(const std::string &device, IgaWrapper *iga, OclocArgHelper *argHelper);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user