1import os
2
3import infra.basetest
4
5
6class TestGlslsandboxPlayer(infra.basetest.BRTest):
7    config = \
8        """
9        BR2_aarch64=y
10        BR2_TOOLCHAIN_EXTERNAL=y
11        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
12        BR2_LINUX_KERNEL=y
13        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
14        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.32"
15        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
16        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
17        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"
18        BR2_PACKAGE_LIBDRM=y
19        BR2_PACKAGE_MESA3D=y
20        BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SWRAST=y
21        BR2_PACKAGE_MESA3D_LLVM=y
22        BR2_PACKAGE_MESA3D_OPENGL_EGL=y
23        BR2_PACKAGE_MESA3D_OPENGL_ES=y
24        BR2_PACKAGE_GLSLSANDBOX_PLAYER=y
25        BR2_PACKAGE_GLSLSANDBOX_PLAYER_KMS=y
26        BR2_TARGET_ROOTFS_CPIO=y
27        BR2_TARGET_ROOTFS_CPIO_GZIP=y
28        # BR2_TARGET_ROOTFS_TAR is not set
29        """.format(
30            infra.filepath("tests/package/test_glslsandbox_player/linux-vkms.fragment"))
31
32    def test_run(self):
33        img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
34        kern = os.path.join(self.builddir, "images", "Image")
35        self.emulator.boot(arch="aarch64",
36                           kernel=kern,
37                           kernel_cmdline=["console=ttyAMA0"],
38                           options=["-M", "virt", "-cpu", "cortex-a57", "-m", "256M", "-initrd", img])
39        self.emulator.login()
40
41        # We force a small resolution in order to keep a relatively
42        # fast software rendering
43        cmd = "GSP_DRM_MODE=640x480 "
44        # We run 3 frames of a reduced resolution of SimpleMandel
45        cmd += "glslsandbox-player -S SimpleMandel -w0 -f3 -R8 -N -vv -r1 -D"
46        self.assertRunOk(cmd, timeout=30)
47
48        # Since we render 3 frames and request a dump of the last one,
49        # a ppm image file is expected to be present
50        self.assertRunOk("test -s SimpleMandel-00002.ppm")
51