From: Luca Boccassi Date: Sun, 27 Jul 2025 12:16:23 +0000 (+0100) Subject: test: preserve ESP when testing bootctl X-Git-Tag: v258-rc2~53^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b61bff3436b1f04978983739cf5c1aeb7f618e75;p=thirdparty%2Fsystemd.git test: preserve ESP when testing bootctl --- diff --git a/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh b/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh index 5f12313a840..0f5f45b3d8b 100755 --- a/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh +++ b/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh @@ -21,7 +21,42 @@ fi (! systemd-detect-virt -cq) +restore_esp() { + if [ ! -d /tmp/esp.bak ]; then + return + fi + + if [ -d /tmp/esp.bak/EFI/ ]; then + cp -r /tmp/esp.bak/EFI/* "$(bootctl --print-esp-path)/EFI/" + fi + if [ -d /tmp/esp.bak/loader/ ]; then + cp -r /tmp/esp.bak/loader/* "$(bootctl --print-esp-path)/loader/" + fi + rm -rf /tmp/esp.bak +} + +backup_esp() { + if [ -d /tmp/esp.bak ]; then + return + fi + + if [[ -d "$(bootctl --print-esp-path)/EFI" ]]; then + mkdir -p /tmp/esp.bak + cp -r "$(bootctl --print-esp-path)/EFI/" /tmp/esp.bak/ + fi + if [[ -d "$(bootctl --print-esp-path)/loader" ]]; then + mkdir -p /tmp/esp.bak + cp -r "$(bootctl --print-esp-path)/loader/" /tmp/esp.bak/ + fi +} + basic_tests() { + # Ensure the system's ESP (no --image/--root args) is still available for the next tests + if [ $# -eq 0 ]; then + backup_esp + trap restore_esp RETURN ERR + fi + bootctl "$@" --help bootctl "$@" --version @@ -274,6 +309,10 @@ testcase_bootctl_varlink() { } testcase_bootctl_secure_boot_auto_enroll() { + # mkosi can also add keys here, so back them up and restored them + backup_esp + trap restore_esp RETURN ERR + cat >/tmp/openssl.conf <