]>
Commit | Line | Data |
---|---|---|
da4fb707 MK |
1 | # SPDX-License-Identifier: GPL-2.0+ |
2 | ||
3 | """Fixture for UEFI eficonfig test | |
4 | """ | |
5 | ||
6 | import os | |
7 | import shutil | |
8 | from subprocess import check_call | |
9 | import pytest | |
10 | ||
11 | @pytest.fixture(scope='session') | |
12 | def efi_eficonfig_data(u_boot_config): | |
13 | """Set up a file system to be used in UEFI "eficonfig" command | |
14 | tests | |
15 | ||
16 | Args: | |
1be82afa | 17 | u_boot_config -- U-Boot configuration. |
da4fb707 MK |
18 | |
19 | Return: | |
20 | A path to disk image to be used for testing | |
21 | """ | |
22 | mnt_point = u_boot_config.persistent_data_dir + '/test_efi_eficonfig' | |
23 | image_path = u_boot_config.persistent_data_dir + '/efi_eficonfig.img' | |
24 | ||
25 | shutil.rmtree(mnt_point, ignore_errors=True) | |
26 | os.mkdir(mnt_point, mode = 0o755) | |
27 | ||
28 | with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') as file: | |
29 | file.write("initrd 1") | |
30 | ||
31 | with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') as file: | |
32 | file.write("initrd 2") | |
33 | ||
34 | shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/initrddump.efi', | |
35 | mnt_point + '/initrddump.efi') | |
36 | ||
37 | check_call(f'virt-make-fs --partition=gpt --size=+1M --type=vfat {mnt_point} {image_path}', | |
38 | shell=True) | |
39 | ||
40 | return image_path |