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