]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa systemd.py: settle() using "running" or "degraded" state
authorMikko Rapeli <mikko.rapeli@linaro.org>
Thu, 4 Jan 2024 13:51:12 +0000 (15:51 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 7 Jan 2024 12:24:54 +0000 (12:24 +0000)
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 <mikko.rapeli@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/runtime/cases/systemd.py

index 2865887959a1c903d5569ee5768406f0c51d62ec..5481e1d840d7618d2f30c4408a2fd6ac7a876874 100644 (file)
@@ -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)