forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: extend bootupd test to include testing adoption and updates
- Loading branch information
1 parent
3335d68
commit fc4828a
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
## kola: | ||
## description: Extend bootupd test to include testing adoption and updates. | ||
|
||
# See https://github.com/coreos/fedora-coreos-tracker/issues/1788#issuecomment-2326473398 | ||
# Steps: | ||
# Overwrite an existing file in the ESP | ||
# Verify that bootupctl validate now fails | ||
# Remove /boot/bootupd-state.json | ||
# Adopt / update again | ||
# Verify that validate is successful | ||
|
||
set -xeuo pipefail | ||
|
||
# shellcheck disable=SC1091 | ||
. "$KOLA_EXT_DATA/commonlib.sh" | ||
|
||
overwrite= | ||
# only x64 and aarch64 have esp device | ||
overwrite_file() { | ||
case "$(arch)" in | ||
x86_64|aarch64) | ||
local efi_dev=$(realpath /dev/disk/by-partlabel/EFI-SYSTEM) | ||
if [ ! -b "${efi_dev}" ]; then | ||
fatal "can not find ${efi_dev}" | ||
fi | ||
mount "${efi_dev}" /boot/efi | ||
local shim_file=$(find /boot/efi -name shim.efi) | ||
if [ -z "${shim_file}" ]; then | ||
fatal "can not find ${shim_file}" | ||
fi | ||
echo test > "${shim_file}" | ||
umount "${efi_dev}" | ||
overwrite=1 | ||
;; | ||
*) | ||
echo "skipped" | ||
;; | ||
esac | ||
} | ||
|
||
adopt_and_update() { | ||
local state_file="/boot/bootupd-state.json" | ||
if [ -f "${state_file}" ]; then | ||
mount -o remount,rw /boot | ||
rm -f ${state_file} | ||
bootupctl adopt-and-update | grep "Adopted and updated.*" | ||
[ ! -f "${state_file}" ] && fatal "Should find ${state_file}" | ||
mount -o remount,ro /boot | ||
fi | ||
} | ||
|
||
validate() { | ||
local msg_efi="Validated: EFI" | ||
local msg_bios="Skipped: BIOS" | ||
|
||
case "$(arch)" in | ||
x86_64) | ||
bootupctl validate | grep "${msg_bios}" | ||
bootupctl validate | grep "${msg_efi}" | ||
;; | ||
aarch64) | ||
bootupctl validate | grep "${msg_efi}" | ||
;; | ||
ppc64le) | ||
bootupctl validate | grep "${msg_bios}" | ||
;; | ||
*) | ||
echo "skipped" | ||
;; | ||
esac | ||
} | ||
|
||
overwrite_file | ||
if [ -n "${overwrite}" ] && bootupctl validate 2>&1; then | ||
fatal "bootupctl validate failed as expected" | ||
fi | ||
|
||
# skip this when there is fixed bootupd >= 0.2.22 | ||
systemctl reset-failed bootupd.service | ||
|
||
adopt_and_update | ||
validate | ||
|
||
ok bootupctl adopt and update |