From 402bc6ca6a84023a87c607e772861be52e168a5c Mon Sep 17 00:00:00 2001 From: Kelvin Fan Date: Thu, 24 Dec 2020 11:16:16 -0500 Subject: [PATCH] tests: Mount ESP before operations Following https://github.com/coreos/fedora-coreos-config/pull/794, the ESP will no longer be mounted in /boot. Adjust tests to mount it before reading from it. --- tests/e2e-adopt/e2e-adopt-in-vm.sh | 7 +++++-- tests/e2e-update/e2e-update-in-vm.sh | 7 +++++-- tests/kola/data/libtest.sh | 8 ++++++++ tests/kola/test-bootupd | 18 ++++++++---------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/tests/e2e-adopt/e2e-adopt-in-vm.sh b/tests/e2e-adopt/e2e-adopt-in-vm.sh index 9d90d4a9..76cd800e 100755 --- a/tests/e2e-adopt/e2e-adopt-in-vm.sh +++ b/tests/e2e-adopt/e2e-adopt-in-vm.sh @@ -80,10 +80,13 @@ if test "$semode" != Enforcing; then fatal "SELinux mode is ${semode}" fi -source_grub_cfg=$(find /boot/efi/EFI -name grub.cfg) +# Mount the EFI partition. +tmpefimount=$(mount_tmp_efi) + +source_grub_cfg=$(find ${tmpefimount}/EFI -name grub.cfg) test -f "${source_grub_cfg}" -source_grub=$(find /boot/efi/EFI -name grubx64.efi) +source_grub=$(find ${tmpefimount}/EFI -name grubx64.efi) test -f ${source_grub} source_grub_sha256=$(sha256sum ${source_grub} | cut -f 1 -d ' ') diff --git a/tests/e2e-update/e2e-update-in-vm.sh b/tests/e2e-update/e2e-update-in-vm.sh index b2cb6b0c..ac3340a2 100755 --- a/tests/e2e-update/e2e-update-in-vm.sh +++ b/tests/e2e-update/e2e-update-in-vm.sh @@ -64,12 +64,15 @@ bootupctl status --print-if-available > out.txt assert_file_has_content_literal 'out.txt' 'Updates available: EFI' ok update avail -assert_not_has_file /boot/efi/EFI/fedora/test-bootupd.efi +# Mount the EFI partition. +tmpefimount=$(mount_tmp_efi) + +assert_not_has_file ${tmpefimount}/EFI/fedora/test-bootupd.efi bootupctl update | tee out.txt assert_file_has_content out.txt "Updated EFI: ${TARGET_GRUB_PKG}.*,test-bootupd-payload-1.0" -assert_file_has_content /boot/efi/EFI/fedora/test-bootupd.efi test-payload +assert_file_has_content ${tmpefimount}/EFI/fedora/test-bootupd.efi test-payload bootupctl status --print-if-available > out.txt if test -s out.txt; then diff --git a/tests/kola/data/libtest.sh b/tests/kola/data/libtest.sh index 91e61f35..cc19f461 100644 --- a/tests/kola/data/libtest.sh +++ b/tests/kola/data/libtest.sh @@ -81,3 +81,11 @@ assert_not_file_has_content_literal () { done } +# Mount the EFI partition at a temporary location. +efipart=/dev/disk/by-partlabel/EFI-SYSTEM +mount_tmp_efi () { + tmpmount=$(mktemp -d) + mkdir -p ${tmpmount} + mount ${efipart} ${tmpmount} + echo ${tmpmount} +} diff --git a/tests/kola/test-bootupd b/tests/kola/test-bootupd index ee0a6543..13fac40b 100755 --- a/tests/kola/test-bootupd +++ b/tests/kola/test-bootupd @@ -19,9 +19,10 @@ function cleanup () { fi } +# Mount the EFI partition. +tmpefimount=$(mount_tmp_efi) bootmount=/boot -bootefimount=${bootmount}/efi -bootefidir=${bootefimount}/EFI +tmpefidir=${tmpefimount}/EFI bootupdir=/usr/lib/bootupd/updates efiupdir=${bootupdir}/EFI ostbaseefi=/usr/lib/ostree-boot/efi/EFI @@ -103,24 +104,21 @@ bootupctl validate | tee out.txt ok validate after update # FIXME see above -# assert_file_has_content ${bootefidir}/${efisubdir}/somenew.efi 'somenewfile' -if test -f ${bootefidir}/${efisubdir}/shim.efi; then +# assert_file_has_content ${tmpefidir}/${efisubdir}/somenew.efi 'somenewfile' +if test -f ${tmpefidir}/${efisubdir}/shim.efi; then fatal "failed to remove file" fi -if ! grep -q 'bootupd-test-changes' ${bootefidir}/${efisubdir}/grubx64.efi; then +if ! grep -q 'bootupd-test-changes' ${tmpefidir}/${efisubdir}/grubx64.efi; then fatal "failed to update modified file" fi -cmp ${bootefidir}/${efisubdir}/shimx64.efi ${efiupdir}/${efisubdir}/shimx64.efi +cmp ${tmpefidir}/${efisubdir}/shimx64.efi ${efiupdir}/${efisubdir}/shimx64.efi ok filesystem changes bootupctl update | tee out.txt assert_file_has_content_literal out.txt 'No update available for any component' assert_not_file_has_content_literal out.txt 'Updated EFI' -# Ensure /boot and /boot/efi can be written to -mount -o remount,rw ${bootmount} -mount -o remount,rw ${bootefimount} -echo "some additions" >> ${bootefidir}/${efisubdir}/shimx64.efi +echo "some additions" >> ${tmpefidir}/${efisubdir}/shimx64.efi if bootupctl validate 2>err.txt; then fatal "unexpectedly passed validation" fi