test_libjxl.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import os
  2. import infra.basetest
  3. class TestLibJXL(infra.basetest.BRTest):
  4. # infra.basetest.BASIC_TOOLCHAIN_CONFIG is not used as it is armv5
  5. # and the image encoding would take too long (several minutes).
  6. # We also add GraphicsMagick to generate and compare images for
  7. # the test.
  8. config = \
  9. """
  10. BR2_aarch64=y
  11. BR2_TOOLCHAIN_EXTERNAL=y
  12. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  13. BR2_LINUX_KERNEL=y
  14. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  15. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.79"
  16. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  17. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  18. BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
  19. BR2_TARGET_ROOTFS_CPIO=y
  20. BR2_TARGET_ROOTFS_CPIO_GZIP=y
  21. # BR2_TARGET_ROOTFS_TAR is not set
  22. BR2_PACKAGE_GRAPHICSMAGICK=y
  23. BR2_PACKAGE_LIBJXL=y
  24. """
  25. def test_run(self):
  26. img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
  27. kern = os.path.join(self.builddir, "images", "Image")
  28. self.emulator.boot(arch="aarch64",
  29. kernel=kern,
  30. kernel_cmdline=["console=ttyAMA0"],
  31. options=["-M", "virt", "-cpu", "cortex-a57", "-m", "256M", "-initrd", img])
  32. self.emulator.login()
  33. ref = "/var/tmp/reference.ppm"
  34. jxl = "/var/tmp/encoded.jxl"
  35. dec = "/var/tmp/decoded.ppm"
  36. cmd = "gm convert IMAGE:LOGO {}".format(ref)
  37. self.assertRunOk(cmd)
  38. cmd = "cjxl {} {}".format(ref, jxl)
  39. self.assertRunOk(cmd, timeout=30)
  40. cmd = "djxl {} {}".format(jxl, dec)
  41. self.assertRunOk(cmd)
  42. cmd = "gm compare -metric mse -maximum-error 1e-3 {} {}".format(
  43. ref, dec)
  44. self.assertRunOk(cmd)