aboutsummaryrefslogtreecommitdiff
path: root/test/py/tests/test_eficonfig/conftest.py
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-09-14 12:31:44 -0400
committerTom Rini <trini@konsulko.com>2022-09-14 12:31:44 -0400
commit1520af3f8450bb58168fe1cc827a56d435e9f74c (patch)
treec68826240a27e03c9edbbffdfc255d0ee6d51086 /test/py/tests/test_eficonfig/conftest.py
parent6541726ee92108935b97449ed28d8dd28c0ef001 (diff)
parentda4fb707ca095c223b67637e2525df4866e51c62 (diff)
Merge tag 'efi-next-2022-09-14' of https://source.denx.de/u-boot/custodians/u-boot-efi into next
Pull request for efi next UEFI: Implement a command eficonfig to maintain Load Options and boot order via menus.
Diffstat (limited to 'test/py/tests/test_eficonfig/conftest.py')
-rw-r--r--test/py/tests/test_eficonfig/conftest.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/py/tests/test_eficonfig/conftest.py b/test/py/tests/test_eficonfig/conftest.py
new file mode 100644
index 0000000000..f289df0362
--- /dev/null
+++ b/test/py/tests/test_eficonfig/conftest.py
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+"""Fixture for UEFI eficonfig test
+"""
+
+import os
+import shutil
+from subprocess import check_call
+import pytest
+
+@pytest.fixture(scope='session')
+def efi_eficonfig_data(u_boot_config):
+ """Set up a file system to be used in UEFI "eficonfig" command
+ 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_eficonfig'
+ image_path = u_boot_config.persistent_data_dir + '/efi_eficonfig.img'
+
+ shutil.rmtree(mnt_point, ignore_errors=True)
+ os.mkdir(mnt_point, mode = 0o755)
+
+ with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') as file:
+ file.write("initrd 1")
+
+ with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') as file:
+ file.write("initrd 2")
+
+ shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/initrddump.efi',
+ mnt_point + '/initrddump.efi')
+
+ check_call(f'virt-make-fs --partition=gpt --size=+1M --type=vfat {mnt_point} {image_path}',
+ shell=True)
+
+ return image_path