diff mbox series

[04/15] oeqa/selftest/efibootpartition: improve test

Message ID 20221109193135.291048-4-ross.burton@arm.com
State New
Headers show
Series [01/15] oeqa/qemurunner: update exception class for QMP API changes | expand

Commit Message

Ross Burton Nov. 9, 2022, 7:31 p.m. UTC
This test was overly complex with a setUp() method for a single test case,
which was marked as a class function for no good reason.

Generalise the test so that it has the possibility of working on more
machines in the future, add a decorator so that it only runs on
qemux86-64, and respect QEMU_USE_KVM to speed up test execution.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../oeqa/selftest/cases/efibootpartition.py   | 41 +++++++------------
 1 file changed, 14 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/efibootpartition.py b/meta/lib/oeqa/selftest/cases/efibootpartition.py
index 26de3a07c9e..e17da9f9a09 100644
--- a/meta/lib/oeqa/selftest/cases/efibootpartition.py
+++ b/meta/lib/oeqa/selftest/cases/efibootpartition.py
@@ -5,42 +5,29 @@ 
 # SPDX-License-Identifier: MIT
 #
 
-import re
-
 from oeqa.selftest.case import OESelftestTestCase
-from oeqa.utils.commands import bitbake, runqemu, get_bb_var
+from oeqa.utils.commands import bitbake, runqemu
+from oeqa.core.decorator.data import skipIfNotMachine
+import oe.types
 
 class GenericEFITest(OESelftestTestCase):
     """EFI booting test class"""
+    @skipIfNotMachine("qemux86-64", "test is qemux86-64 specific currently")
+    def test_boot_efi(self):
+        cmd = "runqemu nographic serial wic ovmf"
+        if oe.types.qemu_use_kvm(self.td['QEMU_USE_KVM'], self.td["TARGET_ARCH"]):
+            cmd += " kvm"
+        image = "core-image-minimal"
 
-    cmd_common = "runqemu nographic serial wic ovmf"
-    efi_provider = "systemd-boot"
-    image = "core-image-minimal"
-    machine = "qemux86-64"
-    recipes_built = False
-
-    @classmethod
-    def setUpLocal(self):
-        super(GenericEFITest, self).setUpLocal(self)
-
-        self.write_config(self,
-"""
-EFI_PROVIDER = "%s"
+        self.write_config("""
+EFI_PROVIDER = "systemd-boot"
 IMAGE_FSTYPES:pn-%s:append = " wic"
-MACHINE = "%s"
 MACHINE_FEATURES:append = " efi"
 WKS_FILE = "efi-bootdisk.wks.in"
 IMAGE_INSTALL:append = " grub-efi systemd-boot kernel-image-bzimage"
 """
-% (self.efi_provider, self.image, self.machine))
-        if not self.recipes_built:
-            bitbake("ovmf")
-            bitbake(self.image)
-            self.recipes_built = True
+% (image))
 
-    @classmethod
-    def test_boot_efi(self):
-        """Test generic boot partition with qemu"""
-        cmd = "%s %s" % (self.cmd_common, self.machine)
-        with runqemu(self.image, ssh=False, launch_cmd=cmd) as qemu:
+        bitbake(image + " ovmf")
+        with runqemu(image, ssh=False, launch_cmd=cmd) as qemu:
             self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)