xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/test_glxinfo.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import os
2
3import infra.basetest
4
5GLXINFO_TIMEOUT = 120
6
7
8class TestGlxinfo(infra.basetest.BRTest):
9    config = \
10        """
11        BR2_x86_core2=y
12        BR2_TOOLCHAIN_EXTERNAL=y
13        BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
14        BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
15        BR2_TOOLCHAIN_EXTERNAL_URL="http://toolchains.bootlin.com/downloads/releases/toolchains/x86-core2/tarballs/x86-core2--glibc--bleeding-edge-2018.11-1.tar.bz2"
16        BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
17        BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
18        BR2_TOOLCHAIN_EXTERNAL_CXX=y
19        BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
20        BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
21        BR2_LINUX_KERNEL=y
22        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
23        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
24        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
25        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86/linux.config"
26        BR2_PACKAGE_MESA3D_DEMOS=y
27        BR2_PACKAGE_MESA3D=y
28        BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SWRAST=y
29        BR2_PACKAGE_MESA3D_OPENGL_GLX=y
30        BR2_PACKAGE_XORG7=y
31        BR2_PACKAGE_XSERVER_XORG_SERVER=y
32        BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
33        BR2_TARGET_ROOTFS_EXT2=y
34        # BR2_TARGET_ROOTFS_TAR is not set
35        BR2_ROOTFS_OVERLAY="{}"
36        """.format(
37          infra.filepath("tests/package/test_glxinfo/rootfs-overlay"))
38
39    def wait_for_xserver(self):
40        # xserver takes some time to start up
41        # The test case fail here if for some reason xserver is not properly installed
42        _, _ = self.emulator.run('while [ ! -e /var/run/xorg.pid ]; do sleep 1; done', 120)
43
44    def login(self):
45        img = os.path.join(self.builddir, "images", "rootfs.ext2")
46        kern = os.path.join(self.builddir, "images", "bzImage")
47        # glxinfo overallocate memory and the minimum that seemed to work was 512MB
48        self.emulator.boot(arch="i386",
49                           kernel=kern,
50                           kernel_cmdline=["root=/dev/vda console=ttyS0"],
51                           options=["-M", "pc", "-m", "512", "-drive", "file={},if=virtio,format=raw".format(img)])
52        self.emulator.login()
53
54    def test_run(self):
55        self.login()
56        self.wait_for_xserver()
57
58        # The test case verifies that the xserver with GLX is working
59        cmd = "glxinfo -B -display :0"
60        output, exit_code = self.emulator.run(cmd, GLXINFO_TIMEOUT)
61        self.assertEqual(exit_code, 0)
62        for line in output:
63            self.assertNotIn("Error", line)
64        # Error case: "Error: couldn't find RGB GLX visual or fbconfig"
65