From ad0dde105ca0b62adcbee35a8ff4b3c49b9e9901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 8 Oct 2026 11:41:15 +0200 Subject: [PATCH] test-bus-unit-util: use an unconnected bus instead of connecting The test only constructs messages locally and never sends them, so a real connection is not needed. Create the bus with sd_bus_new() and fake the state, like test-bus-util does, so that the test is never skipped when no bus is available. (cherry picked from commit 970993efbebb6a302417b593a3935f28bab7c192) --- src/test/test-bus-unit-util.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/test/test-bus-unit-util.c b/src/test/test-bus-unit-util.c index 8185d0269f..a670ff2306 100644 --- a/src/test/test-bus-unit-util.c +++ b/src/test/test-bus-unit-util.c @@ -2,6 +2,7 @@ #include "sd-bus.h" +#include "bus-internal.h" #include "bus-unit-util.h" #include "extract-word.h" #include "unit-def.h" @@ -15,9 +16,6 @@ static void test_transient_settings_one(UnitType type, const char* const* lines) _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; int r; - if (!arg_bus) - return (void) log_tests_skipped("no bus connection"); - ASSERT_OK(sd_bus_message_new(arg_bus, &m, SD_BUS_MESSAGE_METHOD_CALL)); STRV_FOREACH(s, lines) { @@ -1167,13 +1165,9 @@ TEST(bus_dump_transient_settings) { } static int intro(void) { - int r; - - r = sd_bus_default_user(&arg_bus); - if (r < 0) - r = sd_bus_default_system(&arg_bus); - if (r < 0) - log_info_errno(r, "Failed to connect to bus: %m"); + /* An unconnected bus is sufficient to construct and inspect messages locally. */ + ASSERT_OK(sd_bus_new(&arg_bus)); + arg_bus->state = BUS_RUNNING; /* Fake state to allow message creation */ return EXIT_SUCCESS; }