From cbd71fad6d468018727ab04b2bb912989aec0785 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:22:50 -0600 Subject: test: Support tests which can only be run manually At present we normally write tests either in Python or in C. But most Python tests end up doing a lot of checks which would be better done in C. Checks done in C are orders of magnitude faster and it is possible to get full access to U-Boot's internal workings, rather than just relying on the command line. The model is to have a Python test set up some things and then use C code (in a unit test) to check that they were done correctly. But we don't want those checks to happen as part of normal test running, since each C unit tests is dependent on the associate Python tests, so cannot run without it. To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check' tests, so that they can be skipped by default when the 'ut' command is used. Require that tests have a name ending with '_norun', so that pytest knows to skip them. Signed-off-by: Simon Glass --- test/py/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/py') diff --git a/test/py/conftest.py b/test/py/conftest.py index 304e93164aa..fc9dd3a83f8 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -289,7 +289,13 @@ def generate_ut_subtest(metafunc, fixture_name, sym_path): m = re_ut_test_list.search(l) if not m: continue - vals.append(m.group(1) + ' ' + m.group(2)) + suite, name = m.groups() + + # Tests marked with _norun should only be run manually using 'ut -f' + if name.endswith('_norun'): + continue + + vals.append(f'{suite} {name}') ids = ['ut_' + s.replace(' ', '_') for s in vals] metafunc.parametrize(fixture_name, vals, ids=ids) -- cgit v1.2.3 From 98bedf42ea49ceec934e0a47aa35caa38aac31b7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:05 -0600 Subject: vbe: Rename vbe_fixup to vbe_request The vbe_fixup file handles device tree fixups, but these are called OS requests in VBE. Rename the file to reflect its wider purpose. Signed-off-by: Simon Glass --- test/py/tests/test_event_dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/py') diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index 674df2ea001..0984efaf3c1 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -16,7 +16,7 @@ def test_event_dump(u_boot_console): out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ -EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*vbe_fixup.c:.* +EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*vbe_request.c:.* EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*vbe_simple.c:.* EVT_MISC_INIT_F sandbox_misc_init_f .*start.c:''' assert re.match(expect, out, re.MULTILINE) is not None -- cgit v1.2.3 From c263e21bcb01f19e6ccb2452fdcc601ff84942db Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:11 -0600 Subject: vbe: Move OS implementation into a separate file Move this into its own file so it can be built only by U-Boot proper. Signed-off-by: Simon Glass --- test/py/tests/test_event_dump.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/py') diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index 0984efaf3c1..972c3837111 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -17,6 +17,5 @@ def test_event_dump(u_boot_console): expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*vbe_request.c:.* -EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*vbe_simple.c:.* EVT_MISC_INIT_F sandbox_misc_init_f .*start.c:''' assert re.match(expect, out, re.MULTILINE) is not None -- cgit v1.2.3 From 4218456b3fac98966a320c3f2db36d543a32ec17 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:13 -0600 Subject: vbe: Add Kconfig options for VPL Enable the various features needed in VPL, by adding Kconfig options. Update the defconfig for sandbox_vpl so that the build for each phase includes what is needed. Drop LZMA for now and make sure partition support is omitted in SPL, since it is not needed. Signed-off-by: Simon Glass --- test/py/tests/test_event_dump.py | 1 + 1 file changed, 1 insertion(+) (limited to 'test/py') diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index 972c3837111..1a46ca30f42 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -17,5 +17,6 @@ def test_event_dump(u_boot_console): expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*vbe_request.c:.* +EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*vbe_simple_os.c:.* EVT_MISC_INIT_F sandbox_misc_init_f .*start.c:''' assert re.match(expect, out, re.MULTILINE) is not None -- cgit v1.2.3 From 2a5c67f50a438b266dc72c9401e578ec8b81db16 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:17 -0600 Subject: vbe: Use a manual test Use a manual test for the VBE test, so we can make the pytest and the C unit test work together properly. Signed-off-by: Simon Glass --- test/py/tests/test_vbe.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'test/py') diff --git a/test/py/tests/test_vbe.py b/test/py/tests/test_vbe.py index 559c2918868..50b6c1cd911 100644 --- a/test/py/tests/test_vbe.py +++ b/test/py/tests/test_vbe.py @@ -85,7 +85,7 @@ bootm loados bootm prep fdt addr fdt print -ut bootstd vbe_test_fixup +ut bootstd -f vbe_test_fixup_norun ''' @pytest.mark.boardspec('sandbox_flattree') @@ -117,7 +117,4 @@ def test_vbe(u_boot_console): with cons.log.section('Kernel load'): output = cons.run_command_list(cmd.splitlines()) - # This is a little wonky since there are two tests running in CI. The final - # one is the 'ut bootstd' command above - failures = [line for line in output if 'Failures' in line] - assert len(failures) >= 1 and 'Failures: 0' in failures[-1] + assert 'Failures: 0' in output[-1] -- cgit v1.2.3 From 77bec9e3d8bd2dc307447b92a3d5cefd693a62ad Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 20 Oct 2022 18:23:20 -0600 Subject: vbe: Add a test for the VBE flow into U-Boot proper Add a test which checks that VBE boots correctly from TPL through to U-Boot proper. Signed-off-by: Simon Glass --- test/py/tests/test_vbe_vpl.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/py/tests/test_vbe_vpl.py (limited to 'test/py') diff --git a/test/py/tests/test_vbe_vpl.py b/test/py/tests/test_vbe_vpl.py new file mode 100644 index 00000000000..d1c9d0548ae --- /dev/null +++ b/test/py/tests/test_vbe_vpl.py @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2022 Google LLC +# +# Test addition of VBE + +import os + +import pytest +import u_boot_utils + +@pytest.mark.boardspec('sandbox_vpl') +@pytest.mark.requiredtool('dtc') +def test_vbe_vpl(u_boot_console): + cons = u_boot_console + #cmd = [cons.config.build_dir + fname, '-v'] + ram = os.path.join(cons.config.build_dir, 'ram.bin') + fdt = os.path.join(cons.config.build_dir, 'arch/sandbox/dts/test.dtb') + + # Enable firmware1 and the mmc that it uses. These are needed for the full + # VBE flow. + u_boot_utils.run_and_log( + cons, f'fdtput -t s {fdt} /bootstd/firmware0 status disabled') + u_boot_utils.run_and_log( + cons, f'fdtput -t s {fdt} /bootstd/firmware1 status okay') + u_boot_utils.run_and_log( + cons, f'fdtput -t s {fdt} /mmc3 status okay') + + # Remove any existing RAM file, so we don't have old data present + if os.path.exists(ram): + os.remove(ram) + flags = ['-p', os.path.join(cons.config.build_dir, 'image.bin'), '-w', + '-s', 'state.dtb'] + cons.restart_uboot_with_flags(flags) + + # Make sure that VBE was used in both VPL (to load SPL) and SPL (to load + # U-Boot + output = cons.run_command('vbe state') + assert output == 'Phases: VPL SPL' -- cgit v1.2.3