diff --git a/qubes/tests/__init__.py b/qubes/tests/__init__.py index 6fe0513a..876118fa 100644 --- a/qubes/tests/__init__.py +++ b/qubes/tests/__init__.py @@ -37,6 +37,7 @@ import functools import logging import os import pathlib +import shlex import shutil import subprocess import sys @@ -962,6 +963,16 @@ class SystemTestsMixin(object): shutil.rmtree(mountpoint) subprocess.check_call(['sudo', 'losetup', '-d', loopdev]) + def create_local_file(self, filename, content, mode='w'): + with open(filename, mode) as file: + file.write(content) + self.addCleanup(os.unlink, filename) + + def create_remote_file(self, vm, filename, content): + self.loop.run_until_complete(vm.run_for_stdio( + 'cat > {}'.format(shlex.quote(filename)), + user='root', input=content.encode('utf-8'))) + def load_tests(loader, tests, pattern): # pylint: disable=unused-argument # discard any tests from this module, because it hosts base classes diff --git a/qubes/tests/integ/vm_qrexec_gui.py b/qubes/tests/integ/vm_qrexec_gui.py index 2883a0e6..219e2cf9 100644 --- a/qubes/tests/integ/vm_qrexec_gui.py +++ b/qubes/tests/integ/vm_qrexec_gui.py @@ -20,21 +20,17 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -from distutils import spawn - import asyncio import multiprocessing import os -import shlex import subprocess -import time import unittest +from distutils import spawn import qubes.config import qubes.tests import qubes.vm.appvm import qubes.vm.templatevm -import re TEST_DATA = b"0123456789" * 1024 @@ -59,16 +55,6 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin): self.loop.run_until_complete(self.testvm2.create_on_disk()) self.app.save() - def create_local_file(self, filename, content, mode='w'): - with open(filename, mode) as file: - file.write(content) - self.addCleanup(os.unlink, filename) - - def create_remote_file(self, vm, filename, content): - self.loop.run_until_complete(vm.run_for_stdio( - 'cat > {}'.format(shlex.quote(filename)), - user='root', input=content.encode('utf-8'))) - def test_000_start_shutdown(self): # TODO: wait_for, timeout self.loop.run_until_complete(self.testvm1.start()) diff --git a/tests/pvgrub.py b/tests/pvgrub.py index 5467d2a3..9dcc27be 100644 --- a/tests/pvgrub.py +++ b/tests/pvgrub.py @@ -169,4 +169,4 @@ def load_tests(loader, tests, pattern): 'TC_40_PVGrub_' + template, (TC_40_PVGrub, qubes.tests.QubesTestCase), {'template': template}))) - return tests \ No newline at end of file + return tests