Skip to content

Commit

Permalink
tests: Mount ESP before operations
Browse files Browse the repository at this point in the history
Following coreos/fedora-coreos-config#794,
the ESP will no longer be mounted in /boot. Adjust tests to mount
it before reading from it.
  • Loading branch information
kelvinfan001 authored and openshift-merge-robot committed Jan 5, 2021
1 parent 7149cf3 commit 402bc6c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
7 changes: 5 additions & 2 deletions tests/e2e-adopt/e2e-adopt-in-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' ')

Expand Down
7 changes: 5 additions & 2 deletions tests/e2e-update/e2e-update-in-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/kola/data/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
18 changes: 8 additions & 10 deletions tests/kola/test-bootupd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 402bc6c

Please sign in to comment.