diff options
Diffstat (limited to 'test/py/tests')
-rw-r--r-- | test/py/tests/test_efi_bootmgr/conftest.py | 6 | ||||
-rw-r--r-- | test/py/tests/test_efi_capsule/capsule_defs.py | 2 | ||||
-rw-r--r-- | test/py/tests/test_efi_capsule/conftest.py | 11 | ||||
-rw-r--r-- | test/py/tests/test_efi_secboot/conftest.py | 6 | ||||
-rw-r--r-- | test/py/tests/test_efi_secboot/defs.py | 2 | ||||
-rw-r--r-- | test/py/tests/test_efi_selftest.py | 2 | ||||
-rw-r--r-- | test/py/tests/test_hush_if_test.py | 13 | ||||
-rw-r--r-- | test/py/tests/test_net.py | 56 |
8 files changed, 85 insertions, 13 deletions
diff --git a/test/py/tests/test_efi_bootmgr/conftest.py b/test/py/tests/test_efi_bootmgr/conftest.py index a0a754afbe1..eabafa54298 100644 --- a/test/py/tests/test_efi_bootmgr/conftest.py +++ b/test/py/tests/test_efi_bootmgr/conftest.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ -"""Fixture for UEFI bootmanager test -""" +"""Fixture for UEFI bootmanager test.""" import os import shutil @@ -10,8 +9,7 @@ import pytest @pytest.fixture(scope='session') def efi_bootmgr_data(u_boot_config): - """Set up a file system to be used in UEFI bootmanager - tests + """Set up a file system to be used in UEFI bootmanager tests. Args: u_boot_config -- U-boot configuration. diff --git a/test/py/tests/test_efi_capsule/capsule_defs.py b/test/py/tests/test_efi_capsule/capsule_defs.py index 59b40f11bd1..3cc695e29b5 100644 --- a/test/py/tests/test_efi_capsule/capsule_defs.py +++ b/test/py/tests/test_efi_capsule/capsule_defs.py @@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ +"""Directoreis used for authentication and capsule tests.""" + # Directories CAPSULE_DATA_DIR = '/EFI/CapsuleTestData' CAPSULE_INSTALL_DIR = '/EFI/UpdateCapsule' diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 0e5137de60d..a337e629362 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -2,8 +2,7 @@ # Copyright (c) 2020, Linaro Limited # Author: AKASHI Takahiro <takahiro.akashi@linaro.org> -"""Fixture for UEFI capsule test -""" +"""Fixture for UEFI capsule test.""" from subprocess import call, check_call, CalledProcessError import pytest @@ -11,13 +10,15 @@ from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH @pytest.fixture(scope='session') def efi_capsule_data(request, u_boot_config): - """Set up a file system to be used in UEFI capsule and authentication test - and return a ath to disk image to be used for testing + """Set up a file system and return path to image. + + The function sets up a file system to be used in UEFI capsule and + authentication test and returns a path to disk image to be used + for testing. request -- Pytest request object. u_boot_config -- U-boot configuration. """ - mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' data_dir = mnt_point + CAPSULE_DATA_DIR install_dir = mnt_point + CAPSULE_INSTALL_DIR diff --git a/test/py/tests/test_efi_secboot/conftest.py b/test/py/tests/test_efi_secboot/conftest.py index 65cde7a2f23..30ff7029438 100644 --- a/test/py/tests/test_efi_secboot/conftest.py +++ b/test/py/tests/test_efi_secboot/conftest.py @@ -2,7 +2,7 @@ # Copyright (c) 2019, Linaro Limited # Author: AKASHI Takahiro <takahiro.akashi@linaro.org> -""" Fixture for UEFI secure boot test """ +"""Fixture for UEFI secure boot test.""" from subprocess import call, check_call, CalledProcessError import pytest @@ -132,7 +132,9 @@ def efi_boot_env(request, u_boot_config): @pytest.fixture(scope='session') def efi_boot_env_intca(request, u_boot_config): - """Set up a file system to be used in UEFI secure boot test + """Set up file system for secure boot test. + + Set up a file system to be used in UEFI secure boot test of intermediate certificates. Args: diff --git a/test/py/tests/test_efi_secboot/defs.py b/test/py/tests/test_efi_secboot/defs.py index b7a2a118511..6a2317e295b 100644 --- a/test/py/tests/test_efi_secboot/defs.py +++ b/test/py/tests/test_efi_secboot/defs.py @@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ +"""Constants used for secure boot test.""" + # Owner guid GUID = '11111111-2222-3333-4444-123456789abc' diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index e92d63cde6e..43f24245582 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -7,7 +7,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_bootefi_selftest') -def test_efi_selftest(u_boot_console): +def test_efi_selftest_base(u_boot_console): """Run UEFI unit tests u_boot_console -- U-Boot console diff --git a/test/py/tests/test_hush_if_test.py b/test/py/tests/test_hush_if_test.py index 37c1608bb22..3b4b6fcaf40 100644 --- a/test/py/tests/test_hush_if_test.py +++ b/test/py/tests/test_hush_if_test.py @@ -182,3 +182,16 @@ def test_hush_if_test_host_file_exists(u_boot_console): expr = 'test -e hostfs - ' + test_file exec_hush_if(u_boot_console, expr, False) + +def test_hush_var(u_boot_console): + """Test the set and unset of variables""" + u_boot_console.run_command('ut_var_nonexistent=') + u_boot_console.run_command('ut_var_exists=1') + u_boot_console.run_command('ut_var_unset=1') + exec_hush_if(u_boot_console, 'test -z "$ut_var_nonexistent"', True) + exec_hush_if(u_boot_console, 'test -z "$ut_var_exists"', False) + exec_hush_if(u_boot_console, 'test -z "$ut_var_unset"', False) + exec_hush_if(u_boot_console, 'ut_var_unset=', True) + exec_hush_if(u_boot_console, 'test -z "$ut_var_unset"', True) + u_boot_console.run_command('ut_var_exists=') + u_boot_console.run_command('ut_var_unset=') diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index 9ca6743afd9..cd4b4dc53cb 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -9,7 +9,7 @@ import u_boot_utils """ Note: This test relies on boardenv_* containing configuration values to define -which the network environment available for testing. Without this, this test +which network environment is available for testing. Without this, this test will be automatically skipped. For example: @@ -29,6 +29,11 @@ env__net_uses_pci = True # set to False. env__net_dhcp_server = True +# True if a DHCPv6 server is attached to the network, and should be tested. +# If DHCPv6 testing is not possible or desired, this variable may be omitted or +# set to False. +env__net_dhcp6_server = True + # A list of environment variables that should be set in order to configure a # static IP. If solely relying on DHCP, this variable may be omitted or set to # an empty list. @@ -55,9 +60,15 @@ env__net_nfs_readable_file = { 'size': 5058624, 'crc32': 'c2244b26', } + +# 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 """ net_set_up = False +net6_set_up = False def test_net_pre_commands(u_boot_console): """Execute any commands required to enable network hardware. @@ -93,6 +104,25 @@ def test_net_dhcp(u_boot_console): global net_set_up net_set_up = True +@pytest.mark.buildconfigspec('cmd_dhcp6') +def test_net_dhcp6(u_boot_console): + """Test the dhcp6 command. + + The boardenv_* file may be used to enable/disable this test; see the + comment at the beginning of this file. + """ + + test_dhcp6 = u_boot_console.config.env.get('env__net_dhcp6_server', False) + if not test_dhcp6: + pytest.skip('No DHCP6 server available') + + u_boot_console.run_command('setenv autoload no') + output = u_boot_console.run_command('dhcp6') + assert 'DHCP6 client bound to ' in output + + global net6_set_up + net6_set_up = True + @pytest.mark.buildconfigspec('net') def test_net_setup_static(u_boot_console): """Set up a static IP configuration. @@ -126,6 +156,30 @@ def test_net_ping(u_boot_console): output = u_boot_console.run_command('ping $serverip') assert 'is alive' in output +@pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY') +def test_net_network_discovery(u_boot_console): + """Test the network discovery feature of IPv6. + + An IPv6 network command (ping6 in this case) is run to make U-Boot send a + router solicitation packet, receive a router advertisement message, and + parse it. + A router advertisement service needs to be running for this test to succeed. + U-Boot receives the RA, processes it, and if successful, assigns the gateway + IP and prefix length. + The configuration is provided by the boardenv_* file; see the comment at + the beginning of this file. + """ + + router_on_net = u_boot_console.config.env.get('env__router_on_net', False) + if not router_on_net: + pytest.skip('No router on network') + + fake_host_ip = 'fe80::215:5dff:fef6:2ec6' + output = u_boot_console.run_command('ping6 ' + fake_host_ip) + assert 'ROUTER SOLICITATION 1' in output + assert 'Set gatewayip6:' in output + assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output + @pytest.mark.buildconfigspec('cmd_net') def test_net_tftpboot(u_boot_console): """Test the tftpboot command. |