Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,97 @@
# Copyright (C) 2014 Intel Corporation
#
# Released under the MIT license (see COPYING.MIT)
# This module adds support to testimage.bbclass to deploy images and run
# tests on a BeagleBone (original "white" or Black models). The device must
# be set up as per README.hardware and the master image should be deployed
# onto the card so that it boots into it by default. For booting into the
# image under test we interact with u-boot over serial, so for the
# BeagleBone Black you will need an additional TTL serial cable since a
# serial interface isn't automatically provided over the USB connection as
# it is on the original BeagleBone ("white") version. The separate ext3
# partition that will contain the image to be tested must be labelled
# "testrootfs" so that the deployment code below can find it.
#
# NOTE: for the BeagleBone "white" (original version) you may need to use
# a script which handles the serial device disappearing on power down, such
# as scripts/contrib/serdevtry in OE-Core.
import os
import bb
import time
import subprocess
import sys
import pexpect
from oeqa.controllers.controllerimage import ControllerImageHardwareTarget
class BeagleBoneTarget(ControllerImageHardwareTarget):
dtbs = {'uImage-am335x-bone.dtb': 'am335x-bone.dtb', 'uImage-am335x-boneblack.dtb': 'am335x-boneblack.dtb'}
@classmethod
def get_extra_files(self):
return list(self.dtbs.keys())
def __init__(self, d):
super(BeagleBoneTarget, self).__init__(d)
self.image_fstype = self.get_image_fstype(d)
self.deploy_cmds = [
'mkdir -p /mnt/testrootfs',
'mount -L testrootfs /mnt/testrootfs',
'rm -rf /mnt/testrootfs/*',
'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype,
'[ -e /mnt/testrootfs/boot/uImage ] || [ -L /mnt/testrootfs/boot/uImage ] || cp ~/test-kernel /mnt/testrootfs/boot/uImage',
]
for _, dtbfn in self.dtbs.iteritems():
# Kernel and dtb files may not be in the image, so copy them if not
self.deploy_cmds.append('[ -e /mnt/testrootfs/boot/{0} ] || cp ~/{0} /mnt/testrootfs/boot/'.format(dtbfn))
if not self.serialcontrol_cmd:
bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.")
def _deploy(self):
self.controller.run("umount /boot; umount /mnt/testrootfs;")
self.controller.ignore_status = False
# Kernel and dtb files may not be in the image, so copy them just in case
self.controller.copy_to(self.kernel, "~/test-kernel")
kernelpath = os.path.dirname(self.kernel)
for dtborig, dtbfn in self.dtbs.iteritems():
dtbfile = os.path.join(kernelpath, dtborig)
if os.path.exists(dtbfile):
self.controller.copy_to(dtbfile, "~/%s" % dtbfn)
self.controller.copy_to(self.rootfs, "~/test-rootfs.%s" % self.image_fstype)
for cmd in self.deploy_cmds:
self.controller.run(cmd)
def _start(self, params=None):
self.power_cycle(self.controller)
try:
serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
# We'd wait for "U-Boot" here but sometimes we connect too late on BeagleBone white to see it
serialconn.expect("NAND:")
serialconn.expect("MMC:")
serialconn.sendline("a")
serialconn.expect("U-Boot#")
serialconn.sendline("setenv bootpart 0:3")
serialconn.expect("U-Boot#")
serialconn.sendline("setenv mmcroot /dev/mmcblk0p3 ro")
serialconn.expect("U-Boot#")
serialconn.sendline("boot")
serialconn.expect("login:", timeout=120)
serialconn.close()
except pexpect.ExceptionPexpect as e:
bb.fatal('Serial interaction failed: %s' % str(e))
def _wait_until_booted(self):
try:
serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
serialconn.expect("login:", timeout=120)
serialconn.close()
except pexpect.ExceptionPexpect as e:
bb.fatal('Serial interaction failed: %s' % str(e))
@@ -0,0 +1,70 @@
# Copyright (C) 2014 Intel Corporation
#
# Released under the MIT license (see COPYING.MIT)
# This module adds support to testimage.bbclass to deploy images and run
# tests on a Generic PC that boots using grub bootloader. The device must
# be set up as per README.hardware and the master image should be deployed
# onto the harddisk so that it boots into it by default.For booting into the
# image under test we interact with grub over serial, so for the
# Generic PC you will need an additional serial cable and device under test
# needs to have a serial interface. The separate ext3
# partition that will contain the image to be tested must be labelled
# "testrootfs" so that the deployment code below can find it.
import os
import bb
import time
import subprocess
import sys
import pexpect
from oeqa.controllers.controllerimage import ControllerImageHardwareTarget
class GrubTarget(ControllerImageHardwareTarget):
def __init__(self, d):
super(GrubTarget, self).__init__(d)
self.deploy_cmds = [
'mount -L boot /boot',
'mkdir -p /mnt/testrootfs',
'mount -L testrootfs /mnt/testrootfs',
'cp ~/test-kernel /boot',
'rm -rf /mnt/testrootfs/*',
'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype,
]
if not self.serialcontrol_cmd:
bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.")
def _deploy(self):
# make sure these aren't mounted
self.controller.run("umount /boot; umount /mnt/testrootfs;")
self.controller.ignore_status = False
# Kernel files may not be in the image, so copy them just in case
self.controller.copy_to(self.rootfs, "~/test-rootfs." + self.image_fstype)
self.controller.copy_to(self.kernel, "~/test-kernel")
for cmd in self.deploy_cmds:
self.controller.run(cmd)
def _start(self, params=None):
self.power_cycle(self.controller)
try:
serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
serialconn.expect("GNU GRUB version 2.00")
serialconn.expect("Linux")
serialconn.sendline("x")
serialconn.expect("login:", timeout=120)
serialconn.close()
except pexpect.ExceptionPexpect as e:
bb.fatal('Serial interaction failed: %s' % str(e))
def _wait_until_booted(self):
try:
serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
serialconn.expect("login:", timeout=120)
serialconn.close()
except pexpect.ExceptionPexpect as e:
bb.fatal('Serial interaction failed: %s' % str(e))
@@ -0,0 +1,72 @@
import os
from oeqa.selftest.case import OESelftestTestCase
from oeqa.core.decorator.depends import OETestDepends
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
class Systemdboot(OESelftestTestCase):
def test_efi_systemdboot_images_can_be_built(self):
"""
Summary: Check if systemd-boot images can be built correctly
Expected: 1. File systemd-boot.efi should be available in $poky/build/tmp/deploy/images/genericx86-64
2. 'systemd-boot" can be built correctly
Product: oe-core
Author: Jose Perez Carranza <jose.perez.carranza@intel.com>
AutomatedBy: Jose Perez Carranza <jose.perez.carranza@intel.com>
"""
# Set EFI_PROVIDER = "systemdboot" and MACHINE = "genericx86-64" in conf/local.conf
features = 'EFI_PROVIDER = "systemd-boot"\n'
features += 'MACHINE = "genericx86-64"'
self.append_config(features)
image = 'core-image-minimal'
bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'], image)
systemdbootfile = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'systemd-bootx64.efi')
# Ensure we're actually testing that this gets built and not that
# it was around from an earlier build
bitbake('-c clean systemd-boot')
runCmd('rm -f %s' % systemdbootfile)
# Build a genericx86-64/efi systemdboot image
bitbake('mtools-native core-image-minimal wic-tools')
found = os.path.isfile(systemdbootfile)
self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile)
"""
Summary: Check if EFI bootloader for systemd is correctly build
Dependencies: Image was built correctly on testcase 1445
Steps: 1. Copy bootx64.efi file from the wic created
under build/tmp/deploy/images/genericx86-64
2. Check bootx64.efi was copied from wic
3. Verify the checksums from the copied and previously
created file are equal.
Expected : Systemd-bootx64.efi and bootx64.efi should be the same
hence checksums should be equal.
Product: oe-core
Author: Jose Perez Carranza <jose.perez.carranza at linux-intel.com>
AutomatedBy: Jose Perez Carranza <jose.perez.carranza at linux-intel.com>
"""
systemdbootimage = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], '%s.wic' % bb_vars['IMAGE_LINK_NAME'])
imagebootfile = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'bootx64.efi')
# Clean environment before start the test
if os.path.isfile(imagebootfile):
runCmd('rm -f %s' % imagebootfile)
sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
runCmd('wic cp %s:1/EFI/BOOT/bootx64.efi %s -n %s' % (systemdbootimage,
imagebootfile, sysroot))
found = os.path.isfile(imagebootfile)
self.assertTrue(found, 'bootx64.efi file %s was not copied from image'
% imagebootfile)
result = runCmd('md5sum %s %s' % (systemdbootfile, imagebootfile))
self.assertEqual(result.output.split()[0], result.output.split()[2],
'%s was not correclty generated' % imagebootfile)