diff options
| author | Vincent Jardin <[email protected]> | 2026-07-15 18:57:17 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-07-27 09:07:39 -0600 |
| commit | 0ccf0193a58120f7a898a4379434b481be41b9f6 (patch) | |
| tree | ac9c067cd012cdb115b17dccfe801d01d22b0f85 | |
| parent | c23eeeadfc4a2f351f056bc1d12b210a5fb9c3e9 (diff) | |
test: py: load: check null_dev_desc_ok dispatch
Some pytest modules exercising the dispatch added by
fs: dispatch null_dev_desc_ok filesystems before lookup
test_load_semihosting.py:
"load semihosting - <addr> <file>" and the optional
[bytes] [pos] variant. Runs on qemu_arm64 with
CONFIG_SEMIHOSTING=y; reuses test_hostfs.py's host-staged
fixture.
test_load_sandbox.py:
"load sandbox - <addr> <file>" and the optional [bytes] [pos]
variant. Runs on sandbox (boardspec('sandbox')); the sandbox
fstype is registered with name="sandbox" and
null_dev_desc_ok=true,
so the same fs_lookup_null_dev_info() helper that
routes semihosting also routes the "sandbox".
A "load ubifs - <addr> <file>" test is intentionally not provided.
UBIFS is built on UBI on MTD, which requires some additional works
that are not available with qemu/sandbox-ing.
Signed-off-by: Vincent Jardin <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
| -rw-r--r-- | test/py/tests/test_load_sandbox.py | 51 | ||||
| -rw-r--r-- | test/py/tests/test_semihosting/conftest.py | 4 | ||||
| -rw-r--r-- | test/py/tests/test_semihosting/test_load_semihosting.py | 38 |
3 files changed, 91 insertions, 2 deletions
diff --git a/test/py/tests/test_load_sandbox.py b/test/py/tests/test_load_sandbox.py new file mode 100644 index 00000000000..8d28a630e76 --- /dev/null +++ b/test/py/tests/test_load_sandbox.py @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2026 Free Mobile - Vincent Jardin + +"""Regression test for `load sandbox - <addr> <file>`. + +Exercises the null_dev_desc_ok dispatch added in +"fs: dispatch null_dev_desc_ok filesystems before block lookup". + +It is the counterpart of test_load_semihosting.py +""" + +import os +import pytest + + [email protected](scope='session') +def sandbox_fixture(u_boot_config): + """Host-staged fixture file read by `load sandbox`.""" + path = os.path.join(u_boot_config.persistent_data_dir, + 'sandbox-fstype.txt') + with open(path, 'w', encoding='utf-8') as f: + f.write('Das U-Boot\n') # 11 bytes, same as test_hostfs.py / semihosting + yield path + os.remove(path) + + [email protected]('sandbox') +def test_sandbox_load(ubman, sandbox_fixture): + """Run `load sandbox - <addr> <file>` and check the bytes.""" + response = ubman.run_command( + f'load sandbox - $loadaddr {sandbox_fixture}') + + # Fixture is "Das U-Boot\n" (11 bytes). + assert '11 bytes read' in response + + # crc32("Das U-Boot\n") -- identical to the semihosting / hostfs checks. + response = ubman.run_command('crc32 $loadaddr $filesize') + assert '==> 60cfccfc' in response + + [email protected]('sandbox') +def test_sandbox_load_offset(ubman, sandbox_fixture): + """Run the [bytes] [pos] variant through the same dispatch.""" + response = ubman.run_command( + f'load sandbox - $loadaddr {sandbox_fixture} 4 6') + # bytes=4 pos=6 over "Das U-Boot\n" -> "Boot". + assert '4 bytes read' in response + + # crc32("Boot") + response = ubman.run_command('crc32 $loadaddr $filesize') + assert '==> e6df01fa' in response diff --git a/test/py/tests/test_semihosting/conftest.py b/test/py/tests/test_semihosting/conftest.py index b00d8f4ea9c..6b7f3f3c2d9 100644 --- a/test/py/tests/test_semihosting/conftest.py +++ b/test/py/tests/test_semihosting/conftest.py @@ -6,9 +6,9 @@ import os import pytest [email protected](scope='session') [email protected](scope='function') def semihosting_data(u_boot_config): - """Set up a file system to be used in semihosting tests + """Set up a new file for each semihosting test Args: u_boot_config -- U-Boot configuration. diff --git a/test/py/tests/test_semihosting/test_load_semihosting.py b/test/py/tests/test_semihosting/test_load_semihosting.py new file mode 100644 index 00000000000..7c2eb72c69a --- /dev/null +++ b/test/py/tests/test_semihosting/test_load_semihosting.py @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2026 Free Mobile - Vincent Jardin + +"""Regression test for `load semihosting - <addr> <file>`. + +Companion to test_hostfs.py: same fixture, same crc32, different +fstype routing: +see the doc/usage/cmd/load.rst "Null-block-device interfaces" section. +""" + +import pytest + + [email protected]('semihosting') +def test_semihosting_load(ubman, semihosting_data): + """Run `load semihosting - <addr> <file>` and check the bytes.""" + response = ubman.run_command( + f'load semihosting - $loadaddr {semihosting_data}') + + # Fixture is "Das U-Boot\n" (11 bytes). + assert '11 bytes read' in response + + # crc32("Das U-Boot\n") + response = ubman.run_command('crc32 $loadaddr $filesize') + assert '==> 60cfccfc' in response + + [email protected]('semihosting') +def test_semihosting_load_offset(ubman, semihosting_data): + """Run the [bytes] [pos] variant through the same dispatch.""" + response = ubman.run_command( + f'load semihosting - $loadaddr {semihosting_data} 4 6') + # bytes=4 pos=6 over "Das U-Boot\n" -> "Boot". + assert '4 bytes read' in response + + # crc32("Boot") + response = ubman.run_command('crc32 $loadaddr $filesize') + assert '==> e6df01fa' in response |
