From c4a84b3298721782775707cf02360e7b5b722f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 15 Sep 2018 03:53:30 +0200 Subject: [PATCH] tests: wait for DispVM's qubes.VMShell exit It isn't enough to wait for window to disappear, the service may still be running. And if it is, test cleanup logic will complain about FD leak. To avoid deadlock on some test failure, do it with a timeout. --- qubes/tests/integ/dispvm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qubes/tests/integ/dispvm.py b/qubes/tests/integ/dispvm.py index d88ff926..5c26c7e0 100644 --- a/qubes/tests/integ/dispvm.py +++ b/qubes/tests/integ/dispvm.py @@ -23,6 +23,7 @@ import subprocess import tempfile import time import unittest +from contextlib import suppress from distutils import spawn @@ -162,8 +163,15 @@ class TC_20_DispVMMixin(object): self.enter_keys_in_window(window_title, ['Return']) # Wait for window to close self.wait_for_window(window_title, show=False) - finally: p.stdin.close() + self.loop.run_until_complete( + asyncio.wait_for(p.wait(), 30)) + except: + with suppress(ProcessLookupError): + p.terminate() + self.loop.run_until_complete(p.wait()) + raise + finally: del p finally: self.loop.run_until_complete(dispvm.cleanup())