From 93bc019b1e7d3cd073985e1a11795edf9e638447 Mon Sep 17 00:00:00 2001 From: Jiu-xiao <2592509183@qq.com> Date: Thu, 19 Nov 2026 09:04:32 +0000 Subject: [PATCH] fix(test): run the logger case without PlatformInit The isolated logger case ran PlatformInit(), which starts the STDIO read thread. When stdin is not a TTY that thread logs "stdin is not a TTY, parking thread forever" asynchronously, and the line could land in the Pipe the test had swapped into STDIO::write_, so the "\r\n" count became 4. The case needs no STDIO workers (Logger initializes lazily and the test owns the writer), so it now skips PlatformInit like the other isolated cases that need no platform threads. --- test/automatic/main.cpp | 6 ++++-- test/automatic/middleware/logger/logger/test_logger.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/automatic/main.cpp b/test/automatic/main.cpp index a95b0dafd..29dd1b5d7 100644 --- a/test/automatic/main.cpp +++ b/test/automatic/main.cpp @@ -113,8 +113,10 @@ struct TestCase // cases. bool isolated; // 内部要 fork 的用例须同时隔离并跳过 PlatformInit,且自行确保 fork 时没有其他线程。 + // 接管 STDIO 写端并检查全部输出的用例也跳过,避免 STDIO 线程的日志混入输出。 // Cases that fork internally need isolation, no PlatformInit, and no other threads at - // fork. + // fork. Cases that take over the STDIO writer and check all of its output skip it as + // well, so no STDIO worker log lands in that output. bool platform_init = true; }; @@ -279,7 +281,7 @@ constexpr GroupedTestCase kMainTestCases[] = { false}}, {"linux_host_tests", {"linux_database_raw", &RunVoidEntry, true, false}}, - {"system_tests", {"logger", &RunVoidEntry, true}}, + {"system_tests", {"logger", &RunVoidEntry, true, false}}, {"system_tests", {"linux_shm_topic", &RunVoidEntry, true, false}}, {"system_tests", {"linux_shm_bench", &RunBenchLinuxSharedTopicSet, true, false}}, diff --git a/test/automatic/middleware/logger/logger/test_logger.cpp b/test/automatic/middleware/logger/logger/test_logger.cpp index 703b06e6d..5878a2b0d 100644 --- a/test/automatic/middleware/logger/logger/test_logger.cpp +++ b/test/automatic/middleware/logger/logger/test_logger.cpp @@ -62,8 +62,9 @@ void test_logger() auto* old_stream = LibXR::STDIO::write_stream_; // 临时把日志输出接到 Pipe,检查实际生成的文本;读取后恢复 STDIO 的原指针。 + // 本用例不执行 PlatformInit,没有 STDIO 线程会同时写日志。 // Redirect logging to a Pipe to inspect generated text, then restore the original STDIO - // pointers. + // pointers. The case runs without PlatformInit, so no STDIO worker logs meanwhile. LibXR::STDIO::write_ = &output.GetWritePort(); LibXR::STDIO::write_stream_ = nullptr;