diff --git a/support/testing/tests/boot/test_grub.py b/support/testing/tests/boot/test_grub.py index c6e86f7b71..5cbc7fd22b 100644 --- a/support/testing/tests/boot/test_grub.py +++ b/support/testing/tests/boot/test_grub.py @@ -238,3 +238,75 @@ class TestGrubAArch64EFI(infra.basetest.BRTest): cmd = "efivar -l" self.assertRunOk(cmd) + + +class TestGrubRiscV64EFI(infra.basetest.BRTest): + scripts = [ + "board/qemu/post-image.sh", + "board/qemu/riscv64-virt-efi/assemble-flash-images", + "support/scripts/genimage.sh" + ] + post_image_script = " ".join(scripts) + config = \ + f""" + BR2_riscv=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_ROOTFS_POST_IMAGE_SCRIPT="{post_image_script}" + BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/riscv64-virt-efi/genimage.cfg" + BR2_LINUX_KERNEL=y + BR2_LINUX_KERNEL_CUSTOM_VERSION=y + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.59" + BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y + BR2_PACKAGE_EFIVAR=y + BR2_TARGET_ROOTFS_EXT2=y + # BR2_TARGET_ROOTFS_TAR is not set + BR2_TARGET_EDK2=y + BR2_TARGET_GRUB2=y + BR2_TARGET_GRUB2_RISCV64_EFI=y + BR2_PACKAGE_HOST_DOSFSTOOLS=y + BR2_PACKAGE_HOST_GENIMAGE=y + BR2_PACKAGE_HOST_MTOOLS=y + BR2_PACKAGE_HOST_QEMU=y + BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y + """ + + def __init__(self, names): + """Setup common test variables.""" + super(TestGrubRiscV64EFI, self).__init__(names) + """All EDK2 releases <= edk2-stable202408 can't be fetched from git + anymore due to a missing git submodule as reported by [1]. + + Usually Buildroot fall-back using https://sources.buildroot.net + thanks to BR2_BACKUP_SITE where a backup of the generated archive + is available. But the BRConfigTest remove BR2_BACKUP_SITE default + value while generating the .config used by TestGrubAArch64EFI. + + Replace the BR2_BACKUP_SITE override from BRConfigTest in order + to continue testing EDK2 package using the usual backup site. + + To be removed with the next EDK2 version bump using this commit + [2]. + + [1] https://github.com/tianocore/edk2/issues/6398 + [2] https://github.com/tianocore/edk2/commit/95d8a1c255cfb8e063d679930d08ca6426eb5701 + """ + self.config = self.config.replace('BR2_BACKUP_SITE=""\n', '') + + def test_run(self): + disk = os.path.join(self.builddir, "images", "disk.img") + flash0 = os.path.join(self.builddir, "images", "RISCV_VIRT_CODE.fd") + flash1 = os.path.join(self.builddir, "images", "RISCV_VIRT_VARS.fd") + qemu_opts = [ + "-M", "virt,pflash0=pflash0,pflash1=pflash1,acpi=off", + "-blockdev", f"node-name=pflash0,driver=file,read-only=on,filename={flash0}", + "-blockdev", f"node-name=pflash1,driver=file,filename={flash1}", + "-drive", f"file={disk},format=raw,if=virtio" + ] + self.emulator.boot(arch="riscv64", options=qemu_opts) + self.emulator.login() + + cmd = "mount -t efivarfs none /sys/firmware/efi/efivars" + self.assertRunOk(cmd) + + cmd = "efivar -l" + self.assertRunOk(cmd)