[PATCH v3 9/9] test: Add pytest suite for NVMEM framework

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 17 01:03:08 PDT 2025


On Thu, Jun 12, 2025 at 08:58:12AM +0200, Oleksij Rempel wrote:
> Introduce test_nvmem.py, a pytest-based suite for
> validating Barebox's NVMEM framework and shell commands.
> It uses pytest-labgrid for target interaction.
> 
> Tests cover:
> 
> - nvmem command: Listing, dynamic rmem creation (-c, -v), parameter
>   validation, help.
> 
> - CDEV operations (/dev/rmemX): md/mw for read/write with various access
>   sizes (byte, word, long), byte swapping (-x), string/numerical data,
>   and wrapped md output.
> 
> - Protection: protect/unprotect commands, including writes to
>   protected/unprotected areas, out-of-bounds protection attempts, and
> merging of overlapping protected ranges.
> 
> Includes helpers for parsing md output and checks command return
> codes and data integrity. A session-wide fixture skips tests if
> essential related CONFIGs are disabled.
> 
> Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
> ---
>  test/py/test_nvmem.py | 1012 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 1012 insertions(+)
>  create mode 100644 test/py/test_nvmem.py
> 
> diff --git a/test/py/test_nvmem.py b/test/py/test_nvmem.py
> new file mode 100644
> index 000000000000..fdb3c8eb6022
> --- /dev/null
> +++ b/test/py/test_nvmem.py
> @@ -0,0 +1,1012 @@
> +import pytest
> +import re
> +
> +# --- Essential Configuration Check ---
> +
> +# This list should contain the CONFIG strings for all commands and features
> +# that are absolutely essential for the NVMEM test suite to run.
> +ESSENTIAL_CONFIGS = [
> +    "CONFIG_CMD_NVMEM",       # For the 'nvmem' command itself
> +    "CONFIG_CMD_MD",          # For the 'md' (memory display) command
> +    "CONFIG_CMD_MW",          # For the 'mw' (memory write) command
> +    "CONFIG_CMD_FLASH",       # For 'protect' and 'unprotect' commands
> +    "CONFIG_NVMEM_RMEM",      # For creating dynamic rmem NVMEM devices
> +    "CONFIG_FS_DEVFS"         # For /dev/ device character file paths
> +]

There doesn't seem to be any config with this combination of options, so
I assume this test will never be executed.

Specifically CONFIG_CMD_NVMEM is disabled in all defconfigs. It's a good
thing for coverage to have at least one config with this option enabled,
could you add it to multi_v8_defconfig?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list