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();