systemd_boot.py 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import os
  2. from oeqa.selftest.case import OESelftestTestCase
  3. from oeqa.core.decorator.oeid import OETestID
  4. from oeqa.core.decorator.depends import OETestDepends
  5. from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
  6. class Systemdboot(OESelftestTestCase):
  7. def _common_setup(self):
  8. """
  9. Common setup for test cases: 1445, 1528
  10. """
  11. # Set EFI_PROVIDER = "systemdboot" and MACHINE = "genericx86-64" in conf/local.conf
  12. features = 'EFI_PROVIDER = "systemd-boot"\n'
  13. features += 'MACHINE = "genericx86-64"'
  14. self.append_config(features)
  15. def _common_build(self):
  16. """
  17. Common build for test cases: 1445 , 1528
  18. """
  19. # Build a genericx86-64/efi systemdboot image
  20. bitbake('mtools-native core-image-minimal')
  21. @OETestID(1445)
  22. def test_efi_systemdboot_images_can_be_built(self):
  23. """
  24. Summary: Check if systemd-boot images can be built correctly
  25. Expected: 1. File systemd-boot.efi should be available in $poky/build/tmp/deploy/images/genericx86-64
  26. 2. 'systemd-boot" can be built correctly
  27. Product: oe-core
  28. Author: Jose Perez Carranza <jose.perez.carranza@intel.com>
  29. AutomatedBy: Jose Perez Carranza <jose.perez.carranza@intel.com>
  30. """
  31. # We'd use DEPLOY_DIR_IMAGE here, except that we need its value for
  32. # MACHINE="genericx86-64 which is probably not the one configured
  33. systemdbootfile = os.path.join(get_bb_var('DEPLOY_DIR'), 'images', 'genericx86-64', 'systemd-bootx64.efi')
  34. self._common_setup()
  35. # Ensure we're actually testing that this gets built and not that
  36. # it was around from an earlier build
  37. bitbake('-c cleansstate systemd-boot')
  38. runCmd('rm -f %s' % systemdbootfile)
  39. self._common_build()
  40. found = os.path.isfile(systemdbootfile)
  41. self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile)
  42. @OETestID(1528)
  43. @OETestDepends(['systemd_boot.Systemdboot.test_efi_systemdboot_images_can_be_built'])
  44. def test_image_efi_file(self):
  45. """
  46. Summary: Check if EFI bootloader for systemd is correctly build
  47. Dependencies: Image was built correctly on testcase 1445
  48. Steps: 1. Copy bootx64.efi file form the hddimg created
  49. under build/tmp/deploy/images/genericx86-64
  50. 2. Check bootx64.efi was copied form hddimg
  51. 3. Verify the checksums from the copied and previously
  52. created file are equal.
  53. Expected : Systemd-bootx64.efi and bootx64.efi should be the same
  54. hence checksums should be equal.
  55. Product: oe-core
  56. Author: Jose Perez Carranza <jose.perez.carranza at linux-intel.com>
  57. AutomatedBy: Jose Perez Carranza <jose.perez.carranza at linux-intel.com>
  58. """
  59. systemdbootfile = os.path.join(get_bb_var('DEPLOY_DIR'), 'images', 'genericx86-64',
  60. 'systemd-bootx64.efi')
  61. systemdbootimage = os.path.join(get_bb_var('DEPLOY_DIR'), 'images', 'genericx86-64',
  62. 'core-image-minimal-genericx86-64.hddimg')
  63. imagebootfile = os.path.join(get_bb_var('DEPLOY_DIR'), 'images', 'genericx86-64',
  64. 'bootx64.efi')
  65. mcopynative = os.path.join(get_bb_var('STAGING_BINDIR_NATIVE'), 'mcopy')
  66. #Clean environment before start the test
  67. if os.path.isfile(imagebootfile):
  68. runCmd('rm -f %s' % imagebootfile)
  69. #Step 1
  70. runCmd('%s -i %s ::EFI/BOOT/bootx64.efi %s' % (mcopynative ,systemdbootimage,
  71. imagebootfile))
  72. #Step 2
  73. found = os.path.isfile(imagebootfile)
  74. self.assertTrue(found, 'bootx64.efi file %s was not copied from image'
  75. % imagebootfile)
  76. #Step 3
  77. result = runCmd('md5sum %s %s' % (systemdbootfile, imagebootfile))
  78. self.assertEqual(result.output.split()[0], result.output.split()[2],
  79. '%s was not correclty generated' % imagebootfile)