Add clean up fixture for trace cache temporary files (#1836)

* Add clean up fixture for trace cache tmp files

* Switch to bash instead of cmake running command
This commit is contained in:
Milan Radosavljevic
2025-11-14 03:01:04 +01:00
committed by GitHub
parent 4830979f0e
commit 833c250c27
3 changed files with 42 additions and 34 deletions
@@ -131,29 +131,6 @@ get_cache_files()
return cache_map;
}
std::vector<std::string>
get_all_cache_files()
{
const auto tmp_files = list_dir_files(tmp_directory);
std::vector<std::string> result{};
auto parse_and_fill_cache = [&](const std::string& filename) {
const std::regex buff_regex(R"(buffered_storage.*\.bin)");
const std::regex meta_regex(R"(metadata.*\.json)");
std::smatch match;
if(std::regex_match(filename, match, buff_regex))
{
result.push_back(tmp_directory + filename);
}
else if(std::regex_match(filename, match, meta_regex))
{
result.push_back(tmp_directory + filename);
}
};
std::for_each(tmp_files.begin(), tmp_files.end(), parse_and_fill_cache);
return result;
}
} // namespace
cache_manager&
@@ -238,13 +215,16 @@ cache_manager::post_process_bulk()
}
}
ROCPROFSYS_PRINT("Removing all cached temporary files...\n");
ROCPROFSYS_PRINT("Removing cached temporary files...\n");
auto all_cache_files = get_all_cache_files();
for(const auto& filename : all_cache_files)
for(const auto& [pid, files] : _cache_files)
{
ROCPROFSYS_PRINT("Removing cached temporary file: %s\n", filename.c_str());
remove_if_exists(filename);
ROCPROFSYS_PRINT("Removing cached temporary file: %s\n",
files.buff_storage.c_str());
ROCPROFSYS_PRINT("Removing cached temporary file: %s\n",
files.metadata.c_str());
remove_if_exists(files.buff_storage.c_str());
remove_if_exists(files.metadata.c_str());
}
}
}