]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Expand sysupdate test to cover split acquire/install updates 40236/head
authorPhilip Withnall <pwithnall@gnome.org>
Mon, 12 Jan 2026 16:43:46 +0000 (16:43 +0000)
committerPhilip Withnall <pwithnall@gnome.org>
Mon, 9 Feb 2026 12:05:20 +0000 (12:05 +0000)
This essentially means the sysupdate tests are now run twice: once with
a monolithic update (`sysupdate update`) and once with a split update
(`sysupdate acquire; sysupdate install`).

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

index a3e0e834bb36598ed4f9918aa25f8cbc94dcb419..f3b712a6e6ef68351096f49bc520fd9df9cea0e1 100755 (executable)
@@ -92,11 +92,27 @@ new_version() {
 }
 
 update_now() {
+    local update_type="${1:?}"
+
     # Update to newest version. First there should be an update ready, then we
     # do the update, and then there should not be any ready anymore
+    #
+    # The update can either be done monolithically (by calling the `update`
+    # verb) or split (`acquire` then `update`). Both options are allowed for
+    # most updates in the test suite, so the test suite can be run to test both
+    # modes. Some updates in the test suite need to be monolithic (e.g. when
+    # repairing an installation), so that can be overridden via the local.
 
     "$SYSUPDATE" --verify=no check-new
-    "$SYSUPDATE" --verify=no update
+    if [[ "$update_type" == "monolithic" ]]; then
+        "$SYSUPDATE" --verify=no update
+    elif [[ "$update_type" == "split-offline" ]]; then
+        "$SYSUPDATE" --verify=no acquire
+        "$SYSUPDATE" --verify=no update --offline
+    elif [[ "$update_type" == "split" ]]; then
+        "$SYSUPDATE" --verify=no acquire
+        "$SYSUPDATE" --verify=no update
+    fi
     (! "$SYSUPDATE" --verify=no check-new)
 }
 
@@ -135,6 +151,7 @@ verify_version_current() {
 }
 
 for sector_size in "${SECTOR_SIZES[@]}"; do
+for update_type in monolithic split-offline split; do
     # Disk size of:
     # - 1MB for GPT
     # - 4 partitions of 2048 sectors each
@@ -267,18 +284,18 @@ EOF
 
     # Install initial version and verify
     new_version "$sector_size" v1
-    update_now
+    update_now "$update_type"
     verify_version_current "$blockdev" "$sector_size" v1 1
 
     # Create second version, update and verify that it is added
     new_version "$sector_size" v2
-    update_now
+    update_now "$update_type"
     verify_version "$blockdev" "$sector_size" v1 1
     verify_version_current "$blockdev" "$sector_size" v2 2
 
     # Create third version, update and verify it replaced the first version
     new_version "$sector_size" v3
-    update_now
+    update_now "$update_type"
     verify_version_current "$blockdev" "$sector_size" v3 1
     verify_version "$blockdev" "$sector_size" v2 2
     test ! -f "$WORKDIR/xbootldr/EFI/Linux/uki_v1+3-0.efi"
@@ -295,16 +312,17 @@ EOF
     # Create a fifth version, that's complete on the server side. We should
     # completely skip the incomplete v4 and install v5 instead.
     new_version "$sector_size" v5
-    update_now
+    update_now "$update_type"
     verify_version "$blockdev" "$sector_size" v3 1
     verify_version_current "$blockdev" "$sector_size" v5 2
 
     # Make the local installation of v5 incomplete by deleting a file, then make
     # sure that sysupdate still recognizes the installation and can complete it
     # in place
+    # Always do this as a monolithic update for the repair to work.
     rm -r "$WORKDIR/xbootldr/EFI/Linux/uki_v5.efi.extra.d"
     "$SYSUPDATE" --offline list v5 | grep "incomplete" >/dev/null
-    update_now
+    update_now "monolithic"
     "$SYSUPDATE" --offline list v5 | grep -v "incomplete" >/dev/null
     verify_version "$blockdev" "$sector_size" v3 1
     verify_version_current "$blockdev" "$sector_size" v5 2
@@ -316,7 +334,7 @@ EOF
     mkdir "$CONFIGDIR/optional.feature.d"
     echo -e "[Feature]\nEnabled=true" > "$CONFIGDIR/optional.feature.d/enable.conf"
     "$SYSUPDATE" --offline list v5 | grep "incomplete" >/dev/null
-    update_now
+    update_now "monolithic"
     "$SYSUPDATE" --offline list v5 | grep -v "incomplete" >/dev/null
     verify_version "$blockdev" "$sector_size" v3 1
     verify_version_current "$blockdev" "$sector_size" v5 2
@@ -340,7 +358,7 @@ EOF
         updatectl update
     else
         # If no updatectl, gracefully fall back to systemd-sysupdate
-        update_now
+        update_now "$update_type"
     fi
     # User-facing updatectl returns 0 if there's no updates, so use the low-level
     # utility to make sure we did upgrade
@@ -397,7 +415,7 @@ MatchPattern=dir-@v
 InstancesMax=3
 EOF
 
-    update_now
+    update_now "$update_type"
     verify_version "$blockdev" "$sector_size" v6 1
     verify_version_current "$blockdev" "$sector_size" v7 2
 
@@ -420,7 +438,7 @@ EOF
     # (what .transfer files were called before v257)
     for i in "$CONFIGDIR/"*.conf; do echo mv "$i" "${i%.conf}.transfer"; done
     new_version "$sector_size" v8
-    update_now
+    update_now "$update_type"
     verify_version_current "$blockdev" "$sector_size" v8 1
     verify_version "$blockdev" "$sector_size" v7 2
 
@@ -428,5 +446,6 @@ EOF
     [[ -b "$blockdev" ]] && losetup --detach "$blockdev"
     rm "$BACKING_FILE"
 done
+done
 
 touch /testok