[PATCH 6/6] test: Convert test_efi_bootmgr to use FsHelper
Simon Glass
sjg at chromium.org
Wed Feb 25 17:23:50 CET 2026
From: Simon Glass <simon.glass at canonical.com>
As an example of how to use the helper, use it to simplify this test.
Signed-off-by: Simon Glass <simon.glass at canonical.com>
---
test/py/tests/test_efi_bootmgr.py | 38 ++++++++++++-------------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/test/py/tests/test_efi_bootmgr.py b/test/py/tests/test_efi_bootmgr.py
index 4c10cbdf17d..7d1f3f16d00 100644
--- a/test/py/tests/test_efi_bootmgr.py
+++ b/test/py/tests/test_efi_bootmgr.py
@@ -5,7 +5,7 @@
import shutil
import pytest
from subprocess import call, check_call, CalledProcessError
-from tests import fs_helper
+from tests.fs_helper import DiskHelper, FsHelper
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_efidebug')
@@ -20,22 +20,19 @@ def test_efi_bootmgr(ubman):
Args:
ubman -- U-Boot console
"""
- try:
- efi_bootmgr_data, mnt = fs_helper.setup_image(ubman, 0, 0xc,
- basename='test_efi_bootmgr')
-
- with open(mnt + '/initrd-1.img', 'w', encoding = 'ascii') as file:
- file.write("initrd 1")
-
- with open(mnt + '/initrd-2.img', 'w', encoding = 'ascii') as file:
- file.write("initrd 2")
-
- shutil.copyfile(ubman.config.build_dir + '/lib/efi_loader/initrddump.efi',
- mnt + '/initrddump.efi')
-
- fsfile = fs_helper.mk_fs(ubman.config, 'vfat', 0x100000,
- 'test_efi_bootmgr', mnt)
- check_call(f'dd if={fsfile} of={efi_bootmgr_data} bs=1M seek=1', shell=True)
+ with DiskHelper(ubman.config, 0, 'test_efi_bootmgr') as img, \
+ FsHelper(ubman.config, 'vfat', 1, 'test_efi_bootmgr') as fsh:
+ with open(f'{fsh.srcdir}/initrd-1.img', 'w', encoding = 'ascii') as outf:
+ outf.write("initrd 1")
+ with open(f'{fsh.srcdir}/initrd-2.img', 'w', encoding = 'ascii') as outf:
+ outf.write("initrd 2")
+ shutil.copyfile(
+ ubman.config.build_dir + '/lib/efi_loader/initrddump.efi',
+ f'{fsh.srcdir}/initrddump.efi')
+ fsh.mk_fs()
+
+ img.add_fs(fsh, DiskHelper.VFAT)
+ efi_bootmgr_data = img.create()
ubman.run_command(cmd = f'host bind 0 {efi_bootmgr_data}')
@@ -61,10 +58,3 @@ def test_efi_bootmgr(ubman):
ubman.run_command(cmd = 'efidebug boot rm 0001')
ubman.run_command(cmd = 'efidebug boot rm 0002')
- except CalledProcessError as err:
- pytest.skip('Preparing test_efi_bootmgr image failed')
- call('rm -f %s' % efi_bootmgr_data, shell=True)
- return
- finally:
- call('rm -rf %s' % mnt, shell=True)
- call('rm -f %s' % efi_bootmgr_data, shell=True)
--
2.43.0
More information about the U-Boot
mailing list