diff --git a/qubes/tests/integ/vm_update.py b/qubes/tests/integ/vm_update.py index e9732d9e2..79711dca0 100644 --- a/qubes/tests/integ/vm_update.py +++ b/qubes/tests/integ/vm_update.py @@ -20,6 +20,7 @@ # License along with this library; if not, see . # import asyncio +import contextlib import os import shutil import subprocess @@ -226,6 +227,13 @@ def setUp(self): name=self.make_vm_name('vm1'), label='red') self.loop.run_until_complete(self.testvm1.create_on_disk()) + self.repo_proc = None + + def tearDown(self): + if self.repo_proc: + self.repo_proc.terminate() + self.loop.run_until_complete(self.repo_proc.wait()) + super().tearDown() def test_000_simple_update(self): """ @@ -322,12 +330,12 @@ def create_repo_and_serve(self): """ if self.template.count("debian") or self.template.count("whonix"): self.create_repo_apt() - self.loop.run_until_complete(self.netvm_repo.run( + self.repo_proc = self.loop.run_until_complete(self.netvm_repo.run( 'cd /tmp/apt-repo && python3 -m http.server 8080', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) elif self.template.count("fedora"): self.create_repo_yum() - self.loop.run_until_complete(self.netvm_repo.run( + self.repo_proc = self.loop.run_until_complete(self.netvm_repo.run( 'cd /tmp/yum-repo && python3 -m http.server 8080', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) else: @@ -482,9 +490,11 @@ def turn_off_repo(self): :type self: qubes.tests.SystemTestCase | VmUpdatesMixin """ - self.loop.run_until_complete(self.netvm_repo.run( - r"kill -9 `ps -ef | grep python | awk '{print $2}'`", + self.loop.run_until_complete(self.netvm_repo.run_for_stdio( + r"kill -9 `ps -ef | grep python | awk '{print $2}'` ||:", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) + self.loop.run_until_complete(self.repo_proc.wait()) + self.repo_proc = None def update_via_proxy_qubes_vm_update_impl( self,