Skip to content

Commit

Permalink
kunit: tool: Add support for overriding the QEMU serial port
Browse files Browse the repository at this point in the history
On some platforms, the console is not the first serial port.  To make
this work, the first serial port in QEMU must be set to "null".

Add support for this by adding an optional "serial" parameter, which
defaults to "stdio", and can be overridden by platform-specific
configuration.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Geert Uytterhoeven authored and Shuah Khan committed Apr 5, 2023
1 parent cb8865f commit 5ffb862
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/testing/kunit/kunit_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(self, qemu_arch_params: qemu_config.QemuArchParams, cross_compile:
self._kernel_path = qemu_arch_params.kernel_path
self._kernel_command_line = qemu_arch_params.kernel_command_line + ' kunit_shutdown=reboot'
self._extra_qemu_params = qemu_arch_params.extra_qemu_params
self._serial = qemu_arch_params.serial

def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig:
kconfig = kunit_config.parse_from_string(self._kconfig)
Expand All @@ -121,7 +122,7 @@ def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]:
'-append', ' '.join(params + [self._kernel_command_line]),
'-no-reboot',
'-nographic',
'-serial', 'stdio'] + self._extra_qemu_params
'-serial', self._serial] + self._extra_qemu_params
# Note: shlex.join() does what we want, but requires python 3.8+.
print('Running tests with:\n$', ' '.join(shlex.quote(arg) for arg in qemu_command))
return subprocess.Popen(qemu_command,
Expand Down
1 change: 1 addition & 0 deletions tools/testing/kunit/qemu_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ class QemuArchParams:
kernel_path: str
kernel_command_line: str
extra_qemu_params: List[str]
serial: str = 'stdio'

0 comments on commit 5ffb862

Please sign in to comment.