conftest.py 1.1 KB

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