Skip to content

Commit 3d30f88

Browse files
committed
tests/functional: extend test_aarch64_virt with vulkan test
Now that we have virtio-gpu Vulkan support, let's add a test for it. Currently this is using images build by buildroot: https://lists.buildroot.org/pipermail/buildroot/2024-December/768196.html Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-Id: <[email protected]>
1 parent 0d3af96 commit 3d30f88

File tree

1 file changed

+74
-2
lines changed

1 file changed

+74
-2
lines changed

tests/functional/test_aarch64_virt.py

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import logging
1414
from subprocess import check_call, DEVNULL
1515

16+
from qemu.machine.machine import VMLaunchFailure
17+
1618
from qemu_test import QemuSystemTest, Asset
17-
from qemu_test import exec_command_and_wait_for_pattern
19+
from qemu_test import exec_command, exec_command_and_wait_for_pattern
1820
from qemu_test import wait_for_console_pattern
19-
from qemu_test import get_qemu_img
21+
from qemu_test import skipIfMissingCommands, get_qemu_img
2022

2123

2224
class Aarch64VirtMachine(QemuSystemTest):
@@ -132,5 +134,75 @@ def test_aarch64_virt_gicv2(self):
132134
self.common_aarch64_virt("virt,gic-version=2")
133135

134136

137+
ASSET_VIRT_GPU_KERNEL = Asset(
138+
'https://fileserver.linaro.org/s/ce5jXBFinPxtEdx/'
139+
'download?path=%2F&files='
140+
'Image',
141+
'89e5099d26166204cc5ca4bb6d1a11b92c217e1f82ec67e3ba363d09157462f6')
142+
143+
ASSET_VIRT_GPU_ROOTFS = Asset(
144+
'https://fileserver.linaro.org/s/ce5jXBFinPxtEdx/'
145+
'download?path=%2F&files='
146+
'rootfs.ext4.zstd',
147+
'792da7573f5dc2913ddb7c638151d4a6b2d028a4cb2afb38add513c1924bdad4')
148+
149+
@skipIfMissingCommands('zstd')
150+
def test_aarch64_virt_with_gpu(self):
151+
# This tests boots with a buildroot test image that contains
152+
# vkmark and other GPU exercising tools. We run a headless
153+
# weston that nevertheless still exercises the virtio-gpu
154+
# backend.
155+
156+
self.set_machine('virt')
157+
self.require_accelerator("tcg")
158+
159+
kernel_path = self.ASSET_VIRT_GPU_KERNEL.fetch()
160+
image_path = self.uncompress(self.ASSET_VIRT_GPU_ROOTFS, format="zstd")
161+
162+
self.vm.set_console()
163+
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
164+
'console=ttyAMA0 root=/dev/vda')
165+
166+
self.vm.add_args("-accel", "tcg")
167+
self.vm.add_args("-cpu", "neoverse-v1,pauth-impdef=on")
168+
self.vm.add_args("-machine", "virt,gic-version=max",
169+
'-kernel', kernel_path,
170+
'-append', kernel_command_line)
171+
self.vm.add_args("-smp", "2", "-m", "2048")
172+
self.vm.add_args("-device",
173+
"virtio-gpu-gl-pci,hostmem=4G,blob=on,venus=on")
174+
self.vm.add_args("-display", "egl-headless")
175+
self.vm.add_args("-display", "dbus,gl=on")
176+
self.vm.add_args("-device", "virtio-blk-device,drive=hd0")
177+
self.vm.add_args("-blockdev",
178+
"driver=raw,file.driver=file,"
179+
"node-name=hd0,read-only=on,"
180+
f"file.filename={image_path}")
181+
self.vm.add_args("-snapshot")
182+
183+
try:
184+
self.vm.launch()
185+
except VMLaunchFailure as excp:
186+
if "old virglrenderer, blob resources unsupported" in excp.output:
187+
self.skipTest("No blob support for virtio-gpu")
188+
elif "old virglrenderer, venus unsupported" in excp.output:
189+
self.skipTest("No venus support for virtio-gpu")
190+
elif "egl: no drm render node available" in excp.output:
191+
self.skipTest("Can't access host DRM render node")
192+
else:
193+
self.log.info(f"unhandled launch failure: {excp.output}")
194+
raise excp
195+
196+
self.wait_for_console_pattern('buildroot login:')
197+
exec_command(self, 'root')
198+
exec_command(self, 'export XDG_RUNTIME_DIR=/tmp')
199+
exec_command_and_wait_for_pattern(self,
200+
"weston -B headless "
201+
"--renderer gl "
202+
"--shell kiosk "
203+
"-- vkmark -b:duration=1.0",
204+
"vkmark Score")
205+
206+
135207
if __name__ == '__main__':
136208
QemuSystemTest.main()

0 commit comments

Comments
 (0)