A short-form path starting with a file device path will be tested in a new test case.
This type of short-form path will be created with "efidebug boot add -b", in particular, when a file system has no partition table. Signed-off-by: AKASHI Takahiro <takahiro.aka...@linaro.org> --- test/py/tests/test_efi_bootmgr/conftest.py | 25 +++++++++++++++++++ .../test_efi_bootmgr/test_efi_bootmgr.py | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/test/py/tests/test_efi_bootmgr/conftest.py b/test/py/tests/test_efi_bootmgr/conftest.py index a0a754afbe1b..5cd7252671fa 100644 --- a/test/py/tests/test_efi_bootmgr/conftest.py +++ b/test/py/tests/test_efi_bootmgr/conftest.py @@ -38,3 +38,28 @@ def efi_bootmgr_data(u_boot_config): shell=True) return image_path + +@pytest.fixture(scope='session') +def efi_bootmgr_data2(u_boot_config): + """Set up a file system without a partition table to be used + in UEFI bootmanager tests + + Args: + u_boot_config -- U-boot configuration. + + Return: + A path to disk image to be used for testing + """ + mnt_point = u_boot_config.persistent_data_dir + '/test_efi_bootmgr' + image_path = u_boot_config.persistent_data_dir + '/efi_bootmgr_data2.img' + + shutil.rmtree(mnt_point, ignore_errors=True) + os.mkdir(mnt_point, mode = 0o755) + + shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/helloworld.efi', + mnt_point + '/helloworld.efi') + + check_call(f'virt-make-fs --size=+1M --type=vfat {mnt_point} {image_path}', + shell=True) + + return image_path diff --git a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py index 75a6e7c96296..ab3d53a2dc95 100644 --- a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py +++ b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py @@ -41,3 +41,28 @@ def test_efi_bootmgr(u_boot_console, efi_bootmgr_data): u_boot_console.run_command(cmd = 'efidebug boot rm 0001') u_boot_console.run_command(cmd = 'efidebug boot rm 0002') + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_efidebug') +@pytest.mark.buildconfigspec('cmd_bootefi_bootmgr') +def test_efi_bootmgr_short(u_boot_console, efi_bootmgr_data2): + """ Unit test for UEFI bootmanager with a short-form path + In this test case, + - File system has no partition table + - UEFI load option has a short-form path starting with a file device path + + Args: + u_boot_console -- U-Boot console + efi_bootmgr_data2 -- Path to the disk image used for testing. + """ + u_boot_console.run_command(cmd = f'host bind 0 {efi_bootmgr_data2}') + + u_boot_console.run_command(cmd = 'efidebug boot add ' \ + '-b 0001 TEST2 host 0:0 helloworld.efi') + response = u_boot_console.run_command(cmd = 'efidebug boot dump') + assert 'file_path: /helloworld.efi' in response + u_boot_console.run_command(cmd = 'efidebug boot next 0001') + response = u_boot_console.run_command(cmd = 'bootefi bootmgr') + assert 'Hello, world!' in response + + u_boot_console.run_command(cmd = 'efidebug boot rm 0001') -- 2.33.0