doc: pytest: Document the test_net test

Add this test to the documentation. While the diff appears large at
first, the only changes within the test are to move the imports to
follow the pydoc comment and then to code-block and indent the example
configuration.

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:00 -06:00
committed by Heinrich Schuchardt
parent 9e56248584
commit 45d325ba09
3 changed files with 77 additions and 66 deletions

View File

@@ -18,4 +18,5 @@ Individual tests
:maxdepth: 1 :maxdepth: 1
test_000_version test_000_version
test_net
test_net_boot test_net_boot

View File

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

View File

@@ -4,12 +4,6 @@
# Test various network-related functionality, such as the dhcp, ping, and # Test various network-related functionality, such as the dhcp, ping, and
# tftpboot commands. # tftpboot commands.
import pytest
import utils
import uuid
import datetime
import re
""" """
Note: This test relies on boardenv_* containing configuration values to define Note: This test relies on boardenv_* containing configuration values to define
which network environment is available for testing. Without this, this test which network environment is available for testing. Without this, this test
@@ -17,77 +11,85 @@ 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
# False or omitted if a DHCP server is attached to the network, and dhcp abort # True if a DHCP server is attached to the network, and should be tested.
# case should be tested. # If DHCP testing is not possible or desired, this variable may be omitted or
# If DHCP abort testing is not possible or desired, set this variable to True. # set to False.
# For example: On some setup, dhcp is too fast and this case may not work. env__net_dhcp_server = True
env__dhcp_abort_test_skip = True
# True if a DHCPv6 server is attached to the network, and should be tested. # False or omitted if a DHCP server is attached to the network, and dhcp abort
# If DHCPv6 testing is not possible or desired, this variable may be omitted or # case should be tested.
# set to False. # If DHCP abort testing is not possible or desired, set this variable to True.
env__net_dhcp6_server = True # For example: On some setup, dhcp is too fast and this case may not work.
env__dhcp_abort_test_skip = True
# A list of environment variables that should be set in order to configure a # True if a DHCPv6 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 DHCPv6 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_dhcp6_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__net_tftp_readable_file = { # an empty list.
'fn': 'ubtest-readable.bin', env__net_static_env_vars = [
'addr': 0x10000000, ('ipaddr', '10.0.0.100'),
'size': 5058624, ('netmask', '255.255.255.0'),
'crc32': 'c2244b26', ('serverip', '10.0.0.1'),
'timeout': 50000, ]
'fnu': 'ubtest-upload.bin',
}
# Details regarding a file that may be read from a NFS server. This variable # Details regarding a file that may be read from a TFTP server. This variable
# may be omitted or set to None if NFS testing is not possible or desired. # may be omitted or set to None if TFTP testing is not possible or desired.
env__net_nfs_readable_file = { env__net_tftp_readable_file = {
'fn': 'ubtest-readable.bin', 'fn': 'ubtest-readable.bin',
'addr': 0x10000000, 'addr': 0x10000000,
'size': 5058624, 'size': 5058624,
'crc32': 'c2244b26', 'crc32': 'c2244b26',
} 'timeout': 50000,
'fnu': 'ubtest-upload.bin',
}
# Details regarding a file that may be read from a TFTP server. This variable # Details regarding a file that may be read from a NFS server. This variable
# may be omitted or set to None if PXE testing is not possible or desired. # may be omitted or set to None if NFS testing is not possible or desired.
env__net_pxe_readable_file = { env__net_nfs_readable_file = {
'fn': 'default', 'fn': 'ubtest-readable.bin',
'addr': 0x2000000, 'addr': 0x10000000,
'size': 74, 'size': 5058624,
'timeout': 50000, 'crc32': 'c2244b26',
'pattern': 'Linux', }
}
# True if a router advertisement service is connected to the network, and should # Details regarding a file that may be read from a TFTP server. This variable
# be tested. If router advertisement testing is not possible or desired, this # may be omitted or set to None if PXE testing is not possible or desired.
variable may be omitted or set to False. env__net_pxe_readable_file = {
env__router_on_net = True 'fn': 'default',
'addr': 0x2000000,
'size': 74,
'timeout': 50000,
'pattern': 'Linux',
}
# True if a router advertisement service is connected to the network, and should
# be tested. If router advertisement testing is not possible or desired, this
variable may be omitted or set to False.
env__router_on_net = True
""" """
import pytest
import utils
import uuid
import datetime
import re
net_set_up = False net_set_up = False
net6_set_up = False net6_set_up = False