Pull request efi-2025-07-rc3-2

Documentation:

* Add test/py/requirements.txt to documentation
* Use globing for selecting pytest files

UEFI:

* Provide a function to disable ANSI output during tests

Other:

* test: allow multiple config options in buildconfigspec
* test: allow testing with NET_LWIP=y
This commit is contained in:
Tom Rini
2025-05-18 08:06:56 -06:00
11 changed files with 77 additions and 27 deletions

View File

@@ -92,7 +92,7 @@ stages:
set -e set -e
python3 -m venv /tmp/venvhtml python3 -m venv /tmp/venvhtml
. /tmp/venvhtml/bin/activate . /tmp/venvhtml/bin/activate
pip install -r doc/sphinx/requirements.txt pytest pip install -r doc/sphinx/requirements.txt -r test/py/requirements.txt
make htmldocs KDOC_WERROR=1 make htmldocs KDOC_WERROR=1
make infodocs make infodocs

View File

@@ -164,7 +164,7 @@ docs:
script: script:
- python3 -m venv /tmp/venvhtml - python3 -m venv /tmp/venvhtml
- . /tmp/venvhtml/bin/activate - . /tmp/venvhtml/bin/activate
- pip install -r doc/sphinx/requirements.txt pytest - pip install -r doc/sphinx/requirements.txt -r test/py/requirements.txt
- make htmldocs KDOC_WERROR=1 - make htmldocs KDOC_WERROR=1
- make infodocs - make infodocs

View File

@@ -22,3 +22,4 @@ formats: []
python: python:
install: install:
- requirements: doc/sphinx/requirements.txt - requirements: doc/sphinx/requirements.txt
- requirements: test/py/requirements.txt

View File

@@ -16,12 +16,6 @@ Individual tests
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
:glob:
test_000_version test_*
test_bind
test_bootmenu
test_bootstage
test_button
test_efi_loader
test_net
test_net_boot

View File

@@ -522,3 +522,27 @@ of the `ubman.config` object, for example
Build configuration values (from `.config`) may be accessed via the dictionary Build configuration values (from `.config`) may be accessed via the dictionary
`ubman.config.buildconfig`, with keys equal to the Kconfig variable `ubman.config.buildconfig`, with keys equal to the Kconfig variable
names. names.
A required configuration setting can be defined via a buildconfigspec()
annotation. The name of the configuration option is specified in lower case. The
following annotation for a test requires CONFIG_EFI_LOADER=y:
.. code-block:: python
@pytest.mark.buildconfigspec('efi_loader')
Sometimes multiple configuration option supply the same functionality. If
multiple arguments are passed to buildconfigspec(), only one of the
configuration options needs to be set. The following annotation requires that
either of CONFIG_NET or CONFIG_NET_LWIP is set:
.. code-block:: python
@pytest.mark.buildconfigspec('net', 'net lwip')
The notbuildconfigspec() annotation can be used to require a configuration
option not to be set. The following annotation requires CONFIG_RISCV=n:
.. code-block:: python
@pytest.mark.notbuildconfigspec('riscv')

View File

@@ -588,8 +588,27 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index);
efi_status_t efi_bootmgr_run(void *fdt); efi_status_t efi_bootmgr_run(void *fdt);
/* search the boot option index in BootOrder */ /* search the boot option index in BootOrder */
bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index); bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index);
/* Set up console modes */
/**
* efi_setup_console_size() - update the mode table.
*
* By default the only mode available is 80x25. If the console has at least 50
* lines, enable mode 80x50. If we can query the console size and it is neither
* 80x25 nor 80x50, set it as an additional mode.
*/
void efi_setup_console_size(void); void efi_setup_console_size(void);
/**
* efi_console_set_ansi() - Set whether ANSI escape-characters should be emitted
*
* These characters mess up tests which use ut_assert_nextline(). Call this
* function to tell efi_loader not to emit these characters when starting up the
* terminal
*
* @allow_ansi: Allow emitting ANSI escape-characters
*/
void efi_console_set_ansi(bool allow_ansi);
/* Set up load options from environment variable */ /* Set up load options from environment variable */
efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var, efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var,
u16 **load_options); u16 **load_options);

View File

@@ -30,6 +30,17 @@ struct cout_mode {
__maybe_unused static struct efi_object uart_obj; __maybe_unused static struct efi_object uart_obj;
/*
* suppress emission of ANSI escape-characters for use by unit tests. Leave it
* as 0 for the default behaviour
*/
static bool no_ansi;
void efi_console_set_ansi(bool allow_ansi)
{
no_ansi = !allow_ansi;
}
static struct cout_mode efi_cout_modes[] = { static struct cout_mode efi_cout_modes[] = {
/* EFI Mode 0 is 80x25 and always present */ /* EFI Mode 0 is 80x25 and always present */
{ {
@@ -348,13 +359,6 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)
return 0; return 0;
} }
/**
* efi_setup_console_size() - update the mode table.
*
* By default the only mode available is 80x25. If the console has at least 50
* lines, enable mode 80x50. If we can query the console size and it is neither
* 80x25 nor 80x50, set it as an additional mode.
*/
void efi_setup_console_size(void) void efi_setup_console_size(void)
{ {
int rows = 25, cols = 80; int rows = 25, cols = 80;
@@ -362,8 +366,12 @@ void efi_setup_console_size(void)
if (IS_ENABLED(CONFIG_VIDEO)) if (IS_ENABLED(CONFIG_VIDEO))
ret = query_vidconsole(&rows, &cols); ret = query_vidconsole(&rows, &cols);
if (ret) if (ret) {
ret = query_console_serial(&rows, &cols); if (no_ansi)
ret = 0;
else
ret = query_console_serial(&rows, &cols);
}
if (ret) if (ret)
return; return;

View File

@@ -711,9 +711,13 @@ def setup_buildconfigspec(item):
""" """
for options in item.iter_markers('buildconfigspec'): for options in item.iter_markers('buildconfigspec'):
option = options.args[0] nomatch = True
if not ubconfig.buildconfig.get('config_' + option.lower(), None): for arg in options.args:
pytest.skip('.config feature "%s" not enabled' % option.lower()) if ubconfig.buildconfig.get('config_' + arg.lower(), None):
nomatch = False
if nomatch:
argsString = ', '.join(options.args)
pytest.skip(f'.config features "{argsString}" not enabled')
for options in item.iter_markers('notbuildconfigspec'): for options in item.iter_markers('notbuildconfigspec'):
option = options.args[0] option = options.args[0]
if ubconfig.buildconfig.get('config_' + option.lower(), None): if ubconfig.buildconfig.get('config_' + option.lower(), None):

View File

@@ -98,7 +98,7 @@ def test_efi_setup_dhcp(ubman):
global net_set_up global net_set_up
net_set_up = True net_set_up = True
@pytest.mark.buildconfigspec('net') @pytest.mark.buildconfigspec('net', 'net_lwip')
def test_efi_setup_static(ubman): def test_efi_setup_static(ubman):
"""Set up the network using a static IP configuration. """Set up the network using a static IP configuration.

View File

@@ -506,7 +506,7 @@ def test_fpga_loadfs(ubman):
@pytest.mark.buildconfigspec('cmd_fpga_load_secure') @pytest.mark.buildconfigspec('cmd_fpga_load_secure')
@pytest.mark.buildconfigspec('cmd_net') @pytest.mark.buildconfigspec('cmd_net')
@pytest.mark.buildconfigspec('cmd_dhcp') @pytest.mark.buildconfigspec('cmd_dhcp')
@pytest.mark.buildconfigspec('net') @pytest.mark.buildconfigspec('net', 'net_lwip')
def test_fpga_secure_bit_auth(ubman): def test_fpga_secure_bit_auth(ubman):
test_net.test_net_dhcp(ubman) test_net.test_net_dhcp(ubman)
@@ -534,7 +534,7 @@ def test_fpga_secure_bit_auth(ubman):
@pytest.mark.buildconfigspec('cmd_fpga_load_secure') @pytest.mark.buildconfigspec('cmd_fpga_load_secure')
@pytest.mark.buildconfigspec('cmd_net') @pytest.mark.buildconfigspec('cmd_net')
@pytest.mark.buildconfigspec('cmd_dhcp') @pytest.mark.buildconfigspec('cmd_dhcp')
@pytest.mark.buildconfigspec('net') @pytest.mark.buildconfigspec('net', 'net_lwip')
def test_fpga_secure_bit_img_auth_kup(ubman): def test_fpga_secure_bit_img_auth_kup(ubman):
test_net.test_net_dhcp(ubman) test_net.test_net_dhcp(ubman)

View File

@@ -201,7 +201,7 @@ def test_net_dhcp6(ubman):
global net6_set_up global net6_set_up
net6_set_up = True net6_set_up = True
@pytest.mark.buildconfigspec('net') @pytest.mark.buildconfigspec('net', 'net_lwip')
def test_net_setup_static(ubman): def test_net_setup_static(ubman):
"""Set up a static IP configuration. """Set up a static IP configuration.