Simon Glass | b6c665f | 2022-04-30 00:56:55 -0600 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | # Copyright 2022 Google LLC |
| 3 | # Written by Simon Glass <sjg@chromium.org> |
| 4 | |
| 5 | import os.path |
| 6 | import pytest |
| 7 | |
| 8 | def test_vpl(u_boot_console, ut_vpl_subtest): |
| 9 | """Execute a "ut" subtest. |
| 10 | |
| 11 | The subtests are collected in function generate_ut_subtest() from linker |
| 12 | generated lists by applying a regular expression to the lines of file |
| 13 | vpl/u-boot-vpl.sym. The list entries are created using the C macro |
| 14 | UNIT_TEST(). |
| 15 | |
| 16 | Strict naming conventions have to be followed to match the regular |
| 17 | expression. Use UNIT_TEST(foo_test_bar, _flags, foo_test) for a test bar in |
| 18 | test suite foo that can be executed via command 'ut foo bar' and is |
| 19 | implemented in C function foo_test_bar(). |
| 20 | |
| 21 | Args: |
| 22 | u_boot_console (ConsoleBase): U-Boot console |
| 23 | ut_subtest (str): VPL test to be executed (e.g. 'dm platdata_phandle') |
| 24 | """ |
| 25 | try: |
| 26 | cons = u_boot_console |
| 27 | cons.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]]) |
| 28 | output = cons.get_spawn_output().replace('\r', '') |
| 29 | assert 'Failures: 0' in output |
| 30 | finally: |
| 31 | # Restart afterward in case a non-VPL test is run next. This should not |
| 32 | # happen since VPL tests are run in their own invocation of test.py, but |
| 33 | # the cost of doing this is not too great at present. |
| 34 | u_boot_console.restart_uboot() |