test_flutter.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import os
  2. import time
  3. import infra.basetest
  4. from ..graphics_base import GraphicsBase
  5. class TestFlutter(infra.basetest.BRTest, GraphicsBase):
  6. config = f"""
  7. BR2_aarch64=y
  8. BR2_TOOLCHAIN_EXTERNAL=y
  9. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
  10. BR2_ROOTFS_OVERLAY="{infra.filepath("tests/package/test_flutter/overlay")}"
  11. BR2_PER_PACKAGE_DIRECTORIES=y
  12. BR2_INIT_SYSTEMD=y
  13. BR2_LINUX_KERNEL=y
  14. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  15. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.54"
  16. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  17. BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
  18. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  19. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{infra.filepath("tests/package/test_flutter/linux-vkms.fragment")}"
  20. BR2_PACKAGE_LIBDRM=y
  21. BR2_PACKAGE_MESA3D=y
  22. BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SOFTPIPE=y
  23. BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VIRGL=y
  24. BR2_PACKAGE_MESA3D_OPENGL_ES=y
  25. BR2_PACKAGE_FLUTTER_PI=y
  26. BR2_PACKAGE_FLUTTER_PI_RAW_KEYBOARD_PLUGIN=y
  27. BR2_PACKAGE_FLUTTER_PI_TEXT_INPUT_PLUGIN=y
  28. BR2_PACKAGE_FLUTTER_PACKAGES=y
  29. BR2_PACKAGE_FLUTTER_MARKDOWN_EXAMPLE=y
  30. BR2_PACKAGE_FLUTTER_ENGINE=y
  31. BR2_TARGET_ROOTFS_EXT2=y
  32. BR2_TARGET_ROOTFS_EXT2_4=y
  33. BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
  34. # BR2_TARGET_ROOTFS_TAR is not set
  35. """
  36. def test_run(self):
  37. img = os.path.join(self.builddir, "images", "rootfs.ext2")
  38. kern = os.path.join(self.builddir, "images", "Image")
  39. self.emulator.boot(
  40. arch="aarch64",
  41. kernel=kern,
  42. kernel_cmdline=["root=/dev/vda console=ttyAMA0 vt.global_cursor_default=0"],
  43. options=["-M", "virt",
  44. "-cpu", "cortex-a57",
  45. "-m", "512M",
  46. "-smp", "4",
  47. "-vga", "std",
  48. "-vnc", "none",
  49. "-drive", f"file={img},if=virtio,format=raw"])
  50. self.emulator.login()
  51. # Get the CRC from the current ramebuffer
  52. empty_crc = self.get_n_fb_crc(count=1)[0]
  53. # Start the example App. It can take a bit of time to start,
  54. # so lets try a few times. 600 samples should cover about 10s
  55. # @60Hz (although, the rendering could be much slower on slow
  56. # machines)
  57. self.assertRunOk("systemctl start flutter-markdown-example", timeout=10)
  58. for i in range(600):
  59. gallery_crc = self.get_n_fb_crc(count=1)[0]
  60. if gallery_crc != empty_crc:
  61. break
  62. time.sleep(1)
  63. self.assertNotEqual(gallery_crc, empty_crc, "gallery app did not render anything on screen")
  64. # Stop the application, and check it restored the framebuffer content
  65. self.assertRunOk("systemctl stop flutter-markdown-example", timeout=10)
  66. for i in range(600):
  67. gallery_crc = self.get_n_fb_crc(count=1)[0]
  68. if gallery_crc == empty_crc:
  69. break
  70. time.sleep(1)
  71. self.assertEqual(gallery_crc, empty_crc, "gallery app did not stop rendering")