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