blob: 69008fddce7f56c61db647b99c6c96be57042b3b [file] [log] [blame]
Heinrich Schuchardt76d0c872022-03-03 12:31:18 +01001# SPDX-License-Identifier: GPL-2.0+
2
3"""Fixture for UEFI bootmanager test
4"""
5
6import os
7import pytest
8import shutil
9from subprocess import call, check_call
10
11@pytest.fixture(scope='session')
12def efi_bootmgr_data(u_boot_config):
13 """Set up a file system to be used in UEFI bootmanager
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_bootmgr'
23 image_path = u_boot_config.persistent_data_dir + '/efi_bootmgr.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('virt-make-fs --partition=gpt --size=+1M --type=vfat {} {}'
38 .format(mnt_point, image_path), shell=True)
39
40 print(image_path)
41
42 yield image_path