testing: Use local tcp session for DBus to avoid leftover socket files

This commit is contained in:
Vicki Pfau 2025-01-21 17:16:22 -08:00
parent 54351414fa
commit 2547b8d0ef
2 changed files with 16 additions and 1 deletions

15
data/test-dbus.conf Normal file
View file

@ -0,0 +1,15 @@
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<type>session</type>
<keep_umask/>
<listen>tcp:host=localhost,port=0</listen>
<auth>EXTERNAL</auth>
<auth>ANONYMOUS</auth>
<allow_anonymous/>
<policy context="default">
<allow send_destination="*" eavesdrop="true"/>
<allow eavesdrop="true"/>
<allow own="*"/>
</policy>
</busconfig>

View file

@ -112,7 +112,7 @@ pub struct TestHandle {
impl MockDBus { impl MockDBus {
pub async fn new() -> Result<MockDBus> { pub async fn new() -> Result<MockDBus> {
let mut process = Command::new("/usr/bin/dbus-daemon") let mut process = Command::new("/usr/bin/dbus-daemon")
.args(["--session", "--nofork", "--print-address"]) .args(["--nofork", "--print-address", "--config-file=data/test-dbus.conf"])
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn()?; .spawn()?;