summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMaciej Borzecki <maciej.borzecki@rndity.com>2017-03-21 12:35:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-22 11:35:22 +0000
commit00ed0d4aeceec570d33f2f1049ee8c164b113eff (patch)
treecbc006d758aa2349984cddbd382e92ab58bf4009 /meta/lib
parent4453c21d68b7c90c088ed3e9a7c3667c2453a6be (diff)
downloadpoky-00ed0d4aeceec570d33f2f1049ee8c164b113eff.tar.gz
wic: selftest: avoid COMPATIBLE_HOST issues
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. (From OE-Core rev: ff46125082f08eb93cc549bbe1d79c3b8f9cba64) Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/wic.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 0fdd0e65eb..224610c9d7 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -24,15 +24,41 @@
24"""Test cases for wic.""" 24"""Test cases for wic."""
25 25
26import os 26import os
27import unittest
27 28
28from glob import glob 29from glob import glob
29from shutil import rmtree 30from shutil import rmtree
31from functools import wraps, lru_cache
30 32
31from oeqa.selftest.base import oeSelfTest 33from oeqa.selftest.base import oeSelfTest
32from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu 34from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
33from oeqa.utils.decorators import testcase 35from oeqa.utils.decorators import testcase
34 36
35 37
38@lru_cache(maxsize=32)
39def get_host_arch(recipe):
40 """A cached call to get_bb_var('HOST_ARCH', <recipe>)"""
41 return get_bb_var('HOST_ARCH', recipe)
42
43
44def only_for_arch(archs, image='core-image-minimal'):
45 """Decorator for wrapping test cases that can be run only for specific target
46 architectures. A list of compatible architectures is passed in `archs`.
47 Current architecture will be determined by parsing bitbake output for
48 `image` recipe.
49 """
50 def wrapper(func):
51 @wraps(func)
52 def wrapped_f(*args, **kwargs):
53 arch = get_host_arch(image)
54 if archs and arch not in archs:
55 raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch)
56 return func(*args, **kwargs)
57 wrapped_f.__name__ = func.__name__
58 return wrapped_f
59 return wrapper
60
61
36class Wic(oeSelfTest): 62class Wic(oeSelfTest):
37 """Wic test class.""" 63 """Wic test class."""
38 64
@@ -42,13 +68,13 @@ class Wic(oeSelfTest):
42 68
43 def setUpLocal(self): 69 def setUpLocal(self):
44 """This code is executed before each test method.""" 70 """This code is executed before each test method."""
45 self.write_config('MACHINE_FEATURES_append = " efi"\n')
46 71
47 # Do this here instead of in setUpClass as the base setUp does some 72 # Do this here instead of in setUpClass as the base setUp does some
48 # clean up which can result in the native tools built earlier in 73 # clean up which can result in the native tools built earlier in
49 # setUpClass being unavailable. 74 # setUpClass being unavailable.
50 if not Wic.image_is_ready: 75 if not Wic.image_is_ready:
51 bitbake('wic-tools') 76 bitbake('wic-tools')
77
52 bitbake('core-image-minimal') 78 bitbake('core-image-minimal')
53 Wic.image_is_ready = True 79 Wic.image_is_ready = True
54 80
@@ -141,6 +167,7 @@ class Wic(oeSelfTest):
141 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 167 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
142 168
143 @testcase(1157) 169 @testcase(1157)
170 @only_for_arch(['i586', 'i686', 'x86_64'])
144 def test_gpt_image(self): 171 def test_gpt_image(self):
145 """Test creation of core-image-minimal with gpt table and UUID boot""" 172 """Test creation of core-image-minimal with gpt table and UUID boot"""
146 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir 173 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir
@@ -148,6 +175,7 @@ class Wic(oeSelfTest):
148 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) 175 self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
149 176
150 @testcase(1346) 177 @testcase(1346)
178 @only_for_arch(['i586', 'i686', 'x86_64'])
151 def test_iso_image(self): 179 def test_iso_image(self):
152 """Test creation of hybrid iso image with legacy and EFI boot""" 180 """Test creation of hybrid iso image with legacy and EFI boot"""
153 config = 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\ 181 config = 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\
@@ -161,6 +189,7 @@ class Wic(oeSelfTest):
161 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) 189 self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso")))
162 190
163 @testcase(1348) 191 @testcase(1348)
192 @only_for_arch(['i586', 'i686', 'x86_64'])
164 def test_qemux86_directdisk(self): 193 def test_qemux86_directdisk(self):
165 """Test creation of qemux-86-directdisk image""" 194 """Test creation of qemux-86-directdisk image"""
166 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir 195 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir
@@ -168,6 +197,7 @@ class Wic(oeSelfTest):
168 self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct"))) 197 self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct")))
169 198
170 @testcase(1350) 199 @testcase(1350)
200 @only_for_arch(['i586', 'i686', 'x86_64'])
171 def test_mkefidisk(self): 201 def test_mkefidisk(self):
172 """Test creation of mkefidisk image""" 202 """Test creation of mkefidisk image"""
173 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir 203 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
@@ -175,6 +205,7 @@ class Wic(oeSelfTest):
175 self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct"))) 205 self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct")))
176 206
177 @testcase(1385) 207 @testcase(1385)
208 @only_for_arch(['i586', 'i686', 'x86_64'])
178 def test_directdisk_bootloader_config(self): 209 def test_directdisk_bootloader_config(self):
179 """Test creation of directdisk-bootloader-config image""" 210 """Test creation of directdisk-bootloader-config image"""
180 cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir 211 cmd = "wic create directdisk-bootloader-config -e core-image-minimal -o %s" % self.resultdir
@@ -182,6 +213,7 @@ class Wic(oeSelfTest):
182 self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct"))) 213 self.assertEqual(1, len(glob(self.resultdir + "directdisk-bootloader-config-*direct")))
183 214
184 @testcase(1560) 215 @testcase(1560)
216 @only_for_arch(['i586', 'i686', 'x86_64'])
185 def test_systemd_bootdisk(self): 217 def test_systemd_bootdisk(self):
186 """Test creation of systemd-bootdisk image""" 218 """Test creation of systemd-bootdisk image"""
187 config = 'MACHINE_FEATURES_append = " efi"\n' 219 config = 'MACHINE_FEATURES_append = " efi"\n'
@@ -201,6 +233,7 @@ class Wic(oeSelfTest):
201 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct"))) 233 self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
202 234
203 @testcase(1562) 235 @testcase(1562)
236 @only_for_arch(['i586', 'i686', 'x86_64'])
204 def test_default_output_dir(self): 237 def test_default_output_dir(self):
205 """Test default output location""" 238 """Test default output location"""
206 for fname in glob("directdisk-*.direct"): 239 for fname in glob("directdisk-*.direct"):
@@ -210,6 +243,7 @@ class Wic(oeSelfTest):
210 self.assertEqual(1, len(glob("directdisk-*.direct"))) 243 self.assertEqual(1, len(glob("directdisk-*.direct")))
211 244
212 @testcase(1212) 245 @testcase(1212)
246 @only_for_arch(['i586', 'i686', 'x86_64'])
213 def test_build_artifacts(self): 247 def test_build_artifacts(self):
214 """Test wic create directdisk providing all artifacts.""" 248 """Test wic create directdisk providing all artifacts."""
215 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], 249 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'],
@@ -307,6 +341,7 @@ class Wic(oeSelfTest):
307 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct"))) 341 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
308 342
309 @testcase(1268) 343 @testcase(1268)
344 @only_for_arch(['i586', 'i686', 'x86_64'])
310 def test_rootfs_indirect_recipes(self): 345 def test_rootfs_indirect_recipes(self):
311 """Test usage of rootfs plugin with rootfs recipes""" 346 """Test usage of rootfs plugin with rootfs recipes"""
312 status = runCmd("wic create directdisk-multi-rootfs " 347 status = runCmd("wic create directdisk-multi-rootfs "
@@ -318,6 +353,7 @@ class Wic(oeSelfTest):
318 self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct"))) 353 self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct")))
319 354
320 @testcase(1269) 355 @testcase(1269)
356 @only_for_arch(['i586', 'i686', 'x86_64'])
321 def test_rootfs_artifacts(self): 357 def test_rootfs_artifacts(self):
322 """Test usage of rootfs plugin with rootfs paths""" 358 """Test usage of rootfs plugin with rootfs paths"""
323 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], 359 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
531 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct"))) 567 self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
532 568
533 @testcase(1351) 569 @testcase(1351)
570 @only_for_arch(['i586', 'i686', 'x86_64'])
534 def test_wic_image_type(self): 571 def test_wic_image_type(self):
535 """Test building wic images by bitbake""" 572 """Test building wic images by bitbake"""
536 config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 573 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
551 self.assertTrue(os.path.isfile(os.path.realpath(path))) 588 self.assertTrue(os.path.isfile(os.path.realpath(path)))
552 589
553 @testcase(1422) 590 @testcase(1422)
591 @only_for_arch(['i586', 'i686', 'x86_64'])
554 def test_qemu(self): 592 def test_qemu(self):
555 """Test wic-image-minimal under qemu""" 593 """Test wic-image-minimal under qemu"""
556 config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 594 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
565 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 603 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
566 self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt') 604 self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt')
567 605
606 @only_for_arch(['i586', 'i686', 'x86_64'])
568 def test_qemu_efi(self): 607 def test_qemu_efi(self):
569 """Test core-image-minimal efi image under qemu""" 608 """Test core-image-minimal efi image under qemu"""
570 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "mkefidisk.wks"\n' 609 config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "mkefidisk.wks"\n'