vfio-user client functional test
v3 cover vfio-user client functional test
Add a basic functional test for the vfio-user client, along with a couple of test framework extensions to support it.
John Levon (2):
tests/functional: return output from cmd.py helpers tests/functional: add vm param to cmd.py helpers
Mark Cave-Ayland (1):
tests/functional: add a vfio-user smoke test
MAINTAINERS | 1 + tests/functional/qemu_test/cmd.py | 65 ++- tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vfio_user_client.py | 407 ++++++++++++++++++ 4 files changed, 462 insertions(+), 12 deletions(-) create mode 100755 tests/functional/x86_64/test_vfio_user_client.py
Signature · 1 line
2.43.0
PATCH v3 1/3 tests/functional: return output from cmd.py helpers
Tests might want to look at the whole output from a command execution, as well as just logging it. Add support for this.
--- tests/functional/qemu_test/cmd.py | 53 +++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 9 deletions(-)
tests/functional/qemu_test/cmd.py +44 -9
@@ -45,6 +45,9 @@ def is_readable_executable_file(path): # If end of line is seen, with neither @success or @failure # return False # +# In both cases, also return the contents of the line (in bytes) +# up to that point. +# # If @failure is seen, then mark @test as failed def _console_read_line_until_match(test, vm, success, failure): msg = bytes([])
@@ -76,10 +79,23 @@ def _console_read_line_until_match(test, vm, success, failure): except: console_logger.debug(msg) - return done + return done, msg def _console_interaction(test, success_message, failure_message, send_string, keep_sending=False, vm=None): + """ + Interact with the console until either message is seen. + + :param success_message: if this message appears, finish interaction + :param failure_message: if this message appears, test fails + :param send_string: a string to send to the console before trying + to read a new line + :param keep_sending: keep sending the send string each time + :param vm: the VM to interact with + + :return: The collected output (in bytes form). + """ + assert not keep_sending or send_string assert success_message or send_string
@@ -101,6 +117,8 @@ def _console_interaction(test, success_message, failure_message, if failure_message is not None: failure_message_b = failure_message.encode() + out = bytes([]) + while True: if send_string: vm.console_socket.sendall(send_string.encode())
@@ -113,11 +131,17 @@ def _console_interaction(test, success_message, failure_message, break continue - if _console_read_line_until_match(test, vm, - success_message_b, - failure_message_b): + done, line = _console_read_line_until_match(test, vm, + success_message_b, + failure_message_b) + + out += line + + if done: break + return out + def interrupt_interactive_console_until_pattern(test, success_message, failure_message=None, interrupt_string='\r'):
@@ -140,10 +164,12 @@ def interrupt_interactive_console_until_pattern(test, success_message, :param failure_message: if this message appears, test fails :param interrupt_string: a string to send to the console before trying to read a new line + + :return: The collected output (in bytes form). """ assert success_message - _console_interaction(test, success_message, failure_message, - interrupt_string, True) + return _console_interaction(test, success_message, failure_message, + interrupt_string, True) def wait_for_console_pattern(test, success_message, failure_message=None, vm=None):
@@ -155,9 +181,12 @@ def wait_for_console_pattern(test, success_message, failure_message=None, :type test: :class:`qemu_test.QemuSystemTest` :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails + + :return: The collected output (in bytes form). """ assert success_message - _console_interaction(test, success_message, failure_message, None, vm=vm) + return _console_interaction(test, success_message, failure_message, + None, vm=vm) def exec_command(test, command): """
@@ -168,8 +197,10 @@ def exec_command(test, command): :type test: :class:`qemu_test.QemuSystemTest` :param command: the command to send :type command: str + + :return: The collected output (in bytes form). """ - _console_interaction(test, None, None, command + '\r') + return _console_interaction(test, None, None, command + '\r') def exec_command_and_wait_for_pattern(test, command, success_message, failure_message=None):
@@ -184,9 +215,13 @@ def exec_command_and_wait_for_pattern(test, command, :param command: the command to send :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails + + :return: The collected output (in bytes form). """ assert success_message - _console_interaction(test, success_message, failure_message, command + '\r') + + return _console_interaction(test, success_message, failure_message, + command + '\r') def get_qemu_img(test): test.log.debug('Looking for and selecting a qemu-img binary')
Signature · 1 line
2.43.0
PATCH v3 2/3 tests/functional: add vm param to cmd.py helpers
In reply to John LevonExtend the "vm" parameter of wait_for_console_pattern() to all the other utility functions; this allows them to be used on a VM other than test.vm.
--- tests/functional/qemu_test/cmd.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
tests/functional/qemu_test/cmd.py +12 -6
@@ -144,7 +144,8 @@ def _console_interaction(test, success_message, failure_message, def interrupt_interactive_console_until_pattern(test, success_message, failure_message=None, - interrupt_string='\r'): + interrupt_string='\r', + vm=None): """ Keep sending a string to interrupt a console prompt, while logging the console output. Typical use case is to break a boot loader prompt, such:
@@ -164,12 +165,13 @@ def interrupt_interactive_console_until_pattern(test, success_message, :param failure_message: if this message appears, test fails :param interrupt_string: a string to send to the console before trying to read a new line + :param vm: VM to use :return: The collected output (in bytes form). """ assert success_message return _console_interaction(test, success_message, failure_message, - interrupt_string, True) + interrupt_string, True, vm=vm) def wait_for_console_pattern(test, success_message, failure_message=None, vm=None):
@@ -181,6 +183,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None, :type test: :class:`qemu_test.QemuSystemTest` :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails + :param vm: VM to use :return: The collected output (in bytes form). """
@@ -188,7 +191,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None, return _console_interaction(test, success_message, failure_message, None, vm=vm) -def exec_command(test, command): +def exec_command(test, command, vm=None): """ Send a command to a console (appending CRLF characters), while logging the content.
@@ -196,14 +199,16 @@ def exec_command(test, command): :param test: a test containing a VM. :type test: :class:`qemu_test.QemuSystemTest` :param command: the command to send + :param vm: VM to use :type command: str :return: The collected output (in bytes form). """ - return _console_interaction(test, None, None, command + '\r') + return _console_interaction(test, None, None, command + '\r', vm=vm) def exec_command_and_wait_for_pattern(test, command, - success_message, failure_message=None): + success_message, failure_message=None, + vm=None): """ Send a command to a console (appending CRLF characters), then wait for success_message to appear on the console, while logging the.
@@ -215,13 +220,14 @@ def exec_command_and_wait_for_pattern(test, command, :param command: the command to send :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails + :param vm: VM to use :return: The collected output (in bytes form). """ assert success_message return _console_interaction(test, success_message, failure_message, - command + '\r') + command + '\r', vm=vm) def get_qemu_img(test): test.log.debug('Looking for and selecting a qemu-img binary')
Signature · 1 line
2.43.0
PATCH v3 3/3 tests/functional: add a vfio-user smoke test
In reply to John LevonFrom: Mark Cave-Ayland <[email protected]>
Add a basic test of the vfio-user PCI client implementation.
--- MAINTAINERS | 1 + tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vfio_user_client.py | 407 ++++++++++++++++++ 3 files changed, 409 insertions(+) create mode 100755 tests/functional/x86_64/test_vfio_user_client.py
MAINTAINERS +1 -0
@@ -4309,6 +4309,7 @@ F: docs/system/devices/vfio-user.rst F: hw/vfio-user/* F: include/hw/vfio-user/* F: subprojects/libvfio-user +F: tests/functional/x86_64/test_vfio_user_client.py EBPF: M: Jason Wang <[email protected]>
tests/functional/x86_64/meson.build +1 -0
@@ -31,6 +31,7 @@ tests_x86_64_system_thorough = [ 'replay', 'reverse_debug', 'tuxrun', + 'vfio_user_client', 'virtio_balloon', 'virtio_gpu', ]
tests/functional/x86_64/test_vfio_user_client.py new file +407 -0
407 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 10 lines · John Levon
Add a basic functional test for the vfio-user client, along with a couple of test framework extensions to support it.
John Levon (2):
tests/functional: return output fromcmd.pyhelpers tests/functional: add vm param tocmd.pyhelpersMark Cave-Ayland (1):
tests/functional: add a vfio-user smoke test
Quoted 7 lines
MAINTAINERS | 1 + tests/functional/qemu_test/cmd.py | 65 ++- tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vfio_user_client.py | 407 ++++++++++++++++++ 4 files changed, 462 insertions(+), 12 deletions(-)create mode 100755
tests/functional/x86_64/test_vfio_user_client.py
The test is failing :
2025-09-02 11:24:37,944 - ERROR: Server logs did not match: 2025-09-02 11:24:37,944 - ERROR: ---
2025-09-02 11:24:37,944 - ERROR: +++
2025-09-02 11:24:37,944 - ERROR: @@ -50,8 +50,10 @@
2025-09-02 11:24:37,944 - ERROR: gpio: removing DMA region [0xf0000, 0x8000000) flags=0 2025-09-02 11:24:37,944 - ERROR: gpio: adding DMA region [0, 0x8000000) offset=0 flags=0x3 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0x494f from (0:2) 2025-09-02 11:24:37,944 - ERROR: -gpio: region7: read 0 from (0xe:1) 2025-09-02 11:24:37,944 - ERROR: -gpio: region7: read 0x494f from (0:2) 2025-09-02 11:24:37,944 - ERROR: +gpio: region7: read 0 from (0xa:2) 2025-09-02 11:24:37,944 - ERROR: +gpio: region7: read 0 from (0xe:1) 2025-09-02 11:24:37,944 - ERROR: +gpio: region7: read 0x494f from (0:2) 2025-09-02 11:24:37,944 - ERROR: +gpio: region7: read 0 from (0xa:2) 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0 from (0xe:1) 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0x494f from (0:2) 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0xdc8494f from (0:4) 2025-09-02 11:24:37,944 - ERROR: @@ -106,6 +108,7 @@
2025-09-02 11:24:37,944 - ERROR: gpio: removing DMA region [0xd0000, 0xf0000) flags=0 2025-09-02 11:24:37,944 - ERROR: gpio: adding DMA region [0xc4000, 0xe8000) offset=0 flags=0x1 2025-09-02 11:24:37,944 - ERROR: gpio: adding DMA region [0xe8000, 0xf0000) offset=0 flags=0x3 2025-09-02 11:24:37,944 - ERROR: +gpio: region7: read 0 from (0xa:2) 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0x494f from (0:2) 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0xdc8 from (0x2:2) 2025-09-02 11:24:37,944 - ERROR: gpio: region7: read 0 from (0xe:1)
Thanks,
C.
Quoted 19 lines · Cédric Le Goater
Quoted 10 lines · John Levon
Add a basic functional test for the vfio-user client, along with a couple of test framework extensions to support it.
John Levon (2):
tests/functional: return output fromcmd.pyhelpers tests/functional: add vm param tocmd.pyhelpersMark Cave-Ayland (1):
tests/functional: add a vfio-user smoke testQuoted 7 lines
MAINTAINERS | 1 + tests/functional/qemu_test/cmd.py | 65 ++- tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vfio_user_client.py | 407 ++++++++++++++++++ 4 files changed, 462 insertions(+), 12 deletions(-)create mode 100755
tests/functional/x86_64/test_vfio_user_client.py
Quoted 1 line
The test is failing :
What is the parent commit you tried this with?
I've had to fix this from a rebasing before, but it seems it's more sensitive than I expected, and we'll have to be looser in terms of what we expect to see...
regards
john
Quoted 21 lines · John Levon
Quoted 19 lines · Cédric Le Goater
Quoted 17 lines · John Levon
Add a basic functional test for the vfio-user client, along with a couple of test framework extensions to support it.
John Levon (2):
tests/functional: return output fromcmd.pyhelpers tests/functional: add vm param tocmd.pyhelpersMark Cave-Ayland (1):
tests/functional: add a vfio-user smoke testMAINTAINERS | 1 + tests/functional/qemu_test/cmd.py | 65 ++- tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vfio_user_client.py | 407 ++++++++++++++++++ 4 files changed, 462 insertions(+), 12 deletions(-)create mode 100755
tests/functional/x86_64/test_vfio_user_client.py
Quoted 3 lines
Quoted 1 line
The test is failing :
What is the parent commit you tried this with?
91589bcd9fee0e66b241d04e5f37cd4f218187a2
C.