summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2026-04-04 08:03:10 -0600
committerTom Rini <[email protected]>2026-04-21 15:30:38 -0600
commit3dc999d17ef9b4c8873358d0761a03cc5d155281 (patch)
treec35f8461aa9d80b45f7a52de958142ab3eada662 /test
parent17eb232e47fdee7f29e40599b0ce40dbeaaa8064 (diff)
test: Convert test_efi_bootmgr to use FsHelper
Simplify this test by using the helper. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/py/tests/test_efi_bootmgr.py38
1 files 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)