All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joseph Kogut <joseph.kogut@gmail.com>
To: buildroot@buildroot.org
Cc: Adrian Perez de Castro <aperez@igalia.com>,
	 Eric Le Bihan <eric.le.bihan.dev@free.fr>,
	 Romain Naour <romain.naour@gmail.com>,
	 Joseph Kogut <joseph.kogut@gmail.com>,
	 Raphael Pavlidis <raphael.pavlidis@gmail.com>,
	 Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [Buildroot] [PATCH v7 8/8] support/testing: add virglrenderer test
Date: Fri, 15 May 2026 19:03:17 -0700	[thread overview]
Message-ID: <20260515-virglrenderer-v7-8-1f1814b65ccd@gmail.com> (raw)
In-Reply-To: <20260515-virglrenderer-v7-0-1f1814b65ccd@gmail.com>

Add basic smoke test for glmark2 running in a nested qemu guest with
virtio-gpu-gl-pci.

The outer machine uses the Mesa softpipe driver for GLES support with
minimal dependencies. Just test virgl for now, as lavapipe
(software Vulkan driver) requires LLVM, and this validates
virglrenderer.

Signed-off-by: Joseph Kogut <joseph.kogut@gmail.com>
---
 DEVELOPERS                                         |   1 +
 .../testing/tests/package/test_virglrenderer.py    | 117 +++++++++++++++++++++
 .../test_virglrenderer/linux-virgl.fragment        |   6 ++
 .../test_virglrenderer/remove-qemu-blobs.sh        |  12 +++
 .../rootfs-overlay/etc/profile.d/stty-raw.sh       |   3 +
 5 files changed, 139 insertions(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index 774eb0b746..0c0779e8b3 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1766,6 +1766,7 @@ F:	package/sentry-cli/
 F:	package/sentry-native/
 F:	package/unclutter-xfixes/
 F:	package/virglrenderer/
+F:	support/testing/tests/package/test_virglrenderer.py
 
 N:	Joshua Henderson <joshua.henderson@microchip.com>
 F:	package/qt5/qt5wayland/
diff --git a/support/testing/tests/package/test_virglrenderer.py b/support/testing/tests/package/test_virglrenderer.py
new file mode 100644
index 0000000000..521a4b67cd
--- /dev/null
+++ b/support/testing/tests/package/test_virglrenderer.py
@@ -0,0 +1,117 @@
+import os
+
+import infra
+import infra.basetest
+
+
+class TestVirglrendererNestedQemu(infra.basetest.BRTest):
+    # We reuse the same initramfs-enabled kernel for the outer target and
+    # nested guest. This fragment adds initramfs and 9p support so the outer
+    # target can mount the runner's images directory and launch the same kernel
+    # under target-side QEMU. We also enable DRM_VGEM to create the necessary
+    # DRI device node, a requirement of qemu when using virgl.
+    kern_frag = \
+        infra.filepath("tests/package/test_virglrenderer/linux-virgl.fragment")
+    post_build = \
+        infra.filepath("tests/package/test_virglrenderer/remove-qemu-blobs.sh")
+    rootfs_overlay = \
+        infra.filepath("tests/package/test_virglrenderer/rootfs-overlay")
+
+    # Softpipe has no hardware dependencies and does not pull LLVM into the
+    # build, unlike llvmpipe/lavapipe.
+    config = \
+        f"""
+        BR2_x86_64=y
+        BR2_x86_nehalem=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_GLIBC_STABLE=y
+        BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
+        BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+        BR2_ROOTFS_POST_BUILD_SCRIPT="{post_build}"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
+        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_frag}"
+        BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
+        # BR2_PACKAGE_EUDEV_ENABLE_HWDB is not set
+        BR2_PACKAGE_GLMARK2=y
+        BR2_PACKAGE_LIBGLVND=y
+        BR2_PACKAGE_MESA3D=y
+        BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SOFTPIPE=y
+        BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VIRGL=y
+        BR2_PACKAGE_MESA3D_OPENGL_EGL=y
+        BR2_PACKAGE_MESA3D_OPENGL_ES=y
+        BR2_PACKAGE_QEMU=y
+        BR2_PACKAGE_QEMU_SYSTEM=y
+        # BR2_PACKAGE_QEMU_SYSTEM_KVM is not set
+        BR2_PACKAGE_QEMU_SYSTEM_TCG=y
+        BR2_PACKAGE_QEMU_CHOOSE_TARGETS=y
+        BR2_PACKAGE_QEMU_TARGET_X86_64=y
+        BR2_PACKAGE_QEMU_VIRGLRENDERER=y
+        BR2_TARGET_ROOTFS_INITRAMFS=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def boot_outer(self):
+        kern = os.path.join(self.builddir, "images", "bzImage")
+        img_dir = os.path.join(self.builddir, "images")
+        virtfs_tag = "br-imgs"
+        virtfs_opts = [
+            f"local,path={img_dir}",
+            f"mount_tag={virtfs_tag}",
+            "security_model=mapped-xattr",
+            "readonly=on"
+        ]
+        self.emulator.boot(arch="x86_64",
+                           kernel=kern,
+                           kernel_cmdline=["console=ttyS0"],
+                           options=["-cpu", "Nehalem",
+                                    "-m", "1536M",
+                                    "-smp", "4",
+                                    "-vga", "none",
+                                    "-virtfs", ",".join(virtfs_opts)])
+        self.emulator.login()
+        self.assertRunOk(f"mount -t 9p {virtfs_tag} /mnt/")
+
+    def boot_nested(self):
+        qemu_cmd = "env LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=softpipe"
+        qemu_cmd += " qemu-system-x86_64"
+        qemu_cmd += " -M q35,accel=tcg"
+        qemu_cmd += " -cpu Nehalem"
+        qemu_cmd += " -m 512M"
+        qemu_cmd += " -smp 4"
+        qemu_cmd += " -nodefaults"
+        qemu_cmd += " -display egl-headless,gl=on"
+        qemu_cmd += " -device virtio-gpu-gl-pci"
+        qemu_cmd += " -serial stdio"
+        qemu_cmd += " -kernel /mnt/bzImage"
+        qemu_cmd += " -append 'console=ttyS0 br-nested-virgl'"
+
+        # qemu runs in the foreground on the current serial console. Once it
+        # starts, the next login prompt belongs to the nested guest.
+        self.emulator.qemu.sendline(qemu_cmd)
+        self.emulator.login(timeout=180)
+
+    def test_run(self):
+        self.boot_outer()
+        self.assertRunOk("while [ ! -e /dev/dri/renderD128 ]; do sleep 1; done",
+                         timeout=30)
+
+        self.boot_nested()
+
+        out, ret = self.emulator.run("cat /proc/cmdline")
+        self.assertEqual(ret, 0)
+        self.assertIn("br-nested-virgl", out[0])
+
+        cmd = "env MESA_LOADER_DRIVER_OVERRIDE=virtio_gpu"
+        cmd += " glmark2-es2-drm --validate --off-screen"
+        cmd += " --benchmark build:use-vbo=false"
+        out, ret = self.emulator.run(cmd, timeout=60)
+        self.assertEqual(ret, 0)
+
+        renderer = "\n".join([line for line in out if "GL_RENDERER:" in line])
+        self.assertRegex(renderer, r"(?i)virgl")
+        self.assertRegex(renderer, r"(?i)softpipe")
diff --git a/support/testing/tests/package/test_virglrenderer/linux-virgl.fragment b/support/testing/tests/package/test_virglrenderer/linux-virgl.fragment
new file mode 100644
index 0000000000..1023aedc6f
--- /dev/null
+++ b/support/testing/tests/package/test_virglrenderer/linux-virgl.fragment
@@ -0,0 +1,6 @@
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_DRM_VGEM=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_9P_FS=y
+CONFIG_9P_FS_POSIX_ACL=y
diff --git a/support/testing/tests/package/test_virglrenderer/remove-qemu-blobs.sh b/support/testing/tests/package/test_virglrenderer/remove-qemu-blobs.sh
new file mode 100755
index 0000000000..ff040aa96b
--- /dev/null
+++ b/support/testing/tests/package/test_virglrenderer/remove-qemu-blobs.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -eu
+
+qemu_dir="${TARGET_DIR}/usr/share/qemu"
+
+find "${qemu_dir}" -type f \
+	! -name 'bios-256k.bin' \
+	! -name 'kvmvapic.bin' \
+	! -name 'linuxboot.bin' \
+	! -name 'linuxboot_dma.bin' \
+	-delete
diff --git a/support/testing/tests/package/test_virglrenderer/rootfs-overlay/etc/profile.d/stty-raw.sh b/support/testing/tests/package/test_virglrenderer/rootfs-overlay/etc/profile.d/stty-raw.sh
new file mode 100644
index 0000000000..bc1857a910
--- /dev/null
+++ b/support/testing/tests/package/test_virglrenderer/rootfs-overlay/etc/profile.d/stty-raw.sh
@@ -0,0 +1,3 @@
+# Avoid double-cooking the nested serial console, otherwise the test
+# infrastructure cannot reliably retrieve return codes.
+grep -Fq br-nested-virgl /proc/cmdline && stty raw

-- 
2.54.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      parent reply	other threads:[~2026-05-16  2:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-16  2:03 [Buildroot] [PATCH v7 0/8] Add virglrenderer support Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 1/8] package/weston: add EGL dependency for XWayland Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 2/8] package/wpewebkit: fix stale libepoxy dependency comments Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 3/8] package/libepoxy: remove gl/egl dependency Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 4/8] package/virglrenderer: new package Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 5/8] package/virglrenderer: Fix build with glibc 2.43 Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 6/8] package/qemu: add OpenGL config Joseph Kogut
2026-05-16  2:03 ` [Buildroot] [PATCH v7 7/8] package/qemu: add virglrenderer integration Joseph Kogut
2026-05-16  2:03 ` Joseph Kogut [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260515-virglrenderer-v7-8-1f1814b65ccd@gmail.com \
    --to=joseph.kogut@gmail.com \
    --cc=aperez@igalia.com \
    --cc=buildroot@buildroot.org \
    --cc=eric.le.bihan.dev@free.fr \
    --cc=raphael.pavlidis@gmail.com \
    --cc=romain.naour@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.