test_fwts.py 2.8 KB

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