1import os 2 3import infra.basetest 4 5 6class TestFwts(infra.basetest.BRTest): 7 config = \ 8 """ 9 BR2_aarch64=y 10 BR2_TOOLCHAIN_EXTERNAL=y 11 BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 12 BR2_TARGET_ROOTFS_EXT2=y 13 BR2_TARGET_ROOTFS_EXT2_4=y 14 # BR2_TARGET_ROOTFS_TAR is not set 15 BR2_TARGET_ROOTFS_EXT2_SIZE="128M" 16 BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-sbsa/assemble-flash-images support/scripts/genimage.sh" 17 BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/aarch64-sbsa/genimage.cfg" 18 BR2_LINUX_KERNEL=y 19 BR2_LINUX_KERNEL_CUSTOM_VERSION=y 20 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.28" 21 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y 22 BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y 23 BR2_TARGET_EDK2=y 24 BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA=y 25 BR2_TARGET_GRUB2=y 26 BR2_TARGET_GRUB2_ARM64_EFI=y 27 BR2_TARGET_ARM_TRUSTED_FIRMWARE=y 28 BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y 29 BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.9" 30 BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu_sbsa" 31 BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y 32 BR2_PACKAGE_FWTS=y 33 BR2_PACKAGE_FWTS_EFI_RUNTIME_MODULE=y 34 BR2_PACKAGE_HOST_GENIMAGE=y 35 BR2_PACKAGE_HOST_DOSFSTOOLS=y 36 BR2_PACKAGE_HOST_MTOOLS=y 37 """ 38 39 def test_run(self): 40 hda = os.path.join(self.builddir, "images", "disk.img") 41 flash0 = os.path.join(self.builddir, "images", "SBSA_FLASH0.fd") 42 flash1 = os.path.join(self.builddir, "images", "SBSA_FLASH1.fd") 43 self.emulator.boot(arch="aarch64", 44 options=["-M", "sbsa-ref", 45 "-cpu", "cortex-a57", 46 "-m", "512M", 47 "-pflash", flash0, 48 "-pflash", flash1, 49 "-hda", hda]) 50 self.emulator.login() 51 52 # Check the program can execute. 53 self.assertRunOk("fwts --version") 54 55 # We run a simple UEFI runtime service variable interface test 56 # suite. Those tests are using the fwts efi_runtime kernel 57 # module. 58 self.assertRunOk("fwts -q uefirtvariable", timeout=30) 59 60 # The previous fwts invocation is expected to have created a 61 # "results.log" report. We check the file exists and contains 62 # a known header string. 63 expected_str = "Results generated by fwts:" 64 cmd = f"grep -F '{expected_str}' results.log" 65 out, ret = self.emulator.run(cmd) 66 self.assertEqual(ret, 0) 67 self.assertTrue(out[0].startswith(expected_str)) 68