From: Lennart Poettering Date: Thu, 28 May 2026 09:42:57 +0000 (+0200) Subject: test: verify sysupdate invokes the notification callout directory X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89dd06505bc3dffd152fd4ff9dcff59b71bba56a;p=thirdparty%2Fsystemd.git test: verify sysupdate invokes the notification callout directory Extend TEST-72-SYSUPDATE with a check that, after a successful update, systemd-sysupdate connects to every socket linked into /run/systemd/sysupdate/notify/ and invokes io.systemd.SysUpdate.Notify.OnCompletedUpdate(). A tiny recorder socket is hooked into that directory; it captures the request and replies with success. We assert the recorded call carries the expected method, version and resource list, and that a subsequent no-op update emits no notification. --- diff --git a/test/units/TEST-72-SYSUPDATE.sh b/test/units/TEST-72-SYSUPDATE.sh index 4ac8b8a52d3..6cabcab5bb2 100755 --- a/test/units/TEST-72-SYSUPDATE.sh +++ b/test/units/TEST-72-SYSUPDATE.sh @@ -49,6 +49,10 @@ systemctl daemon-reload at_exit() { set +e + systemctl stop test-sysupdate-notify-recorder.socket + rm -f /run/systemd/system/test-sysupdate-notify-recorder.socket \ + /run/systemd/system/test-sysupdate-notify-recorder@.service + losetup -n --output NAME --associated "$BACKING_FILE" | while read -r loop_dev; do losetup --detach "$loop_dev" done @@ -947,4 +951,85 @@ test ! -f "$CLEANUP/target/alpha-v2.bin" rm -rf "$CONFIGDIR" "$INSTALLDB" "$CLEANUP" +# Verify the notification callout: after a successful update, sysupdate must connect to every socket in +# /run/systemd/sysupdate/notify/ and invoke io.systemd.SysUpdate.Notify.OnCompletedUpdate(). We hook a tiny +# recorder socket into that directory that captures the request and replies with success. +NOTIFY_LOG="$WORKDIR/notify.log" +rm -f "$NOTIFY_LOG" + +cat >"$WORKDIR/notify-recorder.py" </run/systemd/system/test-sysupdate-notify-recorder.socket <"/run/systemd/system/test-sysupdate-notify-recorder@.service" <"$WORKDIR/source/notifytest-v1.bin" +(cd "$WORKDIR/source" && sha256sum notifytest-v1.bin >SHA256SUMS) +cat >"$CONFIGDIR/01-notifytest.transfer" </dev/null +jq -e '.parameters.version == "v1"' <<<"$notify_line" >/dev/null +jq -e '.parameters.resources | length >= 1' <<<"$notify_line" >/dev/null +jq -e '.parameters.resources | all(has("transfer"))' <<<"$notify_line" >/dev/null + +# A no-op update ("No update needed") must NOT emit a notification. +rm -f "$NOTIFY_LOG" +"$SYSUPDATE" --verify=no update +test ! -s "$NOTIFY_LOG" + +systemctl stop test-sysupdate-notify-recorder.socket +rm -f /run/systemd/system/test-sysupdate-notify-recorder.socket \ + /run/systemd/system/test-sysupdate-notify-recorder@.service +systemctl daemon-reload +rm -rf "$CONFIGDIR" "$WORKDIR/blobs" +rm -f "$WORKDIR/source/notifytest-v1.bin" "$WORKDIR/source/SHA256SUMS" \ + "$WORKDIR/notify-recorder.py" "$NOTIFY_LOG" + touch /testok