kunit: tool: Add support for overriding the QEMU serial port
authorGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 28 Feb 2023 10:31:02 +0000 (11:31 +0100)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 5 Apr 2023 18:51:06 +0000 (12:51 -0600)
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>
tools/testing/kunit/kunit_kernel.py
tools/testing/kunit/qemu_config.py

index a3321a991f11aa59dceefe3222b3d101b5047c48..f01f9410612965037e6510028351b566ac7ae382 100644 (file)
@@ -106,6 +106,7 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
                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)
@@ -121,7 +122,7 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
                                '-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,
index 0b6a80398cccb50fee5fe94def150c0761d96c20..b1fba9016eed00d010c853f2910c9624e01d4af5 100644 (file)
@@ -17,3 +17,4 @@ class QemuArchParams:
   kernel_path: str
   kernel_command_line: str
   extra_qemu_params: List[str]
+  serial: str = 'stdio'