1import os 2 3from oeqa.selftest.case import OESelftestTestCase 4from oeqa.core.decorator.depends import OETestDepends 5from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu 6 7class Systemdboot(OESelftestTestCase): 8 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 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) 23 24 deploydir = get_bb_var('DEPLOY_DIR_IMAGE', "core-image-minimal") 25 systemdbootfile = os.path.join(deploydir, 'systemd-bootx64.efi') 26 27 # Ensure we're actually testing that this gets built and not that 28 # it was around from an earlier build 29 bitbake('-c clean systemd-boot') 30 runCmd('rm -f %s' % systemdbootfile) 31 32 # Build a genericx86-64/efi systemdboot image 33 bitbake('mtools-native core-image-minimal wic-tools') 34 35 found = os.path.isfile(systemdbootfile) 36 self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile) 37 38 """ 39 Summary: Check if EFI bootloader for systemd is correctly build 40 Dependencies: Image was built correctly on testcase 1445 41 Steps: 1. Copy bootx64.efi file from the wic created 42 under build/tmp/deploy/images/genericx86-64 43 2. Check bootx64.efi was copied from wic 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 53 systemdbootimage = os.path.join(deploydir, 'core-image-minimal-genericx86-64.wic') 54 imagebootfile = os.path.join(deploydir, 'bootx64.efi') 55 56 # Clean environment before start the test 57 if os.path.isfile(imagebootfile): 58 runCmd('rm -f %s' % imagebootfile) 59 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)) 64 65 found = os.path.isfile(imagebootfile) 66 self.assertTrue(found, 'bootx64.efi file %s was not copied from image' 67 % imagebootfile) 68 69 result = runCmd('md5sum %s %s' % (systemdbootfile, imagebootfile)) 70 self.assertEqual(result.output.split()[0], result.output.split()[2], 71 '%s was not correclty generated' % imagebootfile) 72