support/testing/tests/boot: new test cases for Grub
This commit adds four test cases for Grub: - Grub i386 legacy BIOS - Grub i386 UEFI - Grub x86-64 UEFI - Grub AArch64 UEFI There is some overlap with the ISO9660 filesystem test cases, some of which use Grub, but we found it relevant to have separate test cases for Grub, which were useful to test Grub in non-ISO9660 situations. The Grub ARM UEFI case is not tested, as it requires Grub to be chain-loaded by U-Boot. Implementing this test case is left as an exercise for the reader. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> [yann.morin.1998@free.fr: - use EDK2 to build the OVMF blurbs from source, instead of the binary blobs - add host-dosfstools ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
parent
13bb419938
commit
7dcd979098
@ -2871,6 +2871,8 @@ F: package/squashfs/
|
||||
F: package/tinifier/
|
||||
F: package/wayland/
|
||||
F: package/weston/
|
||||
F: support/testing/tests/boot/test_grub.py
|
||||
F: support/testing/tests/boot/test_grub/
|
||||
F: support/testing/tests/boot/test_syslinux.py
|
||||
F: support/testing/tests/package/sample_python_augeas.py
|
||||
F: support/testing/tests/package/sample_python_flask.py
|
||||
|
156
support/testing/tests/boot/test_grub.py
Normal file
156
support/testing/tests/boot/test_grub.py
Normal file
@ -0,0 +1,156 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestGrubi386BIOS(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_x86_core2=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_CORE2_UCLIBC_STABLE=y
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh {}"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-bios.cfg"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config"
|
||||
BR2_LINUX_KERNEL_INSTALL_TARGET=y
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_I386_PC=y
|
||||
BR2_TARGET_GRUB2_INSTALL_TOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
""".format(infra.filepath("tests/boot/test_grub/post-build.sh"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
self.emulator.boot(arch="i386", options=["-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
|
||||
class TestGrubi386EFI(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_x86_core2=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_CORE2_UCLIBC_STABLE=y
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh {}"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image-efi.sh"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config"
|
||||
BR2_LINUX_KERNEL_INSTALL_TARGET=y
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_PACKAGE_EFIVAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_I386_EFI=y
|
||||
BR2_TARGET_GRUB2_INSTALL_TOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
""".format(infra.filepath("tests/boot/test_grub/post-build.sh"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
bios = os.path.join(self.builddir, "images", "OVMF.fd")
|
||||
self.emulator.boot(arch="i386", options=["-bios", bios, "-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "modprobe efivarfs"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "mount -t efivarfs none /sys/firmware/efi/efivars"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "efivar -l"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
|
||||
class TestGrubX8664EFI(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_x86_64=y
|
||||
BR2_x86_corei7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_UCLIBC_STABLE=y
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh {}"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image-efi.sh"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config"
|
||||
BR2_LINUX_KERNEL_INSTALL_TARGET=y
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_PACKAGE_EFIVAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_X86_64_EFI=y
|
||||
BR2_TARGET_GRUB2_INSTALL_TOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
""".format(infra.filepath("tests/boot/test_grub/post-build.sh"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
bios = os.path.join(self.builddir, "images", "OVMF.fd")
|
||||
self.emulator.boot(arch="x86_64", options=["-bios", bios, "-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "modprobe efivarfs"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "mount -t efivarfs none /sys/firmware/efi/efivars"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "efivar -l"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
|
||||
class TestGrubAArch64EFI(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="{post_image}"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.18"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
|
||||
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{linux_fragment}"
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_PACKAGE_EFIVAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
""".format(post_image=infra.filepath("tests/boot/test_grub/post-image-aarch64-efi.sh"),
|
||||
linux_fragment=infra.filepath("tests/boot/test_grub/linux-aarch64-efi.config"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
bios = os.path.join(self.builddir, "images", "QEMU_EFI.fd")
|
||||
self.emulator.boot(arch="aarch64", options=["-M", "virt", "-cpu", "cortex-a53", "-bios", bios, "-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "modprobe efivarfs"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "mount -t efivarfs none /sys/firmware/efi/efivars"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "efivar -l"
|
||||
self.assertRunOk(cmd)
|
@ -0,0 +1,32 @@
|
||||
image efi-part.vfat {
|
||||
vfat {
|
||||
file EFI {
|
||||
image = "efi-part/EFI"
|
||||
}
|
||||
|
||||
file Image {
|
||||
image = "Image"
|
||||
}
|
||||
}
|
||||
|
||||
size = 16352K # 16MB - 32KB
|
||||
}
|
||||
|
||||
image disk.img {
|
||||
hdimage {
|
||||
partition-table-type = "gpt"
|
||||
}
|
||||
|
||||
partition boot {
|
||||
image = "efi-part.vfat"
|
||||
partition-type-uuid = c12a7328-f81f-11d2-ba4b-00a0c93ec93b
|
||||
offset = 32K
|
||||
bootable = true
|
||||
}
|
||||
|
||||
partition root {
|
||||
partition-type-uuid = 44479540-f297-41b2-9af7-d131d5f0458a
|
||||
partition-uuid = UUID_TMP
|
||||
image = "rootfs.ext2"
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
set default="0"
|
||||
set timeout="5"
|
||||
|
||||
menuentry "Buildroot" {
|
||||
linux /Image root=PARTUUID=UUID_TMP rootwait console=ttyAMA0
|
||||
}
|
@ -0,0 +1 @@
|
||||
CONFIG_ACPI=y
|
7
support/testing/tests/boot/test_grub/post-build.sh
Executable file
7
support/testing/tests/boot/test_grub/post-build.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -d "$BINARIES_DIR/efi-part/" ]; then
|
||||
sed -i 's%tty1%ttyS0,115200%' "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg"
|
||||
else
|
||||
sed -i 's%tty1%ttyS0,115200%' "$TARGET_DIR/boot/grub/grub.cfg"
|
||||
fi
|
8
support/testing/tests/boot/test_grub/post-image-aarch64-efi.sh
Executable file
8
support/testing/tests/boot/test_grub/post-image-aarch64-efi.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
UUID=$(dumpe2fs "$BINARIES_DIR/rootfs.ext2" 2>/dev/null | sed -n 's/^Filesystem UUID: *\(.*\)/\1/p')
|
||||
sed "s/UUID_TMP/$UUID/g" support/testing/tests/boot/test_grub/grub-aarch64-efi.cfg > "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg"
|
||||
sed "s/UUID_TMP/$UUID/g" support/testing/tests/boot/test_grub/genimage-aarch64-efi.cfg > "$BINARIES_DIR/genimage-aarch64-efi.cfg"
|
||||
support/scripts/genimage.sh -c "$BINARIES_DIR/genimage-aarch64-efi.cfg"
|
Loading…
Reference in New Issue
Block a user