
From: Simon Glass <sjg@chromium.org> Move setup_efi_image() to its own module. Signed-off-by: Simon Glass <sjg@chromium.org> Co-authored-by: Claude <noreply@anthropic.com> --- test/py/img/efi.py | 37 +++++++++++++++++++++++++++++++++++++ test/py/tests/test_ut.py | 29 +---------------------------- 2 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 test/py/img/efi.py diff --git a/test/py/img/efi.py b/test/py/img/efi.py new file mode 100644 index 00000000000..fbb39c24063 --- /dev/null +++ b/test/py/img/efi.py @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + +"""Create EFI test disk images""" + +import os + +from fs_helper import DiskHelper, FsHelper +from img.common import mkdir_cond + + +def setup_efi_image(config): + """Create a 20MB disk image with an EFI app on it + + Args: + config (ArbitraryAttributeContainer): Configuration + """ + devnum = 1 + fsh = FsHelper(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) + efi_src = os.path.join(config.build_dir, + 'lib/efi_loader/testapp.efi') + efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') + with open(efi_src, 'rb') as inf: + with open(efi_dst, 'wb') as outf: + outf.write(inf.read()) + + fsh.mk_fs() + + img = DiskHelper(config, devnum, 'flash', True) + img.add_fs(fsh, DiskHelper.VFAT) + img.create() + fsh.cleanup() \ No newline at end of file diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index d548bae4bd0..bb3417ad761 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -24,6 +24,7 @@ from img.ubuntu import setup_ubuntu_image from img.armbian import setup_bootmenu_image from img.chromeos import setup_cros_image from img.android import setup_android_image +from img.efi import setup_efi_image def setup_cedit_file(config, log): @@ -78,34 +79,6 @@ def test_ut_dm_init(ubman): fh.write(data) -def setup_efi_image(config): - """Create a 20MB disk image with an EFI app on it - - Args: - config (ArbitraryAttributeContainer): Configuration - """ - devnum = 1 - fsh = FsHelper(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) - efi_src = os.path.join(config.build_dir, - 'lib/efi_loader/testapp.efi') - efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') - with open(efi_src, 'rb') as inf: - with open(efi_dst, 'wb') as outf: - outf.write(inf.read()) - - fsh.mk_fs() - - img = DiskHelper(config, devnum, 'flash', True) - img.add_fs(fsh, DiskHelper.VFAT) - img.create() - fsh.cleanup() - - def setup_localboot_image(config, log): """Create a 20MB disk image with a single FAT partition -- 2.43.0