[PATCH v2 21/21] upl: Add an end-to-end test
Simon Glass
sjg at chromium.org
Sat Jul 13 09:00:55 CEST 2024
Now that sandbox_vpl supports UPL, add a test that checks that the
payload can be loaded by SPL and the handoff information passed through
to U-Boot proper.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Support CI testing
- Rework to use alist instead of fixed-length arrays
MAINTAINERS | 1 +
test/boot/upl.c | 28 ++++++++++++++++++++++++++++
test/py/tests/test_upl.py | 17 +++++++++++++++--
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 96faa9e1acc..e89d166709d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1705,6 +1705,7 @@ F: doc/usage/upl.rst
F: doc/usage/cmd/upl.rst
F: include/upl.h
F: test/boot/upl.c
+F: test/py/tests/test_upl.py
USB
M: Marek Vasut <marex at denx.de>
diff --git a/test/boot/upl.c b/test/boot/upl.c
index c55f1d297d1..9ec2540f455 100644
--- a/test/boot/upl.c
+++ b/test/boot/upl.c
@@ -398,6 +398,34 @@ static int upl_test_read_write(struct unit_test_state *uts)
}
UPL_TEST(upl_test_read_write, UT_TESTF_CONSOLE_REC);
+/* Test UPL passthrough */
+static int upl_test_info_norun(struct unit_test_state *uts)
+{
+ const struct upl_image *img;
+ struct upl *upl = gd_upl();
+ const void *fit;
+
+ ut_assertok(run_command("upl info -v", 0));
+ ut_assert_nextline("UPL state: active");
+ ut_assert_nextline("fit %lx", upl->fit);
+ ut_assert_nextline("conf_offset %x", upl->conf_offset);
+ ut_assert_nextlinen("image 0");
+ ut_assert_console_end();
+
+ /* check the offsets */
+ fit = map_sysmem(upl->fit, 0);
+ ut_asserteq_str("conf-1", fdt_get_name(fit, upl->conf_offset, NULL));
+
+ ut_asserteq(1, upl->image.count);
+
+ img = alist_get(&upl->image, 0, struct upl_image);
+ ut_asserteq_str("firmware-1", fdt_get_name(fit, img->offset, NULL));
+ ut_asserteq(CONFIG_TEXT_BASE, img->load);
+
+ return 0;
+}
+UPL_TEST(upl_test_info_norun, UT_TESTF_CONSOLE_REC | UT_TESTF_MANUAL);
+
int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test *tests = UNIT_TEST_SUITE_START(upl_test);
diff --git a/test/py/tests/test_upl.py b/test/py/tests/test_upl.py
index 171079f8dba..3164bda6b71 100644
--- a/test/py/tests/test_upl.py
+++ b/test/py/tests/test_upl.py
@@ -10,6 +10,15 @@ 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 inpected 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')
@@ -17,9 +26,13 @@ def test_upl_handoff(u_boot_console):
# 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]
+ 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 output == 'UPL state: active'
+ 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
--
2.34.1
More information about the U-Boot
mailing list