[PATCH 20/21] py/tests: test_efi_selftest: Add test for removing EFI netdevices

Adriano Cordova adrianox at gmail.com
Wed Jan 22 18:08:57 CET 2025


unbind ethernet udevices and count them to check that were properly removed
also from the EFI network stack

Signed-off-by: Adriano Cordova <adriano.cordova at canonical.com>
---
 test/py/tests/test_efi_selftest.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py
index af9992a6f7..2b7944d198 100644
--- a/test/py/tests/test_efi_selftest.py
+++ b/test/py/tests/test_efi_selftest.py
@@ -216,3 +216,27 @@ def test_efi_selftest_count_netdevices(u_boot_console):
     u_boot_console.run_command('bootefi selftest', wait_for_prompt=False)
     if u_boot_console.p.expect([f'Detected {ethernet_count} active EFI net devices']):
         raise Exception('Failures occurred during the EFI selftest')
+
+ at pytest.mark.buildconfigspec('cmd_bootefi_selftest')
+ at pytest.mark.buildconfigspec('cmd_dm')
+ at pytest.mark.buildconfigspec('cmd_bind')
+def test_efi_selftest_remove_netdevices(u_boot_console):
+    """Test the EFI net device driver
+
+    u_boot_console -- U-Boot console
+
+    This function removes all the ETH_UCLASS udevices and
+    calls the EFI net device selftest to check that the EFI driver
+    sees the same.
+    """
+    u_boot_console.restart_uboot()
+    response = u_boot_console.run_command('dm tree')
+    lines = response.splitlines()[2:]
+    ethernet_count = sum(1 for line in lines if line.strip().startswith('ethernet') and '[ + ]' in line)
+
+    for i in range(ethernet_count):
+        u_boot_console.run_command(f'unbind ethernet {i}')
+    u_boot_console.run_command(cmd='setenv efi_selftest netdevices')
+    u_boot_console.run_command('bootefi selftest', wait_for_prompt=False)
+    if u_boot_console.p.expect(['Detected 0 active EFI net devices']):
+        raise Exception('Failures occurred during the EFI selftest')
-- 
2.43.0



More information about the U-Boot mailing list