mbox series

[0/2] kunit: tool: Add support for SH under QEMU

Message ID cover.1677579750.git.geert+renesas@glider.be (mailing list archive)
Headers show
Series kunit: tool: Add support for SH under QEMU | expand

Message

Geert Uytterhoeven Feb. 28, 2023, 10:31 a.m. UTC
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

Comments

John Paul Adrian Glaubitz Feb. 28, 2023, 11:52 a.m. UTC | #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
Geert Uytterhoeven Feb. 28, 2023, 11:57 a.m. UTC | #2
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
David Gow March 3, 2023, 7:26 a.m. UTC | #3
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
Geert Uytterhoeven March 3, 2023, 7:42 a.m. UTC | #4
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
David Gow March 4, 2023, 5:33 a.m. UTC | #5
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
David Gow April 4, 2023, 5:13 a.m. UTC | #6
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