From 0341cc52582f8ca7f5166ed1840ee8b6a4b1f20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 10 Mar 2020 01:43:42 +0100 Subject: [PATCH] tests: teardown fixes Add few missing app.close() calls on test teardown. Fix socket cleanup in TC_00_QubesDaemonProtocol() - not only close the FD, but also unregister it from asyncio event loop. --- qubes/tests/api.py | 8 ++++++-- qubes/tests/app.py | 6 ++++++ qubes/tests/storage_lvm.py | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/qubes/tests/api.py b/qubes/tests/api.py index 3c3e1e1a..41b1c2d5 100644 --- a/qubes/tests/api.py +++ b/qubes/tests/api.py @@ -109,8 +109,12 @@ class TC_00_QubesDaemonProtocol(qubes.tests.QubesTestCase): connect_coro) def tearDown(self): - self.sock_server.close() - self.sock_client.close() + self.writer.close() + try: + self.loop.run_until_complete(self.writer.wait_closed()) + except AttributeError: # old python in travis + pass + self.transport.close() super(TC_00_QubesDaemonProtocol, self).tearDown() def test_000_message_ok(self): diff --git a/qubes/tests/app.py b/qubes/tests/app.py index f4c202ea..a9c47ce0 100644 --- a/qubes/tests/app.py +++ b/qubes/tests/app.py @@ -480,6 +480,9 @@ class TC_89_QubesEmpty(qubes.tests.QubesTestCase): with self.assertRaises(AttributeError): self.app.default_fw_netvm + self.app.close() + del self.app + with self.subTest('loop'): with open('/tmp/qubestest.xml', 'w') as xml_file: xml_file.write(xml_template.format( @@ -502,6 +505,9 @@ class TC_89_QubesEmpty(qubes.tests.QubesTestCase): with self.assertRaises(AttributeError): self.app.default_fw_netvm + self.app.close() + del self.app + class TC_90_Qubes(qubes.tests.QubesTestCase): def tearDown(self): diff --git a/qubes/tests/storage_lvm.py b/qubes/tests/storage_lvm.py index 5646ac9f..8d297c6f 100644 --- a/qubes/tests/storage_lvm.py +++ b/qubes/tests/storage_lvm.py @@ -131,6 +131,7 @@ class TC_00_ThinPool(ThinPoolBase): def tearDown(self): super(TC_00_ThinPool, self).tearDown() os.unlink(self.app.store) + self.app.close() del self.app for attr in dir(self): if isinstance(getattr(self, attr), qubes.vm.BaseVM): @@ -1141,6 +1142,7 @@ class TC_02_StorageHelpers(ThinPoolBase): self.thin_dir.cleanup() super(TC_02_StorageHelpers, self).tearDown() os.unlink(self.app.store) + self.app.close() del self.app for attr in dir(self): if isinstance(getattr(self, attr), qubes.vm.BaseVM):