xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/test_openjdk.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import os
2
3import infra.basetest
4
5
6class TestOpenJdk(infra.basetest.BRTest):
7    br2_external = [infra.filepath("tests/package/br2-external/openjdk")]
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.10.34"
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_PACKAGE_XORG7=y
22        BR2_PACKAGE_OPENJDK=y
23        BR2_PACKAGE_OPENJDK_HELLO_WORLD=y
24        BR2_PACKAGE_OPENJDK_JNI_TEST=y
25        """
26
27    def login(self):
28        img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
29        kern = os.path.join(self.builddir, "images", "Image")
30        self.emulator.boot(arch="aarch64",
31                           kernel=kern,
32                           kernel_cmdline=["console=ttyAMA0"],
33                           options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M", "-initrd", img])
34        self.emulator.login()
35
36    def test_run(self):
37        self.login()
38
39        cmd = "java -cp /usr/bin HelloWorld"
40        output, exit_code = self.emulator.run(cmd, 120)
41        print(output)
42        self.assertEqual(exit_code, 0)
43        self.assertEqual(output, ["Hello, World"])
44
45        cmd = "java -cp /usr/bin JniTest"
46        output, exit_code = self.emulator.run(cmd, 120)
47        print(output)
48        self.assertEqual(exit_code, 0)
49