u-boot/test/py/tests/test_upl.py
Tom Rini 8162f35a10 Merge patch series "test: Improvements to ut command and test-suite running"
Simon Glass <sjg@chromium.org> says:

The current method of running unit tests relies on subcommands of the
ut command. Only the code in each subcommand knows how to find the tests
related to that subcomand.

This is not ideal and we now have quite a few subcommands which do
nothing but locate the relevant tests in a linker list, then call a
common function to run them.

This series adds a list of test suites, so that these subcommands can be
removed.

An issue with 'ut all' is that it doesn't record how many tests failed
overall, so it is necessary to examine copious amounts of output to look
for failures. This series adds a new 'total' feature allow recording the
total number of failed tests.

To help with 'ut all' a new pytest is created which runs it (as well as
'ut info') and makes sure that all is well. Due to the 'ut all' failures
this does not pass, so the test is disabled for now. It is here because
it provides security against misnaming a test suite and causing it not
to run.

Future work may:
- get 'ut all' passing
- enable test_suite() in CL, to ensure that 'ut all' keeps passing
- record duration of each suite
- allow running the tests in random order to tease out dependencies
- tweak the output to remove common prefixes
- getting rid of bootstd, optee and seame 'ut' subcommands

Link: https://lore.kernel.org/r/20250120212613.516664-1-sjg@chromium.org
2025-01-24 14:35:37 -06:00

38 lines
1.2 KiB
Python

# SPDX-License-Identifier: GPL-2.0+
# Copyright 2024 Google LLC
#
# Test addition of Universal Payload
import os
import pytest
import u_boot_utils
@pytest.mark.boardspec('sandbox_vpl')
def test_upl_handoff(u_boot_console):
"""Test of UPL handoff
This works by starting up U-Boot VPL, which gets to SPL and then sets up a
UPL handoff using the FIT containing U-Boot proper. It then jumps to U-Boot
proper and runs a test to check that the parameters are correct.
The entire FIT is loaded into memory in SPL (in upl_load_from_image()) so
that it can be inspected in upl_test_info_norun
"""
cons = u_boot_console
ram = os.path.join(cons.config.build_dir, 'ram.bin')
fdt = os.path.join(cons.config.build_dir, 'u-boot.dtb')
# Remove any existing RAM file, so we don't have old data present
if os.path.exists(ram):
os.remove(ram)
flags = ['-m', ram, '-d', fdt, '--upl']
cons.restart_uboot_with_flags(flags, use_dtb=False)
# Make sure that Universal Payload is detected in U-Boot proper
output = cons.run_command('upl info')
assert 'UPL state: active' == output
# Check the FIT offsets look correct
output = cons.run_command('ut upl -f upl_test_info_norun')
assert 'failures: 0' in output