From 3b013ae441d117adeda0d9950e02e9f7d0deba2f Mon Sep 17 00:00:00 2001 From: Mikko Rapeli Date: Thu, 4 Jan 2024 15:51:12 +0200 Subject: oeqa systemd.py: settle() using "running" or "degraded" state systemd boot has completed when system is in "running" or "degraded" (some services failed) state. Check for that in the systemd settle() function instead of listing all services and checking their activation state since some services are in activation state even when whole system is already in "running" state. Examples of services which can be in activation state are rootfs auto mounting related generated services. Without this patch systemd test_systemd_list (systemd.SystemdBasicTests) times out on an image with dm-verity /usr partition and systemd generated rootfs: NOTE: ... FAIL Traceback (most recent call last): File "/home/builder/src/base/build/../poky/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f return func(*args, **kwargs) File "/home/builder/src/base/poky/meta/lib/oeqa/runtime/cases/systemd.py", line 97, in test_systemd_failed self.assertTrue(settled, msg=msg) AssertionError: False is not true : Timed out waiting for systemd to settle: UNIT LOAD ACTIVE SUB DESCRIPTION dev-disk-by\x2did-dm\x2dname\x2droot.device loaded activating tentativ e /dev/disk/by-id/dm-name-root dev-disk-by\x2did-dm\x2dname\x2dusr.device loaded activating tentativ e /dev/disk/by-id/dm-name-usr dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS2\x2df2b944f394174eb5918cb6af2c6b4cb2\x2droot.device loaded activating tentativ e /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-f2b944f394174eb5918cb6af2c6b4cb2-root dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dVERITY\x2d3dd703c88f1946658697a6d57617473b\x2dusr.device loaded activating tentativ e /dev/disk/by-id/dm-uuid-CRYPT-VERITY-3dd703c88f1946658697a6d57617473b-usr dev-disk-by\x2duuid-bfbf856e\x2d3c65\x2d4eb2\x2d9ffb\x2d8e0b11641d85.device loaded activating tentativ e /dev/disk/by-uuid/bfbf856e-3c65-4eb2-9ffb-8e0b11641d85 dev-dm\x2d0.device loaded activating tentativ e /dev/dm-0 dev-dm\x2d1.device loaded activating tentativ e /dev/dm-1 ... Fix is to check for the systemd global "running" or "degraded" state. Note that it would be possible to use a blocking call "systemctl is-system-running --wait" to exit after system enters "running" or "degraded" state but using the existing loop for a 2 minute timeout. Signed-off-by: Mikko Rapeli Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- meta/lib/oeqa/runtime/cases/systemd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'meta/lib/oeqa/runtime') diff --git a/meta/lib/oeqa/runtime/cases/systemd.py b/meta/lib/oeqa/runtime/cases/systemd.py index 2865887959..5481e1d840 100644 --- a/meta/lib/oeqa/runtime/cases/systemd.py +++ b/meta/lib/oeqa/runtime/cases/systemd.py @@ -69,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) -- cgit 1.2.3-korg