From 80c0a0caa822733425172cdb432e91d67609fb40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 14 Jul 2020 01:12:56 +0200 Subject: [PATCH] tests: fix FD leak in qrexec test Terminate dangling process to avoid FD leak (detected by test cleanup code). --- qubes/tests/integ/qrexec.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qubes/tests/integ/qrexec.py b/qubes/tests/integ/qrexec.py index 9d0ee996..b357f5f6 100644 --- a/qubes/tests/integ/qrexec.py +++ b/qubes/tests/integ/qrexec.py @@ -20,6 +20,7 @@ # import asyncio +import contextlib import os import subprocess import sys @@ -585,6 +586,10 @@ class TC_00_QrexecMixin(object): except asyncio.TimeoutError: self.fail( "service timeout, probably EOF wasn't transferred from the VM process") + finally: + with contextlib.suppress(ProcessLookupError): + p.terminate() + self.loop.run_until_complete(p.wait()) self.assertEqual(stdout, b'test\n', 'Received data differs from what was expected') @@ -633,6 +638,10 @@ class TC_00_QrexecMixin(object): except asyncio.TimeoutError: self.fail( "service timeout, probably EOF wasn't transferred from the VM process") + finally: + with contextlib.suppress(ProcessLookupError): + p.terminate() + self.loop.run_until_complete(p.wait()) service_descriptor = b'test.Socket+ test-inst-vm1 keyword adminvm\0' self.assertEqual(service_stdout, service_descriptor + b'test1test2',