All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests
@ 2017-03-16 12:44 Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-16 12:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

A series with enhancements and new test cases for wic selftest. The
enhancements allow for running wic selftest for non-x86 MACHINE, such as
qemuarm (the whole series was verified on qemux86-64 and qemuarm).

The first patch adds a machine independent kickstart file - wictestdisk.
Most of test cases build a disk image using one of the kickstart files
shipped in Poky (mostly directdisk. These are usually x86 oriented due
to use of syslinux and cannot be used when running with non-x86
compatible MACHINE. On the other hand, the image built during tests does
not need to be bootable (with exception of TCs that verify if the image
is indeed bootable).

Patch 2 introduces wictestdisk in test cases where its use is possible.

Patch 3 adds onlyForArch() convenience decorator and applies it to test
cases where x86 specific image must be used. In the end, only 13 TCs are
skipped on qemuarm.

Patch 4 removes some assumptions about kernel image type.

Patch 5 adds tests for --fixed-size partition flags

Maciej Borzecki (5):
  selftest: wictestdisk: machine agnostic WKS for use with selftest
  selftest: wic: replace directdisk with wictestdisk where possible
  wic: selftest: avoid COMPATIBLE_HOST issues
  wic: selftest: do not assume bzImage kernel image
  wic: selftest: add tests for --fixed-size partition flags

 meta-selftest/wic/wictestdisk.wks |   7 ++
 meta/lib/oeqa/selftest/wic.py     | 167 ++++++++++++++++++++++++++++++--------
 2 files changed, 140 insertions(+), 34 deletions(-)
 create mode 100644 meta-selftest/wic/wictestdisk.wks

-- 
2.9.3



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest
  2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
@ 2017-03-16 12:44 ` Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 2/5] selftest: wic: replace directdisk with wictestdisk where possible Maciej Borzecki
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-16 12:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Add a kickstart for an image that is not limited to use on x86 compatible
machines. This allows us to run more wic tests on non-x86 architectures.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta-selftest/wic/wictestdisk.wks | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 meta-selftest/wic/wictestdisk.wks

diff --git a/meta-selftest/wic/wictestdisk.wks b/meta-selftest/wic/wictestdisk.wks
new file mode 100644
index 0000000000000000000000000000000000000000..d4de24d83097dab2851dbf5f2b6884679de7c77c
--- /dev/null
+++ b/meta-selftest/wic/wictestdisk.wks
@@ -0,0 +1,7 @@
+# short-description: image for use in machine agnostic wic test cases
+
+# /boot is intentionally an empty partition
+part /boot --ondisk sda --label boot --active --align 1024 --size 16
+part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
+
+# bootloader is intentionally left out
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 2/5] selftest: wic: replace directdisk with wictestdisk where possible
  2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
@ 2017-03-16 12:44 ` Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 3/5] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-16 12:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Use wictestdisk instead of directdisk thus allowing more tests to be run on
non-x86 compatible machines.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 825312e5a55639129d88246e7335174484260fc1..0fdd0e65eb4e5d6a2dc72c38a9597c187d82575c 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -135,10 +135,10 @@ class Wic(oeSelfTest):
 
     @testcase(1211)
     def test_build_image_name(self):
-        """Test wic create directdisk --image-name=core-image-minimal"""
-        cmd = "wic create directdisk --image-name=core-image-minimal -o %s" % self.resultdir
+        """Test wic create wictestdisk --image-name=core-image-minimal"""
+        cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
         self.assertEqual(0, runCmd(cmd).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1157)
     def test_gpt_image(self):
@@ -230,31 +230,31 @@ class Wic(oeSelfTest):
     @testcase(1264)
     def test_compress_gzip(self):
         """Test compressing an image with gzip"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name core-image-minimal "
                                    "-c gzip -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.gz")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz")))
 
     @testcase(1265)
     def test_compress_bzip2(self):
         """Test compressing an image with bzip2"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-c bzip2 -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.bz2")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2")))
 
     @testcase(1266)
     def test_compress_xz(self):
         """Test compressing an image with xz"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--compress-with=xz -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.xz")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz")))
 
     @testcase(1267)
     def test_wrong_compressor(self):
         """Test how wic breaks if wrong compressor is provided"""
-        self.assertEqual(2, runCmd("wic create directdisk "
+        self.assertEqual(2, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-c wrong -o %s" % self.resultdir,
                                    ignore_status=True).status)
@@ -262,49 +262,49 @@ class Wic(oeSelfTest):
     @testcase(1558)
     def test_debug_short(self):
         """Test -D option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-D -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     def test_debug_long(self):
         """Test --debug option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--debug -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1563)
     def test_skip_build_check_short(self):
         """Test -s option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-s -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     def test_skip_build_check_long(self):
         """Test --skip-build-check option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--skip-build-check "
                                    "--outdir %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1564)
     def test_build_rootfs_short(self):
         """Test -f option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-f -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     def test_build_rootfs_long(self):
         """Test --build-rootfs option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--build-rootfs "
                                    "--outdir %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1268)
     def test_rootfs_indirect_recipes(self):
@@ -461,19 +461,19 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
     @testcase(1496)
     def test_bmap_short(self):
         """Test generation of .bmap file -m option"""
-        cmd = "wic create directdisk -e core-image-minimal -m -o %s" % self.resultdir
+        cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir
         status = runCmd(cmd).status
         self.assertEqual(0, status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
 
     def test_bmap_long(self):
         """Test generation of .bmap file --bmap option"""
-        cmd = "wic create directdisk -e core-image-minimal --bmap -o %s" % self.resultdir
+        cmd = "wic create wictestdisk -e core-image-minimal --bmap -o %s" % self.resultdir
         status = runCmd(cmd).status
         self.assertEqual(0, status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
 
     def _get_image_env_path(self, image):
         """Generate and obtain the path to <image>.env"""
@@ -514,21 +514,21 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
         image = 'core-image-minimal'
         imgenvdir = self._get_image_env_path(image)
 
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=%s -v %s -o %s"
                                    % (image, imgenvdir, self.resultdir)).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
 
     def test_image_vars_dir_long(self):
         """Test image vars directory selection --vars option"""
         image = 'core-image-minimal'
         imgenvdir = self._get_image_env_path(image)
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=%s "
                                    "--vars %s "
                                    "--outdir %s"
                                    % (image, imgenvdir, self.resultdir)).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
 
     @testcase(1351)
     def test_wic_image_type(self):
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 3/5] wic: selftest: avoid COMPATIBLE_HOST issues
  2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 2/5] selftest: wic: replace directdisk with wictestdisk where possible Maciej Borzecki
@ 2017-03-16 12:44 ` Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 4/5] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-16 12:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Wic tests will unconditionally attempt to build images that may require
dependencies that are incompatible with current target.

Resolve this by consulting HOST_ARCH first (which defaults to TARGET_ARCH)
before proceeding to build images that may be incompatible.

A convenience decorator onlyForArch() can be used to skip test cases for
specific architectures.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 0fdd0e65eb4e5d6a2dc72c38a9597c187d82575c..1cf26ce44411362873b5fa0b57da9f5a77613134 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -24,15 +24,38 @@
 """Test cases for wic."""
 
 import os
+import unittest
 
 from glob import glob
 from shutil import rmtree
+from functools import wraps, lru_cache
 
 from oeqa.selftest.base import oeSelfTest
 from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
 from oeqa.utils.decorators import testcase
 
 
+@lru_cache(maxsize=32)
+def get_host_arch(target='core-image-minimal'):
+    return get_bb_var('HOST_ARCH', target)
+
+
+class onlyForArch(object):
+
+    def __init__(self, *args):
+        self.archs = args
+
+    def __call__(self,f):
+        @wraps(f)
+        def wrapped_f(*args, **kwargs):
+            arch = get_host_arch()
+            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."""
 
@@ -42,13 +65,13 @@ class Wic(oeSelfTest):
 
     def setUpLocal(self):
         """This code is executed before each test method."""
-        self.write_config('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('wic-tools')
+
             bitbake('core-image-minimal')
             Wic.image_is_ready = True
 
@@ -141,6 +164,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.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"""
         cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir
@@ -148,6 +172,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
 
     @testcase(1346)
+    @onlyForArch('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'\
@@ -161,6 +186,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso")))
 
     @testcase(1348)
+    @onlyForArch('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
@@ -168,6 +194,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct")))
 
     @testcase(1350)
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_mkefidisk(self):
         """Test creation of mkefidisk image"""
         cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
@@ -175,6 +202,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct")))
 
     @testcase(1385)
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_directdisk_bootloader_config(self):
         """Test creation of directdisk-bootloader-config image"""
         cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir
@@ -182,6 +210,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct")))
 
     @testcase(1560)
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_systemd_bootdisk(self):
         """Test creation of systemd-bootdisk image"""
         config = 'MACHINE_FEATURES_append = " efi"\n'
@@ -201,6 +230,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
 
     @testcase(1562)
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_default_output_dir(self):
         """Test default output location"""
         for fname in glob("directdisk-*.direct"):
@@ -210,6 +240,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob("directdisk-*.direct")))
 
     @testcase(1212)
+    @onlyForArch('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'],
@@ -307,6 +338,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1268)
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_rootfs_indirect_recipes(self):
         """Test usage of rootfs plugin with rootfs recipes"""
         status = runCmd("wic create directdisk-multi-rootfs "
@@ -318,6 +350,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct")))
 
     @testcase(1269)
+    @onlyForArch('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'],
@@ -531,6 +564,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
 
     @testcase(1351)
+    @onlyForArch('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'\
@@ -551,6 +585,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             self.assertTrue(os.path.isfile(os.path.realpath(path)))
 
     @testcase(1422)
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_qemu(self):
         """Test wic-image-minimal under qemu"""
         config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\
@@ -565,6 +600,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt')
 
+    @onlyForArch('i586', 'i686', 'x86_64')
     def test_qemu_efi(self):
         """Test core-image-minimal efi image under qemu"""
         config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "mkefidisk.wks"\n'
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 4/5] wic: selftest: do not assume bzImage kernel image
  2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
                   ` (2 preceding siblings ...)
  2017-03-16 12:44 ` [PATCH v3 3/5] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
@ 2017-03-16 12:44 ` Maciej Borzecki
  2017-03-16 12:44 ` [PATCH v3 5/5] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
  2017-03-17 14:40 ` [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-16 12:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Instead of assuming that bzImage is available, query bitbake enviroment
for KERNEL_IMAGETYPE.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 1cf26ce44411362873b5fa0b57da9f5a77613134..b9c06e56adb70376b6f6a4893026223077b708fd 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -225,7 +225,8 @@ class Wic(oeSelfTest):
     def test_sdimage_bootpart(self):
         """Test creation of sdimage-bootpart image"""
         cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir
-        self.write_config('IMAGE_BOOT_FILES = "bzImage"\n')
+        kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal')
+        self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype)
         self.assertEqual(0, runCmd(cmd).status)
         self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
 
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 5/5] wic: selftest: add tests for --fixed-size partition flags
  2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
                   ` (3 preceding siblings ...)
  2017-03-16 12:44 ` [PATCH v3 4/5] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
@ 2017-03-16 12:44 ` Maciej Borzecki
  2017-03-17 14:40 ` [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-16 12:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

wic has a new flag for setting a fixed parition size --fixed-size. Add
tests that verify if partition is indeed sized properly and that errors
are signaled when there is not enough space to fit partition data.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 62 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index b9c06e56adb70376b6f6a4893026223077b708fd..f83d4a1b51367de42043bb0b840792f1bfddeaf6 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -29,6 +29,7 @@ import unittest
 from glob import glob
 from shutil import rmtree
 from functools import wraps, lru_cache
+from tempfile import NamedTemporaryFile
 
 from oeqa.selftest.base import oeSelfTest
 from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
@@ -61,10 +62,13 @@ class Wic(oeSelfTest):
 
     resultdir = "/var/tmp/wic.oe-selftest/"
     image_is_ready = False
+    native_sysroot = None
     wicenv_cache = {}
 
     def setUpLocal(self):
         """This code is executed before each test method."""
+        if not self.native_sysroot:
+            Wic.native_sysroot = get_bb_var('STAGING_DIR_NATIVE', 'wic-tools')
 
         # 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
@@ -615,3 +619,61 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '3')
+
+    def _make_fixed_size_wks(self, size):
+        """
+        Create a wks of an image with a single partition. Size of the partition is set
+        using --fixed-size flag. Returns a tuple: (path to wks file, wks image name)
+        """
+        with NamedTemporaryFile("w", suffix=".wks", delete=False) as tf:
+            wkspath = tf.name
+            tf.write("part " \
+                     "--source rootfs --ondisk hda --align 4 --fixed-size %d "
+                     "--fstype=ext4\n" % size)
+        wksname = os.path.splitext(os.path.basename(wkspath))[0]
+
+        return wkspath, wksname
+
+    def test_fixed_size(self):
+        """
+        Test creation of a simple image with partition size controlled through
+        --fixed-size flag
+        """
+        wkspath, wksname = self._make_fixed_size_wks(200)
+
+        self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
+                                   % (wkspath, self.resultdir)).status)
+        os.remove(wkspath)
+        wicout = glob(self.resultdir + "%s-*direct" % wksname)
+        self.assertEqual(1, len(wicout))
+
+        wicimg = wicout[0]
+
+        # verify partition size with wic
+        res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg,
+                     ignore_status=True,
+                     native_sysroot=self.native_sysroot)
+        self.assertEqual(0, res.status)
+
+        # parse parted output which looks like this:
+        # BYT;\n
+        # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
+        # 1:0.00MiB:200MiB:200MiB:ext4::;\n
+        partlns = res.output.splitlines()[2:]
+
+        self.assertEqual(1, len(partlns))
+        self.assertEqual("1:0.00MiB:200MiB:200MiB:ext4::;", partlns[0])
+
+    def test_fixed_size_error(self):
+        """
+        Test creation of a simple image with partition size controlled through
+        --fixed-size flag. The size of partition is intentionally set to 1MiB
+        in order to trigger an error in wic.
+        """
+        wkspath, wksname = self._make_fixed_size_wks(1)
+
+        self.assertEqual(1, runCmd("wic create %s -e core-image-minimal -o %s" \
+                                   % (wkspath, self.resultdir), ignore_status=True).status)
+        os.remove(wkspath)
+        wicout = glob(self.resultdir + "%s-*direct" % wksname)
+        self.assertEqual(0, len(wicout))
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests
  2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
                   ` (4 preceding siblings ...)
  2017-03-16 12:44 ` [PATCH v3 5/5] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
@ 2017-03-17 14:40 ` Ed Bartosh
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
  5 siblings, 1 reply; 14+ messages in thread
From: Ed Bartosh @ 2017-03-17 14:40 UTC (permalink / raw)
  To: Maciej Borzecki; +Cc: Maciek Borzecki, openembedded-core

Hi Maciej,

Thank you for the patchset!

Can you fix these pylint regressions?

C: 49, 0: Exactly one space required after comma
    def __call__(self,f):
                     ^ (bad-whitespace)
C: 53, 0: No space allowed before :
            if self.archs and arch not in self.archs :
                                                     ^ (bad-whitespace)
C: 40, 0: Missing function docstring (missing-docstring)
C: 44, 0: Invalid class name "onlyForArch" (invalid-name)
C: 44, 0: Missing class docstring (missing-docstring)
C: 49, 4: Invalid argument name "f" (invalid-name)
C: 51, 8: Missing function docstring (missing-docstring)
R: 44, 0: Too few public methods (0/2) (too-few-public-methods)
C:422,12: Missing function docstring (missing-docstring)
C:628,69: Invalid variable name "tf" (invalid-name)
R:623, 4: Method could be a function (no-self-use)
R: 60, 0: Too many public methods (50/20) (too-many-public-methods)


Is it possible to use functools.wraps to make onlyforarc decorator a function?
would be nice to get rid of CamelCase in its name.

Other than this the patchset looks great! Thank you!

On Thu, Mar 16, 2017 at 01:44:31PM +0100, Maciej Borzecki wrote:
> A series with enhancements and new test cases for wic selftest. The
> enhancements allow for running wic selftest for non-x86 MACHINE, such as
> qemuarm (the whole series was verified on qemux86-64 and qemuarm).
> 
> The first patch adds a machine independent kickstart file - wictestdisk.
> Most of test cases build a disk image using one of the kickstart files
> shipped in Poky (mostly directdisk. These are usually x86 oriented due
> to use of syslinux and cannot be used when running with non-x86
> compatible MACHINE. On the other hand, the image built during tests does
> not need to be bootable (with exception of TCs that verify if the image
> is indeed bootable).
> 
> Patch 2 introduces wictestdisk in test cases where its use is possible.
> 
> Patch 3 adds onlyForArch() convenience decorator and applies it to test
> cases where x86 specific image must be used. In the end, only 13 TCs are
> skipped on qemuarm.
> 
> Patch 4 removes some assumptions about kernel image type.
> 
> Patch 5 adds tests for --fixed-size partition flags
> 
> Maciej Borzecki (5):
>   selftest: wictestdisk: machine agnostic WKS for use with selftest
>   selftest: wic: replace directdisk with wictestdisk where possible
>   wic: selftest: avoid COMPATIBLE_HOST issues
>   wic: selftest: do not assume bzImage kernel image
>   wic: selftest: add tests for --fixed-size partition flags
> 
>  meta-selftest/wic/wictestdisk.wks |   7 ++
>  meta/lib/oeqa/selftest/wic.py     | 167 ++++++++++++++++++++++++++++++--------
>  2 files changed, 140 insertions(+), 34 deletions(-)
>  create mode 100644 meta-selftest/wic/wictestdisk.wks
> 
> -- 
> 2.9.3
> 

-- 
--
Regards,
Ed


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests
  2017-03-17 14:40 ` [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh
@ 2017-03-21 11:35   ` Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
                       ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-21 11:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

v4 of a series with enhancements and new test cases for wic selftest.
The enhancements allow for running wic selftest for non-x86 MACHINE,
such as qemuarm (the whole series was verified on qemux86-64 and
qemuarm).

The first patch adds a machine independent kickstart file - wictestdisk.
Most of test cases build a disk image using one of the kickstart files
shipped in Poky (mostly directdisk. These are usually x86 oriented due
to use of syslinux and cannot be used when running with non-x86
compatible MACHINE. On the other hand, the image built during tests does
not need to be bootable (with exception of TCs that verify if the image
is indeed bootable).

Patch 2 introduces wictestdisk in test cases where its use is possible.

Patch 3 adds only_for_arch() convenience decorator and applies it to test
cases where x86 specific image must be used. In the end, only 13 TCs are
skipped on qemuarm.

Changes from previous version:
- renamed onlyForArch() to only_for_arch(), changed input arguments to
  take image name and list of compatible architectures
- pylint fixes

Patch 4 removes some assumptions about kernel image type.

Patch 5 adds tests for --fixed-size partition flags.

Changes from previous version:
- pylint fixes

Maciej Borzecki (5):
  selftest: wictestdisk: machine agnostic WKS for use with selftest
  selftest: wic: replace directdisk with wictestdisk where possible
  wic: selftest: avoid COMPATIBLE_HOST issues
  wic: selftest: do not assume bzImage kernel image
  wic: selftest: add tests for --fixed-size partition flags

 meta-selftest/wic/wictestdisk.wks |   7 ++
 meta/lib/oeqa/selftest/wic.py     | 171 ++++++++++++++++++++++++++++++--------
 2 files changed, 144 insertions(+), 34 deletions(-)
 create mode 100644 meta-selftest/wic/wictestdisk.wks

-- 
2.9.3



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
@ 2017-03-21 11:35     ` Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 2/5] selftest: wic: replace directdisk with wictestdisk where possible Maciej Borzecki
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-21 11:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Add a kickstart for an image that is not limited to use on x86 compatible
machines. This allows us to run more wic tests on non-x86 architectures.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta-selftest/wic/wictestdisk.wks | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 meta-selftest/wic/wictestdisk.wks

diff --git a/meta-selftest/wic/wictestdisk.wks b/meta-selftest/wic/wictestdisk.wks
new file mode 100644
index 0000000000000000000000000000000000000000..d4de24d83097dab2851dbf5f2b6884679de7c77c
--- /dev/null
+++ b/meta-selftest/wic/wictestdisk.wks
@@ -0,0 +1,7 @@
+# short-description: image for use in machine agnostic wic test cases
+
+# /boot is intentionally an empty partition
+part /boot --ondisk sda --label boot --active --align 1024 --size 16
+part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
+
+# bootloader is intentionally left out
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 2/5] selftest: wic: replace directdisk with wictestdisk where possible
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
@ 2017-03-21 11:35     ` Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 3/5] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-21 11:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Use wictestdisk instead of directdisk thus allowing more tests to be run on
non-x86 compatible machines.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 825312e5a55639129d88246e7335174484260fc1..0fdd0e65eb4e5d6a2dc72c38a9597c187d82575c 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -135,10 +135,10 @@ class Wic(oeSelfTest):
 
     @testcase(1211)
     def test_build_image_name(self):
-        """Test wic create directdisk --image-name=core-image-minimal"""
-        cmd = "wic create directdisk --image-name=core-image-minimal -o %s" % self.resultdir
+        """Test wic create wictestdisk --image-name=core-image-minimal"""
+        cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
         self.assertEqual(0, runCmd(cmd).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1157)
     def test_gpt_image(self):
@@ -230,31 +230,31 @@ class Wic(oeSelfTest):
     @testcase(1264)
     def test_compress_gzip(self):
         """Test compressing an image with gzip"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name core-image-minimal "
                                    "-c gzip -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.gz")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz")))
 
     @testcase(1265)
     def test_compress_bzip2(self):
         """Test compressing an image with bzip2"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-c bzip2 -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.bz2")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2")))
 
     @testcase(1266)
     def test_compress_xz(self):
         """Test compressing an image with xz"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--compress-with=xz -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct.xz")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz")))
 
     @testcase(1267)
     def test_wrong_compressor(self):
         """Test how wic breaks if wrong compressor is provided"""
-        self.assertEqual(2, runCmd("wic create directdisk "
+        self.assertEqual(2, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-c wrong -o %s" % self.resultdir,
                                    ignore_status=True).status)
@@ -262,49 +262,49 @@ class Wic(oeSelfTest):
     @testcase(1558)
     def test_debug_short(self):
         """Test -D option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-D -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     def test_debug_long(self):
         """Test --debug option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--debug -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1563)
     def test_skip_build_check_short(self):
         """Test -s option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-s -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     def test_skip_build_check_long(self):
         """Test --skip-build-check option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--skip-build-check "
                                    "--outdir %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1564)
     def test_build_rootfs_short(self):
         """Test -f option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "-f -o %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     def test_build_rootfs_long(self):
         """Test --build-rootfs option"""
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=core-image-minimal "
                                    "--build-rootfs "
                                    "--outdir %s" % self.resultdir).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1268)
     def test_rootfs_indirect_recipes(self):
@@ -461,19 +461,19 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
     @testcase(1496)
     def test_bmap_short(self):
         """Test generation of .bmap file -m option"""
-        cmd = "wic create directdisk -e core-image-minimal -m -o %s" % self.resultdir
+        cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir
         status = runCmd(cmd).status
         self.assertEqual(0, status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
 
     def test_bmap_long(self):
         """Test generation of .bmap file --bmap option"""
-        cmd = "wic create directdisk -e core-image-minimal --bmap -o %s" % self.resultdir
+        cmd = "wic create wictestdisk -e core-image-minimal --bmap -o %s" % self.resultdir
         status = runCmd(cmd).status
         self.assertEqual(0, status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct.bmap")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
 
     def _get_image_env_path(self, image):
         """Generate and obtain the path to <image>.env"""
@@ -514,21 +514,21 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
         image = 'core-image-minimal'
         imgenvdir = self._get_image_env_path(image)
 
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=%s -v %s -o %s"
                                    % (image, imgenvdir, self.resultdir)).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
 
     def test_image_vars_dir_long(self):
         """Test image vars directory selection --vars option"""
         image = 'core-image-minimal'
         imgenvdir = self._get_image_env_path(image)
-        self.assertEqual(0, runCmd("wic create directdisk "
+        self.assertEqual(0, runCmd("wic create wictestdisk "
                                    "--image-name=%s "
                                    "--vars %s "
                                    "--outdir %s"
                                    % (image, imgenvdir, self.resultdir)).status)
-        self.assertEqual(1, len(glob(self.resultdir + "directdisk-*direct")))
+        self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
 
     @testcase(1351)
     def test_wic_image_type(self):
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 3/5] wic: selftest: avoid COMPATIBLE_HOST issues
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 2/5] selftest: wic: replace directdisk with wictestdisk where possible Maciej Borzecki
@ 2017-03-21 11:35     ` Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 4/5] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-21 11:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Wic tests will unconditionally attempt to build images that may require
dependencies that are incompatible with current target.

Resolve this by consulting HOST_ARCH first (which defaults to TARGET_ARCH)
before proceeding to build images that may be incompatible.

A convenience decorator only_for_arch() can be used to skip test cases for
specific architectures.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 0fdd0e65eb4e5d6a2dc72c38a9597c187d82575c..224610c9d79467a5cb39e703854b76c55fd7e632 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -24,15 +24,41 @@
 """Test cases for wic."""
 
 import os
+import unittest
 
 from glob import glob
 from shutil import rmtree
+from functools import wraps, lru_cache
 
 from oeqa.selftest.base import oeSelfTest
 from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
 from oeqa.utils.decorators import testcase
 
 
+@lru_cache(maxsize=32)
+def get_host_arch(recipe):
+    """A cached call to get_bb_var('HOST_ARCH', <recipe>)"""
+    return get_bb_var('HOST_ARCH', recipe)
+
+
+def only_for_arch(archs, image='core-image-minimal'):
+    """Decorator for wrapping test cases that can be run only for specific target
+    architectures. A list of compatible architectures is passed in `archs`.
+    Current architecture will be determined by parsing bitbake output for
+    `image` recipe.
+    """
+    def wrapper(func):
+        @wraps(func)
+        def wrapped_f(*args, **kwargs):
+            arch = get_host_arch(image)
+            if archs and arch not in archs:
+                raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch)
+            return func(*args, **kwargs)
+        wrapped_f.__name__ = func.__name__
+        return wrapped_f
+    return wrapper
+
+
 class Wic(oeSelfTest):
     """Wic test class."""
 
@@ -42,13 +68,13 @@ class Wic(oeSelfTest):
 
     def setUpLocal(self):
         """This code is executed before each test method."""
-        self.write_config('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('wic-tools')
+
             bitbake('core-image-minimal')
             Wic.image_is_ready = True
 
@@ -141,6 +167,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1157)
+    @only_for_arch(['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
@@ -148,6 +175,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
 
     @testcase(1346)
+    @only_for_arch(['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'\
@@ -161,6 +189,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso")))
 
     @testcase(1348)
+    @only_for_arch(['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
@@ -168,6 +197,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct")))
 
     @testcase(1350)
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_mkefidisk(self):
         """Test creation of mkefidisk image"""
         cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
@@ -175,6 +205,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct")))
 
     @testcase(1385)
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_directdisk_bootloader_config(self):
         """Test creation of directdisk-bootloader-config image"""
         cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir
@@ -182,6 +213,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct")))
 
     @testcase(1560)
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_systemd_bootdisk(self):
         """Test creation of systemd-bootdisk image"""
         config = 'MACHINE_FEATURES_append = " efi"\n'
@@ -201,6 +233,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
 
     @testcase(1562)
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_default_output_dir(self):
         """Test default output location"""
         for fname in glob("directdisk-*.direct"):
@@ -210,6 +243,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob("directdisk-*.direct")))
 
     @testcase(1212)
+    @only_for_arch(['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'],
@@ -307,6 +341,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
 
     @testcase(1268)
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_rootfs_indirect_recipes(self):
         """Test usage of rootfs plugin with rootfs recipes"""
         status = runCmd("wic create directdisk-multi-rootfs "
@@ -318,6 +353,7 @@ class Wic(oeSelfTest):
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct")))
 
     @testcase(1269)
+    @only_for_arch(['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'],
@@ -531,6 +567,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
         self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
 
     @testcase(1351)
+    @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'\
@@ -551,6 +588,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             self.assertTrue(os.path.isfile(os.path.realpath(path)))
 
     @testcase(1422)
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_qemu(self):
         """Test wic-image-minimal under qemu"""
         config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\
@@ -565,6 +603,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt')
 
+    @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_qemu_efi(self):
         """Test core-image-minimal efi image under qemu"""
         config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "mkefidisk.wks"\n'
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 4/5] wic: selftest: do not assume bzImage kernel image
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
                       ` (2 preceding siblings ...)
  2017-03-21 11:35     ` [PATCH v4 3/5] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
@ 2017-03-21 11:35     ` Maciej Borzecki
  2017-03-21 11:35     ` [PATCH v4 5/5] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
  2017-03-22 12:10     ` [PATCH v4 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-21 11:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

Instead of assuming that bzImage is available, query bitbake enviroment
for KERNEL_IMAGETYPE.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 224610c9d79467a5cb39e703854b76c55fd7e632..776e44aac450c545f2329332f5390f6ff1b261ac 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -228,7 +228,8 @@ class Wic(oeSelfTest):
     def test_sdimage_bootpart(self):
         """Test creation of sdimage-bootpart image"""
         cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir
-        self.write_config('IMAGE_BOOT_FILES = "bzImage"\n')
+        kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal')
+        self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype)
         self.assertEqual(0, runCmd(cmd).status)
         self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
 
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 5/5] wic: selftest: add tests for --fixed-size partition flags
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
                       ` (3 preceding siblings ...)
  2017-03-21 11:35     ` [PATCH v4 4/5] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
@ 2017-03-21 11:35     ` Maciej Borzecki
  2017-03-22 12:10     ` [PATCH v4 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh
  5 siblings, 0 replies; 14+ messages in thread
From: Maciej Borzecki @ 2017-03-21 11:35 UTC (permalink / raw)
  To: openembedded-core; +Cc: Maciek Borzecki

wic has a new flag for setting a fixed parition size --fixed-size. Add
tests that verify if partition is indeed sized properly and that errors
are signaled when there is not enough space to fit partition data.

Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
---
 meta/lib/oeqa/selftest/wic.py | 63 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 776e44aac450c545f2329332f5390f6ff1b261ac..4aacd86085309389219d07b90bd307f1431178d5 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -29,6 +29,7 @@ import unittest
 from glob import glob
 from shutil import rmtree
 from functools import wraps, lru_cache
+from tempfile import NamedTemporaryFile
 
 from oeqa.selftest.base import oeSelfTest
 from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
@@ -64,10 +65,13 @@ class Wic(oeSelfTest):
 
     resultdir = "/var/tmp/wic.oe-selftest/"
     image_is_ready = False
+    native_sysroot = None
     wicenv_cache = {}
 
     def setUpLocal(self):
         """This code is executed before each test method."""
+        if not self.native_sysroot:
+            Wic.native_sysroot = get_bb_var('STAGING_DIR_NATIVE', 'wic-tools')
 
         # 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
@@ -618,3 +622,62 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '3')
+
+    @staticmethod
+    def _make_fixed_size_wks(size):
+        """
+        Create a wks of an image with a single partition. Size of the partition is set
+        using --fixed-size flag. Returns a tuple: (path to wks file, wks image name)
+        """
+        with NamedTemporaryFile("w", suffix=".wks", delete=False) as tempf:
+            wkspath = tempf.name
+            tempf.write("part " \
+                     "--source rootfs --ondisk hda --align 4 --fixed-size %d "
+                     "--fstype=ext4\n" % size)
+        wksname = os.path.splitext(os.path.basename(wkspath))[0]
+
+        return wkspath, wksname
+
+    def test_fixed_size(self):
+        """
+        Test creation of a simple image with partition size controlled through
+        --fixed-size flag
+        """
+        wkspath, wksname = Wic._make_fixed_size_wks(200)
+
+        self.assertEqual(0, runCmd("wic create %s -e core-image-minimal -o %s" \
+                                   % (wkspath, self.resultdir)).status)
+        os.remove(wkspath)
+        wicout = glob(self.resultdir + "%s-*direct" % wksname)
+        self.assertEqual(1, len(wicout))
+
+        wicimg = wicout[0]
+
+        # verify partition size with wic
+        res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg,
+                     ignore_status=True,
+                     native_sysroot=self.native_sysroot)
+        self.assertEqual(0, res.status)
+
+        # parse parted output which looks like this:
+        # BYT;\n
+        # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
+        # 1:0.00MiB:200MiB:200MiB:ext4::;\n
+        partlns = res.output.splitlines()[2:]
+
+        self.assertEqual(1, len(partlns))
+        self.assertEqual("1:0.00MiB:200MiB:200MiB:ext4::;", partlns[0])
+
+    def test_fixed_size_error(self):
+        """
+        Test creation of a simple image with partition size controlled through
+        --fixed-size flag. The size of partition is intentionally set to 1MiB
+        in order to trigger an error in wic.
+        """
+        wkspath, wksname = Wic._make_fixed_size_wks(1)
+
+        self.assertEqual(1, runCmd("wic create %s -e core-image-minimal -o %s" \
+                                   % (wkspath, self.resultdir), ignore_status=True).status)
+        os.remove(wkspath)
+        wicout = glob(self.resultdir + "%s-*direct" % wksname)
+        self.assertEqual(0, len(wicout))
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests
  2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
                       ` (4 preceding siblings ...)
  2017-03-21 11:35     ` [PATCH v4 5/5] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
@ 2017-03-22 12:10     ` Ed Bartosh
  5 siblings, 0 replies; 14+ messages in thread
From: Ed Bartosh @ 2017-03-22 12:10 UTC (permalink / raw)
  To: Maciej Borzecki; +Cc: Maciek Borzecki, openembedded-core

Hi Maciej,

The patchset looks great! Thank you!


On Tue, Mar 21, 2017 at 12:35:00PM +0100, Maciej Borzecki wrote:
> v4 of a series with enhancements and new test cases for wic selftest.
> The enhancements allow for running wic selftest for non-x86 MACHINE,
> such as qemuarm (the whole series was verified on qemux86-64 and
> qemuarm).
> 
> The first patch adds a machine independent kickstart file - wictestdisk.
> Most of test cases build a disk image using one of the kickstart files
> shipped in Poky (mostly directdisk. These are usually x86 oriented due
> to use of syslinux and cannot be used when running with non-x86
> compatible MACHINE. On the other hand, the image built during tests does
> not need to be bootable (with exception of TCs that verify if the image
> is indeed bootable).
> 
> Patch 2 introduces wictestdisk in test cases where its use is possible.
> 
> Patch 3 adds only_for_arch() convenience decorator and applies it to test
> cases where x86 specific image must be used. In the end, only 13 TCs are
> skipped on qemuarm.
> 
> Changes from previous version:
> - renamed onlyForArch() to only_for_arch(), changed input arguments to
>   take image name and list of compatible architectures
> - pylint fixes
> 
> Patch 4 removes some assumptions about kernel image type.
> 
> Patch 5 adds tests for --fixed-size partition flags.
> 
> Changes from previous version:
> - pylint fixes
> 
> Maciej Borzecki (5):
>   selftest: wictestdisk: machine agnostic WKS for use with selftest
>   selftest: wic: replace directdisk with wictestdisk where possible
>   wic: selftest: avoid COMPATIBLE_HOST issues
>   wic: selftest: do not assume bzImage kernel image
>   wic: selftest: add tests for --fixed-size partition flags
> 
>  meta-selftest/wic/wictestdisk.wks |   7 ++
>  meta/lib/oeqa/selftest/wic.py     | 171 ++++++++++++++++++++++++++++++--------
>  2 files changed, 144 insertions(+), 34 deletions(-)
>  create mode 100644 meta-selftest/wic/wictestdisk.wks
> 
> -- 
> 2.9.3
> 

-- 
--
Regards,
Ed


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-03-22 12:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 12:44 [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Maciej Borzecki
2017-03-16 12:44 ` [PATCH v3 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
2017-03-16 12:44 ` [PATCH v3 2/5] selftest: wic: replace directdisk with wictestdisk where possible Maciej Borzecki
2017-03-16 12:44 ` [PATCH v3 3/5] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
2017-03-16 12:44 ` [PATCH v3 4/5] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
2017-03-16 12:44 ` [PATCH v3 5/5] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
2017-03-17 14:40 ` [PATCH v3 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh
2017-03-21 11:35   ` [PATCH v4 " Maciej Borzecki
2017-03-21 11:35     ` [PATCH v4 1/5] selftest: wictestdisk: machine agnostic WKS for use with selftest Maciej Borzecki
2017-03-21 11:35     ` [PATCH v4 2/5] selftest: wic: replace directdisk with wictestdisk where possible Maciej Borzecki
2017-03-21 11:35     ` [PATCH v4 3/5] wic: selftest: avoid COMPATIBLE_HOST issues Maciej Borzecki
2017-03-21 11:35     ` [PATCH v4 4/5] wic: selftest: do not assume bzImage kernel image Maciej Borzecki
2017-03-21 11:35     ` [PATCH v4 5/5] wic: selftest: add tests for --fixed-size partition flags Maciej Borzecki
2017-03-22 12:10     ` [PATCH v4 0/5] wic: selftest: enhancements for non-x86 MACHINE support & fixed-size tests Ed Bartosh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.