dbus unit tests
Simon McVittie
smcv at debian.org
Tue Dec 5 11:04:05 UTC 2023
On Tue, 05 Dec 2023 at 10:13:42 +0100, Alec Leamas wrote:
> I'm working with a program (still opencpn) which is about to bring some unit
> tests using dbus. These tests works outside the sandbox in a native build.
>
> However, they fail when applied in the flatpak build. The reason seems to be
> that there is no dbus session bus, DBUS_SESSION_BUS_ADDRESS is undefined.
The autobuilders used by Linux distributions for traditional, non-Flatpak
packaging systems like dpkg and RPM typically do not provide a session
bus either, so this is a problem that would have to be solved with or
without Flatpak.
The upstream project (opencpn) should probably use dbus-run-session(1)
from the reference implementation of D-Bus to start a temporary session
bus, or start a temporary session bus manually some other way (for example
GLib's GTestDBus, if it uses GLib). If it doesn't, the workaround would be
for the Flatpak packaging (and dpkg packaging, and RPM packaging, etc.) to
wrap the test suite in something like dbus-run-session.
It is usually wrong for unit tests to be on the "real" session bus
anyway, because the test should usually to be communicating with a mock
implementation of whatever services it wants (or the real implementation
in a special mode that will operate on a mock data directory, or similar),
not real services that will overwrite your real data.
smcv
More information about the Flatpak
mailing list