[PATCH v5 6/7] test: vboot: refactor run_bootm
Ludwig Nussel
ludwig.nussel at siemens.com
Thu May 28 13:48:02 CEST 2026
- split off a generic part of run_bootm. The helper function is for
future use in similar commands
- moves u-boot restart below section opening for better log structuring
- only look for expected string in last command. This way a failed
assert() doesn't dump unrelated output.
Signed-off-by: Ludwig Nussel <ludwig.nussel at siemens.com>
---
Changes in v5:
- new patch
test/py/tests/test_vboot.py | 54 +++++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 6459c7c313e..66598fde557 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -151,6 +151,37 @@ def test_vboot(ubman, name, sha_algo, padding, sign_options, required,
tmpdir, '-I', tmpdir])
os.environ['PYTHONPATH'] = pythonpath
+
+ def run_fit_commands(commands, expect_string, fit=None):
+ """Load fit image and run commands in U-Boot.
+
+ Asserts that 'expect_string' is contained in the output of the last command
+
+ This always starts a fresh U-Boot instance since the device tree may
+ contain a new public key.
+
+ Args:
+ commands: list of commands to run
+ expect_string: A string which is expected in the output
+ fit: FIT filename to load and verify
+ """
+
+ ubman.restart_uboot()
+
+ if not fit:
+ fit = '%stest.fit' % tmpdir
+ # run commands that just prepare for the actually relevant one
+ ubman.run_command('host load hostfs - 100 %s' % fit)
+ if (len(commands) > 1):
+ for cmd in commands[:-1]:
+ ubman.run_command(cmd)
+
+ output = ''.join(ubman.run_command(commands[-1]))
+
+ assert expect_string in output
+
+ return output
+
def run_bootm(sha_algo, test_type, expect_string, boots, fit=None):
"""Run a 'bootm' command U-Boot.
@@ -166,20 +197,15 @@ def test_vboot(ubman, name, sha_algo, padding, sign_options, required,
we are expected to not boot
fit: FIT filename to load and verify
"""
- if not fit:
- fit = '%stest.fit' % tmpdir
- ubman.restart_uboot()
- with ubman.log.section('Verified boot %s %s' % (sha_algo, test_type)):
- output = ubman.run_command_list(
- ['host load hostfs - 100 %s' % fit,
- 'fdt addr 100',
- 'bootm 100'])
- assert expect_string in ''.join(output)
- if boots:
- assert 'sandbox: continuing, as we cannot run' in ''.join(output)
- else:
- assert('sandbox: continuing, as we cannot run'
- not in ''.join(output))
+
+ with ubman.log.section(f'Verified boot {sha_algo} {test_type}: looking for "{expect_string}"'):
+
+ output = run_fit_commands(['fdt addr 100', 'bootm 100'], expect_string, fit)
+
+ if boots:
+ assert 'sandbox: continuing, as we cannot run' in output
+ else:
+ assert 'sandbox: continuing, as we cannot run' not in output
def sign_fit(sha_algo, options):
"""Sign the FIT
--
2.43.0
More information about the U-Boot
mailing list