blob: f289df03626015e0468b980ed15ca2bfdb4fc9a2 [file] [log] [blame]
Masahisa Kojima2e188442022-09-12 17:33:59 +09001# SPDX-License-Identifier: GPL-2.0+
2
3"""Fixture for UEFI eficonfig test
4"""
5
6import os
7import shutil
8from subprocess import check_call
9import pytest
10
11@pytest.fixture(scope='session')
12def efi_eficonfig_data(u_boot_config):
13 """Set up a file system to be used in UEFI "eficonfig" command
14 tests
15
16 Args:
17 u_boot_config -- U-boot configuration.
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