From d6bf5fbaf20799c82147c24a5f98a5883016c9dd Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Fri, 2 Oct 2026 16:58:21 +0200 Subject: [PATCH] test: cover attaching with a profile that does not exist Both attach and reattach must fail, and the latter must not detach the image first. (cherry picked from commit 430f8962cf2e454cc9b474a22b92a89a26872e9b) --- test/units/TEST-29-PORTABLE.image.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/units/TEST-29-PORTABLE.image.sh b/test/units/TEST-29-PORTABLE.image.sh index ba711e93b3..1e8e872a3e 100755 --- a/test/units/TEST-29-PORTABLE.image.sh +++ b/test/units/TEST-29-PORTABLE.image.sh @@ -17,6 +17,11 @@ if [[ -v ASAN_OPTIONS || -v UBSAN_OPTIONS ]]; then ARGS+=(--profile=trusted) fi +# Attaching with a profile that doesn't exist must fail and must not leave anything behind +(! portablectl attach --runtime --profile=nonexistent /usr/share/minimal_0.raw minimal-app0) +test ! -e /run/systemd/system.attached/minimal-app0.service +test ! -e /run/systemd/system.attached/minimal-app0.service.d + portablectl "${ARGS[@]}" attach --now --runtime /usr/share/minimal_0.raw minimal-app0 portablectl is-attached minimal-app0 @@ -29,6 +34,12 @@ systemctl is-active minimal-app0-bar.service && exit 1 cat /run/systemd/system.attached/minimal-app0-foo.service.d/20-portable.conf grep -q -F 'root=signed+squashfs:' /run/systemd/system.attached/minimal-app0-foo.service.d/20-portable.conf +# Reattaching with a profile that doesn't exist must fail without detaching the image first +(! portablectl reattach --now --runtime --profile=nonexistent /usr/share/minimal_1.raw minimal-app0) +portablectl is-attached minimal-app0 +systemctl is-active minimal-app0.service +systemctl is-active minimal-app0-foo.service + portablectl "${ARGS[@]}" reattach --now --runtime /usr/share/minimal_1.raw minimal-app0 portablectl is-attached minimal-app0