blob: dfd739ae77f6bad3786be6fed8f77748972d3245 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001import os
2
3from oeqa.selftest.case import OESelftestTestCase
4from oeqa.core.decorator.oeid import OETestID
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu
7
8class Systemdboot(OESelftestTestCase):
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009
10 @OETestID(1445)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011 @OETestID(1528)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012 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 Bishop1a4b7ee2018-12-16 17:11:34 -080022 # 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 Bishopd7bf8c12018-02-25 22:55:05 -050026
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027 deploydir = get_bb_var('DEPLOY_DIR_IMAGE', "core-image-minimal")
28 systemdbootfile = os.path.join(deploydir, 'systemd-bootx64.efi')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050029
30 # Ensure we're actually testing that this gets built and not that
31 # it was around from an earlier build
Brad Bishopd5ae7d92018-06-14 09:52:03 -070032 bitbake('-c clean systemd-boot')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033 runCmd('rm -f %s' % systemdbootfile)
34
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035 # Build a genericx86-64/efi systemdboot image
36 bitbake('mtools-native core-image-minimal')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050037
38 found = os.path.isfile(systemdbootfile)
39 self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile)
40
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041 """
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 Bishop1a4b7ee2018-12-16 17:11:34 -080056 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 Bishopd7bf8c12018-02-25 22:55:05 -050059
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080060 # Clean environment before start the test
Brad Bishopd7bf8c12018-02-25 22:55:05 -050061 if os.path.isfile(imagebootfile):
62 runCmd('rm -f %s' % imagebootfile)
63
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080064 runCmd('%s -i %s ::EFI/BOOT/bootx64.efi %s' % (mcopynative ,systemdbootimage,
Brad Bishopd7bf8c12018-02-25 22:55:05 -050065 imagebootfile))
66
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080067 found = os.path.isfile(imagebootfile)
68 self.assertTrue(found, 'bootx64.efi file %s was not copied from image'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069 % imagebootfile)
70
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080071 result = runCmd('md5sum %s %s' % (systemdbootfile, imagebootfile))
72 self.assertEqual(result.output.split()[0], result.output.split()[2],
Brad Bishopd7bf8c12018-02-25 22:55:05 -050073 '%s was not correclty generated' % imagebootfile)