Skip to contentSkip to conversation

oeqa/qemurunner: update exception class for QMP API changes

PATCH New Ross Burton 1 participant 15 messages Nov 9, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/15 oeqa/qemurunner: update exception class for QMP API changes

---
 meta/lib/oeqa/utils/qemurunner.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/utils/qemurunner.py +1 -1
index 6a85f57e498..e602399232b 100644
@@ -354,7 +354,7 @@ class QemuRunner:
             except OSError as msg:
                 self.logger.warning("Failed to connect qemu monitor socket: %s File: %s" % (msg, msg.filename))
                 return False
-            except qmp.QMPConnectError as msg:
+            except qmp.legacy.QMPError as msg:
                 self.logger.warning("Failed to communicate with qemu monitor: %s" % (msg))
                 return False
         finally:
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/15 oeqa/core/decorator: add decorators to skip based on HOST_ARCH

There are already decorators to skip on the value of MACHINE, but for flexibility it's better to skip based on the target architecture. This means, for example, the ISO image tests could skip if the architecture isn't x86.

---
 meta/lib/oeqa/core/decorator/data.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
meta/lib/oeqa/core/decorator/data.py +24 -0
index 3ce10e54999..de881e097ab 100644
@@ -194,3 +194,27 @@ class skipIfQemu(OETestDecorator):
         self.logger.debug("Checking if qemu MACHINE")
         if self.case.td.get('MACHINE', '').startswith('qemu'):
              self.case.skipTest('Test only runs on real hardware')
+
+@registerDecorator
+class skipIfArch(OETestDecorator):
+    """
+    Skip test if HOST_ARCH is present in the tuple specified.
+    """
+
+    attrs = ('archs',)
+    def setUpDecorator(self):
+        arch = self.case.td['HOST_ARCH']
+        if arch in self.archs:
+             self.case.skipTest('Test skipped on %s' % arch)
+
+@registerDecorator
+class skipIfNotArch(OETestDecorator):
+    """
+    Skip test if HOST_ARCH is not present in the tuple specified.
+    """
+
+    attrs = ('archs',)
+    def setUpDecorator(self):
+        arch = self.case.td['HOST_ARCH']
+        if arch not in self.archs:
+             self.case.skipTest('Test skipped on %s' % arch)
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/15 oeqa/selftest/buildoptions: skip test_read_only_image on qemuarm64

In reply to Ross Burton

qemuarm64 currently uses SERIAL_CONSOLES_CHECK but this is incompatible with read-only rootfs under sysvinit. Until qemuarm64 doesn't use this, skip the test on qemuarm64.

---
 meta/lib/oeqa/selftest/cases/buildoptions.py | 3 +++
 1 file changed, 3 insertions(+)
meta/lib/oeqa/selftest/cases/buildoptions.py +3 -0
index ee3e28d74bf..01ea4dce395 100644
@@ -11,6 +11,7 @@ import shutil
 import tempfile
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.selftest.cases.buildhistory import BuildhistoryBase
+from oeqa.core.decorator.data import skipIfMachine
 from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars
 import oeqa.utils.ftools as ftools
 
@@ -49,6 +50,8 @@ class ImageOptionsTests(OESelftestTestCase):
             loglines = "".join(f.readlines())
         self.assertIn("ccache", loglines, msg="No match for ccache in %s log.do_compile. For further details: %s" % (recipe , log_compile))
 
+    # https://bugzilla.yoctoproject.org/show_bug.cgi?id=14962
+    @skipIfMachine("qemuarm64", "fails on qemuarm64 (uses SERIAL_CONSOLES_CHECK)")
     def test_read_only_image(self):
         distro_features = get_bb_var('DISTRO_FEATURES')
         if not ('x11' in distro_features and 'opengl' in distro_features):
Signature · 1 line
2.34.1
#3 lore raw

PATCH 4/15 oeqa/selftest/efibootpartition: improve test

In reply to Ross Burton

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.

---
 .../oeqa/selftest/cases/efibootpartition.py   | 41 +++++++------------
 1 file changed, 14 insertions(+), 27 deletions(-)
meta/lib/oeqa/selftest/cases/efibootpartition.py +14 -27
index 26de3a07c9e..e17da9f9a09 100644
@@ -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)
Signature · 1 line
2.34.1
#4 lore raw

PATCH 5/15 oeqa/selftest/imagefeatures: remove hardcoded MACHINE in test_image_gen_debugfs

In reply to Ross Burton

There's no need for this to be built for genericx86-64, we want to test the current MACHINE.

---
 meta/lib/oeqa/selftest/cases/imagefeatures.py | 1 -
 1 file changed, 1 deletion(-)
meta/lib/oeqa/selftest/cases/imagefeatures.py +0 -1
index d3fd52851c0..f259ebb8041 100644
@@ -271,7 +271,6 @@ SKIP_RECIPE[busybox] = "Don't build this"
         image_name = 'core-image-minimal'
         features = 'IMAGE_GEN_DEBUGFS = "1"\n'
         features += 'IMAGE_FSTYPES_DEBUGFS = "tar.bz2"\n'
-        features += 'MACHINE = "genericx86-64"\n'
         self.write_config(features)
 
         bitbake(image_name)
Signature · 1 line
2.34.1
#5 lore raw

PATCH 6/15 oeqa/selftest/imagefeatures: don't use wic images in test_hypervisor_fmts

In reply to Ross Burton

There's no need to build a wic image in this test as not all machines (such as qemuarm64 currently) have wic images out of the box.

We can simply build ext4 images to work on more machines and save some time.

---
 meta/lib/oeqa/selftest/cases/imagefeatures.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/imagefeatures.py +2 -2
index f259ebb8041..df796eaed09 100644
@@ -136,7 +136,7 @@ class ImageFeatures(OESelftestTestCase):
         img_types = [ 'vmdk', 'vdi', 'qcow2' ]
         features = ""
         for itype in img_types:
-            features += 'IMAGE_FSTYPES += "wic.%s"\n' % itype
+            features += 'IMAGE_FSTYPES += "ext4.%s"\n' % itype
         self.write_config(features)
 
         image_name = 'core-image-minimal'
@@ -145,7 +145,7 @@ class ImageFeatures(OESelftestTestCase):
         deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
         link_name = get_bb_var('IMAGE_LINK_NAME', image_name)
         for itype in img_types:
-            image_path = os.path.join(deploy_dir_image, "%s.wic.%s" %
+            image_path = os.path.join(deploy_dir_image, "%s.ext4.%s" %
                                       (link_name, itype))
 
             # check if result image file is in deploy directory
Signature · 1 line
2.34.1
#6 lore raw

PATCH 7/15 oeqa/selftest/imagefeatures: set a .wks in test_fs_types

In reply to Ross Burton

Set WKS_FILE to wictestdisk.wks, which is a very simple Wic file that simply contains the root filesystem. It may not actually boot but this test doesn't care, and it does exercise the wic image construction on all machines.

---
 meta/lib/oeqa/selftest/cases/imagefeatures.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/selftest/cases/imagefeatures.py +6 -3
index df796eaed09..af38150613b 100644
@@ -206,9 +206,12 @@ class ImageFeatures(OESelftestTestCase):
         skip_image_types = set(('container', 'elf', 'f2fs', 'multiubi', 'tar.zst', 'wic.zst', 'squashfs-lzo'))
         img_types = all_image_types - skip_image_types
 
-        config = 'IMAGE_FSTYPES += "%s"\n'\
-                 'MKUBIFS_ARGS ?= "-m 2048 -e 129024 -c 2047"\n'\
-                 'UBINIZE_ARGS ?= "-m 2048 -p 128KiB -s 512"' % ' '.join(img_types)
+        config = """
+IMAGE_FSTYPES += "%s"
+WKS_FILE = "wictestdisk.wks"
+MKUBIFS_ARGS ?= "-m 2048 -e 129024 -c 2047"
+UBINIZE_ARGS ?= "-m 2048 -p 128KiB -s 512"
+""" % ' '.join(img_types)
         self.write_config(config)
 
         bitbake(image_name)
Signature · 1 line
2.34.1
#7 lore raw

PATCH 8/15 oeqa/selftest/overlayfs: overlayfs: skip x86-specific tests

In reply to Ross Burton

For now, not all machines have a default wks file, so mark the tests which need a wks as being specific to qemux86-64.

---
 meta/lib/oeqa/selftest/cases/overlayfs.py | 6 ++++++
 1 file changed, 6 insertions(+)
meta/lib/oeqa/selftest/cases/overlayfs.py +6 -0
index 57a8c8bdb6e..dfd9f1486d0 100644
@@ -7,6 +7,7 @@
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.utils.commands import bitbake, runqemu
 from oeqa.core.decorator import OETestTag
+from oeqa.core.decorator.data import skipIfNotMachine
 
 def getline_qemu(out, line):
     for l in out.split('\n'):
@@ -333,6 +334,8 @@ EXTRA_IMAGE_FEATURES += "package-management"
         self.assertTrue("overlayfs-etc" in res.output, msg=res.output)
         self.assertTrue("package-management" in res.output, msg=res.output)
 
+    # https://bugzilla.yoctoproject.org/show_bug.cgi?id=14963
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_image_feature_is_missing(self):
         """
         Summary:   Overlayfs-etc class is not applied when image feature is not set
@@ -368,9 +371,11 @@ OVERLAYFS_ETC_DEVICE = "/dev/sda3"
             line = getline_qemu(output, "upperdir=/data/overlay-etc/upper")
             self.assertFalse(line, msg=output)
 
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_sbin_init_preinit(self):
         self.run_sbin_init(False)
 
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_sbin_init_original(self):
         self.run_sbin_init(True)
 
@@ -419,6 +424,7 @@ OVERLAYFS_ETC_DEVICE = "/dev/sda3"
             line = getline_qemu(output, testFile)
             self.assertTrue(line and line.startswith(testFile), msg=output)
 
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_lower_layer_access(self):
         """
         Summary:   Test that lower layer of /etc is available read-only when configured
Signature · 1 line
2.34.1
#8 lore raw

PATCH 9/15 oeqa/selftest/package: generalise test_gdb_hardlink_debug()

In reply to Ross Burton

When the trivial test binary, which just calls printf(), is compiled for aarch64 with -O2 -D_FORTIFY=2 (as is the default configuration), gdb resolves main() to the inlined printf() wrapper in stdio2.h instead of main.c, so the test fails.

Presumably, this is due to debugging being unreliable with -O2. Solve this problem by not caring where the main() breakpoint resolves to, just check that it was resolved at all.

---
 meta/lib/oeqa/selftest/cases/package.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/package.py +4 -2
index 2d1b48a15df..482a7c02ad4 100644
@@ -135,8 +135,10 @@ class PackageTests(OESelftestTestCase):
                     self.logger.error("No debugging symbols found. GDB result:\n%s" % output)
                     return False
 
-                # Check debugging symbols works correctly
-                elif re.match(r"Breakpoint 1.*hello\.c.*4", l):
+                # Check debugging symbols works correctly. Don't look for a
+                # source file as optimisation can put the breakpoint inside
+                # stdio.h.
+                elif "Breakpoint 1 at" in l:
                     return True
 
             self.logger.error("GDB result:\n%d: %s", status, output)
Signature · 1 line
2.34.1
#9 lore raw

PATCH 10/15 oeqa/selftest/package: improve test_preserve_ownership

In reply to Ross Burton

This test was failing very oddly in qemuarm64 runs. Rewriting the test to be clearer and less fragile fixed it.

---
 meta/lib/oeqa/selftest/cases/package.py | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
meta/lib/oeqa/selftest/cases/package.py +11 -11
index 482a7c02ad4..4f7cd10658a 100644
@@ -153,25 +153,25 @@ class PackageTests(OESelftestTestCase):
                     self.fail('GDB %s failed' % binary)
 
     def test_preserve_ownership(self):
-        import os, stat, oe.cachedpath
         features = 'IMAGE_INSTALL:append = " selftest-chown"\n'
         self.write_config(features)
         bitbake("core-image-minimal")
 
-        sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
-        def check_ownership(qemu, gid, uid, path):
+        def check_ownership(qemu, expected_gid, expected_uid, path):
             self.logger.info("Check ownership of %s", path)
-            status, output = qemu.run_serial(r'/bin/stat -c "%U %G" ' + path, timeout=60)
-            output = output.split(" ")
-            if output[0] != uid or output[1] != gid :
-                self.logger.error("Incrrect ownership %s [%s:%s]", path, output[0], output[1])
-                return False
-            return True
+            status, output = qemu.run_serial('stat -c "%U %G" ' + path)
+            self.assertEqual(status, 1, "stat failed: " + output)
+            try:
+                uid, gid = output.split()
+                self.assertEqual(uid, expected_uid)
+                self.assertEqual(gid, expected_gid)
+            except ValueError:
+                self.fail("Cannot parse output: " + output)
 
+        sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
         with runqemu('core-image-minimal') as qemu:
             for path in [ sysconfdir + "/selftest-chown/file",
                           sysconfdir + "/selftest-chown/dir",
                           sysconfdir + "/selftest-chown/symlink",
                           sysconfdir + "/selftest-chown/fifotest/fifo"]:
-                if not check_ownership(qemu, "test", "test", path):
-                    self.fail('Test ownership %s failed' % path)
+                check_ownership(qemu, "test", "test", path)
Signature · 1 line
2.34.1
#10 lore raw

PATCH 11/15 oeqa/selftest/runqemu: don't hardcode qemux86-64

In reply to Ross Burton

Don't hardcode qemux86-64. This has some complications: the IMAGE_FSTYPES needs to be constructed to reflect what the machine can do (only x86 machines can build ISO images), and several tests which need a wic file are currently limited to qemux86-64.

---
 meta/lib/oeqa/selftest/cases/runqemu.py | 26 ++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)
meta/lib/oeqa/selftest/cases/runqemu.py +17 -9
index c1d277a095a..58a4526df64 100644
@@ -9,6 +9,7 @@ import tempfile
 import time
 import oe.types
 from oeqa.core.decorator import OETestTag
+from oeqa.core.decorator.data import skipIfNotArch, skipIfNotMachine
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd
 
@@ -22,23 +23,25 @@ class RunqemuTests(OESelftestTestCase):
     def setUpLocal(self):
         super(RunqemuTests, self).setUpLocal()
         self.recipe = 'core-image-minimal'
-        self.machine =  'qemux86-64'
-        self.fstypes = "ext4 iso hddimg wic.vmdk wic.qcow2 wic.vdi"
-        self.cmd_common = "runqemu nographic"
+        self.machine =  self.td['MACHINE']
+
+        self.fstypes = "ext4"
+        if self.td["HOST_ARCH"] in ('i586', 'i686', 'x86_64'):
+            self.fstypes += " iso hddimg"
+        if self.machine == "qemux86-64":
+            self.fstypes += " wic.vmdk wic.qcow2 wic.vdi"
 
-        kvm = oe.types.qemu_use_kvm(get_bb_var('QEMU_USE_KVM'), 'x86_64')
+        self.cmd_common = "runqemu nographic"
+        kvm = oe.types.qemu_use_kvm(get_bb_var('QEMU_USE_KVM'), self.td["TARGET_ARCH"])
         if kvm:
             self.cmd_common += " kvm"
 
         self.write_config(
 """
-MACHINE = "%s"
 IMAGE_FSTYPES = "%s"
 # 10 means 1 second
 SYSLINUX_TIMEOUT = "10"
-"""
-% (self.machine, self.fstypes)
-        )
+""" % self.fstypes)
 
         if not RunqemuTests.image_is_ready:
             RunqemuTests.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
@@ -59,6 +62,7 @@ SYSLINUX_TIMEOUT = "10"
             with open(qemu.qemurunnerlog) as f:
                 self.assertIn('rootfs.ext4', f.read(), "Failed: %s" % cmd)
 
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_boot_machine_iso(self):
         """Test runqemu machine iso"""
         cmd = "%s %s iso" % (self.cmd_common, self.machine)
@@ -73,7 +77,8 @@ SYSLINUX_TIMEOUT = "10"
             with open(qemu.qemurunnerlog) as f:
                 self.assertTrue(qemu.runner.logged, "Failed: %s, %s" % (cmd, f.read()))
 
-
+    # https://bugzilla.yoctoproject.org/show_bug.cgi?id=14963
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_boot_recipe_image_vmdk(self):
         """Test runqemu recipe-image vmdk"""
         cmd = "%s %s wic.vmdk" % (self.cmd_common, self.recipe)
@@ -81,6 +86,7 @@ SYSLINUX_TIMEOUT = "10"
             with open(qemu.qemurunnerlog) as f:
                 self.assertIn('format=vmdk', f.read(), "Failed: %s" % cmd)
 
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_boot_recipe_image_vdi(self):
         """Test runqemu recipe-image vdi"""
         cmd = "%s %s wic.vdi" % (self.cmd_common, self.recipe)
@@ -96,6 +102,7 @@ SYSLINUX_TIMEOUT = "10"
                 self.assertTrue(qemu.runner.logged, "Failed: %s, %s" % (cmd, f.read()))
 
 
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_boot_deploy_hddimg(self):
         """Test runqemu deploy_dir_image hddimg"""
         cmd = "%s %s hddimg" % (self.cmd_common, self.deploy_dir_image)
@@ -110,6 +117,7 @@ SYSLINUX_TIMEOUT = "10"
             with open(qemu.qemurunnerlog) as f:
                 self.assertIn(' -netdev user', f.read(), "Failed: %s" % cmd)
 
+    @skipIfNotMachine("qemux86-64", "tests are qemux86-64 specific currently")
     def test_boot_machine_slirp_qcow2(self):
         """Test runqemu machine slirp qcow2"""
         cmd = "%s slirp wic.qcow2 %s" % (self.cmd_common, self.machine)
Signature · 1 line
2.34.1
#11 lore raw

PATCH 12/15 oeqa/selftest/runtime_test: only run the virgl tests on qemux86-64

In reply to Ross Burton

These tests should be able to work on qemuarm64, but this is untested and the runners will need configuration.

---
 meta/lib/oeqa/selftest/cases/runtime_test.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/cases/runtime_test.py +4 -1
index fe83b248f35..ae797249562 100644
@@ -10,7 +10,7 @@ from oeqa.core.decorator import OETestTag
 import os
 import tempfile
 import oe.lsb
-from oeqa.core.decorator.data import skipIfNotQemu
+from oeqa.core.decorator.data import skipIfNotQemu, skipIfNotMachine
 
 class TestExport(OESelftestTestCase):
 
@@ -202,6 +202,8 @@ class TestImage(OESelftestTestCase):
         bitbake('core-image-full-cmdline socat')
         bitbake('-c testimage core-image-full-cmdline')
 
+    # https://bugzilla.yoctoproject.org/show_bug.cgi?id=14966
+    @skipIfNotMachine("qemux86-64", "test needs qemux86-64")
     def test_testimage_virgl_gtk_sdl(self):
         """
         Summary: Check host-assisted accelerate OpenGL functionality in qemu with gtk and SDL frontends
@@ -243,6 +245,7 @@ class TestImage(OESelftestTestCase):
         bitbake('core-image-minimal')
         bitbake('-c testimage core-image-minimal')
 
+    @skipIfNotMachine("qemux86-64", "test needs qemux86-64")
     def test_testimage_virgl_headless(self):
         """
         Summary: Check host-assisted accelerate OpenGL functionality in qemu with egl-headless frontend
Signature · 1 line
2.34.1
#12 lore raw

PATCH 13/15 oeqa/selftest/wic: skip more tests on aarch64

In reply to Ross Burton

test_rawcopy_plugin_qemu and test_wic_image_type are x86-specific currently as the .wks uses x86-specific bootloaders.

This can be fixed, but that can come later.

---
 meta/lib/oeqa/selftest/cases/wic.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/wic.py +4 -2
index 0d664d7c395..8abe6918f3f 100644
@@ -817,7 +817,8 @@ class Wic2(WicTestCase):
                                       self.resultdir))
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64'])
+    # TODO this test could also work on aarch64
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_wic_image_type(self):
         """Test building wic images by bitbake"""
         config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\
@@ -1042,7 +1043,8 @@ class Wic2(WicTestCase):
             size = int(size[:-3])
             self.assertGreaterEqual(size, 204800)
 
-    @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64'])
+    # TODO this test could also work on aarch64
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_rawcopy_plugin_qemu(self):
         """Test rawcopy plugin in qemu"""
Signature · 1 line
2.34.1
#13 lore raw

PATCH 14/15 oeqa/selftest/wic: use skipIfNotArch instead of custom decorator

In reply to Ross Burton

There's now a shared decorator for architecture skipping, so use that.

---
 meta/lib/oeqa/selftest/cases/wic.py | 57 ++++++++++-------------------
 1 file changed, 19 insertions(+), 38 deletions(-)
meta/lib/oeqa/selftest/cases/wic.py +19 -38
index 8abe6918f3f..ca1abb970a3 100644
@@ -15,33 +15,14 @@ import hashlib
 
 from glob import glob
 from shutil import rmtree, copy
-from functools import wraps, lru_cache
 from tempfile import NamedTemporaryFile
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.core.decorator import OETestTag
+from oeqa.core.decorator.data import skipIfNotArch
 from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
 
 
-@lru_cache()
-def get_host_arch():
-    return get_bb_var('HOST_ARCH')
-
-
-def only_for_arch(archs):
-    """Decorator for wrapping test cases that can be run only for specific target
-    architectures. A list of compatible architectures is passed in `archs`.
-    """
-    def wrapper(func):
-        @wraps(func)
-        def wrapped_f(*args, **kwargs):
-            arch = get_host_arch()
-            if archs and arch not in archs:
-                raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch)
-            return func(*args, **kwargs)
-        return wrapped_f
-    return wrapper
-
 def extract_files(debugfs_output):
     """
     extract file names from the output of debugfs -R 'ls -p',
@@ -171,14 +152,14 @@ class Wic(WicTestCase):
         runCmd(cmd)
         self.assertEqual(1, len(glob(os.path.join (self.resultdir, "wictestdisk-*.direct"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_gpt_image(self):
         """Test creation of core-image-minimal with gpt table and UUID boot"""
         cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir
         runCmd(cmd)
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-*.direct"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_iso_image(self):
         """Test creation of hybrid iso image with legacy and EFI boot"""
         config = 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\
@@ -192,21 +173,21 @@ class Wic(WicTestCase):
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "HYBRID_ISO_IMG-*.direct"))))
         self.assertEqual(1, len(glob(os.path.join (self.resultdir, "HYBRID_ISO_IMG-*.iso"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_qemux86_directdisk(self):
         """Test creation of qemux-86-directdisk image"""
         cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir
         runCmd(cmd)
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "qemux86-directdisk-*direct"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64', 'aarch64'])
     def test_mkefidisk(self):
         """Test creation of mkefidisk image"""
         cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
         runCmd(cmd)
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "mkefidisk-*direct"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_bootloader_config(self):
         """Test creation of directdisk-bootloader-config image"""
         config = 'DEPENDS:pn-core-image-minimal += "syslinux"\n'
@@ -217,7 +198,7 @@ class Wic(WicTestCase):
         runCmd(cmd)
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-bootloader-config-*direct"))))
 
-    @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64', 'aarch64'])
     def test_systemd_bootdisk(self):
         """Test creation of systemd-bootdisk image"""
         config = 'MACHINE_FEATURES:append = " efi"\n'
@@ -248,7 +229,7 @@ class Wic(WicTestCase):
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "sdimage-bootpart-*direct"))))
 
     # TODO this doesn't have to be x86-specific
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_default_output_dir(self):
         """Test default output location"""
         for fname in glob("directdisk-*.direct"):
@@ -261,7 +242,7 @@ class Wic(WicTestCase):
         runCmd(cmd)
         self.assertEqual(1, len(glob("directdisk-*.direct")))
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_build_artifacts(self):
         """Test wic create directdisk providing all artifacts."""
         bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'],
@@ -353,7 +334,7 @@ class Wic(WicTestCase):
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct"))))
 
     # TODO this doesn't have to be x86-specific
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_rootfs_indirect_recipes(self):
         """Test usage of rootfs plugin with rootfs recipes"""
         runCmd("wic create directdisk-multi-rootfs "
@@ -364,7 +345,7 @@ class Wic(WicTestCase):
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-multi-rootfs*.direct"))))
 
     # TODO this doesn't have to be x86-specific
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_rootfs_artifacts(self):
         """Test usage of rootfs plugin with rootfs paths"""
         bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'],
@@ -818,7 +799,7 @@ class Wic2(WicTestCase):
         self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct"))))
 
     # TODO this test could also work on aarch64
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_wic_image_type(self):
         """Test building wic images by bitbake"""
         config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\
@@ -838,7 +819,7 @@ class Wic2(WicTestCase):
             self.assertTrue(os.path.isfile(os.path.realpath(path)))
 
     # TODO this should work on aarch64
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_qemu(self):
         """Test wic-image-minimal under qemu"""
@@ -859,7 +840,7 @@ class Wic2(WicTestCase):
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, 'UUID=2c71ef06-a81d-4735-9d3a-379b69c6bdba\t/media\text4\tdefaults\t0\t0')
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_qemu_efi(self):
         """Test core-image-minimal efi image under qemu"""
@@ -1044,7 +1025,7 @@ class Wic2(WicTestCase):
             self.assertGreaterEqual(size, 204800)
 
     # TODO this test could also work on aarch64
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_rawcopy_plugin_qemu(self):
         """Test rawcopy plugin in qemu"""
@@ -1111,7 +1092,7 @@ class Wic2(WicTestCase):
         result = runCmd("wic ls %s -n %s | awk -F ' ' '{print $1 \" \" $5}' | grep '^2' | wc -w" % (image_path, sysroot))
         self.assertEqual('1', result.output)
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_biosplusefi_plugin_qemu(self):
         """Test biosplusefi plugin in qemu"""
@@ -1144,7 +1125,7 @@ class Wic2(WicTestCase):
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '*')
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     def test_biosplusefi_plugin(self):
         """Test biosplusefi plugin"""
         # Wic generation below may fail depending on the order of the unittests
@@ -1171,7 +1152,7 @@ class Wic2(WicTestCase):
             self.assertEqual(1, len(out))
 
     # TODO this test could also work on aarch64
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_efi_plugin_unified_kernel_image_qemu(self):
         """Test efi plugin's Unified Kernel Image feature in qemu"""
@@ -1289,7 +1270,7 @@ class Wic2(WicTestCase):
             out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname))
             self.assertEqual(1, len(out))
 
-    @only_for_arch(['i586', 'i686', 'x86_64'])
+    @skipIfNotArch(['i586', 'i686', 'x86_64'])
     @OETestTag("runqemu")
     def test_expand_mbr_image(self):
         """Test wic write --expand command for mbr image"""
Signature · 1 line
2.34.1
#14 lore raw

PATCH 15/15 classes/testexport: move to classes-recipe

In reply to Ross Burton

This class should be in classes-recipe as, like testimage, it is specific to image recipes.

This also solves a regression where simply IMAGE_CLASSES += "testexport" doesn't work if testimage isn't already in IMAGE_CLASSES. The testexport class adds testimage to IMAGE_CLASSES, but by this point it's too late. Now that the class can only be inherited via IMAGE_CLASSES, we can simply inherit testimage directly.

---
 meta/{classes => classes-recipe}/testexport.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
 rename meta/{classes => classes-recipe}/testexport.bbclass (98%)
meta/classes-recipe/testexport.bbclass renamed from meta/classes/testexport.bbclass +3 -3
similarity index 98%
rename from meta/classes/testexport.bbclass
rename to meta/classes-recipe/testexport.bbclass
index f7c5242dc5e..0f0c56107f8 100644
@@ -7,12 +7,14 @@
 # To use it add testexport to global inherit and call your target image with -c testexport
 # You can try it out like this:
 # - First build an image. i.e. core-image-sato
-# - Add INHERIT += "testexport" in local.conf
+# - Add IMAGE_CLASSES += "testexport" in local.conf
 # - Then bitbake core-image-sato -c testexport. That will generate the directory structure
 #   to execute the runtime tests using runexported.py.
 #
 # For more information on TEST_SUITES check testimage class.
 
+inherit testimage
+
 TEST_LOG_DIR ?= "${WORKDIR}/testexport"
 TEST_EXPORT_DIR ?= "${TMPDIR}/testexport/${PN}"
 TEST_EXPORT_PACKAGED_DIR ?= "packages/packaged"
@@ -176,5 +178,3 @@ def testexport_create_tarball(d, tar_name, src_dir):
     tar.add(base_name)
     tar.close()
     os.chdir(current_dir)
-
-IMAGE_CLASSES += "testimage"
Signature · 1 line
2.34.1