]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Test error handling for non-existent targets in sysupdate
authorPhilip Withnall <pwithnall@gnome.org>
Thu, 18 Jun 2026 12:57:35 +0000 (13:57 +0100)
committerPhilip Withnall <pwithnall@gnome.org>
Fri, 26 Jun 2026 12:01:58 +0000 (13:01 +0100)
Primarily I want to test the new varlink error, but this will also test
the `systemd-sysupdate` CLI behaviour too.

test/units/TEST-72-SYSUPDATE.sh

index f8ba6035df70910def494b830d0242003d17663d..a8bc7432c180b9b5f7b623dd1e556ac67d49dd11 100755 (executable)
@@ -589,6 +589,18 @@ EOF
     verify_version "$blockdev" "$sector_size" v8 1
     verify_version_current "$blockdev" "$sector_size" v9 2
 
+    # Test that checking for an update on a non-existent target fails
+    # (for backwards compatibility reasons, the validation in sysupdate-cli is
+    # less strict)
+    if [[ "$client" == "sysupdate-cli" ]]; then
+        (! "$SYSUPDATE" --verify=no check-new --component=../) |& grep "Component name invalid" >/dev/null
+    elif [[ "$client" == "varlink" ]]; then
+        (! varlinkctl call "$VARLINK_SOCKET" io.systemd.SysUpdate.CheckNew '{"target":{"class":"component","name":"../"}}') |& grep org.varlink.service.InvalidParameter >/dev/null
+        (! varlinkctl call "$VARLINK_SOCKET" io.systemd.SysUpdate.CheckNew '{"target":{"class":"component","name":"doesnotexist"}}') |& grep io.systemd.SysUpdate.NoSuchTarget >/dev/null
+    else
+        exit 1
+    fi
+
     # Cleanup
     [[ -b "$blockdev" ]] && losetup --detach "$blockdev"
     rm "$BACKING_FILE"