]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Expand sysupdate test to test updatectl update
authorPhilip Withnall <pwithnall@gnome.org>
Mon, 19 Jan 2026 18:12:39 +0000 (18:12 +0000)
committerPhilip Withnall <pwithnall@gnome.org>
Mon, 23 Feb 2026 16:35:15 +0000 (16:35 +0000)
This further expands the sysupdate test to run the suite a fourth time,
testing that `updatectl update` behaves the same as `sysupdate update`
and `sysupdate acquire; sysupdate update --offline`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
test/units/TEST-72-SYSUPDATE.sh

index 3fe125a26a648190811dae24e910054caa7db56c..46968d4372d88b99aa07e4d332c588d45ed3a1c6 100755 (executable)
@@ -21,6 +21,8 @@ if [[ ! -x "$SYSUPDATE" ]]; then
     exit 77
 fi
 
+have_updatectl=$([[ -x "$SYSUPDATED" ]] && command -v updatectl)
+
 # Loopback devices may not be supported. They are used because sfdisk cannot
 # change the sector size of a file, and we want to test both 512 and 4096 byte
 # sectors. If loopback devices are not supported, we can only test one sector
@@ -112,6 +114,16 @@ update_now() {
     elif [[ "$update_type" == "split" ]]; then
         "$SYSUPDATE" --verify=no acquire
         "$SYSUPDATE" --verify=no update
+    elif [[ "$update_type" == "updatectl" ]]; then
+        if $have_updatectl; then
+            systemctl start systemd-sysupdated
+            updatectl update
+        else
+            # Gracefully fall back to sysupdate
+            "$SYSUPDATE" --verify=no update
+        fi
+    else
+        exit 1
     fi
     (! "$SYSUPDATE" --verify=no check-new)
 }
@@ -157,7 +169,7 @@ verify_object_fields() {
 }
 
 for sector_size in "${SECTOR_SIZES[@]}"; do
-for update_type in monolithic split-offline split; do
+for update_type in monolithic split-offline split updatectl; do
     # Disk size of:
     # - 1MB for GPT
     # - 4 partitions of 2048 sectors each
@@ -358,7 +370,7 @@ EOF
     # Create sixth version, update using updatectl and verify it replaced the
     # correct version
     new_version "$sector_size" v6
-    if [[ -x "$SYSUPDATED" ]] && command -v updatectl; then
+    if $have_updatectl; then
         systemctl start systemd-sysupdated
         "$SYSUPDATE" --verify=no check-new
         updatectl update
@@ -376,7 +388,7 @@ EOF
     # testing for specific output, but this will at least catch obvious crashes
     # and allow updatectl to run under the various sanitizers. We create a
     # component so that updatectl has multiple targets to list.
-    if [[ -x "$SYSUPDATED" ]] && command -v updatectl; then
+    if $have_updatectl; then
         mkdir -p /run/sysupdate.test.d/
         cp "$CONFIGDIR/01-first.transfer" /run/sysupdate.test.d/01-first.transfer
         verify_object_fields "$(updatectl list 2>&1)"