On Fri, 7 Mar 2025 at 01:23, Tom Rini <tr...@konsulko.com> wrote: > > The problem with using "virt-make-fs" to make a filesystem image is that > it is extremely slow. Switch to using the fs_helper functions we have > instead from the filesystem tests as these can add files to images and > are significantly faster and still do not require root access. > > The main change here is that our mount point directory has changed from > "test_efi_capsule" to "scratch" and so we need to update other functions > too. As the disk image that we get created doesn't have a GPT, invoke > sgdisk to do a conversion first. > > Signed-off-by: Tom Rini <tr...@konsulko.com> > --- > I tested this as much as I could with an empty > board/sandbox/capsule_pub_esl_good.esl which did show me a few issues > along the way so I am reasonably confident, but this really does need to > be tested on a platform where all tests are run for real. > > Cc: Ilias Apalodimas <ilias.apalodi...@linaro.org> > Cc: Heinrich Schuchardt <xypron.g...@gmx.de> > --- > .../tests/test_efi_capsule/capsule_common.py | 2 +- > test/py/tests/test_efi_capsule/conftest.py | 21 ++++++++++++------- > 2 files changed, 14 insertions(+), 9 deletions(-) > > diff --git a/test/py/tests/test_efi_capsule/capsule_common.py > b/test/py/tests/test_efi_capsule/capsule_common.py > index fc0d851c619a..68b2e48bf5a5 100644 > --- a/test/py/tests/test_efi_capsule/capsule_common.py > +++ b/test/py/tests/test_efi_capsule/capsule_common.py > @@ -136,7 +136,7 @@ def do_reboot_dtb_specified(u_boot_config, > u_boot_console, dtb_filename): > u_boot_console -- A console connection to U-Boot. > dtb_filename -- DTB file name. > """ > - mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' > + mnt_point = u_boot_config.persistent_data_dir + '/scratch' > u_boot_console.config.dtb = mnt_point + CAPSULE_DATA_DIR \ > + f'/{dtb_filename}' > u_boot_console.restart_uboot() > diff --git a/test/py/tests/test_efi_capsule/conftest.py > b/test/py/tests/test_efi_capsule/conftest.py > index 61eab5112a17..7f8a3de46171 100644 > --- a/test/py/tests/test_efi_capsule/conftest.py > +++ b/test/py/tests/test_efi_capsule/conftest.py > @@ -7,6 +7,7 @@ > import os > > from subprocess import call, check_call, CalledProcessError > +from tests import fs_helper > import pytest > from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH > > @@ -21,12 +22,12 @@ def efi_capsule_data(request, u_boot_config): > request -- Pytest request object. > u_boot_config -- U-Boot configuration. > """ > - mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' > - data_dir = mnt_point + CAPSULE_DATA_DIR > - install_dir = mnt_point + CAPSULE_INSTALL_DIR > - image_path = u_boot_config.persistent_data_dir + '/test_efi_capsule.img' > - > try: > + image_path, mnt_point = fs_helper.setup_image(u_boot_config, 0, 0xc, > + > basename='test_efi_capsule') > + data_dir = mnt_point + CAPSULE_DATA_DIR > + install_dir = mnt_point + CAPSULE_INSTALL_DIR > + > # Create a target device > check_call('dd if=/dev/zero of=./spi.bin bs=1MiB count=16', > shell=True) > > @@ -88,11 +89,15 @@ def efi_capsule_data(request, u_boot_config): > check_call('cp %s/Test* %s' % (u_boot_config.build_dir, data_dir), > shell=True) > os.environ['PYTHONPATH'] = pythonpath > > - # Create a disk image with EFI system partition > - check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s > %s' % > - (mnt_point, image_path), shell=True) > + # Create a 16MiB partition as the EFI system partition in the disk > + # image > + fsfile = fs_helper.mk_fs(u_boot_config, 'vfat', 0x1000000, > + 'test_efi_capsule', mnt_point) > + check_call(f'dd if={fsfile} of={image_path} bs=1M seek=1', > shell=True) > + check_call('sgdisk --mbrtogpt %s' % image_path, shell=True) > check_call('sgdisk %s -A 1:set:0 -t > 1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B' % > image_path, shell=True) > + call('rm -f %s' % fsfile, shell=True) > > except CalledProcessError as exception: > pytest.skip('Setup failed: %s' % exception.cmd) > -- > 2.43.0 >
Acked-by: Ilias Apalodimas <ilias.apalodi...@linaro.org>