test_python_pyqt5.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import os
  2. import infra.basetest
  3. class TestPythonPyQt5(infra.basetest.BRTest):
  4. # We use a specific configuration for:
  5. # - using Aarch64, to have more than 256MB memory,
  6. # - using a kernel config fragment, to enable VKMS,
  7. # - to have an ext4 rootfs image exposed as a virtio storage
  8. # (rather than cpio initrd). This will save some memory, as the
  9. # rootfs image is big.
  10. kernel_fragment = \
  11. infra.filepath("tests/package/test_python_pyqt5/linux-vkms.fragment")
  12. rootfs_overlay = \
  13. infra.filepath("tests/package/test_python_pyqt5/rootfs-overlay")
  14. config = \
  15. f"""
  16. BR2_aarch64=y
  17. BR2_TOOLCHAIN_EXTERNAL=y
  18. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  19. BR2_LINUX_KERNEL=y
  20. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  21. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.81"
  22. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  23. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  24. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kernel_fragment}"
  25. BR2_PACKAGE_DEJAVU=y
  26. BR2_PACKAGE_LIBDRM=y
  27. BR2_PACKAGE_MESA3D=y
  28. BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SOFTPIPE=y
  29. BR2_PACKAGE_MESA3D_LLVM=y
  30. BR2_PACKAGE_MESA3D_OPENGL_EGL=y
  31. BR2_PACKAGE_MESA3D_OPENGL_ES=y
  32. BR2_PACKAGE_PYTHON3=y
  33. BR2_PACKAGE_PYTHON_PYQT5=y
  34. BR2_PACKAGE_QT5=y
  35. BR2_PACKAGE_QT5BASE_EGLFS=y
  36. BR2_PACKAGE_QT5BASE_FONTCONFIG=y
  37. BR2_PACKAGE_QT5BASE_WIDGETS=y
  38. BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
  39. BR2_TARGET_ROOTFS_EXT2=y
  40. BR2_TARGET_ROOTFS_EXT2_4=y
  41. BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
  42. # BR2_TARGET_ROOTFS_TAR is not set
  43. """
  44. def test_run(self):
  45. drive = os.path.join(self.builddir, "images", "rootfs.ext4")
  46. kern = os.path.join(self.builddir, "images", "Image")
  47. self.emulator.boot(arch="aarch64",
  48. kernel=kern,
  49. kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
  50. options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M",
  51. "-drive", f"file={drive},if=virtio,format=raw"])
  52. self.emulator.login()
  53. # We run the test application with a customized message.
  54. # NOTE: to manually debug this test, a Qemu emulator with
  55. # virtio-gpu can be used by starting it the command line from
  56. # the run log generated by this test, and by adding the
  57. # arguments "-device virtio-gpu -display gtk". With this, the
  58. # test application will be observable on the Qemu window. Once
  59. # logged, we can use the "card1" DRM/KMS device (virtio-gpu,
  60. # instead of card0, which is vkms on "card0") by using the
  61. # command:
  62. # echo '{"device":"/dev/dri/card1"}' > cfg.json
  63. # export QT_QPA_EGLFS_KMS_CONFIG="$PWD/cfg.json"
  64. # The Qt debug can also be enabled with the command:
  65. # export QT_LOGGING_RULES=*=true
  66. # Then, run the /root/pyqt5test.py application.
  67. msg = "Hello Buildroot."
  68. cmd = f'/root/pyqt5test.py "{msg}"'
  69. self.assertRunOk(cmd, timeout=30)
  70. # We check the test message is present in the file created by
  71. # the previous application execution.
  72. cmd = f'grep -F "{msg}" /root/message.txt'
  73. self.assertRunOk(cmd)