| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # | 
| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors | 
|  | 3 | # | 
| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT | 
|  | 5 | # | 
|  | 6 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | from oeqa.selftest.case import OESelftestTestCase | 
| Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 8 | from oeqa.core.decorator import OETestTag | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 9 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | from oeqa.utils.sshcontrol import SSHControl | 
| Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 11 | import glob | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | import os | 
|  | 13 | import json | 
|  | 14 |  | 
|  | 15 | class ImageFeatures(OESelftestTestCase): | 
|  | 16 |  | 
|  | 17 | test_user = 'tester' | 
|  | 18 | root_user = 'root' | 
|  | 19 |  | 
| Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 20 | @OETestTag("runqemu") | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | def test_non_root_user_can_connect_via_ssh_without_password(self): | 
|  | 22 | """ | 
|  | 23 | Summary: Check if non root user can connect via ssh without password | 
|  | 24 | Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed. | 
|  | 25 | 2. Connection to the image via ssh using tester user without providing a password should be allowed. | 
|  | 26 | Product: oe-core | 
|  | 27 | Author: Ionut Chisanovici <ionutx.chisanovici@intel.com> | 
|  | 28 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 
|  | 29 | """ | 
|  | 30 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 31 | features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password allow-root-login"\n' | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | features += 'INHERIT += "extrausers"\n' | 
|  | 33 | features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) | 
|  | 34 | self.write_config(features) | 
|  | 35 |  | 
|  | 36 | # Build a core-image-minimal | 
|  | 37 | bitbake('core-image-minimal') | 
|  | 38 |  | 
|  | 39 | with runqemu("core-image-minimal") as qemu: | 
|  | 40 | # Attempt to ssh with each user into qemu with empty password | 
|  | 41 | for user in [self.root_user, self.test_user]: | 
|  | 42 | ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user) | 
|  | 43 | status, output = ssh.run("true") | 
|  | 44 | self.assertEqual(status, 0, 'ssh to user %s failed with %s' % (user, output)) | 
|  | 45 |  | 
| Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 46 | @OETestTag("runqemu") | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 47 | def test_all_users_can_connect_via_ssh_without_password(self): | 
|  | 48 | """ | 
|  | 49 | Summary:     Check if all users can connect via ssh without password | 
|  | 50 | Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed. | 
|  | 51 | 2. Connection to the image via ssh using tester user without providing a password should be allowed. | 
|  | 52 | Product:     oe-core | 
|  | 53 | Author:      Ionut Chisanovici <ionutx.chisanovici@intel.com> | 
|  | 54 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 
|  | 55 | """ | 
|  | 56 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password allow-root-login"\n' | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 58 | features += 'INHERIT += "extrausers"\n' | 
|  | 59 | features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) | 
|  | 60 | self.write_config(features) | 
|  | 61 |  | 
|  | 62 | # Build a core-image-minimal | 
|  | 63 | bitbake('core-image-minimal') | 
|  | 64 |  | 
|  | 65 | with runqemu("core-image-minimal") as qemu: | 
|  | 66 | # Attempt to ssh with each user into qemu with empty password | 
|  | 67 | for user in [self.root_user, self.test_user]: | 
|  | 68 | ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user) | 
|  | 69 | status, output = ssh.run("true") | 
|  | 70 | if user == 'root': | 
|  | 71 | self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been') | 
|  | 72 | else: | 
|  | 73 | self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output) | 
|  | 74 |  | 
|  | 75 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 76 | def test_wayland_support_in_image(self): | 
|  | 77 | """ | 
|  | 78 | Summary:     Check Wayland support in image | 
|  | 79 | Expected:    1. Wayland image can be build | 
|  | 80 | 2. Wayland feature can be installed | 
|  | 81 | Product:     oe-core | 
|  | 82 | Author:      Ionut Chisanovici <ionutx.chisanovici@intel.com> | 
|  | 83 | AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 
|  | 84 | """ | 
|  | 85 |  | 
|  | 86 | distro_features = get_bb_var('DISTRO_FEATURES') | 
|  | 87 | if not ('opengl' in distro_features and 'wayland' in distro_features): | 
|  | 88 | self.skipTest('neither opengl nor wayland present on DISTRO_FEATURES so core-image-weston cannot be built') | 
|  | 89 |  | 
|  | 90 | # Build a core-image-weston | 
|  | 91 | bitbake('core-image-weston') | 
|  | 92 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 93 | def test_bmap(self): | 
|  | 94 | """ | 
|  | 95 | Summary:     Check bmap support | 
|  | 96 | Expected:    1. core-image-minimal can be build with bmap support | 
|  | 97 | 2. core-image-minimal is sparse | 
|  | 98 | Product:     oe-core | 
|  | 99 | Author:      Ed Bartosh <ed.bartosh@linux.intel.com> | 
|  | 100 | """ | 
|  | 101 |  | 
|  | 102 | features = 'IMAGE_FSTYPES += " ext4 ext4.bmap ext4.bmap.gz"' | 
|  | 103 | self.write_config(features) | 
|  | 104 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 105 | image = 'core-image-minimal' | 
|  | 106 | bitbake(image) | 
|  | 107 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 108 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 109 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.ext4" % bb_vars['IMAGE_LINK_NAME']) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 110 | bmap_path = "%s.bmap" % image_path | 
|  | 111 | gzip_path = "%s.gz" % bmap_path | 
|  | 112 |  | 
|  | 113 | # check if result image, bmap and bmap.gz files are in deploy directory | 
|  | 114 | self.assertTrue(os.path.exists(image_path)) | 
|  | 115 | self.assertTrue(os.path.exists(bmap_path)) | 
|  | 116 | self.assertTrue(os.path.exists(gzip_path)) | 
|  | 117 |  | 
|  | 118 | # check if result image is sparse | 
|  | 119 | image_stat = os.stat(image_path) | 
| Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 120 | self.assertGreater(image_stat.st_size, image_stat.st_blocks * 512) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 121 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 122 | # check if the resulting gzip is valid, --force is needed in case gzip_path is a symlink | 
|  | 123 | self.assertTrue(runCmd('gzip --test --force %s' % gzip_path)) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 124 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 125 | def test_hypervisor_fmts(self): | 
|  | 126 | """ | 
|  | 127 | Summary:     Check various hypervisor formats | 
|  | 128 | Expected:    1. core-image-minimal can be built with vmdk, vdi and | 
|  | 129 | qcow2 support. | 
|  | 130 | 2. qemu-img says each image has the expected format | 
|  | 131 | Product:     oe-core | 
|  | 132 | Author:      Tom Rini <trini@konsulko.com> | 
|  | 133 | """ | 
|  | 134 |  | 
|  | 135 | img_types = [ 'vmdk', 'vdi', 'qcow2' ] | 
|  | 136 | features = "" | 
|  | 137 | for itype in img_types: | 
| Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 138 | features += 'IMAGE_FSTYPES += "ext4.%s"\n' % itype | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 139 | self.write_config(features) | 
|  | 140 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 141 | image = 'core-image-minimal' | 
|  | 142 | bitbake(image) | 
|  | 143 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 144 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 145 | for itype in img_types: | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 146 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.ext4.%s" % | 
|  | 147 | (bb_vars['IMAGE_LINK_NAME'], itype)) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 148 |  | 
|  | 149 | # check if result image file is in deploy directory | 
|  | 150 | self.assertTrue(os.path.exists(image_path)) | 
|  | 151 |  | 
|  | 152 | # check if result image is vmdk | 
|  | 153 | sysroot = get_bb_var('STAGING_DIR_NATIVE', 'core-image-minimal') | 
|  | 154 | result = runCmd('qemu-img info --output json %s' % image_path, | 
|  | 155 | native_sysroot=sysroot) | 
| Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 156 | try: | 
|  | 157 | data = json.loads(result.output) | 
|  | 158 | self.assertEqual(data.get('format'), itype, | 
|  | 159 | msg="Unexpected format in '%s'" % (result.output)) | 
|  | 160 | except json.decoder.JSONDecodeError: | 
|  | 161 | self.fail("Could not parse '%ss'" % result.output) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 162 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 163 | def test_long_chain_conversion(self): | 
|  | 164 | """ | 
|  | 165 | Summary:     Check for chaining many CONVERSION_CMDs together | 
|  | 166 | Expected:    1. core-image-minimal can be built with | 
| Andrew Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 167 | ext4.bmap.gz.bz2.zst.xz.u-boot and also create a | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 168 | sha256sum | 
|  | 169 | 2. The above image has a valid sha256sum | 
|  | 170 | Product:     oe-core | 
|  | 171 | Author:      Tom Rini <trini@konsulko.com> | 
|  | 172 | """ | 
|  | 173 |  | 
| Andrew Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 174 | conv = "ext4.bmap.gz.bz2.zst.xz.u-boot" | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 175 | features = 'IMAGE_FSTYPES += "%s %s.sha256sum"' % (conv, conv) | 
|  | 176 | self.write_config(features) | 
|  | 177 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 178 | image = 'core-image-minimal' | 
|  | 179 | bitbake(image) | 
|  | 180 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | 
|  | 181 | image_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.%s" % | 
|  | 182 | (bb_vars['IMAGE_LINK_NAME'], conv)) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 183 |  | 
|  | 184 | # check if resulting image is in the deploy directory | 
|  | 185 | self.assertTrue(os.path.exists(image_path)) | 
|  | 186 | self.assertTrue(os.path.exists(image_path + ".sha256sum")) | 
|  | 187 |  | 
|  | 188 | # check if the resulting sha256sum agrees | 
|  | 189 | self.assertTrue(runCmd('cd %s;sha256sum -c %s.%s.sha256sum' % | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 190 | (bb_vars['DEPLOY_DIR_IMAGE'], bb_vars['IMAGE_LINK_NAME'], conv))) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 191 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 192 | def test_image_fstypes(self): | 
|  | 193 | """ | 
|  | 194 | Summary:     Check if image of supported image fstypes can be built | 
|  | 195 | Expected:    core-image-minimal can be built for various image types | 
|  | 196 | Product:     oe-core | 
|  | 197 | Author:      Ed Bartosh <ed.bartosh@linux.intel.com> | 
|  | 198 | """ | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 199 | image = 'core-image-minimal' | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 200 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 201 | all_image_types = set(get_bb_var("IMAGE_TYPES", image).split()) | 
| Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 202 | skip_image_types = set(('container', 'elf', 'f2fs', 'tar.zst', 'wic.zst', 'squashfs-lzo', 'vfat')) | 
| Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 203 | img_types = all_image_types - skip_image_types | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 204 |  | 
| Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 205 | config = """ | 
|  | 206 | IMAGE_FSTYPES += "%s" | 
|  | 207 | WKS_FILE = "wictestdisk.wks" | 
|  | 208 | MKUBIFS_ARGS ?= "-m 2048 -e 129024 -c 2047" | 
|  | 209 | UBINIZE_ARGS ?= "-m 2048 -p 128KiB -s 512" | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 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" | 
| Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame] | 216 | """ % ' '.join(img_types) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 217 | self.write_config(config) | 
|  | 218 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 219 | bitbake(image) | 
|  | 220 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'MULTIUBI_BUILD'], image) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 221 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 222 | for itype in img_types: | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 223 | if itype == 'multiubi': | 
|  | 224 | # For multiubi build we need to manage MULTIUBI_BUILD entry to append | 
|  | 225 | # specific name to IMAGE_LINK_NAME | 
|  | 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: | 
| Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame] | 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)) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 236 |  | 
|  | 237 | def test_useradd_static(self): | 
|  | 238 | config = """ | 
|  | 239 | USERADDEXTENSION = "useradd-staticids" | 
|  | 240 | USERADD_ERROR_DYNAMIC = "skip" | 
|  | 241 | USERADD_UID_TABLES += "files/static-passwd" | 
|  | 242 | USERADD_GID_TABLES += "files/static-group" | 
|  | 243 | """ | 
|  | 244 | self.write_config(config) | 
|  | 245 | bitbake("core-image-base") | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 246 |  | 
|  | 247 | def test_no_busybox_base_utils(self): | 
|  | 248 | config = """ | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 249 | # Enable wayland | 
| Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 250 | DISTRO_FEATURES:append = " pam opengl wayland" | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 251 |  | 
|  | 252 | # Switch to systemd | 
| Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 253 | DISTRO_FEATURES:append = " systemd usrmerge" | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 254 | VIRTUAL-RUNTIME_init_manager = "systemd" | 
|  | 255 | VIRTUAL-RUNTIME_initscripts = "" | 
|  | 256 | VIRTUAL-RUNTIME_syslog = "" | 
|  | 257 | VIRTUAL-RUNTIME_login_manager = "shadow-base" | 
|  | 258 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" | 
|  | 259 |  | 
|  | 260 | # Replace busybox | 
|  | 261 | PREFERRED_PROVIDER_virtual/base-utils = "packagegroup-core-base-utils" | 
|  | 262 | VIRTUAL-RUNTIME_base-utils = "packagegroup-core-base-utils" | 
|  | 263 | VIRTUAL-RUNTIME_base-utils-hwclock = "util-linux-hwclock" | 
|  | 264 | VIRTUAL-RUNTIME_base-utils-syslog = "" | 
|  | 265 |  | 
| Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 266 | # Skip busybox | 
|  | 267 | SKIP_RECIPE[busybox] = "Don't build this" | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 268 | """ | 
|  | 269 | self.write_config(config) | 
|  | 270 |  | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 271 | bitbake("--graphviz core-image-weston") | 
| Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 272 |  | 
|  | 273 | def test_image_gen_debugfs(self): | 
|  | 274 | """ | 
|  | 275 | Summary:     Check debugfs generation | 
|  | 276 | Expected:    1. core-image-minimal can be build with IMAGE_GEN_DEBUGFS variable set | 
|  | 277 | 2. debug filesystem is created when variable set | 
|  | 278 | 3. debug symbols available | 
|  | 279 | Product:     oe-core | 
|  | 280 | Author:      Humberto Ibarra <humberto.ibarra.lopez@intel.com> | 
|  | 281 | Yeoh Ee Peng <ee.peng.yeoh@intel.com> | 
|  | 282 | """ | 
| Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 283 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 284 | image = 'core-image-minimal' | 
|  | 285 | image_fstypes_debugfs = 'tar.bz2' | 
| Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 286 | features = 'IMAGE_GEN_DEBUGFS = "1"\n' | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 287 | features += 'IMAGE_FSTYPES_DEBUGFS = "%s"\n' % image_fstypes_debugfs | 
| Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 288 | self.write_config(features) | 
|  | 289 |  | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 290 | bitbake(image) | 
|  | 291 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | 
|  | 292 |  | 
|  | 293 | dbg_tar_file = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s-dbg.%s" % (bb_vars['IMAGE_LINK_NAME'], image_fstypes_debugfs)) | 
|  | 294 | self.assertTrue(os.path.exists(dbg_tar_file), 'debug filesystem not generated at %s' % dbg_tar_file) | 
|  | 295 | result = runCmd('cd %s; tar xvf %s' % (bb_vars['DEPLOY_DIR_IMAGE'], dbg_tar_file)) | 
| Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 296 | self.assertEqual(result.status, 0, msg='Failed to extract %s: %s' % (dbg_tar_file, result.output)) | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 297 | result = runCmd('find %s -name %s' % (bb_vars['DEPLOY_DIR_IMAGE'], "udevadm")) | 
| Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 298 | self.assertTrue("udevadm" in result.output, msg='Failed to find udevadm: %s' % result.output) | 
|  | 299 | dbg_symbols_targets = result.output.splitlines() | 
|  | 300 | self.assertTrue(dbg_symbols_targets, msg='Failed to split udevadm: %s' % dbg_symbols_targets) | 
|  | 301 | for t in dbg_symbols_targets: | 
|  | 302 | result = runCmd('objdump --syms %s | grep debug' % t) | 
|  | 303 | self.assertTrue("debug" in result.output, msg='Failed to find debug symbol: %s' % result.output) | 
| Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 304 |  | 
|  | 305 | def test_empty_image(self): | 
|  | 306 | """Test creation of image with no packages""" | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 307 | image = 'test-empty-image' | 
|  | 308 | bitbake(image) | 
|  | 309 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image) | 
|  | 310 | manifest = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "%s.manifest" % bb_vars['IMAGE_LINK_NAME']) | 
|  | 311 | self.assertTrue(os.path.exists(manifest)) | 
|  | 312 |  | 
|  | 313 | with open(manifest, "r") as f: | 
| Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 314 | self.assertEqual(len(f.read().strip()),0) | 
| Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 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) |