From 8f33926a75a400f237d77b5fb4a0f80605d840c2 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 25 Feb 2021 14:01:00 -0800 Subject: [PATCH] test-runner: use cleanup() for start_dbus Use a cleanup routine to remove the dbus_address/dbus_cfg files --- tools/test-runner | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/test-runner b/tools/test-runner index f6d7784d..fccb6233 100755 --- 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('\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)