diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/systemd.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/systemd.py | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/meta/lib/oeqa/runtime/cases/systemd.py b/meta/lib/oeqa/runtime/cases/systemd.py index 460b8fc3a1..80fdae240a 100644 --- a/meta/lib/oeqa/runtime/cases/systemd.py +++ b/meta/lib/oeqa/runtime/cases/systemd.py @@ -1,12 +1,18 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + import re +import threading import time from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends -from oeqa.core.decorator.oeid import OETestID from oeqa.core.decorator.data import skipIfDataVar, skipIfNotDataVar from oeqa.runtime.decorator.package import OEHasPackage -from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.core.decorator.data import skipIfNotFeature, skipIfFeature class SystemdTest(OERuntimeTestCase): @@ -63,8 +69,8 @@ class SystemdBasicTests(SystemdTest): """ endtime = time.time() + (60 * 2) while True: - status, output = self.target.run('SYSTEMD_BUS_TIMEOUT=240s systemctl --state=activating') - if "0 loaded units listed" in output: + status, output = self.target.run('SYSTEMD_BUS_TIMEOUT=240s systemctl is-system-running') + if "running" in output or "degraded" in output: return (True, '') if time.time() >= endtime: return (False, output) @@ -78,12 +84,10 @@ class SystemdBasicTests(SystemdTest): def test_systemd_basic(self): self.systemctl('--version') - @OETestID(551) @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic']) def test_systemd_list(self): self.systemctl('list-unit-files') - @OETestID(550) @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic']) def test_systemd_failed(self): settled, output = self.settle() @@ -104,7 +108,6 @@ class SystemdServiceTests(SystemdTest): def test_systemd_status(self): self.systemctl('status --full', 'avahi-daemon.service') - @OETestID(695) @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status']) def test_systemd_stop_start(self): self.systemctl('stop', 'avahi-daemon.service') @@ -113,14 +116,50 @@ class SystemdServiceTests(SystemdTest): self.systemctl('start','avahi-daemon.service') self.systemctl('is-active', 'avahi-daemon.service', verbose=True) - @OETestID(696) @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status']) + @skipIfFeature('read-only-rootfs', + 'Test is only meant to run without read-only-rootfs in IMAGE_FEATURES') def test_systemd_disable_enable(self): self.systemctl('disable', 'avahi-daemon.service') self.systemctl('is-enabled', 'avahi-daemon.service', expected=1) self.systemctl('enable', 'avahi-daemon.service') self.systemctl('is-enabled', 'avahi-daemon.service') + @OETestDepends(['systemd.SystemdServiceTests.test_systemd_status']) + @skipIfNotFeature('read-only-rootfs', + 'Test is only meant to run with read-only-rootfs in IMAGE_FEATURES') + def test_systemd_disable_enable_ro(self): + status = self.target.run('mount -orw,remount /')[0] + self.assertTrue(status == 0, msg='Remounting / as r/w failed') + try: + self.test_systemd_disable_enable() + finally: + status = self.target.run('mount -oro,remount /')[0] + self.assertTrue(status == 0, msg='Remounting / as r/o failed') + + @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic']) + @skipIfNotFeature('minidebuginfo', 'Test requires minidebuginfo to be in DISTRO_FEATURES') + @OEHasPackage(['busybox']) + def test_systemd_coredump_minidebuginfo(self): + """ + Verify that call-stacks generated by systemd-coredump contain symbolicated call-stacks, + extracted from the minidebuginfo metadata (.gnu_debugdata elf section). + """ + # use "env sleep" instead of "sleep" to avoid calling the shell builtin function + t_thread = threading.Thread(target=self.target.run, args=("ulimit -c unlimited && env sleep 1000",)) + t_thread.start() + time.sleep(1) + + status, output = self.target.run('pidof sleep') + # cause segfault on purpose + self.target.run('kill -SEGV %s' % output) + self.assertEqual(status, 0, msg = 'Not able to find process that runs sleep, output : %s' % output) + + (status, output) = self.target.run('coredumpctl info') + self.assertEqual(status, 0, msg='MiniDebugInfo Test failed: %s' % output) + self.assertEqual('sleep_for_duration (busybox.nosuid' in output or 'xnanosleep (sleep.coreutils' in output, + True, msg='Call stack is missing minidebuginfo symbols (functions shown as "n/a"): %s' % output) + class SystemdJournalTests(SystemdTest): @OETestDepends(['systemd.SystemdBasicTests.test_systemd_basic']) @@ -139,7 +178,7 @@ class SystemdJournalTests(SystemdTest): """ # The expression chain that uniquely identifies the time boot message. - expr_items=['Startup finished', 'kernel', 'userspace','\.$'] + expr_items=['Startup finished', 'kernel', 'userspace', r'\.$'] try: output = self.journalctl(args='-o cat --reverse') except AssertionError: |