Add barebox bootloader support (and testing)
v3 cover Add barebox bootloader support (and testing)
This adds support for the barebox bootloader (and tools) to oe-core.
In order to have proper testing, this extends oe-selftest to allow basic testing of bootloaders. While at it, cover both barebox and u-boot.
v3:
* bump to barebox 2023.04.0
* add anonymous python to not act as provider when no config is set
* reasoning for default BAREBOX_CONFIGs in patch description and set PREFERRED_PROVIDER_virtual/bootloader to u-boot to avoid conflicts
* extend patch description and add comment for vt100 regex
* set CC=${CC} and LD=${LD} in barebox-tools to fix musl builds
Enrico Jorns (7):
barebox: set default BAREBOX_CONFIG for qemu machines oeqa/utils/qemurunner: support ignoring vt100 escape sequences oeqa/utils/qemurunner: simplify output parsing and make crlf-compatible oeqa/utils/commands: document runqemu context manager
oeqa: support passing custom boot patterns to runqemu oeqa/selftest/cases: add barebox tests
oeqa/selftest/cases: add basic u-boot test
Marco Felsch (2):
barebox: add initial support
barebox-tools: add initial barebox tools support
meta/conf/distro/include/maintainers.inc | 2 + meta/conf/machine/qemuarm.conf | 1 + meta/conf/machine/qemuarm64.conf | 1 + meta/conf/machine/qemux86-64.conf | 1 + meta/lib/oeqa/selftest/cases/barebox.py | 72 +++++++++ meta/lib/oeqa/selftest/cases/uboot.py | 40 +++++ meta/lib/oeqa/targetcontrol.py | 5 +- meta/lib/oeqa/utils/commands.py | 22 ++- meta/lib/oeqa/utils/qemurunner.py | 38 ++--- .../barebox/barebox-tools_2023.04.0.bb | 58 +++++++ meta/recipes-bsp/barebox/barebox.inc | 149 ++++++++++++++++++ meta/recipes-bsp/barebox/barebox_2023.04.0.bb | 3 + 12 files changed, 368 insertions(+), 24 deletions(-) create mode 100644 meta/lib/oeqa/selftest/cases/barebox.py create mode 100644 meta/lib/oeqa/selftest/cases/uboot.py create mode 100644 meta/recipes-bsp/barebox/barebox-tools_2023.04.0.bb create mode 100644 meta/recipes-bsp/barebox/barebox.inc create mode 100644 meta/recipes-bsp/barebox/barebox_2023.04.0.bb
Signature · 1 line
2.39.2
PATCH v3 1/9 barebox: add initial support
From: Marco Felsch <[email protected]>
This adds the support for the barebox bootloader to oe-core. The recipe is based on the recipe found in meta-ptx [1] with a few minor adaptions.
This basic support includes the bootloader and the target tools to interact with the bootloader. The host tools support is not part of this commit. This will be added later on as separate recipe.
[1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
--- meta/conf/distro/include/maintainers.inc | 1 + meta/recipes-bsp/barebox/barebox.inc | 144 ++++++++++++++++++ meta/recipes-bsp/barebox/barebox_2023.04.0.bb | 3 + 3 files changed, 148 insertions(+) create mode 100644 meta/recipes-bsp/barebox/barebox.inc create mode 100644 meta/recipes-bsp/barebox/barebox_2023.04.0.bb
meta/conf/distro/include/maintainers.inc +1 -0
@@ -54,6 +54,7 @@ RECIPE_MAINTAINER:pn-automake = "Robert Yang <[email protected]>" RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>" +RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>" RECIPE_MAINTAINER:pn-baremetal-helloworld = "Alejandro Hernandez <[email protected]>" RECIPE_MAINTAINER:pn-base-files = "Anuj Mittal <[email protected]>" RECIPE_MAINTAINER:pn-base-passwd = "Anuj Mittal <[email protected]>"
meta/recipes-bsp/barebox/barebox.inc new file +144 -0
144 lines not on this page · raw message
meta/recipes-bsp/barebox/barebox_2023.04.0.bb new file +3 -0
@@ -0,0 +1,3 @@ +require barebox.inc + +SRC_URI[sha256sum] = "c11386b2b72f7ab16c7aa21216e2119a6661d0f51420d14ab71bc9b0afc418ab"
Signature · 1 line
2.39.2
Re: [OE-core] [PATCH v3 1/9] barebox: add initial support
Hello Enrico,
Quoted 26 lines · On Tue, 25 Apr 2023 20:47:12 +0200 Enrico Jörns <[email protected]> wrote:
From: Marco Felsch <[email protected]>
This adds the support for the barebox bootloader to oe-core. The recipe is based on the recipe found in meta-ptx [1] with a few minor adaptions.
This basic support includes the bootloader and the target tools to interact with the bootloader. The host tools support is not part of this commit. This will be added later on as separate recipe.
[1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
Signed-off-by Marco Felsch <[email protected]>Signed-off-by Enrico Jorns <[email protected]>--- meta/conf/distro/include/maintainers.inc | 1 + meta/recipes-bsp/barebox/barebox.inc | 144 ++++++++++++++++++ meta/recipes-bsp/barebox/barebox_2023.04.0.bb | 3 + 3 files changed, 148 insertions(+) create mode 100644 meta/recipes-bsp/barebox/barebox.inc create mode 100644 meta/recipes-bsp/barebox/barebox_2023.04.0.bbmeta/conf/distro/include/maintainers.inc +0
-0
meta/conf/distro/include/maintainers.inc RECIPE_MAINTAINER:pn-automake = "Robert Yang <[email protected]>" · line 57
Quoted 4 lines
meta/conf/distro/include/maintainers.inc +1
-0@@ -54,6 +54,7 @@ RECIPE_MAINTAINER:pn-automake = "Robert Yang <[email protected]>" RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>" +RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>"
There's been another build failure, but I must say it looks nonsense to me -- perhaps others can shed some light on it:
AssertionError:
Unable to find recipes for the following entries in maintainers.inc:
barebox
https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/1321/steps/14/logs/stdio
Some lines later on the same log file, there is a QEMU error in test_boot_barebox:
2023-04-26 16:37:04,021 - oe-selftest - INFO - barebox.BareboxTest.test_boot_barebox (subunit.RemotedTestCase)
2023-04-26 16:37:04,022 - oe-selftest - INFO - ... ERROR
2023-04-26 16:37:04,023 - oe-selftest - INFO - 1: 1/47 367/530 (24221.61s) (0 failed) (barebox.BareboxTest.test_boot_barebox)
2023-04-26 16:37:04,023 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
File "/home/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/utils/commands.py", line 372, in runqemu
qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd, discard_writes=discard_writes)
File "/home/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/targetcontrol.py", line 183, in start
raise RuntimeError("%s - FAILED to start qemu - check the task log and the boot log" % self.pn)RuntimeError: core-image-minimal - FAILED to start qemu - check the task log and the boot log
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
return func(*args, **kwargs)
File "/home/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/selftest/cases/barebox.py", line 36, in test_boot_barebox
with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic',
File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
File "/home/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/lib/oeqa/utils/commands.py", line 378, in runqemu
raise Exception(msg)
Exception: core-image-minimal - FAILED to start qemu - check the task log and the boot log
Sadly the work directory for that build has already gone. :-/
Best regards,
Luca
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v3 2/9 barebox-tools: add initial barebox tools support
In reply to Enrico JornsFrom: Marco Felsch <[email protected]>
Add initial support to build the barebox tools for the host and the target.
--- meta/conf/distro/include/maintainers.inc | 1 + .../barebox/barebox-tools_2023.04.0.bb | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 meta/recipes-bsp/barebox/barebox-tools_2023.04.0.bb
meta/conf/distro/include/maintainers.inc +1 -0
@@ -55,6 +55,7 @@ RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>" RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>" +RECIPE_MAINTAINER:pn-barebox-tools = "Enrico Jörns <[email protected]>" RECIPE_MAINTAINER:pn-baremetal-helloworld = "Alejandro Hernandez <[email protected]>" RECIPE_MAINTAINER:pn-base-files = "Anuj Mittal <[email protected]>" RECIPE_MAINTAINER:pn-base-passwd = "Anuj Mittal <[email protected]>"
meta/recipes-bsp/barebox/barebox-tools_2023.04.0.bb new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v3 3/9 barebox: set default BAREBOX_CONFIG for qemu machines
In reply to Enrico JornsThese are set in the barebox recipe rather in the corresponding machines (where they would belong otherwise) to keep the impact of barebox to oe-core minimal for now.
"multi_v7_defconfig" is used for qemuarm since this is the default barebox armv7 config that just enables all platforms.
"qemu_virt64_defconfig" is used for qemuarm64 sine this is a dedicated config for the standard QEMU armv8 'virt64' machine.
"efi_defconfig" is used for qemux86-64 which is the primary platform where barebox will not be the first stage bootloader but an EFI payload.
Since these changes make barebox a provider for virtual/bootloader, explicitly default to u-boot in the corresponding MACHINE configs to not unnecessarily surprise users.
--- meta/conf/machine/qemuarm.conf | 1 + meta/conf/machine/qemuarm64.conf | 1 + meta/conf/machine/qemux86-64.conf | 1 + meta/recipes-bsp/barebox/barebox.inc | 5 +++++ 4 files changed, 8 insertions(+)
meta/conf/machine/qemuarm.conf +1 -0
@@ -7,6 +7,7 @@ require conf/machine/include/qemu.inc KERNEL_IMAGETYPE = "zImage" +PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot" UBOOT_MACHINE ?= "qemu_arm_defconfig" SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;hvc0"
meta/conf/machine/qemuarm64.conf +1 -0
@@ -7,6 +7,7 @@ require conf/machine/include/qemu.inc KERNEL_IMAGETYPE = "Image" +PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot" UBOOT_MACHINE ?= "qemu_arm64_defconfig" SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;hvc0"
meta/conf/machine/qemux86-64.conf +1 -0
@@ -13,6 +13,7 @@ DEFAULTTUNE ?= "core2-64" require conf/machine/include/x86/tune-x86-64-v3.inc require conf/machine/include/x86/qemuboot-x86.inc +PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot" UBOOT_MACHINE ?= "qemu-x86_64_defconfig" KERNEL_IMAGETYPE = "bzImage"
meta/recipes-bsp/barebox/barebox.inc +5 -0
@@ -48,6 +48,11 @@ EXTRA_OEMAKE = " \ BAREBOX_CONFIG[doc] = "The barebox kconfig defconfig file. Not used if a file called defconfig is added to the SRC_URI." BAREBOX_CONFIG ?= "" +# set sensible default configs for some of oe-core's QEMU MACHINEs +BAREBOX_CONFIG:qemuarm = "multi_v7_defconfig" +BAREBOX_CONFIG:qemuarm64 = "qemu_virt64_defconfig" +BAREBOX_CONFIG:qemux86-64 = "efi_defconfig" + # prevent from acting as non-buildable provider python () { bareboxconfig = d.getVar('BAREBOX_CONFIG')
Signature · 1 line
2.39.2
PATCH v3 4/9 oeqa/utils/qemurunner: support ignoring vt100 escape sequences
In reply to Enrico JornsIf we talk to terminals that like colors, we need to ignore the vt100 escape sequences when matching strings.
An unprocessed barebox console prompt would e.g. look like:
ESC[1;32mbarebox@ESC[1;36mARM QEMU virt64:/ESC[0m
where we cannot match for something like "barebox@ARM QEMU virt64:/". The same applies to colored Linux terminal output of course.
The "\x1b\[" from the regex catches the standard start of ansii escape sequence while the rest catches the actual command code executed.
--- meta/lib/oeqa/utils/qemurunner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/oeqa/utils/qemurunner.py +3 -1
@@ -30,6 +30,8 @@ control_range = list(range(0,32))+list(range(127,160)) control_chars = [chr(x) for x in control_range if chr(x) not in string.printable] re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) +# Regex to remove the ansii (color) control codes from console strings in order to match the text only +re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_a-z]*[@-_a-z]|\x1b[@-_a-z]') class QemuRunner:
@@ -662,7 +664,7 @@ class QemuRunner: time.sleep(0.1) answer = self.server_socket.recv(1024) if answer: - data += answer.decode('utf-8') + data += re_vt100.sub("", answer.decode('utf-8')) # Search the prompt to stop if re.search(self.boot_patterns['search_cmd_finished'], data): break
Signature · 1 line
2.39.2
Re: [OE-core] [PATCH v3 4/9] oeqa/utils/qemurunner: support ignoring vt100 escape sequences
Hello Enrico,
Quoted 11 lines · On Tue, 25 Apr 2023 20:47:15 +0200 Enrico Jörns <[email protected]> wrote:
If we talk to terminals that like colors, we need to ignore the vt100 escape sequences when matching strings.
An unprocessed barebox console prompt would e.g. look like:
ESC[1;32mbarebox@ESC[1;36mARM QEMU virt64:/ESC[0m
where we cannot match for something like "barebox@ARM QEMU virt64:/". The same applies to colored Linux terminal output of course.
The "\x1b\[" from the regex catches the standard start of ansii escape
^^^^^
I guess you mean "ansi" (single 'i'). I fixed that (and also converted to uppercase) while applying the patch for testing, no need to resend.
Quoted 12 lines
sequence while the rest catches the actual command code executed.
Signed-off-by Enrico Jorns <[email protected]>--- meta/lib/oeqa/utils/qemurunner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)meta/lib/oeqa/utils/qemurunner.py +0
-0
meta/lib/oeqa/utils/qemurunner.py control_range = list(range(0,32))+list(range(127,160)) · line 33
Quoted 4 lines
meta/lib/oeqa/utils/qemurunner.py +1
-0@@ -30,6 +30,8 @@ control_range = list(range(0,32))+list(range(127,160)) control_chars = [chr(x) for x in control_range if chr(x) not in string.printable] re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) +# Regex to remove the ansii (color) control codes from console strings in order to match the text only
^^^^^
Same here.
Best regards,
Luca
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [OE-core] [PATCH v3 4/9] oeqa/utils/qemurunner: support ignoring vt100 escape sequences
Hello Luca,
Am Mittwoch, dem 26.04.2023 um 10:52 +0200 schrieb Luca Ceresoli:
Quoted 12 lines
Hello Enrico,
Quoted 7 lines · On Tue, 25 Apr 2023 20:47:15 +0200 Enrico Jörns <[email protected]> wrote:
If we talk to terminals that like colors, we need to ignore the vt100 escape sequences when matching strings.
An unprocessed barebox console prompt would e.g. look like:
ESC[1;32mbarebox@ESC[1;36mARM QEMU virt64:/ESC[0m
Quoted 7 lines
Quoted 4 lines
where we cannot match for something like "barebox@ARM QEMU virt64:/". The same applies to colored Linux terminal output of course.
The "\x1b\[" from the regex catches the standard start of ansii escape
^^^^ I guess you mean "ansi" (single 'i'). I fixed that (and also converted to uppercase) while applying the patch for testing, no need to resend.
indeed, seems as if a part of me had 'ascii' in mind and when writing this. ANSI is what I meant, yes.
Thanks for fixing it at both places!
Enrico
Quoted 24 lines
Quoted 12 lines
sequence while the rest catches the actual command code executed.
Signed-off-by Enrico Jorns <[email protected]>---
meta/lib/oeqa/utils/qemurunner.py | 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)meta/lib/oeqa/utils/qemurunner.py +0
-0@@ -30,6 +30,8 @@ control_range = list(range(0,32))+list(range(127,160))Quoted 5 lines
control_chars = [chr(x) for x in
control_range
if chr(x) not in string.printable]
re_control_char =re.compile('[%s]' % re.escape("".join(control_chars)))
+# Regex to remove the ansii (color) control codes from console strings in order to match the text only^^^^^
Same here.
Best regards,
Luca
Signature · 4 lines
Pengutronix e.K. | Enrico Jörns | Embedded Linux Consulting & Support | https://www.pengutronix.de/ | Steuerwalder Str. 21 | Phone: +49-5121-206917-180 | 31137 Hildesheim, Germany | Fax: +49-5121-206917-9 |
PATCH v3 5/9 oeqa/utils/qemurunner: simplify output parsing and make crlf-compatible
In reply to Enrico JornsReduces the nesting depth and replaces the manual newline matching by built-in splitlines() method.
This makes it compatible with shells that use windows-compatible line breaks, e.g. for EFI loaders.
More comments and an early return handling should make the code a bit more readable.
--- meta/lib/oeqa/utils/qemurunner.py | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-)
meta/lib/oeqa/utils/qemurunner.py +15 -17
@@ -673,23 +673,21 @@ class QemuRunner: return (1, "") raise Exception("No data on serial console socket, connection closed?") - if data: - if raw: - status = 1 - else: - # Remove first line (command line) and last line (prompt) - data = data[data.find('$?\r\n')+4:data.rfind('\r\n')] - index = data.rfind('\r\n') - if index == -1: - status_cmd = data - data = "" - else: - status_cmd = data[index+2:] - data = data[:index] - if (status_cmd == "0"): - status = 1 - return (status, str(data)) - + # If we got no data, we assume something went wrong and return 0 + if not data: + return (0, str(None)) + + # in raw mode, we cannot check exit status output and thus assume success + if raw: + return (1, str(data)) + + # Split lines into array and remove first line (command line) and last line (prompt) + # Also remove empty lines to ease catching results + outlines = list(filter(None, data.splitlines()[1:-1])) + # Remaining last line contains exit code output + if (outlines[-1] == "0"): + status = 1 + return (status, "\n".join(outlines[0:-1])) def _dump_host(self): self.host_dumper.create_dir("qemu")
Signature · 1 line
2.39.2
PATCH v3 6/9 oeqa/utils/commands: document runqemu context manager
In reply to Enrico JornsUsage and arguments are not necessarily self-explaining.
--- meta/lib/oeqa/utils/commands.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
meta/lib/oeqa/utils/commands.py +16 -1
@@ -312,7 +312,22 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec= @contextlib.contextmanager def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, discard_writes=True): """ - launch_cmd means directly run the command, don't need set rootfs or env vars. + Starts a context manager for a 'oeqa.targetcontrol.QemuTarget' resource. + The underlying Qemu will be booted into a shell when the generator yields. + + Usage: + + with runqemu('core-image-minimal') as qemu: + qemu.run_serial('cat /proc/cpuinfo') + + Args: + pn (str): (image) recipe to run on + ssh (boolean): whether or not to enable SSH (network access) + runqemuparams (str): space-separated list of params to pass to 'runqemu' script (like 'nographics', 'ovmf', etc.) + image_fstype (str): IMAGE_FSTYPE to use + launch_cmd (str): directly run this command and bypass automatic runqemu parameter generation + overrides (dict): dict of "'<bitbake-variable>': value" pairs that allows overriding bitbake variables + discard_writes (boolean): enables qemu -snapshot feature to prevent modifying original image """ import bb.tinfoil
Signature · 1 line
2.39.2
PATCH v3 7/9 oeqa: support passing custom boot patterns to runqemu
In reply to Enrico JornsThis allows defining non-standard patterns from QEMU tests just as they are already supported by the testimage.bbclass.
Will allow testing non-Linux shells in QEMU, too, e.g. a U-Boot or other bootloader shell.
--- meta/lib/oeqa/targetcontrol.py | 5 +++-- meta/lib/oeqa/utils/commands.py | 5 +++-- meta/lib/oeqa/utils/qemurunner.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)
meta/lib/oeqa/targetcontrol.py +3 -2
@@ -88,7 +88,7 @@ class QemuTarget(BaseTarget): supported_image_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic'] - def __init__(self, d, logger, image_fstype=None): + def __init__(self, d, logger, image_fstype=None, boot_patterns=None): import oe.types
@@ -144,7 +144,8 @@ class QemuTarget(BaseTarget): dump_host_cmds = dump_host_cmds, logger = logger, tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"), - serial_ports = len(d.getVar("SERIAL_CONSOLES").split())) + serial_ports = len(d.getVar("SERIAL_CONSOLES").split()), + boot_patterns = boot_patterns) self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner)
meta/lib/oeqa/utils/commands.py +3 -2
@@ -310,7 +310,7 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec= f.write('LAYERSERIES_COMPAT_%s = "%s"\n' % (templayername, corenames)) @contextlib.contextmanager -def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, discard_writes=True): +def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, boot_patterns = {}, discard_writes=True): """ Starts a context manager for a 'oeqa.targetcontrol.QemuTarget' resource. The underlying Qemu will be booted into a shell when the generator yields.
@@ -327,6 +327,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, image_fstype (str): IMAGE_FSTYPE to use launch_cmd (str): directly run this command and bypass automatic runqemu parameter generation overrides (dict): dict of "'<bitbake-variable>': value" pairs that allows overriding bitbake variables + boot_patterns (dict): dict of "'<pattern-name>': value" pairs to override default boot patterns, e.g. when not booting Linux discard_writes (boolean): enables qemu -snapshot feature to prevent modifying original image """
@@ -358,7 +359,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, logdir = recipedata.getVar("TEST_LOG_DIR") - qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, image_fstype) + qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, image_fstype, boot_patterns=boot_patterns) finally: # We need to shut down tinfoil early here in case we actually want # to run tinfoil-using utilities with the running QEMU instance.
meta/lib/oeqa/utils/qemurunner.py +1 -1
@@ -94,7 +94,7 @@ class QemuRunner: # Only override patterns that were set e.g. login user TESTIMAGE_BOOT_PATTERNS[send_login_user] = "webserver\n" for pattern in accepted_patterns: - if not self.boot_patterns[pattern]: + if pattern not in self.boot_patterns or not self.boot_patterns[pattern]: self.boot_patterns[pattern] = default_boot_patterns[pattern] def create_socket(self):
Signature · 1 line
2.39.2
PATCH v3 8/9 oeqa/selftest/cases: add barebox tests
In reply to Enrico Jorns--- meta/lib/oeqa/selftest/cases/barebox.py | 72 +++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/barebox.py
meta/lib/oeqa/selftest/cases/barebox.py new file +72 -0
@@ -0,0 +1,72 @@ +# Qemu-based barebox bootloader integration testing +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import bitbake, runqemu +from oeqa.core.decorator.data import skipIfNotArch +from oeqa.core.decorator import OETestTag + +barebox_boot_patterns = { + 'search_reached_prompt': r"stop autoboot", + 'search_login_succeeded': r"barebox@[^:]+:[^ ]+ ", + 'search_cmd_finished': r"barebox@[a-zA-Z0-9\-\s]+:/" + } + + +class BareboxTest(OESelftestTestCase): + + @skipIfNotArch(['arm', 'aarch64']) + @OETestTag("runqemu") + def test_boot_barebox(self): + """ + Tests building barebox and booting it with QEMU + """ + + self.write_config(""" +QB_DEFAULT_KERNEL = "barebox-dt-2nd.img" +PREFERRED_PROVIDER_virtual/bootloader = "barebox" +""") + + bitbake("virtual/bootloader core-image-minimal") + + with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic', + boot_patterns=barebox_boot_patterns) as qemu: + + # test if barebox console works + cmd = "version" + status, output = qemu.run_serial(cmd) + self.assertEqual(status, 1, msg=output) + self.assertTrue("barebox" in output, msg=output) + + @skipIfNotArch(['x86_64']) + @OETestTag("runqemu") + def test_boot_barebox_efi(self): + """ + Tests building barebox for UEFI and booting it as EFI payload + with QEMU + OVMF + """ + image = "core-image-minimal" + + self.write_config(""" +IMAGE_INSTALL:append = " barebox" +MACHINE_FEATURES:append = " pcbios efi" +EXTRA_IMAGEDEPENDS += "ovmf" +EFI_PROVIDER = "barebox" +IMAGE_FSTYPES += "wic" +WKS_FILE = "efi-bootdisk.wks.in" +""") + + bitbake(image) + + with runqemu(image, ssh=False, runqemuparams='nographic ovmf', + boot_patterns=barebox_boot_patterns, image_fstype='wic') as qemu: + + # test if barebox console works + cmd = "version" + status, output = qemu.run_serial(cmd) + self.assertEqual(status, 1, msg=output) + self.assertTrue("barebox" in output, msg=output)
Signature · 1 line
2.39.2
PATCH v3 9/9 oeqa/selftest/cases: add basic u-boot test
In reply to Enrico Jorns--- meta/lib/oeqa/selftest/cases/uboot.py | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/uboot.py
meta/lib/oeqa/selftest/cases/uboot.py new file +40 -0
@@ -0,0 +1,40 @@ +# Qemu-based u-boot bootloader integration testing +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import bitbake, runqemu +from oeqa.core.decorator import OETestTag + +uboot_boot_patterns = { + 'search_reached_prompt': "stop autoboot", + 'search_login_succeeded': "=>", + 'search_cmd_finished': "=>" + } + + +class UBootTest(OESelftestTestCase): + + @OETestTag("runqemu") + def test_boot_uboot(self): + """ + Tests building u-boot and booting it with QEMU + """ + + self.write_config(""" +QB_DEFAULT_BIOS = "u-boot.bin" +PREFERRED_PROVIDER_virtual/bootloader = "u-boot" +""") + bitbake("virtual/bootloader core-image-minimal") + + with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic', + boot_patterns=uboot_boot_patterns) as qemu: + + # test if u-boot console works + cmd = "version" + status, output = qemu.run_serial(cmd) + self.assertEqual(status, 1, msg=output) + self.assertTrue("U-Boot" in output, msg=output)
Signature · 1 line
2.39.2
Hello Enrico,
Quoted 4 lines · On Tue, 25 Apr 2023 20:47:11 +0200 Enrico Jörns <[email protected]> wrote:
This adds support for the barebox bootloader (and tools) to oe-core.
In order to have proper testing, this extends oe-selftest to allow basic testing of bootloaders. While at it, cover both barebox and u-boot.
Some tests are failing with this series applied. Logs looking like:
--------------------------------8<--------------------------------
2023-04-26 02:45:38,232 - oe-selftest - INFO - barebox.BareboxTest.test_boot_barebox (subunit.RemotedTestCase)
2023-04-26 02:45:38,232 - oe-selftest - INFO - ... skipped 'Test skipped on x86_64\n'
2023-04-26 02:45:38,232 - oe-selftest - INFO - 1: 1/47 2/530 (0.00s) (0 failed) (barebox.BareboxTest.test_boot_barebox)
2023-04-26 02:45:38,232 - oe-selftest - INFO - Test skipped on x86_64
2023-04-26 02:46:47,829 - oe-selftest - INFO - fetch.Dependencies.test_dependencies (subunit.RemotedTestCase)
2023-04-26 02:46:47,829 - oe-selftest - INFO - ... ok
2023-04-26 02:46:47,829 - oe-selftest - INFO - 12: 2/20 3/530 (70.93s) (0 failed) (fetch.Dependencies.test_dependencies)
2023-04-26 02:46:54,605 - oe-selftest - INFO - barebox.BareboxTest.test_boot_barebox_efi (subunit.RemotedTestCase)
2023-04-26 02:46:54,605 - oe-selftest - INFO - ... FAIL
Stderr:
2023-04-26 02:45:38,230 - oe-selftest - INFO - Adding: "include selftest.inc" in /home/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3126928/conf/local.conf
2023-04-26 02:45:38,231 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
2023-04-26 02:46:54,606 - oe-selftest - INFO - 1: 2/47 4/530 (76.37s) (0 failed) (barebox.BareboxTest.test_boot_barebox_efi)
2023-04-26 02:46:54,606 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
return func(*args, **kwargs)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/selftest/cases/barebox.py", line 63, in test_boot_barebox_efi
bitbake(image)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/utils/commands.py", line 234, in bitbake
return runCmd(cmd, ignore_status, timeout, output_log=output_log, **options)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/utils/commands.py", line 212, in runCmd
raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))AssertionError: Command 'bitbake core-image-minimal' returned non-zero exit status 1:
Loading cache...done.
Loaded 0 entries from dependency cache.
Parsing recipes...done.
Parsing of 955 .bb files complete (0 cached, 955 parsed). 1872 targets, 55 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
ERROR: Nothing RPROVIDES 'barebox' (but /home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/recipes-core/images/core-image-minimal.bb, /home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/recipes-core/packagegroups/packagegroup-core-boot.bb RDEPENDS on or otherwise requires it) barebox was skipped: PREFERRED_PROVIDER_virtual/bootloader set to u-boot, not barebox
NOTE: Runtime target 'barebox' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['barebox']
ERROR: Required build target 'core-image-minimal' has no buildable providers.
Missing or unbuildable dependency chain was: ['core-image-minimal', 'barebox']
Summary: There were 2 ERROR messages, returning a non-zero exit code.
--------------------------------8<--------------------------------
Some logs are here:
https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/5054/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/5096/steps/14/logs/stdio
FYI I had to manually solve a trivial conflict on patch 5 due to another patch in my branch that is touching the same file:
https://lore.kernel.org/openembedded-core/[email protected]/
Best regards,
Luca
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hello Luca,
Am Mittwoch, dem 26.04.2023 um 14:12 +0200 schrieb Luca Ceresoli:
Quoted 11 lines
Hello Enrico,
Quoted 4 lines · On Tue, 25 Apr 2023 20:47:11 +0200 Enrico Jörns <[email protected]> wrote:
This adds support for the barebox bootloader (and tools) to oe-core.
In order to have proper testing, this extends oe-selftest to allow basic testing of bootloaders. While at it, cover both barebox and u-boot.
Some tests are failing with this series applied. Logs looking like:
thank you for the test results.
Quoted 55 lines
--------------------------------8<--------------------------------
2023-04-26 02:45:38,232 - oe-selftest - INFO - barebox.BareboxTest.test_boot_barebox (subunit.RemotedTestCase) 2023-04-26 02:45:38,232 - oe-selftest - INFO - ... skipped 'Test skipped on x86_64\n' 2023-04-26 02:45:38,232 - oe-selftest - INFO - 1: 1/47 2/530 (0.00s) (0 failed) (barebox.BareboxTest.test_boot_barebox) 2023-04-26 02:45:38,232 - oe-selftest - INFO - Test skipped on x86_64 2023-04-26 02:46:47,829 - oe-selftest - INFO - fetch.Dependencies.test_dependencies (subunit.RemotedTestCase) 2023-04-26 02:46:47,829 - oe-selftest - INFO - ... ok 2023-04-26 02:46:47,829 - oe-selftest - INFO - 12: 2/20 3/530 (70.93s) (0 failed) (fetch.Dependencies.test_dependencies) 2023-04-26 02:46:54,605 - oe-selftest - INFO - barebox.BareboxTest.test_boot_barebox_efi (subunit.RemotedTestCase) 2023-04-26 02:46:54,605 - oe-selftest - INFO - ... FAIL Stderr: 2023-04-26 02:45:38,230 - oe-selftest - INFO - Adding: "include selftest.inc" in /home/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3126928/conf/local.conf 2023-04-26 02:45:38,231 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf 2023-04-26 02:46:54,606 - oe-selftest - INFO - 1: 2/47 4/530 (76.37s) (0 failed) (barebox.BareboxTest.test_boot_barebox_efi) 2023-04-26 02:46:54,606 - oe-selftest - INFO - testtools.testresult.real._StringException:Traceback (most recent call last):
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, inwrapped_freturnfunc(*args, **kwargs)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/selftest/cases/barebox.py", line 63, intest_boot_barebox_efibitbake(image)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/utils/commands.py", line 234, in bitbake
returnrunCmd(cmd, ignore_status, timeout, output_log=output_log, **options)File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/lib/oeqa/utils/commands.py", line 212, in runCmd
raiseAssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'bitbake core-image-minimal' returned non-zero exit status 1:
Loading cache...done.
Loaded 0 entries from dependency cache.
Parsing recipes...done.
Parsing of 955 .bb files complete (0 cached, 955 parsed). 1872 targets, 55 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
ERROR: Nothing RPROVIDES 'barebox' (but/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/recipes-core/images/core-image-minimal.bb,/home/pokybuild/yocto-worker/oe-selftest-debian/build/meta/recipes-core/packagegroups/packagegroup-core-boot.bb RDEPENDS on or otherwise requires it)
barebox was skipped: PREFERRED_PROVIDER_virtual/bootloader set to u-boot, not barebox
NOTE: Runtime target 'barebox' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['barebox']
ERROR: Required build target 'core-image-minimal' has no buildable providers. Missing or unbuildable dependency chain was: ['core-image-minimal', 'barebox']
Summary: There were 2 ERROR messages, returning a non-zero exit code.
Quoted 1 line
--------------------------------8<--------------------------------
It seems as if I did not re-test the EFI test after having set PREFERRED_PROVIDER_virtual/bootloader to "u-boot" in the machine conf. I will add a PREFERRED_PROVIDER_virtual/bootloader = "barebox" to the test case.
Quoted 5 lines
Some logs are here:
https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/5054/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/5096/steps/14/logs/stdio
There are some wic failures where I am not sure yet if these are caused by my patchset or not.
Quoted 3 lines
FYI I had to manually solve a trivial conflict on patch 5 due to another patch in my branch that is touching the same file:
https://lore.kernel.org/openembedded-core/[email protected]/
I am not really unconvinced that this patch set should be applied as-is. It copies most of the run_serial() method 'just' to change the return value. It would also require to duplicate my adaptions.
Thanks and regards
Enrico
Quoted 3 lines
Best regards,
Luca
Signature · 4 lines
Pengutronix e.K. | Enrico Jörns | Embedded Linux Consulting & Support | https://www.pengutronix.de/ | Steuerwalder Str. 21 | Phone: +49-5121-206917-180 | 31137 Hildesheim, Germany | Fax: +49-5121-206917-9 |