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