test_flutter.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. "-drive", f"file={img},if=virtio,format=raw"])
  48. self.emulator.login()
  49. # Get the CRC from the current ramebuffer
  50. empty_crc = self.get_n_fb_crc(count=1)[0]
  51. # Start the example App. It can take a bit of time to start,
  52. # so lets try a few times. 600 samples should cover about 10s
  53. # @60Hz (although, the rendering could be much slower on slow
  54. # machines)
  55. self.assertRunOk("systemctl start flutter-markdown-example", timeout=10)
  56. for i in range(600):
  57. gallery_crc = self.get_n_fb_crc(count=1)[0]
  58. if gallery_crc != empty_crc:
  59. break
  60. time.sleep(1)
  61. self.assertNotEqual(gallery_crc, empty_crc, "gallery app did not render anything on screen")
  62. # Stop the application, and check it restored the framebuffer content
  63. self.assertRunOk("systemctl stop flutter-markdown-example", timeout=10)
  64. for i in range(600):
  65. gallery_crc = self.get_n_fb_crc(count=1)[0]
  66. if gallery_crc == empty_crc:
  67. break
  68. time.sleep(1)
  69. self.assertEqual(gallery_crc, empty_crc, "gallery app did not stop rendering")