summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/wic.py
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2022-11-09 19:31:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-11 13:43:40 +0000
commit33b4cd0c00618fad170db13a25f96de9bb1c5863 (patch)
tree9efe020b84539aaa94afdd7c37fff5ff0721c3de /meta/lib/oeqa/selftest/cases/wic.py
parentd3ec3aa81f50b2f04b2763fff6925d793c9f1af5 (diff)
downloadpoky-33b4cd0c00618fad170db13a25f96de9bb1c5863.tar.gz
oeqa/selftest/wic: use skipIfNotArch instead of custom decorator
There's now a shared decorator for architecture skipping, so use that. (From OE-Core rev: 1ce83c6b22e5835d8fe3f733f40207526c6771d4) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/wic.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py57
1 files changed, 19 insertions, 38 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 8abe6918f3..ca1abb970a 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -15,33 +15,14 @@ import hashlib
15 15
16from glob import glob 16from glob import glob
17from shutil import rmtree, copy 17from shutil import rmtree, copy
18from functools import wraps, lru_cache
19from tempfile import NamedTemporaryFile 18from tempfile import NamedTemporaryFile
20 19
21from oeqa.selftest.case import OESelftestTestCase 20from oeqa.selftest.case import OESelftestTestCase
22from oeqa.core.decorator import OETestTag 21from oeqa.core.decorator import OETestTag
22from oeqa.core.decorator.data import skipIfNotArch
23from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu 23from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
24 24
25 25
26@lru_cache()
27def get_host_arch():
28 return get_bb_var('HOST_ARCH')
29
30
31def only_for_arch(archs):
32 """Decorator for wrapping test cases that can be run only for specific target
33 architectures. A list of compatible architectures is passed in `archs`.
34 """
35 def wrapper(func):
36 @wraps(func)
37 def wrapped_f(*args, **kwargs):
38 arch = get_host_arch()
39 if archs and arch not in archs:
40 raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch)
41 return func(*args, **kwargs)
42 return wrapped_f
43 return wrapper
44
45def extract_files(debugfs_output): 26def extract_files(debugfs_output):
46 """ 27 """
47 extract file names from the output of debugfs -R 'ls -p', 28 extract file names from the output of debugfs -R 'ls -p',
@@ -171,14 +152,14 @@ class Wic(WicTestCase):
171 runCmd(cmd) 152 runCmd(cmd)
172 self.assertEqual(1, len(glob(os.path.join (self.resultdir, "wictestdisk-*.direct")))) 153 self.assertEqual(1, len(glob(os.path.join (self.resultdir, "wictestdisk-*.direct"))))
173 154
174 @only_for_arch(['i586', 'i686', 'x86_64']) 155 @skipIfNotArch(['i586', 'i686', 'x86_64'])
175 def test_gpt_image(self): 156 def test_gpt_image(self):
176 """Test creation of core-image-minimal with gpt table and UUID boot""" 157 """Test creation of core-image-minimal with gpt table and UUID boot"""
177 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir 158 cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir
178 runCmd(cmd) 159 runCmd(cmd)
179 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-*.direct")))) 160 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-*.direct"))))
180 161
181 @only_for_arch(['i586', 'i686', 'x86_64']) 162 @skipIfNotArch(['i586', 'i686', 'x86_64'])
182 def test_iso_image(self): 163 def test_iso_image(self):
183 """Test creation of hybrid iso image with legacy and EFI boot""" 164 """Test creation of hybrid iso image with legacy and EFI boot"""
184 config = 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\ 165 config = 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\
@@ -192,21 +173,21 @@ class Wic(WicTestCase):
192 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "HYBRID_ISO_IMG-*.direct")))) 173 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "HYBRID_ISO_IMG-*.direct"))))
193 self.assertEqual(1, len(glob(os.path.join (self.resultdir, "HYBRID_ISO_IMG-*.iso")))) 174 self.assertEqual(1, len(glob(os.path.join (self.resultdir, "HYBRID_ISO_IMG-*.iso"))))
194 175
195 @only_for_arch(['i586', 'i686', 'x86_64']) 176 @skipIfNotArch(['i586', 'i686', 'x86_64'])
196 def test_qemux86_directdisk(self): 177 def test_qemux86_directdisk(self):
197 """Test creation of qemux-86-directdisk image""" 178 """Test creation of qemux-86-directdisk image"""
198 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir 179 cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir
199 runCmd(cmd) 180 runCmd(cmd)
200 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "qemux86-directdisk-*direct")))) 181 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "qemux86-directdisk-*direct"))))
201 182
202 @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64']) 183 @skipIfNotArch(['i586', 'i686', 'x86_64', 'aarch64'])
203 def test_mkefidisk(self): 184 def test_mkefidisk(self):
204 """Test creation of mkefidisk image""" 185 """Test creation of mkefidisk image"""
205 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir 186 cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
206 runCmd(cmd) 187 runCmd(cmd)
207 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "mkefidisk-*direct")))) 188 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "mkefidisk-*direct"))))
208 189
209 @only_for_arch(['i586', 'i686', 'x86_64']) 190 @skipIfNotArch(['i586', 'i686', 'x86_64'])
210 def test_bootloader_config(self): 191 def test_bootloader_config(self):
211 """Test creation of directdisk-bootloader-config image""" 192 """Test creation of directdisk-bootloader-config image"""
212 config = 'DEPENDS:pn-core-image-minimal += "syslinux"\n' 193 config = 'DEPENDS:pn-core-image-minimal += "syslinux"\n'
@@ -217,7 +198,7 @@ class Wic(WicTestCase):
217 runCmd(cmd) 198 runCmd(cmd)
218 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-bootloader-config-*direct")))) 199 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-bootloader-config-*direct"))))
219 200
220 @only_for_arch(['i586', 'i686', 'x86_64', 'aarch64']) 201 @skipIfNotArch(['i586', 'i686', 'x86_64', 'aarch64'])
221 def test_systemd_bootdisk(self): 202 def test_systemd_bootdisk(self):
222 """Test creation of systemd-bootdisk image""" 203 """Test creation of systemd-bootdisk image"""
223 config = 'MACHINE_FEATURES:append = " efi"\n' 204 config = 'MACHINE_FEATURES:append = " efi"\n'
@@ -248,7 +229,7 @@ class Wic(WicTestCase):
248 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "sdimage-bootpart-*direct")))) 229 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "sdimage-bootpart-*direct"))))
249 230
250 # TODO this doesn't have to be x86-specific 231 # TODO this doesn't have to be x86-specific
251 @only_for_arch(['i586', 'i686', 'x86_64']) 232 @skipIfNotArch(['i586', 'i686', 'x86_64'])
252 def test_default_output_dir(self): 233 def test_default_output_dir(self):
253 """Test default output location""" 234 """Test default output location"""
254 for fname in glob("directdisk-*.direct"): 235 for fname in glob("directdisk-*.direct"):
@@ -261,7 +242,7 @@ class Wic(WicTestCase):
261 runCmd(cmd) 242 runCmd(cmd)
262 self.assertEqual(1, len(glob("directdisk-*.direct"))) 243 self.assertEqual(1, len(glob("directdisk-*.direct")))
263 244
264 @only_for_arch(['i586', 'i686', 'x86_64']) 245 @skipIfNotArch(['i586', 'i686', 'x86_64'])
265 def test_build_artifacts(self): 246 def test_build_artifacts(self):
266 """Test wic create directdisk providing all artifacts.""" 247 """Test wic create directdisk providing all artifacts."""
267 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], 248 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'],
@@ -353,7 +334,7 @@ class Wic(WicTestCase):
353 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct")))) 334 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*.direct"))))
354 335
355 # TODO this doesn't have to be x86-specific 336 # TODO this doesn't have to be x86-specific
356 @only_for_arch(['i586', 'i686', 'x86_64']) 337 @skipIfNotArch(['i586', 'i686', 'x86_64'])
357 def test_rootfs_indirect_recipes(self): 338 def test_rootfs_indirect_recipes(self):
358 """Test usage of rootfs plugin with rootfs recipes""" 339 """Test usage of rootfs plugin with rootfs recipes"""
359 runCmd("wic create directdisk-multi-rootfs " 340 runCmd("wic create directdisk-multi-rootfs "
@@ -364,7 +345,7 @@ class Wic(WicTestCase):
364 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-multi-rootfs*.direct")))) 345 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "directdisk-multi-rootfs*.direct"))))
365 346
366 # TODO this doesn't have to be x86-specific 347 # TODO this doesn't have to be x86-specific
367 @only_for_arch(['i586', 'i686', 'x86_64']) 348 @skipIfNotArch(['i586', 'i686', 'x86_64'])
368 def test_rootfs_artifacts(self): 349 def test_rootfs_artifacts(self):
369 """Test usage of rootfs plugin with rootfs paths""" 350 """Test usage of rootfs plugin with rootfs paths"""
370 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'], 351 bb_vars = get_bb_vars(['STAGING_DATADIR', 'RECIPE_SYSROOT_NATIVE'],
@@ -818,7 +799,7 @@ class Wic2(WicTestCase):
818 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct")))) 799 self.assertEqual(1, len(glob(os.path.join(self.resultdir, "wictestdisk-*direct"))))
819 800
820 # TODO this test could also work on aarch64 801 # TODO this test could also work on aarch64
821 @only_for_arch(['i586', 'i686', 'x86_64']) 802 @skipIfNotArch(['i586', 'i686', 'x86_64'])
822 def test_wic_image_type(self): 803 def test_wic_image_type(self):
823 """Test building wic images by bitbake""" 804 """Test building wic images by bitbake"""
824 config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\ 805 config = 'IMAGE_FSTYPES += "wic"\nWKS_FILE = "wic-image-minimal"\n'\
@@ -838,7 +819,7 @@ class Wic2(WicTestCase):
838 self.assertTrue(os.path.isfile(os.path.realpath(path))) 819 self.assertTrue(os.path.isfile(os.path.realpath(path)))
839 820
840 # TODO this should work on aarch64 821 # TODO this should work on aarch64
841 @only_for_arch(['i586', 'i686', 'x86_64']) 822 @skipIfNotArch(['i586', 'i686', 'x86_64'])
842 @OETestTag("runqemu") 823 @OETestTag("runqemu")
843 def test_qemu(self): 824 def test_qemu(self):
844 """Test wic-image-minimal under qemu""" 825 """Test wic-image-minimal under qemu"""
@@ -859,7 +840,7 @@ class Wic2(WicTestCase):
859 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 840 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
860 self.assertEqual(output, 'UUID=2c71ef06-a81d-4735-9d3a-379b69c6bdba\t/media\text4\tdefaults\t0\t0') 841 self.assertEqual(output, 'UUID=2c71ef06-a81d-4735-9d3a-379b69c6bdba\t/media\text4\tdefaults\t0\t0')
861 842
862 @only_for_arch(['i586', 'i686', 'x86_64']) 843 @skipIfNotArch(['i586', 'i686', 'x86_64'])
863 @OETestTag("runqemu") 844 @OETestTag("runqemu")
864 def test_qemu_efi(self): 845 def test_qemu_efi(self):
865 """Test core-image-minimal efi image under qemu""" 846 """Test core-image-minimal efi image under qemu"""
@@ -1044,7 +1025,7 @@ class Wic2(WicTestCase):
1044 self.assertGreaterEqual(size, 204800) 1025 self.assertGreaterEqual(size, 204800)
1045 1026
1046 # TODO this test could also work on aarch64 1027 # TODO this test could also work on aarch64
1047 @only_for_arch(['i586', 'i686', 'x86_64']) 1028 @skipIfNotArch(['i586', 'i686', 'x86_64'])
1048 @OETestTag("runqemu") 1029 @OETestTag("runqemu")
1049 def test_rawcopy_plugin_qemu(self): 1030 def test_rawcopy_plugin_qemu(self):
1050 """Test rawcopy plugin in qemu""" 1031 """Test rawcopy plugin in qemu"""
@@ -1111,7 +1092,7 @@ class Wic2(WicTestCase):
1111 result = runCmd("wic ls %s -n %s | awk -F ' ' '{print $1 \" \" $5}' | grep '^2' | wc -w" % (image_path, sysroot)) 1092 result = runCmd("wic ls %s -n %s | awk -F ' ' '{print $1 \" \" $5}' | grep '^2' | wc -w" % (image_path, sysroot))
1112 self.assertEqual('1', result.output) 1093 self.assertEqual('1', result.output)
1113 1094
1114 @only_for_arch(['i586', 'i686', 'x86_64']) 1095 @skipIfNotArch(['i586', 'i686', 'x86_64'])
1115 @OETestTag("runqemu") 1096 @OETestTag("runqemu")
1116 def test_biosplusefi_plugin_qemu(self): 1097 def test_biosplusefi_plugin_qemu(self):
1117 """Test biosplusefi plugin in qemu""" 1098 """Test biosplusefi plugin in qemu"""
@@ -1144,7 +1125,7 @@ class Wic2(WicTestCase):
1144 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) 1125 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
1145 self.assertEqual(output, '*') 1126 self.assertEqual(output, '*')
1146 1127
1147 @only_for_arch(['i586', 'i686', 'x86_64']) 1128 @skipIfNotArch(['i586', 'i686', 'x86_64'])
1148 def test_biosplusefi_plugin(self): 1129 def test_biosplusefi_plugin(self):
1149 """Test biosplusefi plugin""" 1130 """Test biosplusefi plugin"""
1150 # Wic generation below may fail depending on the order of the unittests 1131 # Wic generation below may fail depending on the order of the unittests
@@ -1171,7 +1152,7 @@ class Wic2(WicTestCase):
1171 self.assertEqual(1, len(out)) 1152 self.assertEqual(1, len(out))
1172 1153
1173 # TODO this test could also work on aarch64 1154 # TODO this test could also work on aarch64
1174 @only_for_arch(['i586', 'i686', 'x86_64']) 1155 @skipIfNotArch(['i586', 'i686', 'x86_64'])
1175 @OETestTag("runqemu") 1156 @OETestTag("runqemu")
1176 def test_efi_plugin_unified_kernel_image_qemu(self): 1157 def test_efi_plugin_unified_kernel_image_qemu(self):
1177 """Test efi plugin's Unified Kernel Image feature in qemu""" 1158 """Test efi plugin's Unified Kernel Image feature in qemu"""
@@ -1289,7 +1270,7 @@ class Wic2(WicTestCase):
1289 out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname)) 1270 out = glob(os.path.join(self.resultdir, "%s-*direct" % wksname))
1290 self.assertEqual(1, len(out)) 1271 self.assertEqual(1, len(out))
1291 1272
1292 @only_for_arch(['i586', 'i686', 'x86_64']) 1273 @skipIfNotArch(['i586', 'i686', 'x86_64'])
1293 @OETestTag("runqemu") 1274 @OETestTag("runqemu")
1294 def test_expand_mbr_image(self): 1275 def test_expand_mbr_image(self):
1295 """Test wic write --expand command for mbr image""" 1276 """Test wic write --expand command for mbr image"""