test_openjdk.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import infra.basetest
  3. class TestOpenJdk(infra.basetest.BRTest):
  4. br2_external = [infra.filepath("tests/package/br2-external/openjdk")]
  5. config = \
  6. """
  7. BR2_aarch64=y
  8. BR2_TOOLCHAIN_EXTERNAL=y
  9. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  10. BR2_LINUX_KERNEL=y
  11. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  12. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.10.34"
  13. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  14. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  15. BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
  16. BR2_TARGET_ROOTFS_CPIO=y
  17. BR2_TARGET_ROOTFS_CPIO_GZIP=y
  18. BR2_PACKAGE_XORG7=y
  19. BR2_PACKAGE_OPENJDK=y
  20. BR2_PACKAGE_OPENJDK_HELLO_WORLD=y
  21. BR2_PACKAGE_OPENJDK_JNI_TEST=y
  22. """
  23. def login(self):
  24. img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
  25. kern = os.path.join(self.builddir, "images", "Image")
  26. self.emulator.boot(arch="aarch64",
  27. kernel=kern,
  28. kernel_cmdline=["console=ttyAMA0"],
  29. options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M", "-initrd", img])
  30. self.emulator.login()
  31. def test_run(self):
  32. self.login()
  33. cmd = "java -cp /usr/bin HelloWorld"
  34. output, exit_code = self.emulator.run(cmd, 120)
  35. print(output)
  36. self.assertEqual(exit_code, 0)
  37. self.assertEqual(output, ["Hello, World"])
  38. cmd = "java -cp /usr/bin JniTest"
  39. output, exit_code = self.emulator.run(cmd, 120)
  40. print(output)
  41. self.assertEqual(exit_code, 0)