Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | import os |
| 2 | |
| 3 | from oeqa.selftest.case import OESelftestTestCase |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4 | from oeqa.core.decorator.depends import OETestDepends |
| 5 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu |
| 6 | |
| 7 | class Systemdboot(OESelftestTestCase): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9 | def test_efi_systemdboot_images_can_be_built(self): |
| 10 | """ |
| 11 | Summary: Check if systemd-boot images can be built correctly |
| 12 | Expected: 1. File systemd-boot.efi should be available in $poky/build/tmp/deploy/images/genericx86-64 |
| 13 | 2. 'systemd-boot" can be built correctly |
| 14 | Product: oe-core |
| 15 | Author: Jose Perez Carranza <jose.perez.carranza@intel.com> |
| 16 | AutomatedBy: Jose Perez Carranza <jose.perez.carranza@intel.com> |
| 17 | """ |
| 18 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 19 | # Set EFI_PROVIDER = "systemdboot" and MACHINE = "genericx86-64" in conf/local.conf |
| 20 | features = 'EFI_PROVIDER = "systemd-boot"\n' |
| 21 | features += 'MACHINE = "genericx86-64"' |
| 22 | self.append_config(features) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 23 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE', "core-image-minimal") |
| 25 | systemdbootfile = os.path.join(deploydir, 'systemd-bootx64.efi') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | |
| 27 | # Ensure we're actually testing that this gets built and not that |
| 28 | # it was around from an earlier build |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 29 | bitbake('-c clean systemd-boot') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 30 | runCmd('rm -f %s' % systemdbootfile) |
| 31 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | # Build a genericx86-64/efi systemdboot image |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 33 | bitbake('mtools-native core-image-minimal wic-tools') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | |
| 35 | found = os.path.isfile(systemdbootfile) |
| 36 | self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile) |
| 37 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 38 | """ |
| 39 | Summary: Check if EFI bootloader for systemd is correctly build |
| 40 | Dependencies: Image was built correctly on testcase 1445 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 41 | Steps: 1. Copy bootx64.efi file from the wic created |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 42 | under build/tmp/deploy/images/genericx86-64 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 43 | 2. Check bootx64.efi was copied from wic |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 44 | 3. Verify the checksums from the copied and previously |
| 45 | created file are equal. |
| 46 | Expected : Systemd-bootx64.efi and bootx64.efi should be the same |
| 47 | hence checksums should be equal. |
| 48 | Product: oe-core |
| 49 | Author: Jose Perez Carranza <jose.perez.carranza at linux-intel.com> |
| 50 | AutomatedBy: Jose Perez Carranza <jose.perez.carranza at linux-intel.com> |
| 51 | """ |
| 52 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 53 | systemdbootimage = os.path.join(deploydir, 'core-image-minimal-genericx86-64.wic') |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 54 | imagebootfile = os.path.join(deploydir, 'bootx64.efi') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 55 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 56 | # Clean environment before start the test |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 57 | if os.path.isfile(imagebootfile): |
| 58 | runCmd('rm -f %s' % imagebootfile) |
| 59 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 60 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') |
| 61 | |
| 62 | runCmd('wic cp %s:1/EFI/BOOT/bootx64.efi %s -n %s' % (systemdbootimage, |
| 63 | imagebootfile, sysroot)) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 64 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 65 | found = os.path.isfile(imagebootfile) |
| 66 | self.assertTrue(found, 'bootx64.efi file %s was not copied from image' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 67 | % imagebootfile) |
| 68 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 69 | result = runCmd('md5sum %s %s' % (systemdbootfile, imagebootfile)) |
| 70 | self.assertEqual(result.output.split()[0], result.output.split()[2], |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 71 | '%s was not correclty generated' % imagebootfile) |