Repository navigation
fix(test): run the logger case without PlatformInit - #369
Merged
Merged
Conversation
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.
[Low impact] This appears safe to merge; the change removes the unwanted worker without changing the output checks.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_logger.cpp:91(CountSubstring(text, "\r\n") == 3) failed intermittently whenlibxr_testran with a non-TTY stdin.Cause. The isolated
loggercase ranPlatformInit(), which starts theSTDIO.read_thread. When stdin is not a TTY,StdiThreadlogsXR_LOG_WARN("STDIO.read_: stdin is not a TTY, parking thread forever")asynchronously (system/linux/libxr_system.cpp:57). If that happened while the test hadSTDIO::write_swapped to itsPipe, the warning line landed in the captured text and the count became 4. CI does not hit this becausecteststartslibxr_testunderscript, so stdin is a TTY.Fix. The case needs no STDIO workers:
Loggerinitializes lazily and the test owns the writer. It now runs isolated withplatform_init = false, likelinux_database_rawandlinux_shm_topic. Theplatform_initfield comment and the test comment say why.Test-only change; no product code touched.
Verification
On the Ubuntu 24 build host:
326ae1d28),libxr_test --direct-case logger </dev/nullwith 14 busy loops: 4 failures in 400 runs. In every failing run the warning was missing from stdout, so it had gone into the Pipe. With a TTY stdin (script): 0 failures in 150 runs.libxr_test </dev/null: 0 failures in 25 runs.ctest(Debug/ON,Release/ON,Release/OFF,LIBXR_TEST_BUILD=ON): 10/10 (test_linux_canskipped), 0 warnings.git diff --check origin/dev..HEAD: clean.Not changed
STDIO::write_is a plain pointer read without the mutex inOnLogMessageandBeginWriteSession, andSTDIO::write_mutex_is created lazily without synchronization. This change keeps the logger case away from that race but does not fix it.