From efb6c365674c0c8d840d3d97642009b16fd3f08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 14 Jan 2024 00:19:09 +0100 Subject: [PATCH] Add random id to process id to avoid potential conflicts when testing in parallel in containers --- test/get_process_id_name.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/get_process_id_name.hpp b/test/get_process_id_name.hpp index c2d9733..0ebcd09 100644 --- a/test/get_process_id_name.hpp +++ b/test/get_process_id_name.hpp @@ -24,14 +24,16 @@ namespace test{ inline void get_process_id_name(std::string &str) { std::stringstream sstr; - sstr << "process_" << boost::interprocess::ipcdetail::get_current_process_id() << std::ends; + sstr << "process_" << boost::interprocess::ipcdetail::get_current_process_id() << "_rand_" + << boost::interprocess::ipcdetail::get_system_tick_in_highres_counts() << std::ends; str = sstr.str().c_str(); } inline void get_process_id_ptr_name(std::string &str, const void *ptr) { std::stringstream sstr; - sstr << "process_" << boost::interprocess::ipcdetail::get_current_process_id() << "_" << ptr << std::ends; + sstr << "process_" << boost::interprocess::ipcdetail::get_current_process_id() << "_" << ptr << "_rand_" + << boost::interprocess::ipcdetail::get_system_tick_in_highres_counts() << std::ends; str = sstr.str().c_str(); } @@ -92,7 +94,8 @@ namespace test { inline void get_process_id_wname(std::wstring &str) { std::wstringstream sstr; - sstr << L"process_" << boost::interprocess::ipcdetail::get_current_process_id() << std::ends; + sstr << L"process_" << boost::interprocess::ipcdetail::get_current_process_id() << "_rand_" + << boost::interprocess::ipcdetail::get_system_tick_in_highres_counts() << std::ends; str = sstr.str().c_str(); }