kunit: tool: Add support for SH under QEMU
cover kunit: tool: Add support for SH under QEMU
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
Signature · 12 lines
2.34.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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 TorvaldsPATCH 1/2 kunit: tool: Add support for overriding the QEMU serial port
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.
--- tools/testing/kunit/kunit_kernel.py | 3 ++- tools/testing/kunit/qemu_config.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
tools/testing/kunit/kunit_kernel.py +2 -1
@@ -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,
tools/testing/kunit/qemu_config.py +1 -0
@@ -17,3 +17,4 @@ class QemuArchParams: kernel_path: str kernel_command_line: str extra_qemu_params: List[str] + serial: str = 'stdio'
Signature · 1 line
2.34.1
Re: [PATCH 1/2] kunit: tool: Add support for overriding the QEMU serial port
Quoted 10 lines · Geert Uytterhoeven
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 <[email protected]>---
Seems good to me, cheers!
Thanks,
-- David
Quoted 37 lines
tools/testing/kunit/kunit_kernel.py | 3 ++- tools/testing/kunit/qemu_config.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)tools/testing/kunit/kunit_kernel.py +2
-1@@ -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,tools/testing/kunit/qemu_config.py +1
-1@@ -17,3 +17,4 @@ class QemuArchParams: kernel_path: str kernel_command_line: str extra_qemu_params: List[str] + serial: str = 'stdio' --2.34.1
PATCH 2/2 kunit: tool: Add support for SH under QEMU
In reply to Geert UytterhoevenAdd basic support to run SH under QEMU via kunit_tool using the virtualized r2d platform.
---
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
tools/testing/kunit/qemu_configs/sh.py new file +17 -0
@@ -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'])
Signature · 1 line
2.34.1
Quoted 6 lines · Geert Uytterhoeven
Add basic support to run SH under QEMU via
kunit_toolusing the virtualized r2d platform.Signed-off-by Geert Uytterhoeven <[email protected]>---
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,
Cheers,
-- David
Quoted 34 lines
All tests succeed, except for the usual suspects.
drivers/clk/.kunitconfigcannot be run asCONFIG_COMMON_CLKis not available.--- tools/testing/kunit/qemu_configs/sh.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/testing/kunit/qemu_configs/sh.pytools/testing/kunit/qemu_configs/sh.py new file +17
-1@@ -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
John Paul Adrian Glaubitz
maintainerHi Geert!
Quoted 4 lines · Geert Uytterhoeven
This patch series adds support to run tests via
kunit_toolon 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
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Hi Adrian,
Quoted 9 lines · John Paul Adrian Glaubitz
Quoted 4 lines · Geert Uytterhoeven
This patch series adds support to run tests via
kunit_toolon 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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
Quoted 9 lines · Geert Uytterhoeven
Hi all,
This patch series adds support to run tests via
kunit_toolon 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
Quoted 24 lines
Geert Uytterhoeven (2):
kunit: tool: Add support for overriding the QEMU serial port
kunit: tool: Add support for SH under QEMUtools/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.1Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]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,
Quoted 9 lines · David Gow
Quoted 6 lines · Geert Uytterhoeven
This patch series adds support to run tests via
kunit_toolon 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!
Quoted 7 lines
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.
Review
Quoted 5 lines
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(quoted diff) +0
-2-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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
Quoted 17 lines · Geert Uytterhoeven
Hi David,
Quoted 13 lines · David Gow
Quoted 6 lines · Geert Uytterhoeven
This patch series adds support to run tests via
kunit_toolon 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).
Quoted 6 lines
Quoted 3 lines
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.
Quoted 25 lines
Review
Quoted 5 lines
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(quoted diff) +0
-2-append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdioThat 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:
Quoted 9 lines
$ 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".
Quoted 4 lines
$ 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
Quoted 67 lines · David Gow
Quoted 17 lines · Geert Uytterhoeven
Hi David,
Quoted 13 lines · David Gow
Quoted 6 lines · Geert Uytterhoeven
This patch series adds support to run tests via
kunit_toolon 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).
Quoted 6 lines
Quoted 3 lines
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.
Quoted 25 lines
Review
Quoted 5 lines
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(quoted diff) +0
-2-append 'kunit.enable=1 console=ttySC1 kunit_shutdown=reboot' -no-reboot -nographic -serial null -machine r2d -serial mon:stdioThat 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:Quoted 9 lines
$ 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 ...
Quoted 4 lines
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