Files
chandra/compositor/sys/private_bus_test.mbt
nandiandClaude Sonnet 5.5 70b24ffe47
CI / test (push) Canceled after 24m10s
Private bus: don't take over the session's document portal mount
A nested compositor's private D-Bus kept the session's XDG_RUNTIME_DIR, so
an xdg-document-portal activated on it mounted over $XDG_RUNTIME_DIR/doc and
removed the mount when the bus exited. The session's portal kept running
without it, and flatpak apps stopped starting.

The bus now has its own config that starts the document portal with a runtime
directory per compositor. scripts/test-private-bus.sh covers it. The KDE
colors test gets its own runtime directory for the same reason.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 22:06:51 -08:00

47 lines
2.1 KiB
MoonBit

///|
/// Run by scripts/test-private-bus.sh, which supplies the runtime directory with a "host"
/// document portal mounted in it, and checks afterwards that the mount outlived this process.
test "the private bus's document portal leaves the host's mount alone" {
if @sys.getenv("CHANDRA_PRIVATE_BUS_E2E") != "1" {
return
}
let out = @sys.getenv("XDG_RUNTIME_DIR") + "/activation.txt"
let cmd = "{ echo bus=$DBUS_SESSION_BUS_ADDRESS; " +
"dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus " +
"org.freedesktop.DBus.StartServiceByName string:org.freedesktop.portal.Documents uint32:0; " +
"sleep 1; grep -o '[^ ]*/private-bus-[^ ]*/doc ' /proc/self/mountinfo; " +
"dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus " +
"org.freedesktop.DBus.StartServiceByName string:org.freedesktop.portal.Desktop uint32:0; " +
"sleep 3; dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop " +
"/org/freedesktop/portal/desktop org.freedesktop.DBus.Properties.Get " +
"string:org.freedesktop.portal.Trash string:version; echo done; } >\'" +
out +
"' 2>&1"
assert_true(@sys.spawn(cmd, "wayland-test"))
let mut text = ""
for _i = 0; _i < 300 && !text.contains("done\n"); _i = _i + 1 {
@sys.sleep_ms(100)
// The shim's bytes are ASCII here: dbus-send's reply.
let sb = StringBuilder::new()
for b in @sys.read_file_bytes(out) {
sb.write_char(b.to_int().unsafe_to_char())
}
text = sb.to_string()
}
assert_true(text.contains("done\n"))
// A bus of its own, not the one we were started on...
assert_true(text.contains("bus=unix:"))
assert_false(
text.contains("bus=" + @sys.getenv("DBUS_SESSION_BUS_ADDRESS") + "\n"),
)
// ...where the document portal mounts in a directory of this compositor's own...
assert_true(
text.contains(
"/chandra/private-bus-" + @sys.getpid().to_string() + "/runtime/doc \n",
),
)
// ...and the desktop portal, which exports nothing without it, still works (Trash is one of
// the interfaces it needs no backend for).
assert_true(text.contains("variant uint32"))
}