3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

test-runner: use cleanup() for start_dbus

Use a cleanup routine to remove the dbus_address/dbus_cfg files
This commit is contained in:
James Prestwood 2021-02-25 14:01:00 -08:00 committed by Denis Kenzior
parent 11f0abebe6
commit 8f33926a75

View File

@ -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)