From c5d27d1b39b21530df1ef7a2bf724ba79fcfbc2e Mon Sep 17 00:00:00 2001 From: Arlandrian <20161736+Arlandrian@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:34:29 +0300 Subject: [PATCH] test(linux/portalgrab): drain logs before changing the environment The log formatter reads the environment through localtime(), which can race with setenv() on older glibc. Flush queued records before the fixture sets its variables and before it restores them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018p3TPKSBD7eaHtKtQjCcrv --- tests/unit/platform/linux/test_portalgrab.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/platform/linux/test_portalgrab.cpp b/tests/unit/platform/linux/test_portalgrab.cpp index 83e4371a6..fbc831a26 100644 --- a/tests/unit/platform/linux/test_portalgrab.cpp +++ b/tests/unit/platform/linux/test_portalgrab.cpp @@ -31,6 +31,9 @@ #include #include + // local includes + #include "src/logging.h" + namespace platf { std::vector portal_display_names(bool allow_start_timeout); } // namespace platf @@ -304,6 +307,8 @@ namespace { ASSERT_NE(fgets(address.data(), address.size(), daemon_output_), nullptr) << "dbus-daemon did not print its address"; const std::string bus_address = g_strchomp(address.data()); + // Drain queued log records first: the log formatter reads the environment, which must not race with setenv + logging::log_flush(); set_env("DBUS_SESSION_BUS_ADDRESS", bus_address); // Start resolves monitor names through the compositor; keep the test away from the user's session. set_env("WAYLAND_DISPLAY", (bus_directory_ / "no-wayland").string()); @@ -316,6 +321,7 @@ namespace { */ void TearDown() override { portal_.stop(); + logging::log_flush(); for (const auto &[name, previous] : previous_env_) { if (previous) { g_setenv(name.c_str(), previous->c_str(), true);