test_xen.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import os
  2. import infra.basetest
  3. class TestXen(infra.basetest.BRTest):
  4. # We have a custom kernel config to reduce build time.
  5. # Our genimage.cfg is inspired from qemu_aarch64_ebbr_defconfig as we boot
  6. # Xen with UEFI.
  7. config = \
  8. """
  9. BR2_aarch64=y
  10. BR2_TOOLCHAIN_EXTERNAL=y
  11. BR2_ROOTFS_POST_IMAGE_SCRIPT="support/testing/tests/package/test_xen/post-image.sh support/scripts/genimage.sh"
  12. BR2_ROOTFS_POST_SCRIPT_ARGS="-c support/testing/tests/package/test_xen/genimage.cfg"
  13. BR2_LINUX_KERNEL=y
  14. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  15. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.9"
  16. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  17. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="support/testing/tests/package/test_xen/linux.config"
  18. BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
  19. BR2_PACKAGE_XEN=y
  20. BR2_PACKAGE_XEN_HYPERVISOR=y
  21. BR2_PACKAGE_XEN_TOOLS=y
  22. BR2_TARGET_ROOTFS_EXT2=y
  23. BR2_TARGET_ROOTFS_EXT2_4=y
  24. BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
  25. # BR2_TARGET_ROOTFS_TAR is not set
  26. BR2_TARGET_UBOOT=y
  27. BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
  28. BR2_TARGET_UBOOT_CUSTOM_VERSION=y
  29. BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2025.01"
  30. BR2_TARGET_UBOOT_BOARD_DEFCONFIG="qemu_arm64"
  31. BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
  32. BR2_TARGET_UBOOT_NEEDS_GNUTLS=y
  33. BR2_PACKAGE_HOST_DOSFSTOOLS=y
  34. BR2_PACKAGE_HOST_GENIMAGE=y
  35. BR2_PACKAGE_HOST_MTOOLS=y
  36. """
  37. def test_run(self):
  38. uboot_bin = os.path.join(self.builddir, "images", "u-boot.bin")
  39. disk_img = os.path.join(self.builddir, "images", "disk.img")
  40. qemu_opts = [
  41. "-bios", uboot_bin,
  42. "-cpu", "cortex-a53",
  43. "-device", "virtio-blk-device,drive=hd0",
  44. "-drive", f"file={disk_img},if=none,format=raw,id=hd0",
  45. "-m", "2G",
  46. "-machine", "virt,gic-version=3,virtualization=on,acpi=off",
  47. "-smp", "2"
  48. ]
  49. # Boot the emulator:
  50. # Qemu Devicetree -> U-Boot -> Xen UEFI -> Linux
  51. self.emulator.boot(arch="aarch64",
  52. options=qemu_opts)
  53. self.emulator.login()
  54. # Avoid double-cooking the terminal, otherwise the test infrastructure
  55. # would not be able to retrieve e.g. return codes properly.
  56. self.assertRunOk("stty raw")
  57. # Verify that we are indeed running under Xen.
  58. self.assertRunOk("xl info")