diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/imagefeatures.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/imagefeatures.py | 174 |
1 files changed, 102 insertions, 72 deletions
diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures.py b/meta/lib/oeqa/selftest/cases/imagefeatures.py index 6723a8198f..dc88c222bd 100644 --- a/meta/lib/oeqa/selftest/cases/imagefeatures.py +++ b/meta/lib/oeqa/selftest/cases/imagefeatures.py | |||
@@ -1,9 +1,12 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
3 | # | 5 | # |
4 | 6 | ||
5 | from oeqa.selftest.case import OESelftestTestCase | 7 | from oeqa.selftest.case import OESelftestTestCase |
6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu | 8 | from oeqa.core.decorator import OETestTag |
9 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu | ||
7 | from oeqa.utils.sshcontrol import SSHControl | 10 | from oeqa.utils.sshcontrol import SSHControl |
8 | import glob | 11 | import glob |
9 | import os | 12 | import os |
@@ -14,6 +17,7 @@ class ImageFeatures(OESelftestTestCase): | |||
14 | test_user = 'tester' | 17 | test_user = 'tester' |
15 | root_user = 'root' | 18 | root_user = 'root' |
16 | 19 | ||
20 | @OETestTag("runqemu") | ||
17 | def test_non_root_user_can_connect_via_ssh_without_password(self): | 21 | def test_non_root_user_can_connect_via_ssh_without_password(self): |
18 | """ | 22 | """ |
19 | Summary: Check if non root user can connect via ssh without password | 23 | Summary: Check if non root user can connect via ssh without password |
@@ -39,6 +43,7 @@ class ImageFeatures(OESelftestTestCase): | |||
39 | status, output = ssh.run("true") | 43 | status, output = ssh.run("true") |
40 | self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output)) | 44 | self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output)) |
41 | 45 | ||
46 | @OETestTag("runqemu") | ||
42 | def test_all_users_can_connect_via_ssh_without_password(self): | 47 | def test_all_users_can_connect_via_ssh_without_password(self): |
43 | """ | 48 | """ |
44 | Summary: Check if all users can connect via ssh without password | 49 | Summary: Check if all users can connect via ssh without password |
@@ -68,18 +73,6 @@ class ImageFeatures(OESelftestTestCase): | |||
68 | self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output) | 73 | self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output) |
69 | 74 | ||
70 | 75 | ||
71 | def test_clutter_image_can_be_built(self): | ||
72 | """ | ||
73 | Summary: Check if clutter image can be built | ||
74 | Expected: 1. core-image-clutter can be built | ||
75 | Product: oe-core | ||
76 | Author: Ionut Chisanovici <ionutx.chisanovici@intel.com> | ||
77 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> | ||
78 | """ | ||
79 | |||
80 | # Build a core-image-clutter | ||
81 | bitbake('core-image-clutter') | ||
82 | |||
83 | def test_wayland_support_in_image(self): | 76 | def test_wayland_support_in_image(self): |
84 | """ | 77 | """ |
85 | Summary: Check Wayland support in image | 78 | Summary: Check Wayland support in image |
@@ -109,12 +102,11 @@ class ImageFeatures(OESelftestTestCase): | |||
109 | features = 'IMAGE_FSTYPES += " ext4 ext4.bmap ext4.bmap.gz"' | 102 | features = 'IMAGE_FSTYPES += " ext4 ext4.bmap ext4.bmap.gz"' |
110 | self.write_config(features) | 103 | self.write_config(features) |
111 | 104 | ||
112 | image_name = 'core-image-minimal' | 105 | image = 'core-image-minimal' |
113 | bitbake(image_name) | 106 | bitbake(image) |
107 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | ||
114 | 108 | ||
115 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | 109 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.ext4" % bb_vars['IMAGE_LINK_NAME']) |
116 | link_name = get_bb_var('IMAGE_LINK_NAME', image_name) | ||
117 | image_path = os.path.join(deploy_dir_image, "%s.ext4" % link_name) | ||
118 | bmap_path = "%s.bmap" % image_path | 110 | bmap_path = "%s.bmap" % image_path |
119 | gzip_path = "%s.gz" % bmap_path | 111 | gzip_path = "%s.gz" % bmap_path |
120 | 112 | ||
@@ -127,8 +119,8 @@ class ImageFeatures(OESelftestTestCase): | |||
127 | image_stat = os.stat(image_path) | 119 | image_stat = os.stat(image_path) |
128 | self.assertGreater(image_stat.st_size, image_stat.st_blocks * 512) | 120 | self.assertGreater(image_stat.st_size, image_stat.st_blocks * 512) |
129 | 121 | ||
130 | # check if the resulting gzip is valid | 122 | # check if the resulting gzip is valid, --force is needed in case gzip_path is a symlink |
131 | self.assertTrue(runCmd('gzip -t %s' % gzip_path)) | 123 | self.assertTrue(runCmd('gzip --test --force %s' % gzip_path)) |
132 | 124 | ||
133 | def test_hypervisor_fmts(self): | 125 | def test_hypervisor_fmts(self): |
134 | """ | 126 | """ |
@@ -143,17 +135,16 @@ class ImageFeatures(OESelftestTestCase): | |||
143 | img_types = [ 'vmdk', 'vdi', 'qcow2' ] | 135 | img_types = [ 'vmdk', 'vdi', 'qcow2' ] |
144 | features = "" | 136 | features = "" |
145 | for itype in img_types: | 137 | for itype in img_types: |
146 | features += 'IMAGE_FSTYPES += "wic.%s"\n' % itype | 138 | features += 'IMAGE_FSTYPES += "ext4.%s"\n' % itype |
147 | self.write_config(features) | 139 | self.write_config(features) |
148 | 140 | ||
149 | image_name = 'core-image-minimal' | 141 | image = 'core-image-minimal' |
150 | bitbake(image_name) | 142 | bitbake(image) |
143 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | ||
151 | 144 | ||
152 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | ||
153 | link_name = get_bb_var('IMAGE_LINK_NAME', image_name) | ||
154 | for itype in img_types: | 145 | for itype in img_types: |
155 | image_path = os.path.join(deploy_dir_image, "%s.wic.%s" % | 146 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.ext4.%s" % |
156 | (link_name, itype)) | 147 | (bb_vars['IMAGE_LINK_NAME'], itype)) |
157 | 148 | ||
158 | # check if result image file is in deploy directory | 149 | # check if result image file is in deploy directory |
159 | self.assertTrue(os.path.exists(image_path)) | 150 | self.assertTrue(os.path.exists(image_path)) |
@@ -173,24 +164,22 @@ class ImageFeatures(OESelftestTestCase): | |||
173 | """ | 164 | """ |
174 | Summary: Check for chaining many CONVERSION_CMDs together | 165 | Summary: Check for chaining many CONVERSION_CMDs together |
175 | Expected: 1. core-image-minimal can be built with | 166 | Expected: 1. core-image-minimal can be built with |
176 | ext4.bmap.gz.bz2.lzo.xz.u-boot and also create a | 167 | ext4.bmap.gz.bz2.zst.xz.u-boot and also create a |
177 | sha256sum | 168 | sha256sum |
178 | 2. The above image has a valid sha256sum | 169 | 2. The above image has a valid sha256sum |
179 | Product: oe-core | 170 | Product: oe-core |
180 | Author: Tom Rini <trini@konsulko.com> | 171 | Author: Tom Rini <trini@konsulko.com> |
181 | """ | 172 | """ |
182 | 173 | ||
183 | conv = "ext4.bmap.gz.bz2.lzo.xz.u-boot" | 174 | conv = "ext4.bmap.gz.bz2.zst.xz.u-boot" |
184 | features = 'IMAGE_FSTYPES += "%s %s.sha256sum"' % (conv, conv) | 175 | features = 'IMAGE_FSTYPES += "%s %s.sha256sum"' % (conv, conv) |
185 | self.write_config(features) | 176 | self.write_config(features) |
186 | 177 | ||
187 | image_name = 'core-image-minimal' | 178 | image = 'core-image-minimal' |
188 | bitbake(image_name) | 179 | bitbake(image) |
189 | 180 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | |
190 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | 181 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.%s" % |
191 | link_name = get_bb_var('IMAGE_LINK_NAME', image_name) | 182 | (bb_vars['IMAGE_LINK_NAME'], conv)) |
192 | image_path = os.path.join(deploy_dir_image, "%s.%s" % | ||
193 | (link_name, conv)) | ||
194 | 183 | ||
195 | # check if resulting image is in the deploy directory | 184 | # check if resulting image is in the deploy directory |
196 | self.assertTrue(os.path.exists(image_path)) | 185 | self.assertTrue(os.path.exists(image_path)) |
@@ -198,7 +187,7 @@ class ImageFeatures(OESelftestTestCase): | |||
198 | 187 | ||
199 | # check if the resulting sha256sum agrees | 188 | # check if the resulting sha256sum agrees |
200 | self.assertTrue(runCmd('cd %s;sha256sum -c %s.%s.sha256sum' % | 189 | self.assertTrue(runCmd('cd %s;sha256sum -c %s.%s.sha256sum' % |
201 | (deploy_dir_image, link_name, conv))) | 190 | (bb_vars['DEPLOY_DIR_IMAGE'], bb_vars['IMAGE_LINK_NAME'], conv))) |
202 | 191 | ||
203 | def test_image_fstypes(self): | 192 | def test_image_fstypes(self): |
204 | """ | 193 | """ |
@@ -207,26 +196,43 @@ class ImageFeatures(OESelftestTestCase): | |||
207 | Product: oe-core | 196 | Product: oe-core |
208 | Author: Ed Bartosh <ed.bartosh@linux.intel.com> | 197 | Author: Ed Bartosh <ed.bartosh@linux.intel.com> |
209 | """ | 198 | """ |
210 | image_name = 'core-image-minimal' | 199 | image = 'core-image-minimal' |
211 | 200 | ||
212 | all_image_types = set(get_bb_var("IMAGE_TYPES", image_name).split()) | 201 | all_image_types = set(get_bb_var("IMAGE_TYPES", image).split()) |
213 | blacklist = set(('container', 'elf', 'f2fs', 'multiubi', 'tar.zst', 'wic.zst')) | 202 | skip_image_types = set(('container', 'elf', 'f2fs', 'tar.zst', 'wic.zst', 'squashfs-lzo', 'vfat')) |
214 | img_types = all_image_types - blacklist | 203 | img_types = all_image_types - skip_image_types |
215 | 204 | ||
216 | config = 'IMAGE_FSTYPES += "%s"\n'\ | 205 | config = """ |
217 | 'MKUBIFS_ARGS ?= "-m 2048 -e 129024 -c 2047"\n'\ | 206 | IMAGE_FSTYPES += "%s" |
218 | 'UBINIZE_ARGS ?= "-m 2048 -p 128KiB -s 512"' % ' '.join(img_types) | 207 | WKS_FILE = "wictestdisk.wks" |
208 | MKUBIFS_ARGS ?= "-m 2048 -e 129024 -c 2047" | ||
209 | UBINIZE_ARGS ?= "-m 2048 -p 128KiB -s 512" | ||
210 | MULTIUBI_BUILD += "mtd_2_128" | ||
211 | MKUBIFS_ARGS_mtd_2_128 ?= "-m 2048 -e 129024 -c 2047" | ||
212 | UBINIZE_ARGS_mtd_2_128 ?= "-m 2048 -p 128KiB -s 512" | ||
213 | MULTIUBI_BUILD += "mtd_4_256" | ||
214 | MKUBIFS_ARGS_mtd_4_256 ?= "-m 4096 -e 253952 -c 4096" | ||
215 | UBINIZE_ARGS_mtd_4_256 ?= "-m 4096 -p 256KiB" | ||
216 | """ % ' '.join(img_types) | ||
219 | self.write_config(config) | 217 | self.write_config(config) |
220 | 218 | ||
221 | bitbake(image_name) | 219 | bitbake(image) |
220 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'MULTIUBI_BUILD'], image) | ||
222 | 221 | ||
223 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | ||
224 | link_name = get_bb_var('IMAGE_LINK_NAME', image_name) | ||
225 | for itype in img_types: | 222 | for itype in img_types: |
226 | image_path = os.path.join(deploy_dir_image, "%s.%s" % (link_name, itype)) | 223 | if itype == 'multiubi': |
227 | # check if result image is in deploy directory | 224 | # For multiubi build we need to manage MULTIUBI_BUILD entry to append |
228 | self.assertTrue(os.path.exists(image_path), | 225 | # specific name to IMAGE_LINK_NAME |
229 | "%s image %s doesn't exist" % (itype, image_path)) | 226 | for vname in bb_vars['MULTIUBI_BUILD'].split(): |
227 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s_%s.ubifs" % (bb_vars['IMAGE_LINK_NAME'], vname)) | ||
228 | # check if result image is in deploy directory | ||
229 | self.assertTrue(os.path.exists(image_path), | ||
230 | "%s image %s doesn't exist" % (itype, image_path)) | ||
231 | else: | ||
232 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.%s" % (bb_vars['IMAGE_LINK_NAME'], itype)) | ||
233 | # check if result image is in deploy directory | ||
234 | self.assertTrue(os.path.exists(image_path), | ||
235 | "%s image %s doesn't exist" % (itype, image_path)) | ||
230 | 236 | ||
231 | def test_useradd_static(self): | 237 | def test_useradd_static(self): |
232 | config = """ | 238 | config = """ |
@@ -240,11 +246,11 @@ USERADD_GID_TABLES += "files/static-group" | |||
240 | 246 | ||
241 | def test_no_busybox_base_utils(self): | 247 | def test_no_busybox_base_utils(self): |
242 | config = """ | 248 | config = """ |
243 | # Enable x11 | 249 | # Enable wayland |
244 | DISTRO_FEATURES_append += "x11" | 250 | DISTRO_FEATURES:append = " pam opengl wayland" |
245 | 251 | ||
246 | # Switch to systemd | 252 | # Switch to systemd |
247 | DISTRO_FEATURES += "systemd" | 253 | DISTRO_FEATURES:append = " systemd usrmerge" |
248 | VIRTUAL-RUNTIME_init_manager = "systemd" | 254 | VIRTUAL-RUNTIME_init_manager = "systemd" |
249 | VIRTUAL-RUNTIME_initscripts = "" | 255 | VIRTUAL-RUNTIME_initscripts = "" |
250 | VIRTUAL-RUNTIME_syslog = "" | 256 | VIRTUAL-RUNTIME_syslog = "" |
@@ -257,12 +263,12 @@ VIRTUAL-RUNTIME_base-utils = "packagegroup-core-base-utils" | |||
257 | VIRTUAL-RUNTIME_base-utils-hwclock = "util-linux-hwclock" | 263 | VIRTUAL-RUNTIME_base-utils-hwclock = "util-linux-hwclock" |
258 | VIRTUAL-RUNTIME_base-utils-syslog = "" | 264 | VIRTUAL-RUNTIME_base-utils-syslog = "" |
259 | 265 | ||
260 | # Blacklist busybox | 266 | # Skip busybox |
261 | PNBLACKLIST[busybox] = "Don't build this" | 267 | SKIP_RECIPE[busybox] = "Don't build this" |
262 | """ | 268 | """ |
263 | self.write_config(config) | 269 | self.write_config(config) |
264 | 270 | ||
265 | bitbake("--graphviz core-image-sato") | 271 | bitbake("--graphviz core-image-weston") |
266 | 272 | ||
267 | def test_image_gen_debugfs(self): | 273 | def test_image_gen_debugfs(self): |
268 | """ | 274 | """ |
@@ -275,20 +281,20 @@ PNBLACKLIST[busybox] = "Don't build this" | |||
275 | Yeoh Ee Peng <ee.peng.yeoh@intel.com> | 281 | Yeoh Ee Peng <ee.peng.yeoh@intel.com> |
276 | """ | 282 | """ |
277 | 283 | ||
278 | image_name = 'core-image-minimal' | 284 | image = 'core-image-minimal' |
285 | image_fstypes_debugfs = 'tar.bz2' | ||
279 | features = 'IMAGE_GEN_DEBUGFS = "1"\n' | 286 | features = 'IMAGE_GEN_DEBUGFS = "1"\n' |
280 | features += 'IMAGE_FSTYPES_DEBUGFS = "tar.bz2"\n' | 287 | features += 'IMAGE_FSTYPES_DEBUGFS = "%s"\n' % image_fstypes_debugfs |
281 | features += 'MACHINE = "genericx86-64"\n' | ||
282 | self.write_config(features) | 288 | self.write_config(features) |
283 | 289 | ||
284 | bitbake(image_name) | 290 | bitbake(image) |
285 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | 291 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) |
286 | dbg_tar_file = os.path.join(deploy_dir_image, "*-dbg.rootfs.tar.bz2") | 292 | |
287 | debug_files = glob.glob(dbg_tar_file) | 293 | dbg_tar_file = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s-dbg.%s" % (bb_vars['IMAGE_LINK_NAME'], image_fstypes_debugfs)) |
288 | self.assertNotEqual(len(debug_files), 0, 'debug filesystem not generated at %s' % dbg_tar_file) | 294 | self.assertTrue(os.path.exists(dbg_tar_file), 'debug filesystem not generated at %s' % dbg_tar_file) |
289 | result = runCmd('cd %s; tar xvf %s' % (deploy_dir_image, dbg_tar_file)) | 295 | result = runCmd('cd %s; tar xvf %s' % (bb_vars['DEPLOY_DIR_IMAGE'], dbg_tar_file)) |
290 | self.assertEqual(result.status, 0, msg='Failed to extract %s: %s' % (dbg_tar_file, result.output)) | 296 | self.assertEqual(result.status, 0, msg='Failed to extract %s: %s' % (dbg_tar_file, result.output)) |
291 | result = runCmd('find %s -name %s' % (deploy_dir_image, "udevadm")) | 297 | result = runCmd('find %s -name %s' % (bb_vars['DEPLOY_DIR_IMAGE'], "udevadm")) |
292 | self.assertTrue("udevadm" in result.output, msg='Failed to find udevadm: %s' % result.output) | 298 | self.assertTrue("udevadm" in result.output, msg='Failed to find udevadm: %s' % result.output) |
293 | dbg_symbols_targets = result.output.splitlines() | 299 | dbg_symbols_targets = result.output.splitlines() |
294 | self.assertTrue(dbg_symbols_targets, msg='Failed to split udevadm: %s' % dbg_symbols_targets) | 300 | self.assertTrue(dbg_symbols_targets, msg='Failed to split udevadm: %s' % dbg_symbols_targets) |
@@ -298,9 +304,33 @@ PNBLACKLIST[busybox] = "Don't build this" | |||
298 | 304 | ||
299 | def test_empty_image(self): | 305 | def test_empty_image(self): |
300 | """Test creation of image with no packages""" | 306 | """Test creation of image with no packages""" |
301 | bitbake('test-empty-image') | 307 | image = 'test-empty-image' |
302 | res_dir = get_bb_var('DEPLOY_DIR_IMAGE') | 308 | bitbake(image) |
303 | images = os.path.join(res_dir, "test-empty-image-*.manifest") | 309 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) |
304 | result = glob.glob(images) | 310 | manifest = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.manifest" % bb_vars['IMAGE_LINK_NAME']) |
305 | with open(result[1],"r") as f: | 311 | self.assertTrue(os.path.exists(manifest)) |
312 | |||
313 | with open(manifest, "r") as f: | ||
306 | self.assertEqual(len(f.read().strip()),0) | 314 | self.assertEqual(len(f.read().strip()),0) |
315 | |||
316 | def test_mandb(self): | ||
317 | """ | ||
318 | Test that an image containing manpages has working man and apropos commands. | ||
319 | """ | ||
320 | config = """ | ||
321 | DISTRO_FEATURES:append = " api-documentation" | ||
322 | CORE_IMAGE_EXTRA_INSTALL = "man-pages kmod-doc" | ||
323 | """ | ||
324 | self.write_config(config) | ||
325 | bitbake("core-image-minimal") | ||
326 | |||
327 | with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic') as qemu: | ||
328 | # This manpage is provided by man-pages | ||
329 | status, output = qemu.run_serial("apropos 8859") | ||
330 | self.assertEqual(status, 1, 'Failed to run apropos: %s' % (output)) | ||
331 | self.assertIn("iso_8859_15", output) | ||
332 | |||
333 | # This manpage is provided by kmod | ||
334 | status, output = qemu.run_serial("man --pager=cat modprobe") | ||
335 | self.assertEqual(status, 1, 'Failed to run man: %s' % (output)) | ||
336 | self.assertIn("force-modversion", output) | ||