test: ensure logs are flushed before reading them #33198

pull stickies-v wants to merge 2 commits into bitcoin:master from stickies-v:2025-08/force-log-flush changing 3 files +10 −0
  1. stickies-v commented at 2:45 pm on August 15, 2025: contributor

    Should fix #33195 (still testing, trying to reproduce locally, draft until then)

    Logging to file is unbuffered (src), but is not blocked by flushing. Generally, that seems desireable, but it can be problematic for tests.

    #33195 observes intermittent failure of the TestLogFromLocation() function (see comment for more details), where we write and read to/from file in quick succession.

    This PR introduces a Logger::FlushDebugFile() method, and uses it in the test-only ReadDebugLogLines() function. As such, this PR should not change any non-test behaviour or performance.

  2. log: add FlushDebugFile method
    This function blocks until the file is actually flushed, preventing
    race conditions when accessing m_fileout by just relying on it being
    unbuffered.
    17aba8c0e1
  3. test: ensure logs are flushed before reading them
    Prevents race conditions, such as e.g. in
    https://github.com/bitcoin/bitcoin/issues/33195
    e7758593ba
  4. DrahtBot added the label Tests on Aug 15, 2025
  5. DrahtBot commented at 2:45 pm on August 15, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33198.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  6. hebasto added this to the milestone 30.0 on Aug 15, 2025
  7. stickies-v commented at 4:15 pm on August 18, 2025: contributor
    This PR seems to be on the wrong track, see this comment and further. Closing.
  8. stickies-v closed this on Aug 18, 2025


stickies-v DrahtBot

Labels
Tests

Milestone
30.0


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-23 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me