qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: "Cédric Le Goater" <clg@redhat.com>,
	qemu-arm@nongnu.org, "Guenter Roeck" <linux@roeck-us.net>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH-for-10.0 1/3] tests/functional: Add test for imx8mp-evk board with USDHC coverage
Date: Mon, 7 Apr 2025 07:38:28 +0200	[thread overview]
Message-ID: <122aaf9e-cb4c-4117-90ae-2803f4810700@redhat.com> (raw)
In-Reply-To: <20250405214900.7114-2-shentey@gmail.com>

  Hi!

On 05/04/2025 23.48, Bernhard Beschow wrote:
> Introduce a functional test which boots Debian 12 on the imx8mp-evk board. Since
> the root filesystem resides on an SD card, the test also verifies the basic
> operation of the USDHC.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   MAINTAINERS                                 |  1 +
>   tests/functional/meson.build                |  1 +
>   tests/functional/test_aarch64_imx8mp_evk.py | 69 +++++++++++++++++++++
>   3 files changed, 71 insertions(+)
>   create mode 100644 tests/functional/test_aarch64_imx8mp_evk.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d54b5578f8..4ceffa89dc 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -833,6 +833,7 @@ F: include/hw/arm/fsl-imx8mp.h
>   F: include/hw/misc/imx8mp_*.h
>   F: include/hw/pci-host/fsl_imx8m_phy.h
>   F: docs/system/arm/imx8mp-evk.rst
> +F: tests/functional/test_aarch64_imx8mp_evk.py
>   F: tests/qtest/rs5c372-test.c
>   
>   MPS2 / MPS3
> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
> index 0f8be30fe2..aaaf3472f1 100644
> --- a/tests/functional/meson.build
> +++ b/tests/functional/meson.build
> @@ -75,6 +75,7 @@ tests_aarch64_system_quick = [
>   
>   tests_aarch64_system_thorough = [
>     'aarch64_aspeed',
> +  'aarch64_imx8mp_evk',
>     'aarch64_raspi3',
>     'aarch64_raspi4',
>     'aarch64_replay',
> diff --git a/tests/functional/test_aarch64_imx8mp_evk.py b/tests/functional/test_aarch64_imx8mp_evk.py
> new file mode 100644

The test files should be executable so you can run them directly (after 
setting PYTHONPATH and QEMU_TEST_QEMU_BINARY)

> index 0000000000..5419d3c525
> --- /dev/null
> +++ b/tests/functional/test_aarch64_imx8mp_evk.py
> @@ -0,0 +1,69 @@
> +#!/usr/bin/env python3
> +#
> +# Functional test that boots a Linux kernel and checks the console
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +from qemu_test import LinuxKernelTest, Asset
> +
> +class Imx8mpEvkMachine(LinuxKernelTest):
> +
> +    ASSET_IMAGE = Asset(
> +        ('https://cloud.debian.org/images/cloud/bookworm/20231210-1590/'
> +         'debian-12-generic-arm64-20231210-1590.tar.xz'),
> +        '7ebf1577b32d5af6204df74b54ca2e4675de9b5a9fa14f3ff70b88eeb7b3b359')
> +
> +    KERNEL_OFFSET = 0x51000000
> +    KERNEL_SIZE = 32622528
> +    INITRD_OFFSET = 0x76000000
> +    INITRD_SIZE = 30987766
> +    DTB_OFFSET = 0x64F51000
> +    DTB_SIZE = 45 * 1024
> +
> +    def extract(self, in_path, out_path, offset, size):
> +        try:
> +            with open(in_path, "rb") as source:
> +                source.seek(offset)
> +                data = source.read(size)
> +            with open(out_path, "wb") as target:
> +                target.write(data)
> +        except (IOError, ValueError) as e:
> +            self.log.error(f"Failed to extract {out_path}: {e}")
> +            raise
> +
> +    def setUp(self):
> +        super().setUp()

Is there any special reason for overriding the setUp function here? ... 
otherwise, I think this could also simply be done from the 
test_aarch64_imx8mp_evk_usdhc function instead?

> +        self.ASSET_IMAGE.fetch()

I think you can omit the fetch() here, it should be handled by 
archive_extract() already. At least that's what we're doing in the other 
spots that use archive_extract().

> +        self.archive_extract(self.ASSET_IMAGE)
> +
> +        self.image_path = self.scratch_file("disk.raw")
> +        self.kernel_path = self.scratch_file("linux")
> +        self.initrd_path = self.scratch_file("initrd.zstd")
> +        self.dtb_path = self.scratch_file("imx8mp-evk.dtb")
> +
> +        self.extract(self.image_path, self.kernel_path,
> +                     self.KERNEL_OFFSET, self.KERNEL_SIZE)
> +        self.extract(self.image_path, self.initrd_path,
> +                     self.INITRD_OFFSET, self.INITRD_SIZE)
> +        self.extract(self.image_path, self.dtb_path,
> +                     self.DTB_OFFSET, self.DTB_SIZE)
> +
> +    def test_aarch64_imx8mp_evk_usdhc(self):
> +        self.set_machine('imx8mp-evk')
> +        self.vm.set_console(console_index=1)
> +        self.vm.add_args('-m', '2G',
> +                         '-smp', '4',
> +                         '-accel', 'tcg',

The imx8mp-evk board has a "depends on TCG" in its Kconfig file, so I think 
you could omit "-accel tcg" here (but it also does not hurt to be explicit, 
I guess).

  Thomas


> +                         '-kernel', self.kernel_path,
> +                         '-initrd', self.initrd_path,
> +                         '-dtb', self.dtb_path,
> +                         '-append', 'root=/dev/mmcblk2p1',
> +                         '-drive', f'file={self.image_path},if=sd,bus=2,'
> +                                    'format=raw,id=mmcblk2')
> +
> +        self.vm.launch()
> +        self.wait_for_console_pattern('Welcome to ')
> +
> +if __name__ == '__main__':
> +    LinuxKernelTest.main()



  reply	other threads:[~2025-04-07  5:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-05 21:48 [PATCH-for-10.0 0/3] More imx8mp-evk improvements Bernhard Beschow
2025-04-05 21:48 ` [PATCH-for-10.0 1/3] tests/functional: Add test for imx8mp-evk board with USDHC coverage Bernhard Beschow
2025-04-07  5:38   ` Thomas Huth [this message]
2025-04-08 10:15     ` Bernhard Beschow
2025-04-05 21:48 ` [PATCH-for-10.0 2/3] hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties from devicetree Bernhard Beschow
2025-04-05 21:49 ` [PATCH-for-10.0 3/3] hw/arm/imx8mp-evk: Remove unimplemented nxp, imx8mp-fspi node " Bernhard Beschow
2025-04-08 18:57 ` [PATCH-for-10.0 0/3] More imx8mp-evk improvements Philippe Mathieu-Daudé
2025-04-08 20:39   ` Bernhard Beschow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=122aaf9e-cb4c-4117-90ae-2803f4810700@redhat.com \
    --to=thuth@redhat.com \
    --cc=clg@redhat.com \
    --cc=linux@roeck-us.net \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).