From 174a428e813cda8342de5c78b8ba200063c47868 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 15 Oct 2026 12:22:36 -0400 Subject: [PATCH] [Test] (MG_Test/Util): give each log level test process its own log file --- MobileGL/MG_Test/Util/LogLevelTest.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Test/Util/LogLevelTest.cpp b/MobileGL/MG_Test/Util/LogLevelTest.cpp index dd59cdc5..53356220 100644 --- a/MobileGL/MG_Test/Util/LogLevelTest.cpp +++ b/MobileGL/MG_Test/Util/LogLevelTest.cpp @@ -30,6 +30,12 @@ #include #include +#if defined(_WIN32) +#include +#else +#include +#endif + namespace { // --------------------------------------------------------------------------- @@ -77,6 +83,14 @@ namespace { // line per level and then reads the file back. std::string g_logPath; + int ProcessId() { +#if defined(_WIN32) + return _getpid(); +#else + return static_cast(getpid()); +#endif + } + struct Emitted { bool debug = false; bool info = false; @@ -186,9 +200,11 @@ namespace { int main(int argc, char** argv) { // Must happen before anything logs: MG_Util::Debug::InitFile() reads the variable - // once, on the first write, and caches the FILE*. + // once, on the first write, and caches the FILE*. The name carries the process id because + // ctest runs each case as its own process, in parallel. namespace fs = std::filesystem; - const fs::path path = fs::temp_directory_path() / "mobilegl-loglevel-test.log"; + const fs::path path = + fs::temp_directory_path() / ("mobilegl-loglevel-test-" + std::to_string(ProcessId()) + ".log"); std::error_code ec; fs::remove(path, ec); g_logPath = path.string();