[PATCH] test/py: mtd: Add tests for mtd command

Tom Rini trini at konsulko.com
Tue May 26 18:30:36 CEST 2026


On Tue, May 26, 2026 at 01:07:49PM +0530, Love Kumar wrote:

> Add test cases for mtd commands to verify list, erase, write, read
> and dump operations on NOR flash and binary-file data integrity.
> This test relies on boardenv_* configurations to run it for single or
> multiple MTD partitions.
> 
> Signed-off-by: Love Kumar <love.kumar at amd.com>
> ---
>  doc/develop/pytest/test_mtd.rst |  10 +
>  test/py/tests/test_mtd.py       | 648 ++++++++++++++++++++++++++++++++
>  2 files changed, 658 insertions(+)
>  create mode 100644 doc/develop/pytest/test_mtd.rst
>  create mode 100644 test/py/tests/test_mtd.py

Have you built the documentation and looked at it to make sure it
renders correctly? I ask because:

[snip]
> +"""
> +Note: This test relies on boardenv_* containing configuration values to
> +define one or more MTD partitions on which to exercise the 'mtd' U-Boot
> +command. The test reads env__mtd_partitions itself and loops over every
> +entry. Without this configuration the test is automatically skipped.
> +
> +It exercises the 'mtd' subcommands (list, erase, write, read, dump) and
> +a binary-file data integrity round-trip (tftp + write + read + cmp.b).
> +The suite works for single and stacked flash configurations. Partitions
> +whose detected MTD type is not 'NOR flash' are logged and skipped
> +per-partition.
> +
> +For Example:
> +
> +# List of MTD partitions to test. partition_name is the MTD partition
> +# name passed to every 'mtd' subcommand; flash_part_name is optional
> +# and, when set, is verified against 'SF: Detected <name>' lines in
> +# 'mtd list' output.
> +#
> +# partition_name      - MTD partition name (required)
> +# flash_part_name     - expected flash chip name (optional)
> +# expected_size       - partition size in bytes (optional cross-check)
> +# expected_erasesize  - erase-block size in bytes (optional cross-check)
> +# writeable           - bool; if False only non-destructive tests run
> +# timeout             - per-partition command timeout for long ops
> +env__mtd_partitions = [
> +    {
> +        'partition_name': 'qspi-fsbl-uboot',
> +        'flash_part_name': 'mt25qu512a',
> +        'expected_size': 0x1000000,
> +        'expected_erasesize': 0x10000,
> +        'writeable': True,
> +    },
> +    {
> +        'partition_name': 'rootfs_b',
> +        'flash_part_name': 'mt25qu512a',
> +        'expected_size': 0x1000000,
> +        'writeable': True,
> +    },
> +    {
> +        'partition_name': 'rootfs_a-rootfs_c-concat',
> +        'flash_part_name': 'mt25qu512a',
> +        'expected_size': 0x6000000,
> +        'writeable': True,
> +    },
> +]

I recall it being tricky to get this kind of markup to render correctly
and not produce a warning (which is fatal in CI) when doing some of the
other tests. It's possible, it's just a matter of indentation and some
other hinting to the tools that this is an example bit of code, in
essence. Thanks.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260526/5b2ea39b/attachment.sig>


More information about the U-Boot mailing list