Skip to content

Commit

Permalink
tests: verify using the target system's grub2-install to install
Browse files Browse the repository at this point in the history
  • Loading branch information
HuijingHei committed Nov 24, 2022
1 parent 94dde18 commit 0bfab01
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/kola/boot/grub2-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Verify to install BIOS/PReP bootloader using grub2-install from
# the target system.
# See:
# - https://github.com/coreos/coreos-assembler/pull/3190
# - https://github.com/coreos/coreos-assembler/issues/3148

## kola:
## # This test should pass everywhere if it passes anywhere.
## platforms: qemu
## # The test is not available for aarch64 and s390x,
## # as aarch64 is UEFI only and s390x is not using grub2
## architectures: "!aarch64 s390x"
set -xeuo pipefail

. $KOLA_EXT_DATA/commonlib.sh

boot_dev=/boot
core=
device=
target=
arch=$(arch)
case ${arch} in
x86_64)
target=i386-pc
core="${boot_dev}/grub2/${target}/core.img"
device=$(findmnt -no SOURCE ${boot_dev} | sed 's/[0-9]$//g')

[ -e ${core} ] || fatal "file ${core} doesn't exist"
core_sum=$(sha256sum ${core} | awk '{print $1}')

mount -o remount,rw ${boot_dev}
grub2-install --target ${target} --boot-directory ${boot_dev} --modules mdraid1x ${device}
;;

ppc64le)
target=powerpc-ieee1275
core="${boot_dev}/grub2/${target}/core.elf"
device=$(findfs PARTLABEL=PowerPC-PReP-boot)

[ -e ${core} ] || fatal "file ${core} doesn't exist"
core_sum=$(sha256sum ${core} | awk '{print $1}')

mount -o remount,rw ${boot_dev}
grub2-install --target ${target} --boot-directory ${boot_dev} --no-nvram ${device}
;;

*)
fatal "grub2-install testing is not supported on ${arch}"
;;
esac

new_core_sum=$(sha256sum ${core} | awk '{print $1}')

# compare core.img checksum before and after run grub2-install
if [ "${core_sum}" != "${new_core_sum}" ]; then
fatal "Error: not using grub2-install from target system"
fi
ok "using grub2-install from target system on ${arch}"

0 comments on commit 0bfab01

Please sign in to comment.