test: skip D-Bus FD truncation test with dbus-daemon

dbus-daemon intentionally disconnects peers when FDs get
truncated. Detect it and skip it in that case, as the purpose
of the test is not to exercise the D-Bus implementation, but
our library.
When running with dbus-broker (Fedora, etc) we'll get full
coverage.

Fixes https://github.com/systemd/systemd/issues/41150

Follow-up for 744d589632
This commit is contained in:
Luca Boccassi
2026-03-20 15:25:26 +01:00
committed by Daan De Meyer
parent 55e7dc5ce4
commit 69c087bade
+7 -1
View File
@@ -567,11 +567,17 @@ TEST(ctrunc) {
/* The very first message should be the one we expect */
ASSERT_OK(get_one_message(bus, &recvd));
ASSERT_TRUE(sd_bus_message_is_method_call(recvd, "org.freedesktop.systemd.test", "SendFds"));
/* This needs to succeed or the following tests are going to be unhappy... */
ASSERT_EQ(setrlimit(RLIMIT_NOFILE, &orig_rl), 0);
/* dbus-daemon disconnects peers when FDs get truncated
* https://github.com/systemd/systemd/issues/41150 */
if (sd_bus_message_is_signal(recvd, "org.freedesktop.DBus.Local", "Disconnected") > 0)
return (void) log_tests_skipped("Running with dbus-daemon, which doesn't support fd passing with truncation");
ASSERT_TRUE(sd_bus_message_is_method_call(recvd, "org.freedesktop.systemd.test", "SendFds"));
/* Try to read all the fds. We expect at least one to fail with -EBADMSG due to
* truncation, and all subsequent reads must also fail with -EBADMSG. */
int i;