doc: pytest: Document the test_efi_loader test

Add this test to the documentation. We need to add a code-block
annotation to the example and indent it correctly. We also need to
document the do_test_efi_helloworld_net function and that in turn means
changing the documentation to test_efi_helloworld_net_http and
test_efi_helloworld_net_tftp to reflect what is and isn't done in those
functions themselves now.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Tom Rini
2025-05-07 17:23:02 -06:00
committed by Heinrich Schuchardt
parent 58b2f0895b
commit 6c3c08c478
3 changed files with 50 additions and 36 deletions

View File

@@ -19,5 +19,6 @@ Individual tests
test_000_version test_000_version
test_bootstage test_bootstage
test_efi_loader
test_net test_net
test_net_boot test_net_boot

View File

@@ -0,0 +1,8 @@
test_efi_loader
===============
.. automodule:: test_efi_loader
:synopsis:
:member-order: bysource
:members:
:undoc-members:

View File

@@ -13,43 +13,45 @@ that rely on network will be automatically skipped.
For example: For example:
# Boolean indicating whether the Ethernet device is attached to USB, and hence .. code-block:: python
# USB enumeration needs to be performed prior to network tests.
# This variable may be omitted if its value is False.
env__net_uses_usb = False
# Boolean indicating whether the Ethernet device is attached to PCI, and hence # Boolean indicating whether the Ethernet device is attached to USB, and hence
# PCI enumeration needs to be performed prior to network tests. # USB enumeration needs to be performed prior to network tests.
# This variable may be omitted if its value is False. # This variable may be omitted if its value is False.
env__net_uses_pci = True env__net_uses_usb = False
# True if a DHCP server is attached to the network, and should be tested. # Boolean indicating whether the Ethernet device is attached to PCI, and hence
# If DHCP testing is not possible or desired, this variable may be omitted or # PCI enumeration needs to be performed prior to network tests.
# set to False. # This variable may be omitted if its value is False.
env__net_dhcp_server = True env__net_uses_pci = True
# A list of environment variables that should be set in order to configure a # True if a DHCP server is attached to the network, and should be tested.
# static IP. If solely relying on DHCP, this variable may be omitted or set to # If DHCP testing is not possible or desired, this variable may be omitted or
# an empty list. # set to False.
env__net_static_env_vars = [ env__net_dhcp_server = True
('ipaddr', '10.0.0.100'),
('netmask', '255.255.255.0'),
('serverip', '10.0.0.1'),
]
# Details regarding a file that may be read from a TFTP server. This variable # A list of environment variables that should be set in order to configure a
# may be omitted or set to None if TFTP testing is not possible or desired. # static IP. If solely relying on DHCP, this variable may be omitted or set to
env__efi_loader_helloworld_file = { # an empty list.
'fn': 'lib/efi_loader/helloworld.efi', # file name env__net_static_env_vars = [
'size': 5058624, # file length in bytes ('ipaddr', '10.0.0.100'),
'crc32': 'c2244b26', # CRC32 check sum ('netmask', '255.255.255.0'),
'addr': 0x40400000, # load address ('serverip', '10.0.0.1'),
} ]
# False if the helloworld EFI over HTTP boot test should be performed. # Details regarding a file that may be read from a TFTP server. This variable
# If HTTP boot testing is not possible or desired, set this variable to True or # may be omitted or set to None if TFTP testing is not possible or desired.
# ommit it. env__efi_loader_helloworld_file = {
env__efi_helloworld_net_http_test_skip = True 'fn': 'lib/efi_loader/helloworld.efi', # file name
'size': 5058624, # file length in bytes
'crc32': 'c2244b26', # CRC32 check sum
'addr': 0x40400000, # load address
}
# False if the helloworld EFI over HTTP boot test should be performed.
# If HTTP boot testing is not possible or desired, set this variable to True or
# ommit it.
env__efi_helloworld_net_http_test_skip = True
""" """
import pytest import pytest
@@ -161,6 +163,11 @@ def fetch_file(ubman, env_conf, proto):
return addr return addr
def do_test_efi_helloworld_net(ubman, proto): def do_test_efi_helloworld_net(ubman, proto):
"""Download and execute the helloworld appliation
The helloworld.efi file is downloaded based on the value passed to us as a
protocol and is executed using the fallback device tree at $fdtcontroladdr.
"""
addr = fetch_file(ubman, 'env__efi_loader_helloworld_file', proto) addr = fetch_file(ubman, 'env__efi_loader_helloworld_file', proto)
output = ubman.run_command('bootefi %x' % addr) output = ubman.run_command('bootefi %x' % addr)
@@ -175,8 +182,7 @@ def do_test_efi_helloworld_net(ubman, proto):
def test_efi_helloworld_net_tftp(ubman): def test_efi_helloworld_net_tftp(ubman):
"""Run the helloworld.efi binary via TFTP. """Run the helloworld.efi binary via TFTP.
The helloworld.efi file is downloaded from the TFTP server and is executed Call the do_test_efi_helloworld_net function to execute the test via TFTP.
using the fallback device tree at $fdtcontroladdr.
""" """
do_test_efi_helloworld_net(ubman, PROTO_TFTP); do_test_efi_helloworld_net(ubman, PROTO_TFTP);
@@ -187,8 +193,7 @@ def test_efi_helloworld_net_tftp(ubman):
def test_efi_helloworld_net_http(ubman): def test_efi_helloworld_net_http(ubman):
"""Run the helloworld.efi binary via HTTP. """Run the helloworld.efi binary via HTTP.
The helloworld.efi file is downloaded from the HTTP server and is executed Call the do_test_efi_helloworld_net function to execute the test via HTTP.
using the fallback device tree at $fdtcontroladdr.
""" """
if ubman.config.env.get('env__efi_helloworld_net_http_test_skip', True): if ubman.config.env.get('env__efi_helloworld_net_http_test_skip', True):
pytest.skip('helloworld.efi HTTP test is not enabled!') pytest.skip('helloworld.efi HTTP test is not enabled!')