From 22798b5978de5fc32a1111da6d8f321fae95282d Mon Sep 17 00:00:00 2001 From: El Mehdi YOUNES Date: Fri, 6 Jun 2025 09:01:52 +0200 Subject: [PATCH] support/testing: add runtime test for Mesa3D Rusticl This test verifies that clinfo correctly detects the rustiCL platform and llvmpipe as device. We check: - exit code, - Platform name matches rusticl, - Device name matches llvmpipe. Signed-off-by: El Mehdi YOUNES [Julien: - rename file to test_mesa3d.py - add Medhi in DEVELOPERS for this test file ] Signed-off-by: Julien Olivain --- DEVELOPERS | 1 + support/testing/tests/package/test_mesa3d.py | 53 ++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 support/testing/tests/package/test_mesa3d.py diff --git a/DEVELOPERS b/DEVELOPERS index 7031087157..9e31f6b515 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -914,6 +914,7 @@ F: package/docopt-cpp/ N: El Mehdi YOUNES F: package/opencl-headers/ F: package/opencl-icd-loader/ +F: support/testing/tests/package/test_mesa3d.py N: Eloi Bail F: package/bayer2rgb-neon/ diff --git a/support/testing/tests/package/test_mesa3d.py b/support/testing/tests/package/test_mesa3d.py new file mode 100644 index 0000000000..f5133c2eef --- /dev/null +++ b/support/testing/tests/package/test_mesa3d.py @@ -0,0 +1,53 @@ +import os +import infra.basetest + +RUSTICL_TIMEOUT = 180 + + +class TestMesa3DRusticl(infra.basetest.BRTest): + config = """ + BR2_aarch64=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y + BR2_LINUX_KERNEL=y + BR2_LINUX_KERNEL_CUSTOM_VERSION=y + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.31" + BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y + BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config" + BR2_PACKAGE_MESA3D=y + BR2_PACKAGE_MESA3D_LLVM=y + BR2_PACKAGE_MESA3D_OPENCL=y + BR2_PACKAGE_MESA3D_RUSTICL=y + BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_LLVMPIPE=y + BR2_PACKAGE_CLINFO=y + BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" + BR2_TARGET_ROOTFS_EXT2=y + BR2_TARGET_ROOTFS_EXT2_SIZE="1024M" + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def login(self): + img = os.path.join(self.builddir, "images", "rootfs.ext2") + kern = os.path.join(self.builddir, "images", "Image") + self.emulator.boot( + arch="aarch64", + kernel=kern, + kernel_cmdline=["root=/dev/vda console=ttyAMA0"], + options=[ + "-M", "virt", + "-cpu", "cortex-a57", + "-m", "512", + "-drive", f"file={img},if=virtio,format=raw" + ] + ) + self.emulator.login() + + def test_run(self): + self.login() + + # check the output exit code + output, exit_code = self.emulator.run("RUSTICL_ENABLE=llvmpipe clinfo", RUSTICL_TIMEOUT) + self.assertEqual(exit_code, 0) + # also check if platform name is rusticl and device name is llvmpipe + self.assertRegex("\n".join(output), r"Platform Name\s+rusticl") + self.assertRegex("\n".join(output), r"Device Name\s+llvmpipe")