[OE-core] [PATCH v3 06/11] wic: selftest: avoid COMPATIBLE_HOST issues
Maciej Borzecki
maciej.borzecki at rndity.com
Tue Nov 15 09:52:06 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 | 51 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index faac11e21643e4c32a83b649b6ae986fead498f1..2db14445956bc5adcf1e755844bbdb69edcb468f 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,15 +59,22 @@ 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')
+ 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')
# 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
@@ -71,6 +96,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 "
@@ -78,6 +104,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')) \
@@ -92,6 +119,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 "
@@ -125,6 +153,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 "
@@ -134,6 +163,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 "
@@ -143,6 +173,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 "
@@ -152,6 +183,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 "
@@ -159,6 +191,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"
@@ -170,6 +203,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')) \
@@ -188,6 +222,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 "
@@ -220,6 +255,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)
@@ -235,6 +271,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"
@@ -243,6 +280,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"
@@ -251,6 +289,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"
@@ -259,6 +298,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"
@@ -267,6 +307,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)
@@ -277,6 +318,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"
@@ -285,6 +327,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.0
More information about the Openembedded-core
mailing list