Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Core] Add pid to generateTestFilePrefix (#35913)

Pavel Durandine4934a4d704f
diff --git a/src/tests/test_utils/common_test_utils/src/common_utils.cpp b/src/tests/test_utils/common_test_utils/src/common_utils.cpp
index a432e74bb31..161ce2f4acd 100644
--- a/src/tests/test_utils/common_test_utils/src/common_utils.cpp
+++ b/src/tests/test_utils/common_test_utils/src/common_utils.cpp
@@ -18,6 +18,8 @@
# include <windows.h>
# include "psapi.h"
+#else
+# include <unistd.h>
#endif
namespace ov {
@@ -39,8 +41,8 @@ std::ostream& operator<<(std::ostream& os, OpType type) {
}
std::string generateTestFilePrefix() {
- // Generate unique file names based on test name, thread id and timestamp
- // This allows execution of tests in parallel (stress mode)
+ // Generate unique file names based on test name, process id, thread id and timestamp.
+ // This allows execution of tests in parallel across threads and processes.
auto testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
std::string testName = testInfo->test_case_name();
testName += testInfo->name();
@@ -48,7 +50,12 @@ std::string generateTestFilePrefix() {
std::stringstream ss;
auto ts = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::high_resolution_clock::now().time_since_epoch());
- ss << testName << "_" << std::this_thread::get_id() << "_" << ts.count();
+#ifdef _WIN32
+ const auto pid = static_cast<uint64_t>(::GetCurrentProcessId());
+#else
+ const auto pid = static_cast<uint64_t>(::getpid());
+#endif
+ ss << testName << "_" << pid << "_" << std::this_thread::get_id() << "_" << ts.count();
testName = ss.str();
std::replace(testName.begin(), testName.end(), ':', '_');
return testName;