Hi all,
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Thanks for your comments!
Geert Uytterhoeven (2): kunit: tool: Add support for overriding the QEMU serial port kunit: tool: Add support for SH under QEMU
tools/testing/kunit/kunit_kernel.py | 3 ++- tools/testing/kunit/qemu_config.py | 1 + tools/testing/kunit/qemu_configs/sh.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tools/testing/kunit/qemu_configs/sh.py
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 --- tools/testing/kunit/kunit_kernel.py | 3 ++- tools/testing/kunit/qemu_config.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index 53e90c3358348dbe..64262875993ff070 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -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, diff --git a/tools/testing/kunit/qemu_config.py b/tools/testing/kunit/qemu_config.py index 0b6a80398cccb50f..b1fba9016eed00d0 100644 --- a/tools/testing/kunit/qemu_config.py +++ b/tools/testing/kunit/qemu_config.py @@ -17,3 +17,4 @@ class QemuArchParams: kernel_path: str kernel_command_line: str extra_qemu_params: List[str] + serial: str = 'stdio'
On Tue, 28 Feb 2023 at 18:31, Geert Uytterhoeven geert+renesas@glider.be wrote:
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
Seems good to me, cheers!
Reviewed-by: David Gow davidgow@google.com
Thanks, -- David
tools/testing/kunit/kunit_kernel.py | 3 ++- tools/testing/kunit/qemu_config.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index 53e90c3358348dbe..64262875993ff070 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -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,
diff --git a/tools/testing/kunit/qemu_config.py b/tools/testing/kunit/qemu_config.py index 0b6a80398cccb50f..b1fba9016eed00d0 100644 --- a/tools/testing/kunit/qemu_config.py +++ b/tools/testing/kunit/qemu_config.py @@ -17,3 +17,4 @@ class QemuArchParams: kernel_path: str kernel_command_line: str extra_qemu_params: List[str]
- serial: str = 'stdio'
-- 2.34.1
Add basic support to run SH under QEMU via kunit_tool using the virtualized r2d platform.
Signed-off-by: Geert Uytterhoeven geert+renesas@glider.be --- All tests succeed, except for the usual suspects. drivers/clk/.kunitconfig cannot be run as CONFIG_COMMON_CLK is not available. --- tools/testing/kunit/qemu_configs/sh.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/testing/kunit/qemu_configs/sh.py
diff --git a/tools/testing/kunit/qemu_configs/sh.py b/tools/testing/kunit/qemu_configs/sh.py new file mode 100644 index 0000000000000000..78a474a5b95f3a7d --- /dev/null +++ b/tools/testing/kunit/qemu_configs/sh.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +from ..qemu_config import QemuArchParams + +QEMU_ARCH = QemuArchParams(linux_arch='sh', + kconfig=''' +CONFIG_CPU_SUBTYPE_SH7751R=y +CONFIG_MEMORY_START=0x0c000000 +CONFIG_SH_RTS7751R2D=y +CONFIG_RTS7751R2D_PLUS=y +CONFIG_SERIAL_SH_SCI=y''', + qemu_arch='sh4', + kernel_path='arch/sh/boot/zImage', + kernel_command_line='console=ttySC1', + serial='null', + extra_qemu_params=[ + '-machine', 'r2d', + '-serial', 'mon:stdio'])
On Tue, 28 Feb 2023 at 18:31, Geert Uytterhoeven geert+renesas@glider.be wrote:
Add basic support to run SH under QEMU via kunit_tool using the virtualized r2d platform.
Signed-off-by: Geert Uytterhoeven geert+renesas@glider.be
I finally managed to get this working: it's fine under openSUSE tumbleweed (with the kernel.org toolchain), and in a debian stable container, so I'll chalk the problems I was having up to my Google-ified setup here.
Even if that turns out to be a more widespread issue, it'll be easier to track down with these patches applied,
So, Reviewed-by: David Gow davidgow@google.com
Cheers, -- David
All tests succeed, except for the usual suspects. drivers/clk/.kunitconfig cannot be run as CONFIG_COMMON_CLK is not available.
tools/testing/kunit/qemu_configs/sh.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/testing/kunit/qemu_configs/sh.py
diff --git a/tools/testing/kunit/qemu_configs/sh.py b/tools/testing/kunit/qemu_configs/sh.py new file mode 100644 index 0000000000000000..78a474a5b95f3a7d --- /dev/null +++ b/tools/testing/kunit/qemu_configs/sh.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +from ..qemu_config import QemuArchParams
+QEMU_ARCH = QemuArchParams(linux_arch='sh',
kconfig='''
+CONFIG_CPU_SUBTYPE_SH7751R=y +CONFIG_MEMORY_START=0x0c000000 +CONFIG_SH_RTS7751R2D=y +CONFIG_RTS7751R2D_PLUS=y +CONFIG_SERIAL_SH_SCI=y''',
qemu_arch='sh4',
kernel_path='arch/sh/boot/zImage',
kernel_command_line='console=ttySC1',
serial='null',
extra_qemu_params=[
'-machine', 'r2d',
'-serial', 'mon:stdio'])
-- 2.34.1
Hi Geert!
On Tue, 2023-02-28 at 11:31 +0100, Geert Uytterhoeven wrote:
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Very cool idea. I have never used the kunit testsuite before, I will have a look at it. Is there documentation available which shows how to get started?
Adrian
Hi Adrian,
On Tue, Feb 28, 2023 at 12:55 PM John Paul Adrian Glaubitz glaubitz@physik.fu-berlin.de wrote:
On Tue, 2023-02-28 at 11:31 +0100, Geert Uytterhoeven wrote:
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Very cool idea. I have never used the kunit testsuite before, I will have a look at it. Is there documentation available which shows how to get started?
Run e.g.:
./tools/testing/kunit/kunit.py run --arch=sh --cross_compile=sh4-linux-gnu- --raw_output=all --kunitconfig fs/ext4/.kunitconfig
Gr{oetje,eeting}s,
Geert
On Tue, 28 Feb 2023 at 18:31, Geert Uytterhoeven geert+renesas@glider.be wrote:
Hi all,
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Thanks for your comments!
This series looks good to me, but I've not been able to successfully get qemu to boot anything on SuperH (it just seems to hang with no output).
Is there anything like magic config or firmware images (I didn't think so for r2d: shix prints out an error, though) required to get this going?
The qemu command KUnit is using seems correct (and none of the obvious permutations, particularly around the serial ports seem to help): qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio
Cheers, -- David
Geert Uytterhoeven (2): kunit: tool: Add support for overriding the QEMU serial port kunit: tool: Add support for SH under QEMU
tools/testing/kunit/kunit_kernel.py | 3 ++- tools/testing/kunit/qemu_config.py | 1 + tools/testing/kunit/qemu_configs/sh.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tools/testing/kunit/qemu_configs/sh.py
-- 2.34.1
Gr{oetje,eeting}s,
Geert
-- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi David,
On Fri, Mar 3, 2023 at 8:26 AM David Gow davidgow@google.com wrote:
On Tue, 28 Feb 2023 at 18:31, Geert Uytterhoeven geert+renesas@glider.be wrote:
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Thanks for your comments!
This series looks good to me, but I've not been able to successfully get qemu to boot anything on SuperH (it just seems to hang with no output).
Is there anything like magic config or firmware images (I didn't think so for r2d: shix prints out an error, though) required to get this going?
No idea. I thought it just works.
The qemu command KUnit is using seems correct (and none of the obvious permutations, particularly around the serial ports seem to help): qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio
That works just fine for me.
On plain v6.2 with this series applied: $ ./tools/testing/kunit/kunit.py run --arch=sh --cross_compile=sh4-linux-gnu- --raw_output=all --kunitconfig fs/ext4/.kunitconfig [08:38:59] Configuring KUnit Kernel ... Regenerating .config ... Populating config with: $ make ARCH=sh O=.kunit olddefconfig CROSS_COMPILE=sh4-linux-gnu- [08:39:01] Building KUnit Kernel ... Populating config with: $ make ARCH=sh O=.kunit olddefconfig CROSS_COMPILE=sh4-linux-gnu- Building with: $ make ARCH=sh O=.kunit --jobs=12 CROSS_COMPILE=sh4-linux-gnu- <stdin>:1517:2: warning: #warning syscall clone3 not implemented [-Wcpp] [... more warnings ...] [08:39:51] Starting KUnit Kernel (1/1)... Running tests with: $ qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio Linux version 6.2.0-00002-g5b394444bb0d (geert@rox) (sh4-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #3 Fri Mar 3 08:39:50 CET 2023 ...
$ qemu-system-sh4 --version QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.6) Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
Gr{oetje,eeting}s,
Geert
On Fri, 3 Mar 2023 at 15:42, Geert Uytterhoeven geert@linux-m68k.org wrote:
Hi David,
On Fri, Mar 3, 2023 at 8:26 AM David Gow davidgow@google.com wrote:
On Tue, 28 Feb 2023 at 18:31, Geert Uytterhoeven geert+renesas@glider.be wrote:
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Thanks for your comments!
This series looks good to me, but I've not been able to successfully get qemu to boot anything on SuperH (it just seems to hang with no output).
Is there anything like magic config or firmware images (I didn't think so for r2d: shix prints out an error, though) required to get this going?
No idea. I thought it just works.
Strange: I'm not able to get anything to boot here, regardless of the versions I use.
I'm definitely not convinced that it's a qemu issue, as opposed to a kernel issue, but either way I can't get anything to boot.
The qemu command KUnit is using seems correct (and none of the obvious permutations, particularly around the serial ports seem to help): qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio
That works just fine for me.
On plain v6.2 with this series applied: $ ./tools/testing/kunit/kunit.py run --arch=sh --cross_compile=sh4-linux-gnu- --raw_output=all --kunitconfig fs/ext4/.kunitconfig [08:38:59] Configuring KUnit Kernel ... Regenerating .config ... Populating config with: $ make ARCH=sh O=.kunit olddefconfig CROSS_COMPILE=sh4-linux-gnu- [08:39:01] Building KUnit Kernel ... Populating config with: $ make ARCH=sh O=.kunit olddefconfig CROSS_COMPILE=sh4-linux-gnu- Building with: $ make ARCH=sh O=.kunit --jobs=12 CROSS_COMPILE=sh4-linux-gnu- <stdin>:1517:2: warning: #warning syscall clone3 not implemented [-Wcpp] [... more warnings ...] [08:39:51] Starting KUnit Kernel (1/1)... Running tests with: $ qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio Linux version 6.2.0-00002-g5b394444bb0d (geert@rox) (sh4-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #3 Fri Mar 3 08:39:50 CET 2023 ...
I see the same issue with a clean 6.2 and these patches, with both "sh4-linux-gnu-gcc (Debian 12.2.0-10) 12.2.0" and "sh4-linux-gnu-gcc-11 (Debian 11.3.0-8) 11.3.0".
$ qemu-system-sh4 --version QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.6) Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
I've mostly been using "QEMU emulator version 7.2.0 (Debian 1:7.2+dfsg-1+build1)", but did try building 6.2.0 myself ("QEMU emulator version 6.2.0 "), which didn't help either.
In any case, I'm happy to accept this if it's working well elsewhere, and I'll see if it starts working on this machine (or if I can try it on another) later on.
Cheers, -- David
On Sat, 4 Mar 2023 at 13:33, David Gow davidgow@google.com wrote:
On Fri, 3 Mar 2023 at 15:42, Geert Uytterhoeven geert@linux-m68k.org wrote:
Hi David,
On Fri, Mar 3, 2023 at 8:26 AM David Gow davidgow@google.com wrote:
On Tue, 28 Feb 2023 at 18:31, Geert Uytterhoeven geert+renesas@glider.be wrote:
This patch series adds support to run tests via kunit_tool on the SuperH-based virtualized r2d platform. As r2d uses the second serial port as the console, this needs a small modification of the core infrastructure.
Thanks for your comments!
This series looks good to me, but I've not been able to successfully get qemu to boot anything on SuperH (it just seems to hang with no output).
Is there anything like magic config or firmware images (I didn't think so for r2d: shix prints out an error, though) required to get this going?
No idea. I thought it just works.
Strange: I'm not able to get anything to boot here, regardless of the versions I use.
I'm definitely not convinced that it's a qemu issue, as opposed to a kernel issue, but either way I can't get anything to boot.
The qemu command KUnit is using seems correct (and none of the obvious permutations, particularly around the serial ports seem to help): qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio
That works just fine for me.
On plain v6.2 with this series applied: $ ./tools/testing/kunit/kunit.py run --arch=sh --cross_compile=sh4-linux-gnu- --raw_output=all --kunitconfig fs/ext4/.kunitconfig [08:38:59] Configuring KUnit Kernel ... Regenerating .config ... Populating config with: $ make ARCH=sh O=.kunit olddefconfig CROSS_COMPILE=sh4-linux-gnu- [08:39:01] Building KUnit Kernel ... Populating config with: $ make ARCH=sh O=.kunit olddefconfig CROSS_COMPILE=sh4-linux-gnu- Building with: $ make ARCH=sh O=.kunit --jobs=12 CROSS_COMPILE=sh4-linux-gnu- <stdin>:1517:2: warning: #warning syscall clone3 not implemented [-Wcpp] [... more warnings ...] [08:39:51] Starting KUnit Kernel (1/1)... Running tests with: $ qemu-system-sh4 -nodefaults -m 1024 -kernel .kunit/arch/sh/boot/zImage -append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdio Linux version 6.2.0-00002-g5b394444bb0d (geert@rox) (sh4-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #3 Fri Mar 3 08:39:50 CET 2023 ...
I see the same issue with a clean 6.2 and these patches, with both "sh4-linux-gnu-gcc (Debian 12.2.0-10) 12.2.0" and "sh4-linux-gnu-gcc-11 (Debian 11.3.0-8) 11.3.0".
Looks like this is an issue with the compiler in Debian testing.
Broken (Debian Testing): sh4-linux-gnu-gcc (Debian 12.2.0-10) 12.2.0 Works (From https://mirrors.edge.kernel.org/pub/tools/crosstool/ ): sh4-linux-gcc (GCC) 12.2.0 Works (Debian Stable): sh4-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
I'll leave debugging it here, as my SuperH knowledge is nonexistant, but there's definitely something going wrong.
Cheers, -- David
linux-kselftest-mirror@lists.linaro.org