[PATCH 01/10] test: Convert test_eficonfig to FsHelper

Simon Glass sjg at chromium.org
Wed May 6 17:56:15 CEST 2026


Simplify this test-setup code by using the helper.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 test/py/tests/test_eficonfig.py | 46 +++++++++++++++------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/test/py/tests/test_eficonfig.py b/test/py/tests/test_eficonfig.py
index ac1600ec252..903d9eab6d2 100644
--- a/test/py/tests/test_eficonfig.py
+++ b/test/py/tests/test_eficonfig.py
@@ -6,8 +6,8 @@ import pytest
 import shutil
 import pytest
 import time
-from subprocess import call, check_call, CalledProcessError
-from tests import fs_helper
+from subprocess import CalledProcessError
+from tests.fs_helper import DiskHelper, FsHelper
 
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('cmd_eficonfig')
@@ -29,30 +29,26 @@ def test_efi_eficonfig(ubman):
 
         """
         try:
-            image_path, mnt_point = fs_helper.setup_image(u_boot_config, 0,
-                                                          0xc,
-                                                          basename='test_eficonfig')
-
-            with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') as file:
-                file.write("initrd 1")
-
-            with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') as file:
-                file.write("initrd 2")
-
-            shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/initrddump.efi',
-                            mnt_point + '/initrddump.efi')
-
-            fsfile = fs_helper.mk_fs(ubman.config, 'vfat', 0x100000,
-                                     'test_eficonfig', mnt_point)
-            check_call(f'dd if={fsfile} of={image_path} bs=1M seek=1', shell=True)
-
-            yield image_path
-        except CalledProcessError as err:
+            with DiskHelper(u_boot_config, 0, 'test_eficonfig') as img, \
+                    FsHelper(u_boot_config, 'vfat', 1,
+                             'test_eficonfig') as fsh:
+                with open(f'{fsh.srcdir}/initrd-1.img', 'w',
+                          encoding='ascii') as file:
+                    file.write("initrd 1")
+
+                with open(f'{fsh.srcdir}/initrd-2.img', 'w',
+                          encoding='ascii') as file:
+                    file.write("initrd 2")
+
+                shutil.copyfile(
+                    u_boot_config.build_dir + '/lib/efi_loader/initrddump.efi',
+                    f'{fsh.srcdir}/initrddump.efi')
+
+                fsh.mk_fs()
+                img.add_fs(fsh, DiskHelper.VFAT)
+                yield img.create()
+        except CalledProcessError:
             pytest.skip('Preparing test_eficonfig image failed')
-            call('rm -f %s' % image_path, shell=True)
-        finally:
-            call('rm -rf %s' % mnt_point, shell=True)
-            call('rm -f %s' % image_path, shell=True)
 
     def send_user_input_and_wait(user_str, expect_str):
         time.sleep(0.1) # TODO: does not work correctly without sleep
-- 
2.43.0



More information about the U-Boot mailing list