commit 8f33926a75a400f237d77b5fb4a0f80605d840c2
parent 11f0abebe678a5be59192ce1a034619ac59ff7e1
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 25 Feb 2021 14:01:00 -0800
test-runner: use cleanup() for start_dbus
Use a cleanup routine to remove the dbus_address/dbus_cfg files
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/test-runner b/tools/test-runner
@@ -615,7 +615,15 @@ class Namespace:
return True
return False
- def start_dbus(self, multi_test=True):
+ def _cleanup_dbus(self):
+ try:
+ os.remove(self.dbus_address.split('=')[1])
+ except:
+ pass
+
+ os.remove(self.dbus_cfg)
+
+ def start_dbus(self):
global dbus_count
self.dbus_address = 'unix:path=/tmp/dbus%d' % dbus_count
@@ -628,7 +636,7 @@ class Namespace:
f.write('</busconfig>\n')
p = self.start_process(['dbus-daemon', '--config-file=%s' % self.dbus_cfg],
- wait=False)
+ wait=False, cleanup=self._cleanup_dbus)
p.wait_for_socket(self.dbus_address.split('=')[1], wait=5)