Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | from oeqa.selftest.case import OESelftestTestCase |
| 6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 7 | from oeqa.core.decorator import OETestTag |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | import os |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9 | import tempfile |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 10 | import oe.lsb |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 11 | from oeqa.core.decorator.data import skipIfNotQemu |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | |
| 13 | class TestExport(OESelftestTestCase): |
| 14 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 15 | @OETestTag("runqemu") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | def test_testexport_basic(self): |
| 17 | """ |
| 18 | Summary: Check basic testexport functionality with only ping test enabled. |
| 19 | Expected: 1. testexport directory must be created. |
| 20 | 2. runexported.py must run without any error/exception. |
| 21 | 3. ping test must succeed. |
| 22 | Product: oe-core |
| 23 | Author: Mariano Lopez <mariano.lopez@intel.com> |
| 24 | """ |
| 25 | |
| 26 | features = 'INHERIT += "testexport"\n' |
| 27 | # These aren't the actual IP addresses but testexport class needs something defined |
| 28 | features += 'TEST_SERVER_IP = "192.168.7.1"\n' |
| 29 | features += 'TEST_TARGET_IP = "192.168.7.1"\n' |
| 30 | features += 'TEST_SUITES = "ping"\n' |
| 31 | self.write_config(features) |
| 32 | |
| 33 | # Build tesexport for core-image-minimal |
| 34 | bitbake('core-image-minimal') |
| 35 | bitbake('-c testexport core-image-minimal') |
| 36 | |
| 37 | testexport_dir = get_bb_var('TEST_EXPORT_DIR', 'core-image-minimal') |
| 38 | |
| 39 | # Verify if TEST_EXPORT_DIR was created |
| 40 | isdir = os.path.isdir(testexport_dir) |
| 41 | self.assertEqual(True, isdir, 'Failed to create testexport dir: %s' % testexport_dir) |
| 42 | |
| 43 | with runqemu('core-image-minimal') as qemu: |
| 44 | # Attempt to run runexported.py to perform ping test |
| 45 | test_path = os.path.join(testexport_dir, "oe-test") |
| 46 | data_file = os.path.join(testexport_dir, 'data', 'testdata.json') |
| 47 | manifest = os.path.join(testexport_dir, 'data', 'manifest') |
| 48 | cmd = ("%s runtime --test-data-file %s --packages-manifest %s " |
| 49 | "--target-ip %s --server-ip %s --quiet" |
| 50 | % (test_path, data_file, manifest, qemu.ip, qemu.server_ip)) |
| 51 | result = runCmd(cmd) |
| 52 | # Verify ping test was succesful |
| 53 | self.assertEqual(0, result.status, 'oe-test runtime returned a non 0 status') |
| 54 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 55 | def test_testexport_sdk(self): |
| 56 | """ |
| 57 | Summary: Check sdk functionality for testexport. |
| 58 | Expected: 1. testexport directory must be created. |
| 59 | 2. SDK tarball must exists. |
| 60 | 3. Uncompressing of tarball must succeed. |
| 61 | 4. Check if the SDK directory is added to PATH. |
| 62 | 5. Run tar from the SDK directory. |
| 63 | Product: oe-core |
| 64 | Author: Mariano Lopez <mariano.lopez@intel.com> |
| 65 | """ |
| 66 | |
| 67 | features = 'INHERIT += "testexport"\n' |
| 68 | # These aren't the actual IP addresses but testexport class needs something defined |
| 69 | features += 'TEST_SERVER_IP = "192.168.7.1"\n' |
| 70 | features += 'TEST_TARGET_IP = "192.168.7.1"\n' |
| 71 | features += 'TEST_SUITES = "ping"\n' |
| 72 | features += 'TEST_EXPORT_SDK_ENABLED = "1"\n' |
| 73 | features += 'TEST_EXPORT_SDK_PACKAGES = "nativesdk-tar"\n' |
| 74 | self.write_config(features) |
| 75 | |
| 76 | # Build tesexport for core-image-minimal |
| 77 | bitbake('core-image-minimal') |
| 78 | bitbake('-c testexport core-image-minimal') |
| 79 | |
| 80 | needed_vars = ['TEST_EXPORT_DIR', 'TEST_EXPORT_SDK_DIR', 'TEST_EXPORT_SDK_NAME'] |
| 81 | bb_vars = get_bb_vars(needed_vars, 'core-image-minimal') |
| 82 | testexport_dir = bb_vars['TEST_EXPORT_DIR'] |
| 83 | sdk_dir = bb_vars['TEST_EXPORT_SDK_DIR'] |
| 84 | sdk_name = bb_vars['TEST_EXPORT_SDK_NAME'] |
| 85 | |
| 86 | # Check for SDK |
| 87 | tarball_name = "%s.sh" % sdk_name |
| 88 | tarball_path = os.path.join(testexport_dir, sdk_dir, tarball_name) |
| 89 | msg = "Couldn't find SDK tarball: %s" % tarball_path |
| 90 | self.assertEqual(os.path.isfile(tarball_path), True, msg) |
| 91 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 92 | with tempfile.TemporaryDirectory() as tmpdirname: |
| 93 | # Extract SDK and run tar from SDK |
| 94 | result = runCmd("%s -y -d %s" % (tarball_path, tmpdirname)) |
| 95 | self.assertEqual(0, result.status, "Couldn't extract SDK") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 96 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 97 | env_script = result.output.split()[-1] |
| 98 | result = runCmd(". %s; which tar" % env_script, shell=True) |
| 99 | self.assertEqual(0, result.status, "Couldn't setup SDK environment") |
| 100 | is_sdk_tar = True if tmpdirname in result.output else False |
| 101 | self.assertTrue(is_sdk_tar, "Couldn't setup SDK environment") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 102 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 103 | tar_sdk = result.output |
| 104 | result = runCmd("%s --version" % tar_sdk) |
| 105 | self.assertEqual(0, result.status, "Couldn't run tar from SDK") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 106 | |
| 107 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 108 | @OETestTag("runqemu") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 109 | class TestImage(OESelftestTestCase): |
| 110 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 111 | def test_testimage_install(self): |
| 112 | """ |
| 113 | Summary: Check install packages functionality for testimage/testexport. |
| 114 | Expected: 1. Import tests from a directory other than meta. |
| 115 | 2. Check install/uninstall of socat. |
| 116 | Product: oe-core |
| 117 | Author: Mariano Lopez <mariano.lopez@intel.com> |
| 118 | """ |
| 119 | if get_bb_var('DISTRO') == 'poky-tiny': |
| 120 | self.skipTest('core-image-full-cmdline not buildable for poky-tiny') |
| 121 | |
| 122 | features = 'INHERIT += "testimage"\n' |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 123 | features += 'IMAGE_INSTALL:append = " libssl"\n' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 124 | features += 'TEST_SUITES = "ping ssh selftest"\n' |
| 125 | self.write_config(features) |
| 126 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 127 | bitbake('core-image-full-cmdline socat') |
| 128 | bitbake('-c testimage core-image-full-cmdline') |
| 129 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 130 | def test_testimage_dnf(self): |
| 131 | """ |
| 132 | Summary: Check package feeds functionality for dnf |
| 133 | Expected: 1. Check that remote package feeds can be accessed |
| 134 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 135 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 136 | """ |
| 137 | if get_bb_var('DISTRO') == 'poky-tiny': |
| 138 | self.skipTest('core-image-full-cmdline not buildable for poky-tiny') |
| 139 | |
| 140 | features = 'INHERIT += "testimage"\n' |
| 141 | features += 'TEST_SUITES = "ping ssh dnf_runtime dnf.DnfBasicTest.test_dnf_help"\n' |
| 142 | # We don't yet know what the server ip and port will be - they will be patched |
| 143 | # in at the start of the on-image test |
| 144 | features += 'PACKAGE_FEED_URIS = "http://bogus_ip:bogus_port"\n' |
| 145 | features += 'EXTRA_IMAGE_FEATURES += "package-management"\n' |
| 146 | features += 'PACKAGE_CLASSES = "package_rpm"\n' |
| 147 | |
Brad Bishop | 6f8dcde | 2018-10-16 10:47:12 +0800 | [diff] [blame] | 148 | bitbake('gnupg-native -c addto_recipe_sysroot') |
| 149 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 150 | # Enable package feed signing |
| 151 | self.gpg_home = tempfile.mkdtemp(prefix="oeqa-feed-sign-") |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 152 | self.track_for_cleanup(self.gpg_home) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 153 | signing_key_dir = os.path.join(self.testlayer_path, 'files', 'signing') |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 154 | runCmd('gpgconf --list-dirs --homedir %s; gpg -v --batch --homedir %s --import %s' % (self.gpg_home, self.gpg_home, os.path.join(signing_key_dir, 'key.secret')), native_sysroot=get_bb_var("RECIPE_SYSROOT_NATIVE", "gnupg-native"), shell=True) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 155 | features += 'INHERIT += "sign_package_feed"\n' |
| 156 | features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n' |
| 157 | features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase') |
| 158 | features += 'GPG_PATH = "%s"\n' % self.gpg_home |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 159 | features += 'PSEUDO_IGNORE_PATHS .= ",%s"\n' % self.gpg_home |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 160 | self.write_config(features) |
| 161 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 162 | bitbake('core-image-full-cmdline socat') |
| 163 | bitbake('-c testimage core-image-full-cmdline') |
| 164 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 165 | def test_testimage_apt(self): |
| 166 | """ |
| 167 | Summary: Check package feeds functionality for apt |
| 168 | Expected: 1. Check that remote package feeds can be accessed |
| 169 | Product: oe-core |
| 170 | Author: Ferry Toth <fntoth@gmail.com> |
| 171 | """ |
| 172 | if get_bb_var('DISTRO') == 'poky-tiny': |
| 173 | self.skipTest('core-image-full-cmdline not buildable for poky-tiny') |
| 174 | |
| 175 | features = 'INHERIT += "testimage"\n' |
| 176 | features += 'TEST_SUITES = "ping ssh apt.AptRepoTest.test_apt_install_from_repo"\n' |
| 177 | # We don't yet know what the server ip and port will be - they will be patched |
| 178 | # in at the start of the on-image test |
| 179 | features += 'PACKAGE_FEED_URIS = "http://bogus_ip:bogus_port"\n' |
| 180 | features += 'EXTRA_IMAGE_FEATURES += "package-management"\n' |
| 181 | features += 'PACKAGE_CLASSES = "package_deb"\n' |
| 182 | # We need gnupg on the target to install keys |
| 183 | features += 'IMAGE_INSTALL:append:pn-core-image-full-cmdline = " gnupg"\n' |
| 184 | |
| 185 | bitbake('gnupg-native -c addto_recipe_sysroot') |
| 186 | |
| 187 | # Enable package feed signing |
| 188 | self.gpg_home = tempfile.mkdtemp(prefix="oeqa-feed-sign-") |
| 189 | self.track_for_cleanup(self.gpg_home) |
| 190 | signing_key_dir = os.path.join(self.testlayer_path, 'files', 'signing') |
| 191 | runCmd('gpgconf --list-dirs --homedir %s; gpg -v --batch --homedir %s --import %s' % (self.gpg_home, self.gpg_home, os.path.join(signing_key_dir, 'key.secret')), native_sysroot=get_bb_var("RECIPE_SYSROOT_NATIVE", "gnupg-native"), shell=True) |
| 192 | features += 'INHERIT += "sign_package_feed"\n' |
| 193 | features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n' |
| 194 | features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase') |
| 195 | features += 'GPG_PATH = "%s"\n' % self.gpg_home |
| 196 | features += 'PSEUDO_IGNORE_PATHS .= ",%s"\n' % self.gpg_home |
| 197 | self.write_config(features) |
| 198 | |
| 199 | # Build core-image-sato and testimage |
| 200 | bitbake('core-image-full-cmdline socat') |
| 201 | bitbake('-c testimage core-image-full-cmdline') |
| 202 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 203 | def test_testimage_virgl_gtk_sdl(self): |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 204 | """ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 205 | Summary: Check host-assisted accelerate OpenGL functionality in qemu with gtk and SDL frontends |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 206 | Expected: 1. Check that virgl kernel driver is loaded and 3d acceleration is enabled |
| 207 | 2. Check that kmscube demo runs without crashing. |
| 208 | Product: oe-core |
| 209 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
| 210 | """ |
| 211 | if "DISPLAY" not in os.environ: |
| 212 | self.skipTest("virgl gtk test must be run inside a X session") |
| 213 | distro = oe.lsb.distro_identifier() |
| 214 | if distro and distro == 'debian-8': |
| 215 | self.skipTest('virgl isn\'t working with Debian 8') |
Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 216 | if distro and distro == 'debian-9': |
| 217 | self.skipTest('virgl isn\'t working with Debian 9') |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 218 | if distro and distro == 'centos-7': |
| 219 | self.skipTest('virgl isn\'t working with Centos 7') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 220 | if distro and distro == 'opensuseleap-15.0': |
| 221 | self.skipTest('virgl isn\'t working with Opensuse 15.0') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 222 | |
| 223 | qemu_packageconfig = get_bb_var('PACKAGECONFIG', 'qemu-system-native') |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 224 | qemu_distrofeatures = get_bb_var('DISTRO_FEATURES', 'qemu-system-native') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 225 | features = 'INHERIT += "testimage"\n' |
| 226 | if 'gtk+' not in qemu_packageconfig: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 227 | features += 'PACKAGECONFIG:append:pn-qemu-system-native = " gtk+"\n' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 228 | if 'sdl' not in qemu_packageconfig: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 229 | features += 'PACKAGECONFIG:append:pn-qemu-system-native = " sdl"\n' |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 230 | if 'opengl' not in qemu_distrofeatures: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 231 | features += 'DISTRO_FEATURES:append = " opengl"\n' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 232 | features += 'TEST_SUITES = "ping ssh virgl"\n' |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 233 | features += 'IMAGE_FEATURES:append = " ssh-server-dropbear"\n' |
| 234 | features += 'IMAGE_INSTALL:append = " kmscube"\n' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 235 | features_gtk = features + 'TEST_RUNQEMUPARAMS = "gtk gl"\n' |
| 236 | self.write_config(features_gtk) |
| 237 | bitbake('core-image-minimal') |
| 238 | bitbake('-c testimage core-image-minimal') |
| 239 | features_sdl = features + 'TEST_RUNQEMUPARAMS = "sdl gl"\n' |
| 240 | self.write_config(features_sdl) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 241 | bitbake('core-image-minimal') |
| 242 | bitbake('-c testimage core-image-minimal') |
| 243 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 244 | def test_testimage_virgl_headless(self): |
| 245 | """ |
| 246 | Summary: Check host-assisted accelerate OpenGL functionality in qemu with egl-headless frontend |
| 247 | Expected: 1. Check that virgl kernel driver is loaded and 3d acceleration is enabled |
| 248 | 2. Check that kmscube demo runs without crashing. |
| 249 | Product: oe-core |
| 250 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
| 251 | """ |
| 252 | import subprocess, os |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 253 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 254 | distro = oe.lsb.distro_identifier() |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 255 | if distro and distro in ['debian-9', 'debian-10', 'centos-7', 'centos-8', 'ubuntu-16.04', 'ubuntu-18.04', 'almalinux-8.5', 'almalinux-8.6']: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 256 | self.skipTest('virgl headless cannot be tested with %s' %(distro)) |
| 257 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 258 | render_hint = """If /dev/dri/renderD* is absent due to lack of suitable GPU, 'modprobe vgem' will create one suitable for mesa llvmpipe software renderer.""" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 259 | try: |
| 260 | content = os.listdir("/dev/dri") |
| 261 | if len([i for i in content if i.startswith('render')]) == 0: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 262 | self.fail("No render nodes found in /dev/dri: %s. %s" %(content, render_hint)) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 263 | except FileNotFoundError: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 264 | self.fail("/dev/dri directory does not exist; no render nodes available on this machine. %s" %(render_hint)) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 265 | try: |
| 266 | dripath = subprocess.check_output("pkg-config --variable=dridriverdir dri", shell=True) |
| 267 | except subprocess.CalledProcessError as e: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 268 | self.fail("Could not determine the path to dri drivers on the host via pkg-config.\nPlease install Mesa development files (particularly, dri.pc) on the host machine.") |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 269 | qemu_distrofeatures = get_bb_var('DISTRO_FEATURES', 'qemu-system-native') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 270 | features = 'INHERIT += "testimage"\n' |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 271 | if 'opengl' not in qemu_distrofeatures: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 272 | features += 'DISTRO_FEATURES:append = " opengl"\n' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 273 | features += 'TEST_SUITES = "ping ssh virgl"\n' |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 274 | features += 'IMAGE_FEATURES:append = " ssh-server-dropbear"\n' |
| 275 | features += 'IMAGE_INSTALL:append = " kmscube"\n' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 276 | features += 'TEST_RUNQEMUPARAMS = "egl-headless"\n' |
| 277 | self.write_config(features) |
| 278 | bitbake('core-image-minimal') |
| 279 | bitbake('-c testimage core-image-minimal') |
| 280 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 281 | @OETestTag("runqemu") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 282 | class Postinst(OESelftestTestCase): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 283 | |
| 284 | def init_manager_loop(self, init_manager): |
| 285 | import oe.path |
| 286 | |
| 287 | vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal") |
| 288 | rootfs = vars["IMAGE_ROOTFS"] |
| 289 | self.assertIsNotNone(rootfs) |
| 290 | sysconfdir = vars["sysconfdir"] |
| 291 | self.assertIsNotNone(sysconfdir) |
| 292 | # Need to use oe.path here as sysconfdir starts with / |
| 293 | hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test") |
| 294 | targettestdir = os.path.join(sysconfdir, "postinst-test") |
| 295 | |
| 296 | for classes in ("package_rpm", "package_deb", "package_ipk"): |
| 297 | with self.subTest(init_manager=init_manager, package_class=classes): |
| 298 | features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-delayed-b"\n' |
| 299 | features += 'IMAGE_FEATURES += "package-management empty-root-password"\n' |
| 300 | features += 'PACKAGE_CLASSES = "%s"\n' % classes |
| 301 | if init_manager == "systemd": |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 302 | features += 'DISTRO_FEATURES:append = " systemd"\n' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 303 | features += 'VIRTUAL-RUNTIME_init_manager = "systemd"\n' |
| 304 | features += 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n' |
| 305 | features += 'VIRTUAL-RUNTIME_initscripts = ""\n' |
| 306 | self.write_config(features) |
| 307 | |
| 308 | bitbake('core-image-minimal') |
| 309 | |
| 310 | self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs")), |
| 311 | "rootfs state file was not created") |
| 312 | |
| 313 | with runqemu('core-image-minimal') as qemu: |
| 314 | # Make the test echo a string and search for that as |
| 315 | # run_serial()'s status code is useless.' |
| 316 | for filename in ("rootfs", "delayed-a", "delayed-b"): |
| 317 | status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename)) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 318 | self.assertIn("found", output, "%s was not present on boot" % filename) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 319 | |
| 320 | |
| 321 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 322 | @skipIfNotQemu() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 323 | def test_postinst_rootfs_and_boot_sysvinit(self): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 324 | """ |
| 325 | Summary: The purpose of this test case is to verify Post-installation |
| 326 | scripts are called when rootfs is created and also test |
| 327 | that script can be delayed to run at first boot. |
| 328 | Dependencies: NA |
| 329 | Steps: 1. Add proper configuration to local.conf file |
| 330 | 2. Build a "core-image-minimal" image |
| 331 | 3. Verify that file created by postinst_rootfs recipe is |
| 332 | present on rootfs dir. |
| 333 | 4. Boot the image created on qemu and verify that the file |
| 334 | created by postinst_boot recipe is present on image. |
| 335 | Expected: The files are successfully created during rootfs and boot |
| 336 | time for 3 different package managers: rpm,ipk,deb and |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 337 | for initialization managers: sysvinit. |
| 338 | |
| 339 | """ |
| 340 | self.init_manager_loop("sysvinit") |
| 341 | |
| 342 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 343 | @skipIfNotQemu() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 344 | def test_postinst_rootfs_and_boot_systemd(self): |
| 345 | """ |
| 346 | Summary: The purpose of this test case is to verify Post-installation |
| 347 | scripts are called when rootfs is created and also test |
| 348 | that script can be delayed to run at first boot. |
| 349 | Dependencies: NA |
| 350 | Steps: 1. Add proper configuration to local.conf file |
| 351 | 2. Build a "core-image-minimal" image |
| 352 | 3. Verify that file created by postinst_rootfs recipe is |
| 353 | present on rootfs dir. |
| 354 | 4. Boot the image created on qemu and verify that the file |
| 355 | created by postinst_boot recipe is present on image. |
| 356 | Expected: The files are successfully created during rootfs and boot |
| 357 | time for 3 different package managers: rpm,ipk,deb and |
| 358 | for initialization managers: systemd. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 359 | |
| 360 | """ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 361 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 362 | self.init_manager_loop("systemd") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 363 | |
| 364 | |
| 365 | def test_failing_postinst(self): |
| 366 | """ |
| 367 | Summary: The purpose of this test case is to verify that post-installation |
| 368 | scripts that contain errors are properly reported. |
| 369 | Expected: The scriptlet failure is properly reported. |
| 370 | The file that is created after the error in the scriptlet is not present. |
| 371 | Product: oe-core |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 372 | Author: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 373 | """ |
| 374 | |
| 375 | import oe.path |
| 376 | |
| 377 | vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal") |
| 378 | rootfs = vars["IMAGE_ROOTFS"] |
| 379 | self.assertIsNotNone(rootfs) |
| 380 | sysconfdir = vars["sysconfdir"] |
| 381 | self.assertIsNotNone(sysconfdir) |
| 382 | # Need to use oe.path here as sysconfdir starts with / |
| 383 | hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test") |
| 384 | |
| 385 | for classes in ("package_rpm", "package_deb", "package_ipk"): |
| 386 | with self.subTest(package_class=classes): |
| 387 | features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-rootfs-failing"\n' |
| 388 | features += 'PACKAGE_CLASSES = "%s"\n' % classes |
| 389 | self.write_config(features) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 390 | bb_result = bitbake('core-image-minimal', ignore_status=True) |
| 391 | self.assertGreaterEqual(bb_result.output.find("Postinstall scriptlets of ['postinst-rootfs-failing'] have failed."), 0, |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 392 | "Warning about a failed scriptlet not found in bitbake output: %s" %(bb_result.output)) |
| 393 | |
| 394 | self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs-before-failure")), |
| 395 | "rootfs-before-failure file was not created") |
| 396 | self.assertFalse(os.path.isfile(os.path.join(hosttestdir, "rootfs-after-failure")), |
| 397 | "rootfs-after-failure file was created") |
| 398 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 399 | @OETestTag("runqemu") |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 400 | class SystemTap(OESelftestTestCase): |
| 401 | """ |
| 402 | Summary: The purpose of this test case is to verify native crosstap |
| 403 | works while talking to a target. |
| 404 | Expected: The script should successfully connect to the qemu machine |
| 405 | and run some systemtap examples on a qemu machine. |
| 406 | """ |
| 407 | |
| 408 | @classmethod |
| 409 | def setUpClass(cls): |
| 410 | super(SystemTap, cls).setUpClass() |
| 411 | cls.image = "core-image-minimal" |
| 412 | |
| 413 | def default_config(self): |
| 414 | return """ |
| 415 | # These aren't the actual IP addresses but testexport class needs something defined |
| 416 | TEST_SERVER_IP = "192.168.7.1" |
| 417 | TEST_TARGET_IP = "192.168.7.2" |
| 418 | |
| 419 | EXTRA_IMAGE_FEATURES += "tools-profile dbg-pkgs" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 420 | IMAGE_FEATURES:append = " ssh-server-dropbear" |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 421 | |
| 422 | # enables kernel debug symbols |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 423 | KERNEL_EXTRA_FEATURES:append = " features/debug/debug-kernel.scc" |
| 424 | KERNEL_EXTRA_FEATURES:append = " features/systemtap/systemtap.scc" |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 425 | |
| 426 | # add systemtap run-time into target image if it is not there yet |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 427 | IMAGE_INSTALL:append = " systemtap-runtime" |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 428 | """ |
| 429 | |
| 430 | def test_crosstap_helloworld(self): |
| 431 | self.write_config(self.default_config()) |
| 432 | bitbake('systemtap-native') |
| 433 | systemtap_examples = os.path.join(get_bb_var("WORKDIR","systemtap-native"), "usr/share/systemtap/examples") |
| 434 | bitbake(self.image) |
| 435 | |
| 436 | with runqemu(self.image) as qemu: |
| 437 | cmd = "crosstap -r root@192.168.7.2 -s %s/general/helloworld.stp " % systemtap_examples |
| 438 | result = runCmd(cmd) |
| 439 | self.assertEqual(0, result.status, 'crosstap helloworld returned a non 0 status:%s' % result.output) |
| 440 | |
| 441 | def test_crosstap_pstree(self): |
| 442 | self.write_config(self.default_config()) |
| 443 | |
| 444 | bitbake('systemtap-native') |
| 445 | systemtap_examples = os.path.join(get_bb_var("WORKDIR","systemtap-native"), "usr/share/systemtap/examples") |
| 446 | bitbake(self.image) |
| 447 | |
| 448 | with runqemu(self.image) as qemu: |
| 449 | cmd = "crosstap -r root@192.168.7.2 -s %s/process/pstree.stp" % systemtap_examples |
| 450 | result = runCmd(cmd) |
| 451 | self.assertEqual(0, result.status, 'crosstap pstree returned a non 0 status:%s' % result.output) |
| 452 | |
| 453 | def test_crosstap_syscalls_by_proc(self): |
| 454 | self.write_config(self.default_config()) |
| 455 | |
| 456 | bitbake('systemtap-native') |
| 457 | systemtap_examples = os.path.join(get_bb_var("WORKDIR","systemtap-native"), "usr/share/systemtap/examples") |
| 458 | bitbake(self.image) |
| 459 | |
| 460 | with runqemu(self.image) as qemu: |
| 461 | cmd = "crosstap -r root@192.168.7.2 -s %s/process/ syscalls_by_proc.stp" % systemtap_examples |
| 462 | result = runCmd(cmd) |
| 463 | self.assertEqual(0, result.status, 'crosstap syscalls_by_proc returned a non 0 status:%s' % result.output) |
| 464 | |
| 465 | def test_crosstap_syscalls_by_pid(self): |
| 466 | self.write_config(self.default_config()) |
| 467 | |
| 468 | bitbake('systemtap-native') |
| 469 | systemtap_examples = os.path.join(get_bb_var("WORKDIR","systemtap-native"), "usr/share/systemtap/examples") |
| 470 | bitbake(self.image) |
| 471 | |
| 472 | with runqemu(self.image) as qemu: |
| 473 | cmd = "crosstap -r root@192.168.7.2 -s %s/process/ syscalls_by_pid.stp" % systemtap_examples |
| 474 | result = runCmd(cmd) |
| 475 | self.assertEqual(0, result.status, 'crosstap syscalls_by_pid returned a non 0 status:%s' % result.output) |