From 08621e7225475ab28aca2d726c82a70868cbaee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 5 Jan 2019 17:09:10 +0100 Subject: [PATCH] tests: grub in HVM qubes Test grub in both PV and HVM. This change will also ease adding grub test for PVH, when supported. --- qubes/tests/__init__.py | 2 +- qubes/tests/integ/{pvgrub.py => grub.py} | 36 ++++++++++++++++-------- rpm_spec/core-dom0.spec.in | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) rename qubes/tests/integ/{pvgrub.py => grub.py} (88%) diff --git a/qubes/tests/__init__.py b/qubes/tests/__init__.py index 394350d5..35af75f6 100644 --- a/qubes/tests/__init__.py +++ b/qubes/tests/__init__.py @@ -1363,7 +1363,7 @@ def load_tests(loader, tests, pattern): # pylint: disable=unused-argument # integration tests 'qubes.tests.integ.basic', 'qubes.tests.integ.storage', - 'qubes.tests.integ.pvgrub', + 'qubes.tests.integ.grub', 'qubes.tests.integ.devices_block', 'qubes.tests.integ.devices_pci', 'qubes.tests.integ.dom0_update', diff --git a/qubes/tests/integ/pvgrub.py b/qubes/tests/integ/grub.py similarity index 88% rename from qubes/tests/integ/pvgrub.py rename to qubes/tests/integ/grub.py index 5c1e7cb1..e4a9457d 100644 --- a/qubes/tests/integ/pvgrub.py +++ b/qubes/tests/integ/grub.py @@ -28,11 +28,12 @@ import unittest import qubes.tests -@unittest.skipUnless(os.path.exists('/var/lib/qubes/vm-kernels/pvgrub2'), - 'grub-xen package not installed') -class TC_40_PVGrub(object): +class GrubBase(object): + virt_mode = None + kernel = None + def setUp(self): - super(TC_40_PVGrub, self).setUp() + super(GrubBase, self).setUp() supported = False if self.template.startswith('fedora-'): supported = True @@ -87,7 +88,7 @@ class TC_40_PVGrub(object): self.testvm1 = self.app.add_new_vm('StandaloneVM', name=self.make_vm_name('vm1'), label='red') - self.testvm1.virt_mode = 'pv' + self.testvm1.virt_mode = self.virt_mode self.testvm1.features.update(self.app.domains[self.template].features) self.loop.run_until_complete( self.testvm1.clone_disk_files(self.app.domains[self.template])) @@ -96,7 +97,7 @@ class TC_40_PVGrub(object): kver = self.get_kernel_version(self.testvm1) self.loop.run_until_complete(self.testvm1.shutdown(wait=True)) - self.testvm1.kernel = 'pvgrub2' + self.testvm1.kernel = self.kernel self.loop.run_until_complete(self.testvm1.start()) (actual_kver, _) = self.loop.run_until_complete( self.testvm1.run_for_stdio('uname -r')) @@ -105,7 +106,7 @@ class TC_40_PVGrub(object): def test_010_template_based_vm(self): self.test_template = self.app.add_new_vm('TemplateVM', name=self.make_vm_name('template'), label='red') - self.test_template.virt_mode = 'pv' + self.test_template.virt_mode = self.virt_mode self.test_template.features.update(self.app.domains[self.template].features) self.loop.run_until_complete( self.test_template.clone_disk_files(self.app.domains[self.template])) @@ -114,15 +115,15 @@ class TC_40_PVGrub(object): template=self.test_template, name=self.make_vm_name('vm1'), label='red') - self.testvm1.virt_mode = 'pv' + self.testvm1.virt_mode = self.virt_mode self.loop.run_until_complete(self.testvm1.create_on_disk()) self.loop.run_until_complete(self.test_template.start()) self.install_packages(self.test_template) kver = self.get_kernel_version(self.test_template) self.loop.run_until_complete(self.test_template.shutdown(wait=True)) - self.test_template.kernel = 'pvgrub2' - self.testvm1.kernel = 'pvgrub2' + self.test_template.kernel = self.kernel + self.testvm1.kernel = self.kernel # Check if TemplateBasedVM boots and has the right kernel self.loop.run_until_complete( @@ -137,10 +138,23 @@ class TC_40_PVGrub(object): self.test_template.run_for_stdio('uname -r')) self.assertEquals(actual_kver.strip(), kver) +@unittest.skipUnless(os.path.exists('/var/lib/qubes/vm-kernels/pvgrub2'), + 'grub-xen package not installed') +class TC_40_PVGrub(GrubBase): + virt_mode = 'pv' + kernel = 'pvgrub2' + +class TC_41_HVMGrub(GrubBase): + virt_mode = 'hvm' + kernel = None + def create_testcases_for_templates(): - return qubes.tests.create_testcases_for_templates('TC_40_PVGrub', + yield from qubes.tests.create_testcases_for_templates('TC_40_PVGrub', TC_40_PVGrub, qubes.tests.SystemTestCase, module=sys.modules[__name__]) + yield from qubes.tests.create_testcases_for_templates('TC_41_HVMGrub', + TC_41_HVMGrub, qubes.tests.SystemTestCase, + module=sys.modules[__name__]) def load_tests(loader, tests, pattern): tests.addTests(loader.loadTestsFromNames( diff --git a/rpm_spec/core-dom0.spec.in b/rpm_spec/core-dom0.spec.in index bf37ddec..ab382803 100644 --- a/rpm_spec/core-dom0.spec.in +++ b/rpm_spec/core-dom0.spec.in @@ -345,7 +345,7 @@ fi %{python3_sitelib}/qubes/tests/integ/dom0_update.py %{python3_sitelib}/qubes/tests/integ/mime.py %{python3_sitelib}/qubes/tests/integ/network.py -%{python3_sitelib}/qubes/tests/integ/pvgrub.py +%{python3_sitelib}/qubes/tests/integ/grub.py %{python3_sitelib}/qubes/tests/integ/salt.py %{python3_sitelib}/qubes/tests/integ/storage.py %{python3_sitelib}/qubes/tests/integ/vm_qrexec_gui.py