Skip to content

Commit

Permalink
Add test for UEFI entry insertion from bootupd
Browse files Browse the repository at this point in the history
The rpm-ostree-container installations will by default install an UEFI
entry which did not happened before. However, if leavebootorder is set
it shouldn't happen.

Test this by extending rpm-ostree-container-bootc test with check for
UEFI entry and adding a new test which will add
`bootloader --leavebootorder`.

This works only for Fedora Rawhide so far but it will be backported to
RHEL-9 and RHEL-10.
  • Loading branch information
jkonecny12 committed Jul 19, 2024
1 parent a790079 commit 0dba74e
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rpm-ostree-container-bootc.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ reboot
# Validate on the first boot.
%ksappend validation/success_on_first_boot.ks

%post
# Test if new entry was created in efibootmgr
# This functionality is available on Fedora-Rawhide only so far:
# RHEL-9 enablement issue: https://issues.redhat.com/browse/RHEL-48837
# RHEL-10 enablement issue: https://issues.redhat.com/browse/RHEL-48821

# Check that there is new efibootmgr entry on the first disk created
if [ "@KSTEST_OS_NAME@" == "fedora" ]; then
efibootmgr | grep "Boot0001" | grep "HD(1"
if [ $? -ne 0 ]; then
echo -e "EFI boot entry wasn't created properly:\n$(efibootmgr)" >> /root/RESULT
fi
fi
%end

%post

# Checks after boot
Expand Down
4 changes: 4 additions & 0 deletions rpm-ostree-container-bootc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ TESTTYPE="payload ostree bootc reboot skip-on-rhel-8"

. ${KSTESTDIR}/functions.sh

enable_uefi() {
echo "true"
}

copy_interesting_files_from_system() {
local disksdir
disksdir="${1}"
Expand Down
40 changes: 40 additions & 0 deletions rpm-ostree-container-leavebootorder.ks.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#test name: rpm-ostree-container-bootorder
# https://github.com/rhinstaller/anaconda/pull/5399
#
# Test that ostree container installation works with leavebootorder.
# In this test bootupd should be able to do dualboot. For sanity
# of this test just check if bootupd is invoked with the correct
# arguments.
#

# Use the default settings.
%ksappend common/common.ks

# network
network --bootproto=dhcp
# l10n
keyboard us
lang en
timezone America/New_York
# user confguration
rootpw testcase

# On Fedora enforce lvm scheme (overriding btrfs default)
%ksappend storage/ostreecontainer_autopart.ks

# Test if UEFI entry is not created!
bootloader --leavebootorder --timeout 1

ostreecontainer --no-signature-verification --remote=test-remote --stateroot=test-stateroot --url=@KSTEST_OSTREECONTAINER_URL@


%post
# check if efibootmgr don't have entry to boot from a disk
efibootmgr | grep "HD("
if [ $? -eq 0 ]; then
echo "EFI boot entry was created with leavebootorder: $(efibootmgr)" >> /root/RESULT
fi

%ksappend validation/success_if_result_empty.ks

%end
71 changes: 71 additions & 0 deletions rpm-ostree-container-leavebootorder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#

# Ignore unused variable parsed out by tooling scripts as test tags metadata
# shellcheck disable=SC2034
TESTTYPE="payload ostree bootc reboot skip-on-rhel-8"

. ${KSTESTDIR}/functions.sh

enable_uefi() {
echo "true"
}

copy_interesting_files_from_system() {
local disksdir
disksdir="${1}"

# Find disks.
local args
args=$(for d in ${disksdir}/disk-*img; do echo -a ${d}; done)

# Use also iscsi disk if there is any.
if [[ -n ${iscsi_disk_img} ]]; then
args="${args} -a ${disksdir}/${iscsi_disk_img}"
fi

# Grab files out of the installed system while it still exists.
# Grab these files:
#
# logs from Anaconda - whole /var/log/anaconda/ directory is copied out,
# this can be used for saving specific test output
# original-ks.cfg - the kickstart used for the test
# anaconda-ks.cfg - the kickstart saved after installation, useful for
# debugging
# RESULT - file from the test
#
# The location of aforementioned files is different in an ostree system

root_device=$(guestfish ${args} <<< "
launch
lvs" | \
grep root)

for item in /ostree/deploy/test-stateroot/var/roothome/original-ks.cfg \
/ostree/deploy/test-stateroot/var/roothome/anaconda-ks.cfg \
/ostree/deploy/test-stateroot/var/roothome/anabot.log \
/ostree/deploy/test-stateroot/var/log/anaconda/ \
/ostree/deploy/test-stateroot/var/roothome/RESULT
do
guestfish ${args} <<< "
launch
mount ${root_device} /
copy-out '${item}' '${disksdir}'
" 2>/dev/null
done
}

0 comments on commit 0dba74e

Please sign in to comment.