Improve cleanup lifecycle readability

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-10-10 21:09:04 +08:00
parent bd02e4b4c7
commit 1e4c8b6683
9 changed files with 121 additions and 0 deletions
+6
View File
@@ -161,8 +161,10 @@ class SingTUNLinuxHostTest(unittest.TestCase):
def wait(timeout=None):
self.assertIsNone(timeout)
entered.set()
if not authorized.wait(5):
raise RuntimeError('fixture authorization was not released')
process.poll.return_value = 0
return 0
@@ -173,6 +175,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
self.host.execute([['ip', 'link', 'delete', 'dev', 'utun101']])
except Exception as ex:
# Any non-exit exceptions
errors.append(ex)
finally:
complete.set()
@@ -182,6 +185,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
), mock.patch.object(self.module.subprocess, 'Popen', return_value=process):
worker = threading.Thread(target=recover)
worker.start()
try:
self.assertTrue(entered.wait(2))
self.assertFalse(complete.is_set())
@@ -269,8 +273,10 @@ class SingTUNLinuxHostTest(unittest.TestCase):
self.assertIs(self.host._process, process)
self.assertTrue(directory.exists())
process.poll.return_value = 126
self.host.drain()
self.assertFalse(directory.exists())
def testLiveForwarderDnsCannotBeReportedAsRestored(self):