test: Convert setup_efi_image() to use FsHelper

Simplify this test-setup code by using the helper.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2026-04-04 08:03:14 -06:00 committed by Tom Rini
parent e7c46fc967
commit 22ff15d191

View File

@ -561,11 +561,9 @@ def test_ut_dm_init(ubman):
def setup_efi_image(ubman):
"""Create a 20MB disk image with an EFI app on it"""
devnum = 1
basename = 'flash'
fname, mnt = fs_helper.setup_image(ubman, devnum, 0xc, second_part=True,
basename=basename)
efi_dir = os.path.join(mnt, 'EFI')
fsh = FsHelper(ubman.config, 'vfat', 18, 'flash')
fsh.setup()
efi_dir = os.path.join(fsh.srcdir, 'EFI')
mkdir_cond(efi_dir)
bootdir = os.path.join(efi_dir, 'BOOT')
mkdir_cond(bootdir)
@ -575,13 +573,14 @@ def setup_efi_image(ubman):
with open(efi_src, 'rb') as inf:
with open(efi_dst, 'wb') as outf:
outf.write(inf.read())
fsfile = 'vfat18M.img'
utils.run_and_log(ubman, f'fallocate -l 18M {fsfile}')
utils.run_and_log(ubman, f'mkfs.vfat {fsfile}')
utils.run_and_log(ubman, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/'])
copy_partition(ubman, fsfile, fname)
utils.run_and_log(ubman, f'rm -rf {mnt}')
utils.run_and_log(ubman, f'rm -f {fsfile}')
fsh.mk_fs()
img = DiskHelper(ubman.config, devnum, 'flash', True)
img.add_fs(fsh, DiskHelper.VFAT)
img.create()
fsh.cleanup()
def setup_rauc_image(ubman):
"""Create a 40MB disk image with an A/B RAUC system on it"""