[OE-core] [PATCH v6 3/5] wic: selftest: avoid COMPATIBLE_HOST issues
Maciej Borzecki
maciej.borzecki at rndity.com
Mon Dec 19 11:20:59 UTC 2016
wic tests will unconditionally attempt to build syslinux and add
configuration options that may not be compatible with current machine.
Resolve this by consulting HOST_ARCH (which defaults to TARGET_ARCH) and build
recipes, add configuration options or skip tests conditionally.
A convenience decorator onlyForArch() can be used to skip test cases for
specific architectures.
Signed-off-by: Maciej Borzecki <maciej.borzecki at rndity.com>
---
meta/lib/oeqa/selftest/wic.py | 53 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 48 insertions(+), 5 deletions(-)
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index e652fad24ab6dd7ab1b998b60a98a4052a2f1dd7..35cd14fb0c4a9b863a7a6324885f80da8e86d3eb 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -24,15 +24,33 @@
"""Test cases for wic."""
import os
+import unittest
from glob import glob
from shutil import rmtree
+from functools import wraps
from oeqa.selftest.base import oeSelfTest
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
from oeqa.utils.decorators import testcase
+class onlyForArch(object):
+
+ def __init__(self, *args):
+ self.archs = args
+
+ def __call__(self,f):
+ @wraps(f)
+ def wrapped_f(*args, **kwargs):
+ arch = get_bb_var('HOST_ARCH', 'core-image-minimal')
+ if self.archs and arch not in self.archs :
+ raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch)
+ return f(*args, **kwargs)
+ wrapped_f.__name__ = f.__name__
+ return wrapped_f
+
+
class Wic(oeSelfTest):
"""Wic test class."""
@@ -41,16 +59,23 @@ class Wic(oeSelfTest):
def setUpLocal(self):
"""This code is executed before each test method."""
- self.write_config('IMAGE_FSTYPES += " hddimg"\n'
- 'MACHINE_FEATURES_append = " efi"\n'
- 'WKS_FILE = "wic-image-minimal"\n')
+ arch = get_bb_var('HOST_ARCH', 'core-image-minimal')
+ is_x86 = arch in ['i586', 'i686', 'x86_64']
+ if is_x86:
+ self.write_config('IMAGE_FSTYPES += " hddimg"\n' \
+ 'MACHINE_FEATURES_append = " efi"\n'
+ 'WKS_FILE = "wic-image-minimal"\n')
# Do this here instead of in setUpClass as the base setUp does some
# clean up which can result in the native tools built earlier in
# setUpClass being unavailable.
if not Wic.image_is_ready:
- bitbake('syslinux syslinux-native parted-native gptfdisk-native '
- 'dosfstools-native mtools-native bmap-tools-native')
+ tools = 'parted-native gptfdisk-native ' \
+ 'dosfstools-native mtools-native bmap-tools-native'
+ if is_x86:
+ tools += ' syslinux syslinux-native'
+ bitbake(tools)
+
bitbake('core-image-minimal')
Wic.image_is_ready = True
@@ -72,6 +97,7 @@ class Wic(oeSelfTest):
self.assertEqual(0, runCmd('wic list --help').status)
@testcase(1211)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_build_image_name(self):
"""Test wic create directdisk --image-name core-image-minimal"""
self.assertEqual(0, runCmd("wic create directdisk "
@@ -79,6 +105,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
@testcase(1212)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_build_artifacts(self):
"""Test wic create directdisk providing all artifacts."""
bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \
@@ -93,6 +120,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
@testcase(1157)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_gpt_image(self):
"""Test creation of core-image-minimal with gpt table and UUID boot"""
self.assertEqual(0, runCmd("wic create directdisk-gpt "
@@ -126,6 +154,7 @@ class Wic(oeSelfTest):
self.assertEqual(0, runCmd('wic help kickstart').status)
@testcase(1264)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_compress_gzip(self):
"""Test compressing an image with gzip"""
self.assertEqual(0, runCmd("wic create directdisk "
@@ -135,6 +164,7 @@ class Wic(oeSelfTest):
"directdisk-*.direct.gz")))
@testcase(1265)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_compress_bzip2(self):
"""Test compressing an image with bzip2"""
self.assertEqual(0, runCmd("wic create directdisk "
@@ -144,6 +174,7 @@ class Wic(oeSelfTest):
"directdisk-*.direct.bz2")))
@testcase(1266)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_compress_xz(self):
"""Test compressing an image with xz"""
self.assertEqual(0, runCmd("wic create directdisk "
@@ -153,6 +184,7 @@ class Wic(oeSelfTest):
"directdisk-*.direct.xz")))
@testcase(1267)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_wrong_compressor(self):
"""Test how wic breaks if wrong compressor is provided"""
self.assertEqual(2, runCmd("wic create directdisk "
@@ -160,6 +192,7 @@ class Wic(oeSelfTest):
"-c wrong", ignore_status=True).status)
@testcase(1268)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_rootfs_indirect_recipes(self):
"""Test usage of rootfs plugin with rootfs recipes"""
wks = "directdisk-multi-rootfs"
@@ -171,6 +204,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "%s*.direct" % wks)))
@testcase(1269)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_rootfs_artifacts(self):
"""Test usage of rootfs plugin with rootfs paths"""
bbvars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \
@@ -189,6 +223,7 @@ class Wic(oeSelfTest):
"%(wks)s-*.direct" % bbvars)))
@testcase(1346)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_iso_image(self):
"""Test creation of hybrid iso image with legacy and EFI boot"""
self.assertEqual(0, runCmd("wic create mkhybridiso "
@@ -221,6 +256,7 @@ class Wic(oeSelfTest):
self.assertTrue(content[var])
@testcase(1351)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_wic_image_type(self):
"""Test building wic images by bitbake"""
self.assertEqual(0, bitbake('wic-image-minimal').status)
@@ -236,6 +272,7 @@ class Wic(oeSelfTest):
self.assertTrue(os.path.isfile(os.path.realpath(path)))
@testcase(1348)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_qemux86_directdisk(self):
"""Test creation of qemux-86-directdisk image"""
image = "qemux86-directdisk"
@@ -244,6 +281,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
@testcase(1349)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_mkgummidisk(self):
"""Test creation of mkgummidisk image"""
image = "mkgummidisk"
@@ -252,6 +290,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
@testcase(1350)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_mkefidisk(self):
"""Test creation of mkefidisk image"""
image = "mkefidisk"
@@ -260,6 +299,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
@testcase(1385)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_directdisk_bootloader_config(self):
"""Test creation of directdisk-bootloader-config image"""
image = "directdisk-bootloader-config"
@@ -268,6 +308,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
@testcase(1422)
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_qemu(self):
"""Test wic-image-minimal under qemu"""
self.assertEqual(0, bitbake('wic-image-minimal').status)
@@ -278,6 +319,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, status, 'Failed to run command "%s": %s' % (command, output))
self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt')
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_bmap(self):
"""Test generation of .bmap file"""
image = "directdisk"
@@ -286,6 +328,7 @@ class Wic(oeSelfTest):
self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
self.assertEqual(1, len(glob(self.resultdir + "%s-*direct.bmap" % image)))
+ @onlyForArch('i586', 'i686', 'x86_64')
def test_systemd_bootdisk(self):
"""Test creation of systemd-bootdisk image"""
image = "systemd-bootdisk"
--
2.5.5
More information about the Openembedded-core
mailing list