blob: 57599e19aad19120c42bec32c87e555a6f3973df [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001import os
2
3from oeqa.selftest.case import OESelftestTestCase
Brad Bishopd7bf8c12018-02-25 22:55:05 -05004from oeqa.core.decorator.depends import OETestDepends
5from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
6
7class Systemdboot(OESelftestTestCase):
Brad Bishopd7bf8c12018-02-25 22:55:05 -05008
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009 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 Bishop1a4b7ee2018-12-16 17:11:34 -080019 # 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 Bishopd7bf8c12018-02-25 22:55:05 -050023
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 deploydir = get_bb_var('DEPLOY_DIR_IMAGE', "core-image-minimal")
25 systemdbootfile = os.path.join(deploydir, 'systemd-bootx64.efi')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050026
27 # Ensure we're actually testing that this gets built and not that
28 # it was around from an earlier build
Brad Bishopd5ae7d92018-06-14 09:52:03 -070029 bitbake('-c clean systemd-boot')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050030 runCmd('rm -f %s' % systemdbootfile)
31
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032 # Build a genericx86-64/efi systemdboot image
Andrew Geissler82c905d2020-04-13 13:39:40 -050033 bitbake('mtools-native core-image-minimal wic-tools')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034
35 found = os.path.isfile(systemdbootfile)
36 self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile)
37
Brad Bishopd7bf8c12018-02-25 22:55:05 -050038 """
39 Summary: Check if EFI bootloader for systemd is correctly build
40 Dependencies: Image was built correctly on testcase 1445
Andrew Geissler82c905d2020-04-13 13:39:40 -050041 Steps: 1. Copy bootx64.efi file from the wic created
Brad Bishopd7bf8c12018-02-25 22:55:05 -050042 under build/tmp/deploy/images/genericx86-64
Andrew Geissler82c905d2020-04-13 13:39:40 -050043 2. Check bootx64.efi was copied from wic
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044 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 Geissler82c905d2020-04-13 13:39:40 -050053 systemdbootimage = os.path.join(deploydir, 'core-image-minimal-genericx86-64.wic')
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080054 imagebootfile = os.path.join(deploydir, 'bootx64.efi')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050055
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080056 # Clean environment before start the test
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057 if os.path.isfile(imagebootfile):
58 runCmd('rm -f %s' % imagebootfile)
59
Andrew Geissler82c905d2020-04-13 13:39:40 -050060 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 Bishopd7bf8c12018-02-25 22:55:05 -050064
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080065 found = os.path.isfile(imagebootfile)
66 self.assertTrue(found, 'bootx64.efi file %s was not copied from image'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050067 % imagebootfile)
68
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080069 result = runCmd('md5sum %s %s' % (systemdbootfile, imagebootfile))
70 self.assertEqual(result.output.split()[0], result.output.split()[2],
Brad Bishopd7bf8c12018-02-25 22:55:05 -050071 '%s was not correclty generated' % imagebootfile)