From: Frantisek Sumsal Date: Mon, 10 Nov 2025 18:26:43 +0000 (+0100) Subject: test: ignore EC from the second `systemctl status -a` as well X-Git-Tag: v259-rc1~101 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b131e8d3a478a793956ecd4ab2138e3c4ce5a284;p=thirdparty%2Fsystemd.git test: ignore EC from the second `systemctl status -a` as well There is a TOCTOU in the `systemctl status` where a unit might change its state during the initial ListUnitsByPatterns call and the subsequent individual GetAll calls, which then makes the systemctl call fail even if the unit that was originally pulled in was active/running: [ 1922.040463] TEST-26-SYSTEMCTL.sh[117]: + systemctl status -a --state active,running,plugged [ 1922.051423] systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=ListUnitsByPatterns cookie=1 reply_cookie=0 signature=asas error-name=n/a error-message=n/a [ 1922.052501] systemd[1]: Sent message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=a(ssssssouso) error-name=n/a error-message=n/a [ 1922.052650] systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1/unit/_2d_2emount interface=org.freedesktop.DBus.Properties member=GetAll cookie=2 reply_cookie=0 signature=s error-name=n/a error-message=n/a ... [ 1922.222061] systemd-hostnamed[424]: Idle for 30s, exiting. ... [ 1922.224961] systemd[1]: systemd-hostnamed.service: Got notification message from PID 424: STOPPING=1, STATUS=Shutting down... [ 1922.224983] systemd[1]: systemd-hostnamed.service: Changed running ->stop-sigterm ... [ 1922.228984] systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1/unit/systemd_2dhostnamed_2eservice interface=org.freedesktop.DBus.Properties member=GetAll cookie=41 reply_cookie=0 signature=s error-name=n/a error-message=n/a [ 1922.234402] systemd[1]: Sent message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=43 reply_cookie=41 signature=a{sv} error-name=n/a error-message=n/a Since in this case we care mostly about the code paths the command triggers, ignore its exit code as we do for the previous one. Resolves: #39612 --- diff --git a/test/units/TEST-26-SYSTEMCTL.sh b/test/units/TEST-26-SYSTEMCTL.sh index 0bfffa54350..4a2f4eabce8 100755 --- a/test/units/TEST-26-SYSTEMCTL.sh +++ b/test/units/TEST-26-SYSTEMCTL.sh @@ -359,7 +359,10 @@ systemctl show systemd-logind.service systemctl status # Ignore the exit code in this case, as it might try to load non-existing units systemctl status -a >/dev/null || : -systemctl status -a --state active,running,plugged >/dev/null +# Ditto - there is a window between the first ListUnitsByByPatterns and the querying of individual units in +# which some units might change their state (e.g. running -> stop-sigterm), which then causes systemctl to +# return EC > 0 +systemctl status -a --state active,running,plugged >/dev/null || : systemctl status "systemd-*.timer" systemctl status "systemd-journald*.socket" systemctl status "sys-devices-*-ttyS0.device"