blob: a269c7c262ef4245acb47e23ae1d8df5d0379e63 [file] [log] [blame]
Simon Glassb6c665f2022-04-30 00:56:55 -06001# SPDX-License-Identifier: GPL-2.0
2# Copyright 2022 Google LLC
3# Written by Simon Glass <sjg@chromium.org>
4
5import os.path
6import pytest
7
Simon Glassddba5202025-02-09 09:07:14 -07008def test_vpl(ubman, ut_vpl_subtest):
Simon Glassb6c665f2022-04-30 00:56:55 -06009 """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:
Simon Glassddba5202025-02-09 09:07:14 -070022 ubman (ConsoleBase): U-Boot console
Simon Glassb6c665f2022-04-30 00:56:55 -060023 ut_subtest (str): VPL test to be executed (e.g. 'dm platdata_phandle')
24 """
25 try:
Simon Glass32701112025-02-09 09:07:17 -070026 ubman.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]])
27 output = ubman.get_spawn_output().replace('\r', '')
Simon Glass1f271dc2025-01-20 14:26:01 -070028 assert 'failures: 0' in output
Simon Glassb6c665f2022-04-30 00:56:55 -060029 finally:
30 # Restart afterward in case a non-VPL test is run next. This should not
31 # happen since VPL tests are run in their own invocation of test.py, but
32 # the cost of doing this is not too great at present.
Simon Glassddba5202025-02-09 09:07:14 -070033 ubman.restart_uboot()