summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/runtime_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/runtime_test.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/runtime_test.py169
1 files changed, 108 insertions, 61 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index b20c5b427b..d58ffa80f5 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -1,24 +1,20 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
5from oeqa.selftest.case import OESelftestTestCase 7from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu 8from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
7from oeqa.utils.sshcontrol import SSHControl 9from oeqa.core.decorator import OETestTag
8import os 10import os
9import re
10import tempfile 11import tempfile
11import shutil
12import oe.lsb 12import oe.lsb
13from oeqa.core.decorator.data import skipIfNotQemu 13from oeqa.core.decorator.data import skipIfNotQemu, skipIfNotMachine
14 14
15class TestExport(OESelftestTestCase): 15class TestExport(OESelftestTestCase):
16 16
17 @classmethod 17 @OETestTag("runqemu")
18 def tearDownClass(cls):
19 runCmd("rm -rf /tmp/sdk")
20 super(TestExport, cls).tearDownClass()
21
22 def test_testexport_basic(self): 18 def test_testexport_basic(self):
23 """ 19 """
24 Summary: Check basic testexport functionality with only ping test enabled. 20 Summary: Check basic testexport functionality with only ping test enabled.
@@ -29,7 +25,7 @@ class TestExport(OESelftestTestCase):
29 Author: Mariano Lopez <mariano.lopez@intel.com> 25 Author: Mariano Lopez <mariano.lopez@intel.com>
30 """ 26 """
31 27
32 features = 'INHERIT += "testexport"\n' 28 features = 'IMAGE_CLASSES += "testexport"\n'
33 # These aren't the actual IP addresses but testexport class needs something defined 29 # These aren't the actual IP addresses but testexport class needs something defined
34 features += 'TEST_SERVER_IP = "192.168.7.1"\n' 30 features += 'TEST_SERVER_IP = "192.168.7.1"\n'
35 features += 'TEST_TARGET_IP = "192.168.7.1"\n' 31 features += 'TEST_TARGET_IP = "192.168.7.1"\n'
@@ -70,7 +66,7 @@ class TestExport(OESelftestTestCase):
70 Author: Mariano Lopez <mariano.lopez@intel.com> 66 Author: Mariano Lopez <mariano.lopez@intel.com>
71 """ 67 """
72 68
73 features = 'INHERIT += "testexport"\n' 69 features = 'IMAGE_CLASSES += "testexport"\n'
74 # These aren't the actual IP addresses but testexport class needs something defined 70 # These aren't the actual IP addresses but testexport class needs something defined
75 features += 'TEST_SERVER_IP = "192.168.7.1"\n' 71 features += 'TEST_SERVER_IP = "192.168.7.1"\n'
76 features += 'TEST_TARGET_IP = "192.168.7.1"\n' 72 features += 'TEST_TARGET_IP = "192.168.7.1"\n'
@@ -95,21 +91,23 @@ class TestExport(OESelftestTestCase):
95 msg = "Couldn't find SDK tarball: %s" % tarball_path 91 msg = "Couldn't find SDK tarball: %s" % tarball_path
96 self.assertEqual(os.path.isfile(tarball_path), True, msg) 92 self.assertEqual(os.path.isfile(tarball_path), True, msg)
97 93
98 # Extract SDK and run tar from SDK 94 with tempfile.TemporaryDirectory() as tmpdirname:
99 result = runCmd("%s -y -d /tmp/sdk" % tarball_path) 95 # Extract SDK and run tar from SDK
100 self.assertEqual(0, result.status, "Couldn't extract SDK") 96 result = runCmd("%s -y -d %s" % (tarball_path, tmpdirname))
97 self.assertEqual(0, result.status, "Couldn't extract SDK")
101 98
102 env_script = result.output.split()[-1] 99 env_script = result.output.split()[-1]
103 result = runCmd(". %s; which tar" % env_script, shell=True) 100 result = runCmd(". %s; which tar" % env_script, shell=True)
104 self.assertEqual(0, result.status, "Couldn't setup SDK environment") 101 self.assertEqual(0, result.status, "Couldn't setup SDK environment")
105 is_sdk_tar = True if "/tmp/sdk" in result.output else False 102 is_sdk_tar = True if tmpdirname in result.output else False
106 self.assertTrue(is_sdk_tar, "Couldn't setup SDK environment") 103 self.assertTrue(is_sdk_tar, "Couldn't setup SDK environment")
107 104
108 tar_sdk = result.output 105 tar_sdk = result.output
109 result = runCmd("%s --version" % tar_sdk) 106 result = runCmd("%s --version" % tar_sdk)
110 self.assertEqual(0, result.status, "Couldn't run tar from SDK") 107 self.assertEqual(0, result.status, "Couldn't run tar from SDK")
111 108
112 109
110@OETestTag("runqemu")
113class TestImage(OESelftestTestCase): 111class TestImage(OESelftestTestCase):
114 112
115 def test_testimage_install(self): 113 def test_testimage_install(self):
@@ -123,15 +121,30 @@ class TestImage(OESelftestTestCase):
123 if get_bb_var('DISTRO') == 'poky-tiny': 121 if get_bb_var('DISTRO') == 'poky-tiny':
124 self.skipTest('core-image-full-cmdline not buildable for poky-tiny') 122 self.skipTest('core-image-full-cmdline not buildable for poky-tiny')
125 123
126 features = 'INHERIT += "testimage"\n' 124 features = 'IMAGE_CLASSES += "testimage"\n'
127 features += 'IMAGE_INSTALL_append = " libssl"\n' 125 features += 'IMAGE_INSTALL:append = " libssl"\n'
128 features += 'TEST_SUITES = "ping ssh selftest"\n' 126 features += 'TEST_SUITES = "ping ssh selftest"\n'
129 self.write_config(features) 127 self.write_config(features)
130 128
131 # Build core-image-sato and testimage
132 bitbake('core-image-full-cmdline socat') 129 bitbake('core-image-full-cmdline socat')
133 bitbake('-c testimage core-image-full-cmdline') 130 bitbake('-c testimage core-image-full-cmdline')
134 131
132 def test_testimage_slirp(self):
133 """
134 Summary: Check basic testimage functionality with qemu and slirp networking.
135 """
136
137 features = '''
138IMAGE_CLASSES:append = " testimage"
139IMAGE_FEATURES:append = " ssh-server-dropbear"
140IMAGE_ROOTFS_EXTRA_SPACE:append = "${@bb.utils.contains("IMAGE_CLASSES", "testimage", " + 5120", "", d)}"
141TEST_RUNQEMUPARAMS += " slirp"
142'''
143 self.write_config(features)
144
145 bitbake('core-image-minimal')
146 bitbake('-c testimage core-image-minimal')
147
135 def test_testimage_dnf(self): 148 def test_testimage_dnf(self):
136 """ 149 """
137 Summary: Check package feeds functionality for dnf 150 Summary: Check package feeds functionality for dnf
@@ -142,7 +155,7 @@ class TestImage(OESelftestTestCase):
142 if get_bb_var('DISTRO') == 'poky-tiny': 155 if get_bb_var('DISTRO') == 'poky-tiny':
143 self.skipTest('core-image-full-cmdline not buildable for poky-tiny') 156 self.skipTest('core-image-full-cmdline not buildable for poky-tiny')
144 157
145 features = 'INHERIT += "testimage"\n' 158 features = 'IMAGE_CLASSES += "testimage"\n'
146 features += 'TEST_SUITES = "ping ssh dnf_runtime dnf.DnfBasicTest.test_dnf_help"\n' 159 features += 'TEST_SUITES = "ping ssh dnf_runtime dnf.DnfBasicTest.test_dnf_help"\n'
147 # We don't yet know what the server ip and port will be - they will be patched 160 # We don't yet know what the server ip and port will be - they will be patched
148 # in at the start of the on-image test 161 # in at the start of the on-image test
@@ -161,13 +174,50 @@ class TestImage(OESelftestTestCase):
161 features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n' 174 features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n'
162 features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase') 175 features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase')
163 features += 'GPG_PATH = "%s"\n' % self.gpg_home 176 features += 'GPG_PATH = "%s"\n' % self.gpg_home
164 features += 'PSEUDO_IGNORE_PATHS .= ",%s"\n' % self.gpg_home 177 self.write_config(features)
178
179 bitbake('core-image-full-cmdline socat')
180 bitbake('-c testimage core-image-full-cmdline')
181
182 def test_testimage_apt(self):
183 """
184 Summary: Check package feeds functionality for apt
185 Expected: 1. Check that remote package feeds can be accessed
186 Product: oe-core
187 Author: Ferry Toth <fntoth@gmail.com>
188 """
189 if get_bb_var('DISTRO') == 'poky-tiny':
190 self.skipTest('core-image-full-cmdline not buildable for poky-tiny')
191
192 features = 'IMAGE_CLASSES += "testimage"\n'
193 features += 'TEST_SUITES = "ping ssh apt.AptRepoTest.test_apt_install_from_repo"\n'
194 # We don't yet know what the server ip and port will be - they will be patched
195 # in at the start of the on-image test
196 features += 'PACKAGE_FEED_URIS = "http://bogus_ip:bogus_port"\n'
197 features += 'EXTRA_IMAGE_FEATURES += "package-management"\n'
198 features += 'PACKAGE_CLASSES = "package_deb"\n'
199 # We need gnupg on the target to install keys
200 features += 'IMAGE_INSTALL:append:pn-core-image-full-cmdline = " gnupg"\n'
201
202 bitbake('gnupg-native -c addto_recipe_sysroot')
203
204 # Enable package feed signing
205 self.gpg_home = tempfile.mkdtemp(prefix="oeqa-feed-sign-")
206 self.track_for_cleanup(self.gpg_home)
207 signing_key_dir = os.path.join(self.testlayer_path, 'files', 'signing')
208 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)
209 features += 'INHERIT += "sign_package_feed"\n'
210 features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n'
211 features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase')
212 features += 'GPG_PATH = "%s"\n' % self.gpg_home
165 self.write_config(features) 213 self.write_config(features)
166 214
167 # Build core-image-sato and testimage 215 # Build core-image-sato and testimage
168 bitbake('core-image-full-cmdline socat') 216 bitbake('core-image-full-cmdline socat')
169 bitbake('-c testimage core-image-full-cmdline') 217 bitbake('-c testimage core-image-full-cmdline')
170 218
219 # https://bugzilla.yoctoproject.org/show_bug.cgi?id=14966
220 @skipIfNotMachine("qemux86-64", "test needs qemux86-64")
171 def test_testimage_virgl_gtk_sdl(self): 221 def test_testimage_virgl_gtk_sdl(self):
172 """ 222 """
173 Summary: Check host-assisted accelerate OpenGL functionality in qemu with gtk and SDL frontends 223 Summary: Check host-assisted accelerate OpenGL functionality in qemu with gtk and SDL frontends
@@ -190,25 +240,26 @@ class TestImage(OESelftestTestCase):
190 240
191 qemu_packageconfig = get_bb_var('PACKAGECONFIG', 'qemu-system-native') 241 qemu_packageconfig = get_bb_var('PACKAGECONFIG', 'qemu-system-native')
192 qemu_distrofeatures = get_bb_var('DISTRO_FEATURES', 'qemu-system-native') 242 qemu_distrofeatures = get_bb_var('DISTRO_FEATURES', 'qemu-system-native')
193 features = 'INHERIT += "testimage"\n' 243 features = 'IMAGE_CLASSES += "testimage"\n'
194 if 'gtk+' not in qemu_packageconfig: 244 if 'gtk+' not in qemu_packageconfig:
195 features += 'PACKAGECONFIG_append_pn-qemu-system-native = " gtk+"\n' 245 features += 'PACKAGECONFIG:append:pn-qemu-system-native = " gtk+"\n'
196 if 'sdl' not in qemu_packageconfig: 246 if 'sdl' not in qemu_packageconfig:
197 features += 'PACKAGECONFIG_append_pn-qemu-system-native = " sdl"\n' 247 features += 'PACKAGECONFIG:append:pn-qemu-system-native = " sdl"\n'
198 if 'opengl' not in qemu_distrofeatures: 248 if 'opengl' not in qemu_distrofeatures:
199 features += 'DISTRO_FEATURES_append = " opengl"\n' 249 features += 'DISTRO_FEATURES:append = " opengl"\n'
200 features += 'TEST_SUITES = "ping ssh virgl"\n' 250 features += 'TEST_SUITES = "ping ssh virgl"\n'
201 features += 'IMAGE_FEATURES_append = " ssh-server-dropbear"\n' 251 features += 'IMAGE_FEATURES:append = " ssh-server-dropbear"\n'
202 features += 'IMAGE_INSTALL_append = " kmscube"\n' 252 features += 'IMAGE_INSTALL:append = " kmscube"\n'
203 features_gtk = features + 'TEST_RUNQEMUPARAMS = "gtk gl"\n' 253 features_gtk = features + 'TEST_RUNQEMUPARAMS += " gtk gl"\n'
204 self.write_config(features_gtk) 254 self.write_config(features_gtk)
205 bitbake('core-image-minimal') 255 bitbake('core-image-minimal')
206 bitbake('-c testimage core-image-minimal') 256 bitbake('-c testimage core-image-minimal')
207 features_sdl = features + 'TEST_RUNQEMUPARAMS = "sdl gl"\n' 257 features_sdl = features + 'TEST_RUNQEMUPARAMS += " sdl gl"\n'
208 self.write_config(features_sdl) 258 self.write_config(features_sdl)
209 bitbake('core-image-minimal') 259 bitbake('core-image-minimal')
210 bitbake('-c testimage core-image-minimal') 260 bitbake('-c testimage core-image-minimal')
211 261
262 @skipIfNotMachine("qemux86-64", "test needs qemux86-64")
212 def test_testimage_virgl_headless(self): 263 def test_testimage_virgl_headless(self):
213 """ 264 """
214 Summary: Check host-assisted accelerate OpenGL functionality in qemu with egl-headless frontend 265 Summary: Check host-assisted accelerate OpenGL functionality in qemu with egl-headless frontend
@@ -218,28 +269,27 @@ class TestImage(OESelftestTestCase):
218 Author: Alexander Kanavin <alex.kanavin@gmail.com> 269 Author: Alexander Kanavin <alex.kanavin@gmail.com>
219 """ 270 """
220 import subprocess, os 271 import subprocess, os
221 try: 272
222 content = os.listdir("/dev/dri") 273 distro = oe.lsb.distro_identifier()
223 if len([i for i in content if i.startswith('render')]) == 0: 274 # Merge request to address the issue on centos/rhel/derivatives:
224 self.skipTest("No render nodes found in /dev/dri: %s" %(content)) 275 # https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3449
225 except FileNotFoundError: 276 if distro and (distro in ['debian-9', 'debian-10', 'centos-7', 'centos-8', 'centos-9', 'ubuntu-16.04', 'ubuntu-18.04'] or
226 self.skipTest("/dev/dri directory does not exist; no render nodes available on this machine.") 277 distro.startswith('almalinux') or distro.startswith('rocky')):
227 try: 278 self.skipTest('virgl headless cannot be tested with %s' %(distro))
228 dripath = subprocess.check_output("pkg-config --variable=dridriverdir dri", shell=True) 279
229 except subprocess.CalledProcessError as e:
230 self.skipTest("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.")
231 qemu_distrofeatures = get_bb_var('DISTRO_FEATURES', 'qemu-system-native') 280 qemu_distrofeatures = get_bb_var('DISTRO_FEATURES', 'qemu-system-native')
232 features = 'INHERIT += "testimage"\n' 281 features = 'IMAGE_CLASSES += "testimage"\n'
233 if 'opengl' not in qemu_distrofeatures: 282 if 'opengl' not in qemu_distrofeatures:
234 features += 'DISTRO_FEATURES_append = " opengl"\n' 283 features += 'DISTRO_FEATURES:append = " opengl"\n'
235 features += 'TEST_SUITES = "ping ssh virgl"\n' 284 features += 'TEST_SUITES = "ping ssh virgl"\n'
236 features += 'IMAGE_FEATURES_append = " ssh-server-dropbear"\n' 285 features += 'IMAGE_FEATURES:append = " ssh-server-dropbear"\n'
237 features += 'IMAGE_INSTALL_append = " kmscube"\n' 286 features += 'IMAGE_INSTALL:append = " kmscube"\n'
238 features += 'TEST_RUNQEMUPARAMS = "egl-headless"\n' 287 features += 'TEST_RUNQEMUPARAMS += " egl-headless"\n'
239 self.write_config(features) 288 self.write_config(features)
240 bitbake('core-image-minimal') 289 bitbake('core-image-minimal')
241 bitbake('-c testimage core-image-minimal') 290 bitbake('-c testimage core-image-minimal')
242 291
292@OETestTag("runqemu")
243class Postinst(OESelftestTestCase): 293class Postinst(OESelftestTestCase):
244 294
245 def init_manager_loop(self, init_manager): 295 def init_manager_loop(self, init_manager):
@@ -260,10 +310,7 @@ class Postinst(OESelftestTestCase):
260 features += 'IMAGE_FEATURES += "package-management empty-root-password"\n' 310 features += 'IMAGE_FEATURES += "package-management empty-root-password"\n'
261 features += 'PACKAGE_CLASSES = "%s"\n' % classes 311 features += 'PACKAGE_CLASSES = "%s"\n' % classes
262 if init_manager == "systemd": 312 if init_manager == "systemd":
263 features += 'DISTRO_FEATURES_append = " systemd"\n' 313 features += 'INIT_MANAGER = "systemd"\n'
264 features += 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
265 features += 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n'
266 features += 'VIRTUAL-RUNTIME_initscripts = ""\n'
267 self.write_config(features) 314 self.write_config(features)
268 315
269 bitbake('core-image-minimal') 316 bitbake('core-image-minimal')
@@ -280,7 +327,7 @@ class Postinst(OESelftestTestCase):
280 327
281 328
282 329
283 @skipIfNotQemu('qemuall', 'Test only runs in qemu') 330 @skipIfNotQemu()
284 def test_postinst_rootfs_and_boot_sysvinit(self): 331 def test_postinst_rootfs_and_boot_sysvinit(self):
285 """ 332 """
286 Summary: The purpose of this test case is to verify Post-installation 333 Summary: The purpose of this test case is to verify Post-installation
@@ -301,7 +348,7 @@ class Postinst(OESelftestTestCase):
301 self.init_manager_loop("sysvinit") 348 self.init_manager_loop("sysvinit")
302 349
303 350
304 @skipIfNotQemu('qemuall', 'Test only runs in qemu') 351 @skipIfNotQemu()
305 def test_postinst_rootfs_and_boot_systemd(self): 352 def test_postinst_rootfs_and_boot_systemd(self):
306 """ 353 """
307 Summary: The purpose of this test case is to verify Post-installation 354 Summary: The purpose of this test case is to verify Post-installation
@@ -357,6 +404,7 @@ class Postinst(OESelftestTestCase):
357 self.assertFalse(os.path.isfile(os.path.join(hosttestdir, "rootfs-after-failure")), 404 self.assertFalse(os.path.isfile(os.path.join(hosttestdir, "rootfs-after-failure")),
358 "rootfs-after-failure file was created") 405 "rootfs-after-failure file was created")
359 406
407@OETestTag("runqemu")
360class SystemTap(OESelftestTestCase): 408class SystemTap(OESelftestTestCase):
361 """ 409 """
362 Summary: The purpose of this test case is to verify native crosstap 410 Summary: The purpose of this test case is to verify native crosstap
@@ -377,14 +425,14 @@ TEST_SERVER_IP = "192.168.7.1"
377TEST_TARGET_IP = "192.168.7.2" 425TEST_TARGET_IP = "192.168.7.2"
378 426
379EXTRA_IMAGE_FEATURES += "tools-profile dbg-pkgs" 427EXTRA_IMAGE_FEATURES += "tools-profile dbg-pkgs"
380IMAGE_FEATURES_append = " ssh-server-dropbear" 428IMAGE_FEATURES:append = " ssh-server-dropbear"
381 429
382# enables kernel debug symbols 430# enables kernel debug symbols
383KERNEL_EXTRA_FEATURES_append = " features/debug/debug-kernel.scc" 431KERNEL_EXTRA_FEATURES:append = " features/debug/debug-kernel.scc"
384KERNEL_EXTRA_FEATURES_append = " features/systemtap/systemtap.scc" 432KERNEL_EXTRA_FEATURES:append = " features/systemtap/systemtap.scc"
385 433
386# add systemtap run-time into target image if it is not there yet 434# add systemtap run-time into target image if it is not there yet
387IMAGE_INSTALL_append = " systemtap-runtime" 435IMAGE_INSTALL:append = " systemtap-runtime"
388""" 436"""
389 437
390 def test_crosstap_helloworld(self): 438 def test_crosstap_helloworld(self):
@@ -433,4 +481,3 @@ IMAGE_INSTALL_append = " systemtap-runtime"
433 cmd = "crosstap -r root@192.168.7.2 -s %s/process/ syscalls_by_pid.stp" % systemtap_examples 481 cmd = "crosstap -r root@192.168.7.2 -s %s/process/ syscalls_by_pid.stp" % systemtap_examples
434 result = runCmd(cmd) 482 result = runCmd(cmd)
435 self.assertEqual(0, result.status, 'crosstap syscalls_by_pid returned a non 0 status:%s' % result.output) 483 self.assertEqual(0, result.status, 'crosstap syscalls_by_pid returned a non 0 status:%s' % result.output)
436