From patchwork Fri Jan 9 01:53:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1363 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923626; bh=XYuZDm3x5sPzNDjZE5ELtmQIacmHqBojkFbkF9RdNOc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PFPw/ot8CGk0vyQIDfU7vY0nf1q56xOx1pi3lMB8MjYXuQGPdJokysAmWdj+Ne6qc ijrAId/7PrAtsiJxGOtDnbxFpZoNeDu20hf/h31rRKfccl4hOZY1ygX9Sm9+uIZZph maVr/ezEz9PyWL8gOJYFY/+i2PmQYPiHMxvmVwW/5g00pXK+okdbMfS3VXV7HqIsS0 H8OXw1IZsly/3sEJJ8/gb2el7m8GqH5u/4hLQAiMpz665r7yT2O9ZaTaf5na4u153K JrERVxpbzkptnVwkdwT74gkFbym20hARsGOhcjDst0e97RdMRoW/w5u9nyFV5Ri3xk fzYWG67SozGoQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C279369130 for ; Thu, 8 Jan 2026 18:53:46 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4OKvVp79sL_D for ; Thu, 8 Jan 2026 18:53:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923626; bh=XYuZDm3x5sPzNDjZE5ELtmQIacmHqBojkFbkF9RdNOc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PFPw/ot8CGk0vyQIDfU7vY0nf1q56xOx1pi3lMB8MjYXuQGPdJokysAmWdj+Ne6qc ijrAId/7PrAtsiJxGOtDnbxFpZoNeDu20hf/h31rRKfccl4hOZY1ygX9Sm9+uIZZph maVr/ezEz9PyWL8gOJYFY/+i2PmQYPiHMxvmVwW/5g00pXK+okdbMfS3VXV7HqIsS0 H8OXw1IZsly/3sEJJ8/gb2el7m8GqH5u/4hLQAiMpz665r7yT2O9ZaTaf5na4u153K JrERVxpbzkptnVwkdwT74gkFbym20hARsGOhcjDst0e97RdMRoW/w5u9nyFV5Ri3xk fzYWG67SozGoQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B179C691E9 for ; Thu, 8 Jan 2026 18:53:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923625; bh=b7HhqJEcwFFyEUrHxltZEAzSheJhZyB0nGnBZPLpmeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnXrG5sh8ccEz2foR5xxyKqsVChZQLRwyfmWxm8pqUMQVuhvmQ5z0EszT7xj3Ly0d YZZDrnawo1qHbZ/oxhYkV1lpUR7fC33bafyP3jl7E+tNMOjzEA4OOInOvFrVpo+Oel DlAe12arZx3FqEE9kt2FZKd3zO+MrJTmSPaIfwfIQ2G6rrkdlz24bYF0qfPNCYbJqX fQg8CTBOrtwBXd2aQ0R7lQgL7+wsKKnrfgQJVZ9MAYWLJYcoWlfdKwDlNDsPt/DJbi FnuuDJbgser31do8JFoVZCbNfDo6WIGD2WMG7lNUSJXPqHRPP7YWPU0Gs9g8Vrbv9Z QTXPMaOWSE6qg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2967369130; Thu, 8 Jan 2026 18:53:45 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7ZAQGBtc-fCv; Thu, 8 Jan 2026 18:53:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923621; bh=DjPlEOWswZfFoOeMLqcSjPfvU5S2+V1u/HkOTQV0FgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JhtnYPrkVqTLz9mbse11D5Vw1M9DsfCEgAkjdB0U1Vo106i64cDst9j7FtPrBvd1K Ehv8RtggfQpVKt4A3mK6HYqWkZTmZgz58dDna/8/FJxEExZaPxAdNkE5JLG7iEB459 VSTFnsVx6SUxIgRo+EawsZAC1P0+zXB8npmZAwcoSFnmSu92r8SRKNMYJ9zgiMW+jO 593Og66BNFwofMx4DOwyOCl21m/IBIcR+rQYUhPFLTB9T52dBm7GQ1t7DEtdnFyPqw 9scNRZPQliSlz63tdA3h99d2nww2TQ3SBbB12aNDFrktMPm0b6M+WD8P6XFqiLU8an xItUz2v7gAHDg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AF8A96912D; Thu, 8 Jan 2026 18:53:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:02 -0700 Message-ID: <20260109015323.3411528-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2BKB43MQDKFYKPIRUURQ6P6AHCQRNIVQ X-Message-ID-Hash: 2BKB43MQDKFYKPIRUURQ6P6AHCQRNIVQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/16] buildman: Fix f-string in the delta column header List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The '+' sign format specifier is only valid for numeric types to force showing the sign. Using it with a string literal causes a ValueError. Remove the invalid '+' from the "delta" column header format specifier. Fixes: 34567e06b6a7 ("buildman: Convert to f-strings in builder.py") Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index d92748b01e9..b7343b57c0d 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1219,7 +1219,7 @@ class Builder: f'{args[0]}/{args[1]}, grow: {args[2]}/{args[3]} bytes: ' f'{args[4]}/{args[5]} ({args[6]})') tprint(f'{indent} {"function":<38s} {"old":>7s} {"new":>7s} ' - f'{"delta":>+7s}') + f'{"delta":>7s}') for diff, name in delta: if diff: color = self.col.RED if diff > 0 else self.col.GREEN From patchwork Fri Jan 9 01:53:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1364 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923631; bh=FbSdz+P6cJ9OEmExj8P0axlDJ9E2O8v6GEVVfCnyApg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=mHn8nwlVnkIZrmuG3j+5nlMNLSeVPgf2BZkNgCjY/HrLckGEkPZiCognYa75t0jZC XC00EIWgwcc1PcPRhNSwERGcyAOv9pW1maUtZlUYPTFMn2CJdmT7P6t97zawMishHw +KH5R62H0uv/oL2EZj6hYCxOmx/ixel8KCrmG2KC2ih9/mCmIWmYCDM/kna3Krku75 D2Fymcxxbznpv0nmIBtpn6EiZuIc/TwW64FET4k7r1lVzubI8NchlSUKNZtUt4D6kt nChH+x+ysjVGNXZwxplnHt34FJsqivHQB/rYvgBjdEhm61a0Oz1n9SMxaVB0aZWtH2 z++nTvyWaa8qw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 824B9691E9 for ; Thu, 8 Jan 2026 18:53:51 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yodEi2ia3dMT for ; Thu, 8 Jan 2026 18:53:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923631; bh=FbSdz+P6cJ9OEmExj8P0axlDJ9E2O8v6GEVVfCnyApg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=mHn8nwlVnkIZrmuG3j+5nlMNLSeVPgf2BZkNgCjY/HrLckGEkPZiCognYa75t0jZC XC00EIWgwcc1PcPRhNSwERGcyAOv9pW1maUtZlUYPTFMn2CJdmT7P6t97zawMishHw +KH5R62H0uv/oL2EZj6hYCxOmx/ixel8KCrmG2KC2ih9/mCmIWmYCDM/kna3Krku75 D2Fymcxxbznpv0nmIBtpn6EiZuIc/TwW64FET4k7r1lVzubI8NchlSUKNZtUt4D6kt nChH+x+ysjVGNXZwxplnHt34FJsqivHQB/rYvgBjdEhm61a0Oz1n9SMxaVB0aZWtH2 z++nTvyWaa8qw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71737691E6 for ; Thu, 8 Jan 2026 18:53:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923630; bh=VcdG/kr5qEzkBDfUKKE8bjLX6CTCaK54XoO3sZfXdJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wi7NnoGqHPhaH34i/SRYi/efLfpgdNtWGfMoO8iAelum6kWmB649k6ociC4iwpWbd M9K2Jw07t6pg50IsRLvTnSf9Jht5Y+XRw+E2qosEILeOkhLWZOYfkr31rBqH+n/lT0 fJgiMyY3MXuppTb1sUxV77Xw0h0XJhJPFB1bEIxan3z1GYfRRSWHGLQ99jYzdtkNQA lVyhJ+o+qXpRtVNZCUD3NfSfD8hRNhavSG68ea0hmHt4IOgSjdQCH82le8lKVKM3Ye 7Xxp72QwFH2IheiygArM7WaudPhOhDvxmS+8RRCfOEEg+fJ0f0Ym+T6uLO2lFCz/r1 0dHfQbY0SkBOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12B1269130; Thu, 8 Jan 2026 18:53:50 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id A2OQe7wxXxb8; Thu, 8 Jan 2026 18:53:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923625; bh=EK7FpG3QBvwV9C3LvW0ZdhfghDO7Yc71C/p1V3ah+RE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fUNKc/niVqNI24ACpfj9oLjoHNAT6NwWCjtPGr2aQ3vEkHhiAP71ZFGRsgTCgiqyl h/Rz8VTbaswpozIaDRBj1m+/gDK+nlwNwLHw+29CmRkY48GwwmwmO+FFToZ6ftFvYR W4RLCYbaqC7+vWvdBCP2vJH9UPSzjTvFah9OZ6S2t1lvb+Rj0xQYQxgKGy+CsBshOM rPNMVzxOXcDEEOnQkWPEv0o29pun/jb3yKVMcQGeUh8zBrSHO47bbtEOHxvoIZ2TO5 S5SA4+a8xSiZNuZ9bitajJq85v3WdFQGDKsjN6Ety2L2oBvjtLOyglrXeudlr9hz49 1GX0FQKOwn+jw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6A2076912D; Thu, 8 Jan 2026 18:53:45 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:03 -0700 Message-ID: <20260109015323.3411528-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: D2KN3NS64HZKG74JYVEI6OGHUR46JO4M X-Message-ID-Hash: D2KN3NS64HZKG74JYVEI6OGHUR46JO4M X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/16] test: pxe: Add unit tests for PXE/extlinux parser List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add comprehensive tests for the PXE/extlinux.conf parser APIs. The tests verify that config files can be parsed and label properties inspected without loading kernel/initrd/FDT files. The C test (test/boot/pxe.c) validates all struct pxe_label fields: - String fields: name, menu, kernel, kernel_label, config, append, initrd, fdt, fdtdir, fdtoverlays - Integer fields: ipappend, attempted, localboot, localboot_val, kaslrseed, num The test also verifies struct pxe_menu fields: title, default_label, fallback_label, bmp, timeout, prompt. Parser keywords exercised include: kernel, linux, fit (with #config syntax), append, initrd, fdt, fdtdir, fdtoverlays, localboot, ipappend, kaslrseed, menu title, timeout, prompt, default, fallback, background. The Python wrapper (test/py/tests/test_pxe_parser.py) creates a FAT filesystem image with an extlinux.conf file and passes it to the C test. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/Makefile | 1 + test/boot/pxe.c | 197 +++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 + test/py/tests/test_pxe_parser.py | 182 ++++++++++++++++++++++++++++ 4 files changed, 382 insertions(+) create mode 100644 test/boot/pxe.c create mode 100644 test/py/tests/test_pxe_parser.py diff --git a/test/boot/Makefile b/test/boot/Makefile index 21f533cdc4c..ceb863969dd 100644 --- a/test/boot/Makefile +++ b/test/boot/Makefile @@ -4,6 +4,7 @@ ifdef CONFIG_UT_BOOTSTD obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o +obj-$(CONFIG_CMDLINE) += pxe.o obj-$(CONFIG_FIT) += image.o obj-$(CONFIG_$(PHASE_)FIT_PRINT) += fit_print.o obj-$(CONFIG_BLK_LUKS) += luks.o diff --git a/test/boot/pxe.c b/test/boot/pxe.c new file mode 100644 index 00000000000..49d8d160389 --- /dev/null +++ b/test/boot/pxe.c @@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * PXE parser tests - C implementation for Python wrapper + * + * Copyright 2026 Canonical Ltd + * + * These tests verify the extlinux.conf parser APIs. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Define test macro for pxe suite - no init function needed */ +#define PXE_TEST_ARGS(_name, _flags, ...) \ + UNIT_TEST_ARGS(_name, _flags, pxe, __VA_ARGS__) + +/* Argument indices */ +#define PXE_ARG_FS_IMAGE 0 /* Path to filesystem image */ +#define PXE_ARG_CFG_PATH 1 /* Path to config file within image */ + +/* Memory address for loading files */ +#define PXE_LOAD_ADDR 0x01000000 + +/** + * struct pxe_test_info - context for the test getfile callback + * + * @uts: Unit test state for assertions + */ +struct pxe_test_info { + struct unit_test_state *uts; +}; + +/** + * pxe_test_getfile() - Read a file from the host filesystem + * + * This callback is used by the PXE parser to read included files. + */ +static int pxe_test_getfile(struct pxe_context *ctx, const char *file_path, + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *sizep) +{ + loff_t len_read; + int ret; + + if (!*addrp) + return -ENOTSUPP; + + ret = fs_set_blk_dev("host", "0:0", FS_TYPE_ANY); + if (ret) + return ret; + ret = fs_legacy_read(file_path, *addrp, 0, 0, &len_read); + if (ret) + return ret; + *sizep = len_read; + + return 0; +} + +/** + * Test parsing an extlinux.conf file + * + * This test: + * 1. Binds a filesystem image containing extlinux.conf + * 2. Parses the config using parse_pxefile() + * 3. Verifies the parsed labels can be inspected + * 4. Verifies label properties are accessible + */ +static int pxe_test_parse_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + ulong addr = PXE_LOAD_ADDR; + struct pxe_test_info info; + struct pxe_context ctx; + struct pxe_label *label; + struct pxe_menu *cfg; + int ret; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + info.uts = uts; + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set up the PXE context */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, + false, false, NULL)); + + /* Read the config file into memory */ + ret = get_pxe_file(&ctx, cfg_path, addr); + ut_asserteq(1, ret); /* get_pxe_file returns 1 on success */ + + /* Parse the config file */ + cfg = parse_pxefile(&ctx, addr); + ut_assertnonnull(cfg); + + /* Verify menu properties */ + ut_asserteq_str("Test Boot Menu", cfg->title); + ut_asserteq_str("linux", cfg->default_label); + ut_asserteq_str("rescue", cfg->fallback_label); + ut_asserteq_str("/boot/background.bmp", cfg->bmp); + ut_asserteq(50, cfg->timeout); + ut_asserteq(1, cfg->prompt); + + /* Verify first label: linux (with fdt, fdtoverlays) */ + label = list_first_entry(&cfg->labels, struct pxe_label, list); + ut_asserteq_str("", label->num); /* only set when menu is built */ + ut_asserteq_str("linux", label->name); + ut_asserteq_str("Boot Linux", label->menu); + ut_asserteq_str("/vmlinuz", label->kernel_label); + ut_asserteq_str("/vmlinuz", label->kernel); + ut_assertnull(label->config); + ut_asserteq_str("root=/dev/sda1 quiet", label->append); + ut_asserteq_str("/initrd.img", label->initrd); + ut_asserteq_str("/dtb/board.dtb", label->fdt); + ut_assertnull(label->fdtdir); + ut_asserteq_str("/dtb/overlay1.dtbo /dtb/overlay2.dtbo", + label->fdtoverlays); + ut_asserteq(0, label->ipappend); + ut_asserteq(0, label->attempted); + ut_asserteq(0, label->localboot); + ut_asserteq(0, label->localboot_val); + ut_asserteq(1, label->kaslrseed); + + /* Verify second label: rescue (linux keyword, fdtdir, ipappend) */ + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("", label->num); + ut_asserteq_str("rescue", label->name); + ut_asserteq_str("Rescue Mode", label->menu); + ut_asserteq_str("/vmlinuz-rescue", label->kernel_label); + ut_asserteq_str("/vmlinuz-rescue", label->kernel); + ut_assertnull(label->config); + ut_asserteq_str("single", label->append); + ut_assertnull(label->initrd); + ut_assertnull(label->fdt); + ut_asserteq_str("/dtb/", label->fdtdir); + ut_assertnull(label->fdtoverlays); + ut_asserteq(3, label->ipappend); + ut_asserteq(0, label->attempted); + ut_asserteq(0, label->localboot); + ut_asserteq(0, label->localboot_val); + ut_asserteq(0, label->kaslrseed); + + /* Verify third label: local (localboot only) */ + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("", label->num); + ut_asserteq_str("local", label->name); + ut_asserteq_str("Local Boot", label->menu); + ut_assertnull(label->kernel_label); + ut_assertnull(label->kernel); + ut_assertnull(label->config); + ut_assertnull(label->append); + ut_assertnull(label->initrd); + ut_assertnull(label->fdt); + ut_assertnull(label->fdtdir); + ut_assertnull(label->fdtoverlays); + ut_asserteq(0, label->ipappend); + ut_asserteq(0, label->attempted); + ut_asserteq(1, label->localboot); + ut_asserteq(1, label->localboot_val); + ut_asserteq(0, label->kaslrseed); + + /* Verify fourth label: fitboot (fit keyword sets kernel and config) */ + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("", label->num); + ut_asserteq_str("fitboot", label->name); + ut_asserteq_str("FIT Boot", label->menu); + ut_asserteq_str("/boot/image.fit#config-1", label->kernel_label); + ut_asserteq_str("/boot/image.fit", label->kernel); + ut_asserteq_str("#config-1", label->config); + ut_asserteq_str("console=ttyS0", label->append); + ut_assertnull(label->initrd); + ut_assertnull(label->fdt); + ut_assertnull(label->fdtdir); + ut_assertnull(label->fdtoverlays); + ut_asserteq(0, label->ipappend); + ut_asserteq(0, label->attempted); + ut_asserteq(0, label->localboot); + ut_asserteq(0, label->localboot_val); + ut_asserteq(0, label->kaslrseed); + + /* Clean up */ + destroy_pxe_menu(cfg); + pxe_destroy_ctx(&ctx); + + return 0; +} +PXE_TEST_ARGS(pxe_test_parse_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index a35ac69434d..f8ff02bdbc7 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -71,6 +71,7 @@ SUITE_DECL(measurement); SUITE_DECL(mem); SUITE_DECL(optee); SUITE_DECL(pci_mps); +SUITE_DECL(pxe); SUITE_DECL(seama); SUITE_DECL(setexpr); SUITE_DECL(upl); @@ -100,6 +101,7 @@ static struct suite suites[] = { SUITE(mem, "memory-related commands"), SUITE(optee, "OP-TEE"), SUITE(pci_mps, "PCI Express Maximum Payload Size"), + SUITE(pxe, "PXE/extlinux parser tests"), SUITE(seama, "seama command parameters loading and decoding"), SUITE(setexpr, "setexpr command"), SUITE(upl, "Universal payload support"), diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py new file mode 100644 index 00000000000..c9af135b17d --- /dev/null +++ b/test/py/tests/test_pxe_parser.py @@ -0,0 +1,182 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2026 Canonical Ltd + +""" +Test the PXE/extlinux parser APIs + +These tests verify that the extlinux.conf parser can be used independently +to inspect boot labels without loading kernel/initrd/FDT files. + +Tests are implemented in C (test/boot/pxe.c) and called from here. +Python handles filesystem image setup and configuration. +""" + +import os +import pytest + +from fs_helper import FsHelper + + +def create_extlinux_conf(srcdir, labels, menu_opts=None): + """Create an extlinux.conf file with the given labels + + Args: + srcdir (str): Directory to create the extlinux directory in + labels (list): List of dicts with label properties: + - name: Label name (required) + - menu: Menu label text (optional) + - kernel: Kernel path (optional) + - linux: Linux kernel path (alternative to kernel) + - initrd: Initrd path (optional) + - append: Kernel arguments (optional) + - fdt: Device tree path (optional) + - fdtdir: Device tree directory (optional) + - fdtoverlays: Device tree overlays (optional) + - localboot: Local boot flag (optional) + - ipappend: IP append flags (optional) + - fit: FIT config path (optional) + - kaslrseed: Enable KASLR seed (optional) + - default: If True, this is the default label (optional) + menu_opts (dict): Menu-level options: + - title: Menu title + - timeout: Timeout in tenths of a second + - prompt: Prompt flag + - fallback: Fallback label name + - ontimeout: Label to boot on timeout + - background: Background image path + - say: Message to print + - include: File to include + + Returns: + str: Path to the config file relative to srcdir + """ + if menu_opts is None: + menu_opts = {} + + extdir = os.path.join(srcdir, 'extlinux') + os.makedirs(extdir, exist_ok=True) + + conf_path = os.path.join(extdir, 'extlinux.conf') + with open(conf_path, 'w', encoding='ascii') as fd: + # Menu-level options + title = menu_opts.get('title', 'Test Boot Menu') + fd.write(f'menu title {title}\n') + fd.write(f"timeout {menu_opts.get('timeout', 1)}\n") + if 'prompt' in menu_opts: + fd.write(f"prompt {menu_opts['prompt']}\n") + if 'fallback' in menu_opts: + fd.write(f"fallback {menu_opts['fallback']}\n") + if 'ontimeout' in menu_opts: + fd.write(f"ontimeout {menu_opts['ontimeout']}\n") + if 'background' in menu_opts: + fd.write(f"menu background {menu_opts['background']}\n") + if 'say' in menu_opts: + fd.write(f"say {menu_opts['say']}\n") + if 'include' in menu_opts: + fd.write(f"include {menu_opts['include']}\n") + + for label in labels: + if label.get('default'): + fd.write(f"default {label['name']}\n") + + for label in labels: + fd.write(f"\nlabel {label['name']}\n") + if 'menu' in label: + fd.write(f" menu label {label['menu']}\n") + if 'kernel' in label: + fd.write(f" kernel {label['kernel']}\n") + if 'linux' in label: + fd.write(f" linux {label['linux']}\n") + if 'initrd' in label: + fd.write(f" initrd {label['initrd']}\n") + if 'append' in label: + fd.write(f" append {label['append']}\n") + if 'fdt' in label: + fd.write(f" fdt {label['fdt']}\n") + if 'fdtdir' in label: + fd.write(f" fdtdir {label['fdtdir']}\n") + if 'fdtoverlays' in label: + fd.write(f" fdtoverlays {label['fdtoverlays']}\n") + if 'localboot' in label: + fd.write(f" localboot {label['localboot']}\n") + if 'ipappend' in label: + fd.write(f" ipappend {label['ipappend']}\n") + if 'fit' in label: + fd.write(f" fit {label['fit']}\n") + if label.get('kaslrseed'): + fd.write(" kaslrseed\n") + + return '/extlinux/extlinux.conf' + + +@pytest.fixture +def pxe_image(u_boot_config): + """Create a filesystem image with an extlinux.conf file""" + fsh = FsHelper(u_boot_config, 'vfat', 4, prefix='pxe_test') + fsh.setup() + + # Create a simple extlinux.conf with multiple labels + labels = [ + { + 'name': 'linux', + 'menu': 'Boot Linux', + 'kernel': '/vmlinuz', + 'initrd': '/initrd.img', + 'append': 'root=/dev/sda1 quiet', + 'fdt': '/dtb/board.dtb', + 'fdtoverlays': '/dtb/overlay1.dtbo /dtb/overlay2.dtbo', + 'kaslrseed': True, + 'default': True, + }, + { + 'name': 'rescue', + 'menu': 'Rescue Mode', + 'linux': '/vmlinuz-rescue', # test 'linux' keyword + 'append': 'single', + 'fdtdir': '/dtb/', + 'ipappend': '3', + }, + { + 'name': 'local', + 'menu': 'Local Boot', + 'localboot': '1', + }, + { + 'name': 'fitboot', + 'menu': 'FIT Boot', + 'fit': '/boot/image.fit#config-1', + 'append': 'console=ttyS0', + }, + ] + + menu_opts = { + 'title': 'Test Boot Menu', + 'timeout': 50, + 'prompt': 1, + 'fallback': 'rescue', + 'ontimeout': 'linux', + 'background': '/boot/background.bmp', + } + + cfg_path = create_extlinux_conf(fsh.srcdir, labels, menu_opts) + + # Create the filesystem + fsh.mk_fs() + + yield fsh.fs_img, cfg_path + + # Cleanup + if not u_boot_config.persist: + fsh.cleanup() + + +@pytest.mark.boardspec('sandbox') +class TestPxeParser: + """Test PXE/extlinux parser APIs via C unit tests""" + + def test_pxe_parse(self, ubman, pxe_image): + """Test parsing an extlinux.conf and verifying label properties""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE parse'): + ubman.run_ut('pxe', 'pxe_test_parse', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 01:53:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1365 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923637; bh=NggVMik/hybm+ZZzvK5o4582kBD9rL2lCCbqLXUDkdI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ivCE+G+PyLLBr0cu6fCiLq8s0xuwmi0m34k97F7PSqL0yvzAEJIsVnpqAfGhqtQFT 3R2VEl0ri362kaYE5ml29DMN2WNhLrqWUPpezvKFCtByLvzsvXbrzWjPX8Gqa5NXqw jv+tvOgkrGhDQBcP9EhDHSdxRAS/mSVoJIw+OfAW/+he0QyWNaiA+jv6jrPdmX7pYd 3Hq1iHJ16B/BOJvtyBO6hNk0D3x9ZtmlfQW5R/1Hva0kpAsTxZPJfZprJ+P0195+QW iQyRdyisdbnxnl19jvD7ZjeL87Gvm8lNuqvG3MKc2ndzWfzgHFgtzgOaFG1lrYUjvo HUYbHfP6Sulhg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0ADF769130 for ; Thu, 8 Jan 2026 18:53:57 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4nP3Lc1U6hBJ for ; Thu, 8 Jan 2026 18:53:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923636; bh=NggVMik/hybm+ZZzvK5o4582kBD9rL2lCCbqLXUDkdI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=dUFjpT5OwurAU+198lDzvPwr9N9iNiA8lcthfdWcRjZIWlRO+UErtpxXwSidlb2bo d1W9kCQH5+IswGJV9Y4ZcZzp5zoSYt7baUx92xGzHYMS0Qpr0NG5UPT4Zz/HiT+Fe/ eFI1Qp7m5xLT1zKBAZW52kzxPlqCGACJ4oo8lkgBtocFsnzQk/Hvb+CG+p+uZS7UbS lib+pYNDcszC3IFTbcv87Ju9bYniTTu+Y5Pt1MWinJ9XKYRQ2YrsHg5CBSwWFMaEyO ZCd3c1u1xaIysSONyYPKKy87Nnr13HZDMNiCyYBjZONzGuXsF2Cnj7VnpFW7bKv3br 9z1EMau1El0dw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED54A691E6 for ; Thu, 8 Jan 2026 18:53:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923634; bh=6dQo+S6XrNGFbv9wxvGJc/WHhZKA+4/GYd2inDLo+Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RzoJgdvkf/IqXORo1Og2ot45KK3LIB42QV7NI9foxxNc/egOvjE7rprKob2tdXbuh 4Y0qyxEQK7tpNc65rinliVzB+Opi1XdHdb6liibKLwADwtRGmROdPeXarfDCpgiOFO pMzWUcx8P45Jx8Aol8HJ/K8+bASCK+HW7P2O5pvVZ7fSwPWP/PXq1kVw5z5zbZgRYb +iBUGARazjruauKO6O1ZBIjWMST/MkmuAfuWJnBeX79u+Rkj7493UmOODeQnP3/Jw5 k1mXQHpNh6GncbTmtwB9mYk3suh9awty5dpq/iBwX1Irkj3HILTQsrlEtKZLDdH2nv /z7yiTbhJYhaw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F78969130; Thu, 8 Jan 2026 18:53:54 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 4g6uQUgRDWBO; Thu, 8 Jan 2026 18:53:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923630; bh=2RaKpeGSBgX7Ud2LWqGKAdcupLyHG1k3XA6x/a4iQD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/GRLoQaK8UooVUP2kvq/ZHkJH58t38YeCkXCA7umYTPU3bMO276dx+yFhoLayAYF 0jRAtgX+LrgKBQXpTKX4xveXFO8W4rPerb/pTp9TWGMG5N/dw8FO59ydK60PRQKVjF Nd2lJ92AikRob2ty0xc63a9ZLjbNh1VLJgbqAixOg+Eccix2Qfo0dTBw1euM3Hz5W8 tXuiF4qDsWElwgDTSR4wJjUapgeMNKu/cwfrNy/3SDnkhML2ZmZcTIwkTbmUSQec4d N3qrzpaN2ZaMXYZ1NclkQ5NxBA41LkqDaMWfipXSzQHIuNwCTbxAYI4xrP544TxvwS chqua3k0rBjHA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 55C346912D; Thu, 8 Jan 2026 18:53:50 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:04 -0700 Message-ID: <20260109015323.3411528-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TCOVSQ7GKI6WQTKF2WVAO5MZMAKEGAXO X-Message-ID-Hash: TCOVSQ7GKI6WQTKF2WVAO5MZMAKEGAXO X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/16] test: pxe: Add a test for the 'say' keyword List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add test coverage for the 'say' keyword which prints a message during label-parsing. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 7 +++++++ test/py/tests/test_pxe_parser.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 49d8d160389..ef42026e748 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -101,6 +101,10 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) cfg = parse_pxefile(&ctx, addr); ut_assertnonnull(cfg); + /* Verify 'say' keyword printed its message during parsing */ + ut_assert_nextline("Retrieving file: %s", cfg_path); + ut_assert_nextline("Booting default Linux kernel"); + /* Verify menu properties */ ut_asserteq_str("Test Boot Menu", cfg->title); ut_asserteq_str("linux", cfg->default_label); @@ -186,6 +190,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(0, label->localboot_val); ut_asserteq(0, label->kaslrseed); + /* Verify no more console output */ + ut_assert_console_end(); + /* Clean up */ destroy_pxe_menu(cfg); pxe_destroy_ctx(&ctx); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index c9af135b17d..1d51116a97a 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -105,6 +105,8 @@ def create_extlinux_conf(srcdir, labels, menu_opts=None): fd.write(f" fit {label['fit']}\n") if label.get('kaslrseed'): fd.write(" kaslrseed\n") + if 'say' in label: + fd.write(f" say {label['say']}\n") return '/extlinux/extlinux.conf' @@ -126,6 +128,7 @@ def pxe_image(u_boot_config): 'fdt': '/dtb/board.dtb', 'fdtoverlays': '/dtb/overlay1.dtbo /dtb/overlay2.dtbo', 'kaslrseed': True, + 'say': 'Booting default Linux kernel', 'default': True, }, { From patchwork Fri Jan 9 01:53:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1366 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923641; bh=8/QHgYKmGmNq76LFz5oK4hClt13nWNvaqi3xOog3DVo=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WTW7UsRUhi6AfP+30Us1jH/jIk9eRzVcIWn/cAvlg9tXZU40X92kK7z/12X+tsI7F fxW4pagKa6biqpqc0a6UiPYTsX/XbPEb9OQGsFx6qbjkJpq0tI39LJX6FdAIR83cQl pDYcH7tyzprIptgQb1JvXk98qwGavAJl6kTbugKaTfrU/RMunxGFKY0hQLxvmsy92i DYHHumQ0c5UeESIl0BMA1Y1lCOXbqGKHIhCKwEO3JTdsfydBy8FbPJ7muwamiwxd6t 8qwC4PXz6B2MlrGl8af3B+V9iUULDrrsyXEUiIhdAsN0CWkWJZTFIJvgVBJRzhp0Nn +IXpoeQq4Whqg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A8D0469130 for ; Thu, 8 Jan 2026 18:54:01 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5HtiYtjByWAd for ; Thu, 8 Jan 2026 18:54:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923641; bh=8/QHgYKmGmNq76LFz5oK4hClt13nWNvaqi3xOog3DVo=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WTW7UsRUhi6AfP+30Us1jH/jIk9eRzVcIWn/cAvlg9tXZU40X92kK7z/12X+tsI7F fxW4pagKa6biqpqc0a6UiPYTsX/XbPEb9OQGsFx6qbjkJpq0tI39LJX6FdAIR83cQl pDYcH7tyzprIptgQb1JvXk98qwGavAJl6kTbugKaTfrU/RMunxGFKY0hQLxvmsy92i DYHHumQ0c5UeESIl0BMA1Y1lCOXbqGKHIhCKwEO3JTdsfydBy8FbPJ7muwamiwxd6t 8qwC4PXz6B2MlrGl8af3B+V9iUULDrrsyXEUiIhdAsN0CWkWJZTFIJvgVBJRzhp0Nn +IXpoeQq4Whqg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 92EAB691E7 for ; Thu, 8 Jan 2026 18:54:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923639; bh=XoLHm4O/9KQsTZruzIJNvDx9UR85cqE26/s3Er8DCEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqQY1GoLvKcOr4ckaadqpDC9WjvmMQTejmlzgMCzwMzq2J76bP2CDZWA2o8hqrcLU XBrQ84P/wwYutkb3N0b0SRhsu0tvBdp1+bqi5T5p0IgykjHd8ruFEoFqK8tIgqJEgB /J90SpGMTUJ5JW+h0HdqvSd2CataMhrjHtSVgc7qJrsliZnZFO2KjxO8H1npyHOidb NjyGxzjRbuPRSFYukCotpoLBZ18XEb+6Ltl9S/ZneWzhct81M52Tjv+U2imiA2BiQg hkjfsgHEh0gSd3KxxyPi4dMKxszvyMnsAuRKOvsSvCXgdE9ObywQ7OPZKO27LItfnx BiFXajpku0opg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7952669130; Thu, 8 Jan 2026 18:53:59 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id dkqLoR2Yoj05; Thu, 8 Jan 2026 18:53:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923635; bh=f6D2ItlNpmK1E7rcx8Zy6YYmLKlQuqEjLn5xD9HVd/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lSAU48POwxxY8kPMVui5Q30+PjFbd5/0E8Ud2EJqnufJppGJBwf4wWsrvCc1g/7q3 RqIt7OUP8a1rHVy7pvpxVO261LIn3xDa+Y7jM8nNK36pWpZFRG8YR4qiNNnaYBxxSG k3zR6l8M9+2gKdtP24MMZT/Gys/nDtV5hG0AOZysOju279WwWkbQBt4ifK+B8Iqhix rON4PROewjkUWnuYJqFOyqXzt/bzV8EF+65B0xr80D4GEiRm+yoja9Fe0RvbcitwGK 9GtYF5AFmZvGd5N14XLYSRy4sNmspzEsTySwXfUK3KEYiuakZo+BdPMcM2zDZsi7rY 4OM86CeOjoyAA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E20CF6912D; Thu, 8 Jan 2026 18:53:54 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:05 -0700 Message-ID: <20260109015323.3411528-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LE3IYVYOYELAEYJYIJFITQL57P2LXMDN X-Message-ID-Hash: LE3IYVYOYELAEYJYIJFITQL57P2LXMDN X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/16] boot: pxe: Stop after first boot attempt on sandbox List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Sandbox cannot actually boot a kernel, so there is no point in trying subsequent labels after the first boot attempt fails. Return success after the boot attempt so that sysboot stops, allowing tests to verify that files were loaded correctly. This change only affects sandbox builds. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 981023a3012..ba1f7c41512 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -849,9 +849,15 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) label_run_boot(ctx, label, kern_addr_str, kern_addr, kern_size, initrd_addr, initrd_size, initrd_str, conf_fdt_str, conf_fdt); - /* ignore the error value since we are going to fail anyway */ - return 1; /* returning is always failure */ + /* + * Sandbox cannot boot a real kernel, so stop after the first attempt. + * On real hardware, returning is always failure, so try next label. + */ + if (IS_ENABLED(CONFIG_SANDBOX)) + return 0; + + return 1; } /* From patchwork Fri Jan 9 01:53:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1367 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923646; bh=wSB2KNH+ocyH2ilQHjHBbp+lBMFkxx/z2x3cAHgKqT8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RQqJZlpRwVW1d2Hc46Z+lQlOTFc/SIlR8sNp7ViSnt13kDazRotNyagMY2QlFF4SS Fora7pJ5ck4baAEp5oXALohjPcoqpAiEChr9Cvk8ew0YKBxwh1qKQVxcN0qVEqn58D Dmy/RnfHHhGYrLLPaaB9aFxg8jZoCXwDP7t7cyDCZf9yK7O+pLI0t1Wz+1BejRIHGY dlakWFNLHENGPBNMHIp3y4m28I3omYKx8W5pOFJ3ePTDBPO0HDZ6ShxZMEBk527piH AsEa9LmKaTihLfn5i3JPOfN1n5ETo73foaSWRzimCzj4K+qavISBIMXWklaRaZVy7N BWa4JFitC5oiw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9CA7E69130 for ; Thu, 8 Jan 2026 18:54:06 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BVsL2PNXsM_W for ; Thu, 8 Jan 2026 18:54:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923646; bh=wSB2KNH+ocyH2ilQHjHBbp+lBMFkxx/z2x3cAHgKqT8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RQqJZlpRwVW1d2Hc46Z+lQlOTFc/SIlR8sNp7ViSnt13kDazRotNyagMY2QlFF4SS Fora7pJ5ck4baAEp5oXALohjPcoqpAiEChr9Cvk8ew0YKBxwh1qKQVxcN0qVEqn58D Dmy/RnfHHhGYrLLPaaB9aFxg8jZoCXwDP7t7cyDCZf9yK7O+pLI0t1Wz+1BejRIHGY dlakWFNLHENGPBNMHIp3y4m28I3omYKx8W5pOFJ3ePTDBPO0HDZ6ShxZMEBk527piH AsEa9LmKaTihLfn5i3JPOfN1n5ETo73foaSWRzimCzj4K+qavISBIMXWklaRaZVy7N BWa4JFitC5oiw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8AF61691E6 for ; Thu, 8 Jan 2026 18:54:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923643; bh=6pMjrTeG246LGtNKff/o9DKLymezzs50LUyli0y305c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+GwdtwQpRR1z2sTkxjqUpWQFQh7l69X+4DG+oJIBbJZdfLaFkEdiCkWKFRSl/MqW YNz0NTmtxb3pPKah6Wu42Kb976JykbDKw3WmbVJdJVBaJ3s314HXaZctiG1M8P/SqW mK4l2EciCnzG/y/HS70PexZIOjSgsuR0eKK5rBNRQaJy0qR/L8TSjMVeri1EdA/e70 t3EcB/C82AjrATRuw2GftEAD0/ggpTI4KCF4jrgGDVipVkuRaTxkpy226L+AtvOTT7 jfAOufTuawt8g79VFoAHwU7CP/ulUSphPlixzNZG4IXB8eK9s+Hel1JRwZXJBekpX+ QIwJe/Y6PMHgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CE6C769130; Thu, 8 Jan 2026 18:54:03 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id j0o5LLtiG0rM; Thu, 8 Jan 2026 18:54:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923639; bh=kWmA9tzOTJ0qG/cQfxCpfj6MUVeCMsWOoUBY75f/ydY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=puL1wztww52Nrj+EzH4g6XdVCxAFQY3r2UpDS+xOKXysWE/Go5+72zCj2GJoR+UqD msckMsijSFzBl8RRptMByq1l/NwgeTV27RDjvAiUNaIYHHUCH44xyyDoaZ5ujiZnMP uz/S9F1spIorXaty/Tj6/UJTrKWKenJDNeXagM6MxVTGall43Vze+WQTmvapwHI+y1 oayPG7e2GC6pum02TMB9Pgf+4GIOVULaQZYEZDKzWbhEOM86Y6nOqP45ZZtnSk8YHL HM7UaNl3690prf67XmQPQ2xnK5f/W9CdGVNri8mGy1+NOpCQ9MHalMoYzEXLr1/xhO v7Zxh8GAwfUDA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7D95F6912D; Thu, 8 Jan 2026 18:53:59 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:06 -0700 Message-ID: <20260109015323.3411528-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QSNLBFEDMJ5KJ2ERI5GFERX3JGKT6OJS X-Message-ID-Hash: QSNLBFEDMJ5KJ2ERI5GFERX3JGKT6OJS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/16] test: pxe: Test include directive List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Test the 'include' directive which allows one extlinux.conf file to include another. Create an extra.conf file with an additional label and verify it is parsed correctly when included from the main config. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 20 ++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 16 ++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index ef42026e748..45948ab4ef4 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -104,6 +104,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) /* Verify 'say' keyword printed its message during parsing */ ut_assert_nextline("Retrieving file: %s", cfg_path); ut_assert_nextline("Booting default Linux kernel"); + ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); /* Verify menu properties */ ut_asserteq_str("Test Boot Menu", cfg->title); @@ -190,6 +191,25 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(0, label->localboot_val); ut_asserteq(0, label->kaslrseed); + /* Verify fifth label: included (from include directive) */ + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("", label->num); + ut_asserteq_str("included", label->name); + ut_asserteq_str("Included Label", label->menu); + ut_asserteq_str("/boot/included-kernel", label->kernel_label); + ut_asserteq_str("/boot/included-kernel", label->kernel); + ut_assertnull(label->config); + ut_asserteq_str("root=/dev/sdb1", label->append); + ut_assertnull(label->initrd); + ut_assertnull(label->fdt); + ut_assertnull(label->fdtdir); + ut_assertnull(label->fdtoverlays); + ut_asserteq(0, label->ipappend); + ut_asserteq(0, label->attempted); + ut_asserteq(0, label->localboot); + ut_asserteq(0, label->localboot_val); + ut_asserteq(0, label->kaslrseed); + /* Verify no more console output */ ut_assert_console_end(); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index 1d51116a97a..b289bf58b11 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -72,8 +72,6 @@ def create_extlinux_conf(srcdir, labels, menu_opts=None): fd.write(f"menu background {menu_opts['background']}\n") if 'say' in menu_opts: fd.write(f"say {menu_opts['say']}\n") - if 'include' in menu_opts: - fd.write(f"include {menu_opts['include']}\n") for label in labels: if label.get('default'): @@ -108,6 +106,10 @@ def create_extlinux_conf(srcdir, labels, menu_opts=None): if 'say' in label: fd.write(f" say {label['say']}\n") + # Write include at the end so included labels come after main labels + if 'include' in menu_opts: + fd.write(f"\ninclude {menu_opts['include']}\n") + return '/extlinux/extlinux.conf' @@ -159,10 +161,20 @@ def pxe_image(u_boot_config): 'fallback': 'rescue', 'ontimeout': 'linux', 'background': '/boot/background.bmp', + 'include': '/extlinux/extra.conf', } cfg_path = create_extlinux_conf(fsh.srcdir, labels, menu_opts) + # Create an included config file with an additional label + extra_path = os.path.join(fsh.srcdir, 'extlinux', 'extra.conf') + with open(extra_path, 'w', encoding='ascii') as fd: + fd.write("# Included configuration\n") + fd.write("label included\n") + fd.write(" menu label Included Label\n") + fd.write(" kernel /boot/included-kernel\n") + fd.write(" append root=/dev/sdb1\n") + # Create the filesystem fsh.mk_fs() From patchwork Fri Jan 9 01:53:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1368 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923651; bh=DU+FaIR/rNAOIbqvxyo+s4z7no4d0f9oCyVIzALgH+8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XWOtXD+ASmfQTErPBivLVrTZOH7oZyBUCLTea+l3YFIIRBxvL9wm93X5YoDABIi5U fJrvARCyYT+38DDTU1Nwc34dlrNfCBX72o9GHdzGybX5wHjjyPd59r0sYKs4hTPPnP uA0dwF7AW/fPlR0wW3P4HrCSC5j8outWEwbJNiLW/eg8/b3ehFgXDvCw6qYb9s1rAt iTaIx8H43st1V2VotSrS23H/pTu1vp1V9XI9PpcU3szFypBchGQn3yh4jmQbx3bmeA nVVpsReJHw1v8l2BVfGm9+YpZ8RaNTP2gGmWOECHeiN/OPs6T1BNWqKvrvEeMoHZu+ GOBV/gPh9sQhw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12359691EC for ; Thu, 8 Jan 2026 18:54:11 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id f9fjCsN4-A04 for ; Thu, 8 Jan 2026 18:54:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923651; bh=DU+FaIR/rNAOIbqvxyo+s4z7no4d0f9oCyVIzALgH+8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XWOtXD+ASmfQTErPBivLVrTZOH7oZyBUCLTea+l3YFIIRBxvL9wm93X5YoDABIi5U fJrvARCyYT+38DDTU1Nwc34dlrNfCBX72o9GHdzGybX5wHjjyPd59r0sYKs4hTPPnP uA0dwF7AW/fPlR0wW3P4HrCSC5j8outWEwbJNiLW/eg8/b3ehFgXDvCw6qYb9s1rAt iTaIx8H43st1V2VotSrS23H/pTu1vp1V9XI9PpcU3szFypBchGQn3yh4jmQbx3bmeA nVVpsReJHw1v8l2BVfGm9+YpZ8RaNTP2gGmWOECHeiN/OPs6T1BNWqKvrvEeMoHZu+ GOBV/gPh9sQhw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 01EE4691E6 for ; Thu, 8 Jan 2026 18:54:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923649; bh=NOUGLSmli2FLXy6Dh+sNs8rK/GUUzUBpl4jCAr2YS+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIO8br0z07fHM2YfxAW3W30yPfN5AwvQicBRne67rZ7V9SjwBl9T3TWfBhU4fQXjL 3aLxy5DDCdlDLULDKNoNsWXovwYIhOsi0+PamFAq/O/q9DqWekSxQQMZedOETrpDFX Bbs6wOoi/3NLL1JrsqnLmHqT9eHPILtWhhYWQl9e4YEIOrtkP6Tw12l/sN4nV+ipMJ IVEc0xPZe7TtCL4H9RzT4/WHtt5G+4THGa5b0o1b3xdKDTweZM+uWtED2OPNz8+PJP Wa9IcCOP/cjze0LTbZwkax7/qOJo+M3L1nbHW74uR51rUANmm+q+Mu+OAEcsH0je5h IjqbFriqN+hYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 02C88691E6; Thu, 8 Jan 2026 18:54:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 1MV1tBC0scXt; Thu, 8 Jan 2026 18:54:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923644; bh=AMdCtA0AZTGYvjzP1pXFo38JFeE47xiktEEv008vCxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTyOxhkZBBo2XJPx3rprwlR6VqQfo1vaYDjt9LmY0znKUW0EvvIqGDzKH5YUSbg3Z Zkt9AmSWVypiNnjJWVkmroQTtCc2Ry/N6fbNom09mEpGSc0ghaemZjQttGDjO0WnDS mzyJxMgoqAWSwnjczh+cBlDcNoTJyHpTCErskJpOE7zfcT0Q4RCbtqyfRjOUcsfO5u z3w1Di5RcMGeuZg/wA9p0i9TnJBQnafUKs3mxWuzryRNGke1DfYZenpZK/CytN5viB hFIiFosadlg++1jCETpwORLZuraSDfOTi5B2dsjKD/uNvD6M4NzVvVMimHuFWN+BGW lNV8kWyV0uJkg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1FF0D6912D; Thu, 8 Jan 2026 18:54:04 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:07 -0700 Message-ID: <20260109015323.3411528-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UH6CKO35T4MPFF2L3CSMXS7WYMIPMNNJ X-Message-ID-Hash: UH6CKO35T4MPFF2L3CSMXS7WYMIPMNNJ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/16] test: pxe: Add a test for nested include List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test for the include directive with maximum nesting depth: a chain of 16 include files (the MAX_NEST_LEVEL limit), each adding a label. This checks that the nest_level tracking in struct pxe_include works correctly through all levels. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 11 +++++++++++ test/py/tests/test_pxe_parser.py | 31 +++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 45948ab4ef4..778c7d62816 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -79,6 +79,8 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) struct pxe_context ctx; struct pxe_label *label; struct pxe_menu *cfg; + char name[16]; + uint i; int ret; ut_assertnonnull(fs_image); @@ -105,6 +107,8 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assert_nextline("Retrieving file: %s", cfg_path); ut_assert_nextline("Booting default Linux kernel"); ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); + for (i = 3; i <= 16; i++) + ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); /* Verify menu properties */ ut_asserteq_str("Test Boot Menu", cfg->title); @@ -210,6 +214,13 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(0, label->localboot_val); ut_asserteq(0, label->kaslrseed); + /* Verify labels from nested includes (levels 3-16) - just check names */ + for (i = 3; i <= 16; i++) { + label = list_entry(label->list.next, struct pxe_label, list); + snprintf(name, sizeof(name), "level%d", i); + ut_asserteq_str(name, label->name); + } + /* Verify no more console output */ ut_assert_console_end(); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index b289bf58b11..614252a444f 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -166,14 +166,29 @@ def pxe_image(u_boot_config): cfg_path = create_extlinux_conf(fsh.srcdir, labels, menu_opts) - # Create an included config file with an additional label - extra_path = os.path.join(fsh.srcdir, 'extlinux', 'extra.conf') - with open(extra_path, 'w', encoding='ascii') as fd: - fd.write("# Included configuration\n") - fd.write("label included\n") - fd.write(" menu label Included Label\n") - fd.write(" kernel /boot/included-kernel\n") - fd.write(" append root=/dev/sdb1\n") + # Create a chain of 16 nested include files to test MAX_NEST_LEVEL + # Level 1 is extlinux.conf, levels 2-16 are extra.conf, nest3.conf, etc. + for level in range(2, 17): + if level == 2: + fname = 'extra.conf' + label_name = 'included' + label_menu = 'Included Label' + else: + fname = f'nest{level}.conf' + label_name = f'level{level}' + label_menu = f'Level {level} Label' + + fpath = os.path.join(fsh.srcdir, 'extlinux', fname) + with open(fpath, 'w', encoding='ascii') as fd: + fd.write(f"# Level {level} configuration\n") + fd.write(f"label {label_name}\n") + fd.write(f" menu label {label_menu}\n") + fd.write(f" kernel /boot/{label_name}-kernel\n") + fd.write(f" append root=/dev/sd{chr(ord('a') + level - 1)}1\n") + # Include next level unless we're at level 16 + if level < 16: + next_fname = f'nest{level + 1}.conf' + fd.write(f"\ninclude /extlinux/{next_fname}\n") # Create the filesystem fsh.mk_fs() From patchwork Fri Jan 9 01:53:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1369 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923656; bh=xiwEnvyrZWTXM4j5lvo+1X6JkLdsBGw7+fdiykEzNjc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=d8vdRaskRqueNP1MYoYfFgwh0jsoiEj3MkiMS/3zjj2CtwVoRxtPLKPnsXWtjm8SX UYkW9eu4fKSVWXyF01J+vApP02L2gPF37zVZA0l9qCydgtGN1zRRUYlrI4h+EeqbHH KOaNY0tAmDL1WTwKNo5A4cdJ5u9KkUh+IQk6f7sZqlbehFzz8GwPamA1+by0LHkRW+ J55vjOizmuO8XQ1dU4N+C1Q1YM/+9m+xDoFKZcwqH6L3KMGuPuUL3Tb+IMSmUoawV7 ygkL15Mua3YdRL12hw1y9afy7zuReUz9ePCqA0xq1vio5+UPzhCLbpy8qaaBACzlyI N1hvMTi7Jg/+g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54ECC691E9 for ; Thu, 8 Jan 2026 18:54:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5Hg7_zYkCDjt for ; Thu, 8 Jan 2026 18:54:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923656; bh=xiwEnvyrZWTXM4j5lvo+1X6JkLdsBGw7+fdiykEzNjc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=d8vdRaskRqueNP1MYoYfFgwh0jsoiEj3MkiMS/3zjj2CtwVoRxtPLKPnsXWtjm8SX UYkW9eu4fKSVWXyF01J+vApP02L2gPF37zVZA0l9qCydgtGN1zRRUYlrI4h+EeqbHH KOaNY0tAmDL1WTwKNo5A4cdJ5u9KkUh+IQk6f7sZqlbehFzz8GwPamA1+by0LHkRW+ J55vjOizmuO8XQ1dU4N+C1Q1YM/+9m+xDoFKZcwqH6L3KMGuPuUL3Tb+IMSmUoawV7 ygkL15Mua3YdRL12hw1y9afy7zuReUz9ePCqA0xq1vio5+UPzhCLbpy8qaaBACzlyI N1hvMTi7Jg/+g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4294D69130 for ; Thu, 8 Jan 2026 18:54:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923653; bh=/CXcsP9pIrPrwRMLCwHoAsOZOqUUwQNEsv5QMnHqKJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQZQlrhm61DfV/I+e0lXdiEKJ3zIN2YAE1aPEN9EGz0ksrYbq112Tct4qEpGyvOL5 /cPEroigY/t/yPRx3J83bGtvrUP+keuENHwANCDm3xhtE1mpALUIc333jZzgHPGNSn b63EUhvwxd9QxHNBSakD685DK47jtAGgS51jOP+iIM/4VXFo24OAoT45uWD8ay8oiY cngTFB5HYUeWbGKq9mfBBLHNH87wPXvayBBL74+MCpg140Quzla+uA56VCMibIqlsi giYOup8lKMRogyUtfsMrD1lw4I/TeLNBw72hYx0a3+fU9rfAfkSdtoCkxrWwgn0e63 aRzxPsSgRQkKA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7175F691E6; Thu, 8 Jan 2026 18:54:13 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 2-5EGI5zlJHH; Thu, 8 Jan 2026 18:54:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923649; bh=3grnabYcdIae9LvApaQ9FqxKvF9qjCzMmxEF3BWoDkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1HEm0MrEeF5eLgHyO15oYoO8yVSEE2vVGWlJjPSOA5f9ztCJZHoSWY5yL2sR6rJ+ slXFq99X2TfsqkGo6jPyfozoH+3iKEwcYu927iOWva8EK1BjWW0Z4zrAFAQPLdgXs4 aGTiEU2+SuoBgRSb0MYB0K896U4l5fg3WRCrhpjeHzXwCCM4PVPQk4+B1MMID+N7c8 mcwNMFJ4N8WiTRu5mdPhpvVbCmYAUrjmj2ieYDcfhUrdE0rMDjm0hix+P0U6qQ0WqJ +vuUVVTrbciSN9/3dqKFvZtsERRgFv87neM5Q5I740wAVhguPT/RYFcuPchHe93aH8 Cmwv0ef13yclw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B1ACB69130; Thu, 8 Jan 2026 18:54:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:08 -0700 Message-ID: <20260109015323.3411528-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JSYHRB7F3ZHZTAUJSYY6HK32UUDMY7K5 X-Message-ID-Hash: JSYHRB7F3ZHZTAUJSYY6HK32UUDMY7K5 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/16] boot: pxe: Add a test for the sysboot command List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that uses the sysboot command to boot a label and verifies that files are loaded to the correct memory addresses. - Run sysboot with an extlinux.conf containing multiple labels - Verify console output shows files being retrieved - Check kernel, initrd, and FDT are at expected addresses - Verifiy file contents match what was written to the filesystem Use simple strings for the dummy kernel and initrd files so we can check that the correct files are loaded. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 85 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 77 +++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 778c7d62816..3d560fd9ade 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -9,7 +9,9 @@ #include #include +#include #include +#include #include #include #include @@ -25,6 +27,10 @@ /* Memory address for loading files */ #define PXE_LOAD_ADDR 0x01000000 +#define PXE_KERNEL_ADDR 0x02000000 +#define PXE_INITRD_ADDR 0x02800000 +#define PXE_FDT_ADDR 0x03000000 +#define PXE_OVERLAY_ADDR 0x03100000 /** * struct pxe_test_info - context for the test getfile callback @@ -233,3 +239,82 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_parse_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test booting via sysboot command + * + * This test: + * 1. Binds a filesystem image containing extlinux.conf + * 2. Sets up environment variables for file loading + * 3. Runs sysboot to boot the default label + * 4. Verifies files were loaded by checking console output + */ +static int pxe_test_sysboot_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + void *kernel, *initrd, *fdt; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set environment variables for file loading */ + ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); + ut_assertok(env_set("bootfile", cfg_path)); + + /* + * Run sysboot - it will try all labels and return 0 after failing + * to boot them all (since sandbox can't actually boot Linux) + */ + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + /* Skip menu output and find the first label boot attempt */ + ut_assert_skip_to_line("Enter choice: 1:\tBoot Linux"); + + /* Verify files were loaded in order */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /initrd.img"); + ut_assert_nextline("append: root=/dev/sda1 quiet"); + ut_assert_nextline("Retrieving file: /dtb/board.dtb"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + ut_assert_nextline("Retrieving file: /dtb/overlay2.dtbo"); + + /* Boot fails on sandbox */ + ut_assert_nextline("Unrecognized zImage"); + ut_assert_nextlinen(" unmap_physmem"); + + /* Verify files were loaded at the correct addresses */ + kernel = map_sysmem(PXE_KERNEL_ADDR, 0); + initrd = map_sysmem(PXE_INITRD_ADDR, 0); + fdt = map_sysmem(PXE_FDT_ADDR, 0); + + /* Kernel should contain "kernel" at start */ + ut_asserteq_mem("kernel", kernel, 6); + + /* Initrd should contain "ramdisk" at start */ + ut_asserteq_mem("ramdisk", initrd, 7); + + /* FDT should have valid magic number */ + ut_assertok(fdt_check_header(fdt)); + + /* Verify overlays were applied - check for properties added by overlays */ + ut_asserteq_str("from-overlay1", + fdt_getprop(fdt, fdt_path_offset(fdt, "/test-node"), + "overlay1-property", NULL)); + ut_asserteq_str("from-overlay2", + fdt_getprop(fdt, fdt_path_offset(fdt, "/test-node"), + "overlay2-property", NULL)); + + return 0; +} +PXE_TEST_ARGS(pxe_test_sysboot_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index 614252a444f..c2467f70f5d 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -13,10 +13,64 @@ Python handles filesystem image setup and configuration. import os import pytest +import subprocess from fs_helper import FsHelper +# Simple base DTS with symbols enabled (for overlay support) +BASE_DTS = """\ +/dts-v1/; + +/ { + model = "Test Board"; + compatible = "test,board"; + + test: test-node { + test-property = <42>; + status = "okay"; + }; +}; +""" + +# Simple overlay that modifies the test node +OVERLAY1_DTS = """\ +/dts-v1/; +/plugin/; + +&test { + overlay1-property = "from-overlay1"; +}; +""" + +# Another overlay that adds a different property +OVERLAY2_DTS = """\ +/dts-v1/; +/plugin/; + +&test { + overlay2-property = "from-overlay2"; +}; +""" + + +def compile_dts(dts_content, output_path, is_overlay=False): + """Compile DTS content to DTB/DTBO file + + Args: + dts_content (str): DTS source content + output_path (str): Path to output DTB/DTBO file + is_overlay (bool): True if this is an overlay (needs -@) + + Raises: + subprocess.CalledProcessError: If dtc fails + """ + # Use -@ for both base (to generate __symbols__) and overlays + cmd = ['dtc', '-@', '-I', 'dts', '-O', 'dtb', '-o', output_path] + subprocess.run(cmd, input=dts_content.encode(), check=True, + capture_output=True) + + def create_extlinux_conf(srcdir, labels, menu_opts=None): """Create an extlinux.conf file with the given labels @@ -190,6 +244,21 @@ def pxe_image(u_boot_config): next_fname = f'nest{level + 1}.conf' fd.write(f"\ninclude /extlinux/{next_fname}\n") + # Create DTB and overlay files for testing + dtbdir = os.path.join(fsh.srcdir, 'dtb') + os.makedirs(dtbdir, exist_ok=True) + compile_dts(BASE_DTS, os.path.join(dtbdir, 'board.dtb')) + compile_dts(OVERLAY1_DTS, os.path.join(dtbdir, 'overlay1.dtbo'), + is_overlay=True) + compile_dts(OVERLAY2_DTS, os.path.join(dtbdir, 'overlay2.dtbo'), + is_overlay=True) + + # Create dummy kernel and initrd files with identifiable content + with open(os.path.join(fsh.srcdir, 'vmlinuz'), 'wb') as fd: + fd.write(b'kernel') + with open(os.path.join(fsh.srcdir, 'initrd.img'), 'wb') as fd: + fd.write(b'ramdisk') + # Create the filesystem fsh.mk_fs() @@ -201,6 +270,7 @@ def pxe_image(u_boot_config): @pytest.mark.boardspec('sandbox') +@pytest.mark.requiredtool('dtc') class TestPxeParser: """Test PXE/extlinux parser APIs via C unit tests""" @@ -210,3 +280,10 @@ class TestPxeParser: with ubman.log.section('Test PXE parse'): ubman.run_ut('pxe', 'pxe_test_parse', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_sysboot(self, ubman, pxe_image): + """Test booting via sysboot command""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE sysboot'): + ubman.run_ut('pxe', 'pxe_test_sysboot', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 01:53:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1370 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923656; bh=44BMBgtj66IiteBbw/u9KBVMQcVuSP/kf3KgukIIsw4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=E45vNt1ycfO8vfVUmNR/nosdoY58c0vn1E3oUKjZDIp48a1tf/aQBuP7Aabgl/qMX nwXEDMVymfBacIOlb8CjdHfyc6ZKwleAsWkqzE1HQLoVRuyq76q5sGeQYrTpiJ5Bwe TEtgtmOYesw0BV1hS1UsUUy9IKZklQNnha42lQsB8J17/MEQkGGUs8oteVmQmMPe/3 ER/f/shXdkn17PvzNbij9BX4lvceCXTGrMPZU6xgecpOSmY5c18z/kWrxCt5D6U4qc LUmtTbmMj0tI0WeCBmkjEcBnFqSjBt11n+KGEPiKZcW3Mlv39VJcvhe9on41S8uH8r d3QPVJV+XwAHg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E3183691FE for ; Thu, 8 Jan 2026 18:54:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 0L3rmymQMEIL for ; Thu, 8 Jan 2026 18:54:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923656; bh=44BMBgtj66IiteBbw/u9KBVMQcVuSP/kf3KgukIIsw4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=E45vNt1ycfO8vfVUmNR/nosdoY58c0vn1E3oUKjZDIp48a1tf/aQBuP7Aabgl/qMX nwXEDMVymfBacIOlb8CjdHfyc6ZKwleAsWkqzE1HQLoVRuyq76q5sGeQYrTpiJ5Bwe TEtgtmOYesw0BV1hS1UsUUy9IKZklQNnha42lQsB8J17/MEQkGGUs8oteVmQmMPe/3 ER/f/shXdkn17PvzNbij9BX4lvceCXTGrMPZU6xgecpOSmY5c18z/kWrxCt5D6U4qc LUmtTbmMj0tI0WeCBmkjEcBnFqSjBt11n+KGEPiKZcW3Mlv39VJcvhe9on41S8uH8r d3QPVJV+XwAHg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CB62269130 for ; Thu, 8 Jan 2026 18:54:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923654; bh=+niLABB1Wr7vxG2f+9ITN9q8BZU14Oz8DMWR1qHLhQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iFE74V2449s7OZ75ZGqwfuFN9LvYwlPzQQmEAiPo+fia7FjDgYXxqD9LT4dxz8K9Q +PdQ7QOODx0CvfbI/iauax/Gd+zn9FdboLbV9k0egUjWynv3itEIJF4A0zv1SQngaf AzaQWVj1V79iMFOG3ouix3R8iGnopFZFFid6K2C4BsnK2vNp2Aq4+A9n4mCKYPjARJ P4jaSW4bif62YCDS5zpy4bL1yvid4YbS1/NaiHHkolreNMuA1i8r9zpEbkperXNawx ycQABI9AAhnf8nlkYQoLtbv+O041kyL/rQrJg4cPwd8f1CCgC8MfEWKLxCrn6peywa +2+lVNpRpFy4Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0590B69130; Thu, 8 Jan 2026 18:54:14 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id exCDQnlVXf0W; Thu, 8 Jan 2026 18:54:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923653; bh=Srf1V7D6ClUcLNWA0itP/jKvfjq3RxQqxgFALcJp+aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNrYwfphoBQzw+UPa+wrZ1yYgeElOw4uLbEF9RTpxyh0zTP2exDK/nPG7OLidfceq U7JM3bNddhhpVhospSoqociR6kcEx0VulSL6Fx1hsPuyCrCJ0l1ptlQ39N1+pAE9xt ivnDbCfSBrgKKyVx5V4/MDL+FfyKahgekFsJBtNLlzgELHU4n7uZ0zRk3307ItOT+I wM0+nOPHEITom0tv3sTuUxQrQ9c3BJv7QXSIFli0AV4AGLjU5iRPdu1nFiSRW6NaSm H6my6NHhIAttO41tYaGNaWbEGnDjKXt87+6+BnXaNpa0d21j+UNzIRzaWFoYfuukEr gVaagD1lynzmQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5AEC46912D; Thu, 8 Jan 2026 18:54:13 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:09 -0700 Message-ID: <20260109015323.3411528-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: J22RQZOJJIQINEYVERUEWKP5HJRJIPI7 X-Message-ID-Hash: J22RQZOJJIQINEYVERUEWKP5HJRJIPI7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/16] boot: pxe: Add a test for fdtdir path-resolution List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that verifies fdtdir path-construction via sysboot: - fdtdir with fdtfile env var uses the variable directly - fdtdir with soc/board env vars constructs {soc}-{board}.dtb The test runs sysboot twice with different environment settings and checks console output to verify the correct FDT paths are constructed. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 93 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 65 ++++++++++++++++++++++ 2 files changed, 158 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 3d560fd9ade..a924247bf98 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -318,3 +318,96 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_sysboot_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test fdtdir path resolution via sysboot + * + * This test verifies fdtdir path construction by running sysboot and + * checking console output: + * 1. fdtdir with fdtfile env var - uses fdtfile value directly + * 2. fdtdir with soc/board env vars - constructs {soc}-{board}.dtb + * 3. fdtdir without trailing slash - slash is inserted + */ +static int pxe_test_fdtdir_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + void *fdt; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* + * Test 1: fdtdir with fdtfile env var + * The first label uses fdtdir=/dtb/ and we set fdtfile=test-board.dtb + * so it should retrieve /dtb/test-board.dtb + */ + ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); + ut_assertok(env_set("fdtfile", "test-board.dtb")); + ut_assertok(env_set("bootfile", cfg_path)); + + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + /* Skip to the boot attempt - first label is fdtfile-test */ + ut_assert_skip_to_line("Enter choice: 1:\tTest fdtfile env var"); + + /* Verify fdtdir used fdtfile env var to construct path */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("append: console=ttyS0"); + ut_assert_nextline("Retrieving file: /dtb/test-board.dtb"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + + /* Boot fails but we verified the path construction */ + ut_assert_nextline("Unrecognized zImage"); + ut_assert_nextlinen(" unmap_physmem"); + + /* Verify FDT was loaded correctly */ + fdt = map_sysmem(PXE_FDT_ADDR, 0); + ut_assertok(fdt_check_header(fdt)); + + /* + * Test 2: fdtdir with soc/board env vars (no fdtfile) + * Clear fdtfile and set soc/board - the default label (fdtfile-test) + * will now construct the path from soc-board: /dtb/tegra-jetson.dtb + */ + ut_assertok(env_set("fdtfile", NULL)); /* Clear fdtfile */ + ut_assertok(env_set("soc", "tegra")); + ut_assertok(env_set("board", "jetson")); + + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + /* Still boots default label, but now uses soc-board path construction */ + ut_assert_skip_to_line("Enter choice: 1:\tTest fdtfile env var"); + + /* Verify fdtdir constructed path from soc-board */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("append: console=ttyS0"); + ut_assert_nextline("Retrieving file: /dtb/tegra-jetson.dtb"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + + /* Boot fails but we verified the path construction */ + ut_assert_nextline("Unrecognized zImage"); + ut_assert_nextlinen(" unmap_physmem"); + + /* Verify FDT was loaded */ + fdt = map_sysmem(PXE_FDT_ADDR, 0); + ut_asserteq(FDT_MAGIC, fdt_magic(fdt)); + + /* Clean up env vars */ + env_set("fdtfile", NULL); + env_set("soc", NULL); + env_set("board", NULL); + + return 0; +} +PXE_TEST_ARGS(pxe_test_fdtdir_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index c2467f70f5d..ee8acb8c674 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -269,6 +269,64 @@ def pxe_image(u_boot_config): fsh.cleanup() +@pytest.fixture +def pxe_fdtdir_image(u_boot_config): + """Create a filesystem image with fdtdir-based configuration + + This tests the fdtdir path-resolution logic where the FDT filename + is constructed from environment variables. + """ + fsh = FsHelper(u_boot_config, 'vfat', 4, prefix='pxe_fdtdir') + fsh.setup() + + # Create labels using fdtdir instead of explicit fdt path + labels = [ + { + 'name': 'fdtfile-test', + 'menu': 'Test fdtfile env var', + 'kernel': '/vmlinuz', + 'append': 'console=ttyS0', + 'fdtdir': '/dtb/', # Will use fdtfile env var + 'fdtoverlays': '/dtb/overlay1.dtbo', + 'default': True, + }, + { + 'name': 'socboard-test', + 'menu': 'Test soc/board construction', + 'kernel': '/vmlinuz', + 'append': 'console=ttyS0', + 'fdtdir': '/dtb', # No trailing slash - tests slash insertion + }, + ] + + cfg_path = create_extlinux_conf(fsh.srcdir, labels) + + # Create DTB directory with files for different naming conventions + dtbdir = os.path.join(fsh.srcdir, 'dtb') + os.makedirs(dtbdir, exist_ok=True) + + # DTB for fdtfile env var test (fdtfile=test-board.dtb) + compile_dts(BASE_DTS, os.path.join(dtbdir, 'test-board.dtb')) + + # DTB for soc-board construction (soc=tegra, board=jetson) + compile_dts(BASE_DTS, os.path.join(dtbdir, 'tegra-jetson.dtb')) + + # Overlay for fdtdir test + compile_dts(OVERLAY1_DTS, os.path.join(dtbdir, 'overlay1.dtbo'), + is_overlay=True) + + # Create dummy kernel + with open(os.path.join(fsh.srcdir, 'vmlinuz'), 'wb') as fd: + fd.write(b'kernel') + fd.write(b'\x00' * (1024 - 6)) + + fsh.mk_fs() + + yield fsh.fs_img, cfg_path + + fsh.cleanup() + + @pytest.mark.boardspec('sandbox') @pytest.mark.requiredtool('dtc') class TestPxeParser: @@ -287,3 +345,10 @@ class TestPxeParser: with ubman.log.section('Test PXE sysboot'): ubman.run_ut('pxe', 'pxe_test_sysboot', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_fdtdir(self, ubman, pxe_fdtdir_image): + """Test fdtdir path resolution with fdtfile and soc/board env vars""" + fs_img, cfg_path = pxe_fdtdir_image + with ubman.log.section('Test PXE fdtdir'): + ubman.run_ut('pxe', 'pxe_test_fdtdir', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 01:53:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1371 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923660; bh=6TakBt6QTNZsbBU8lVqCzURYojp57TJoG39i8GbGFGk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SXVWmAmVRHkBh75kJ6NJPnUeD8poEW1+QqYOhu1K+LL54WOj4wxaFSWJj9IPnG7KK snz9i5UFou3F4sZzOpN6Zyse9NOneIm2L5zmwwDuWYR6/iZmHWl0wCJgc1GQHSsnbJ EIVVZFRikLmEt+44XmHiKpJvi/0x72RXXaz25wL6ukgUfd6WV1SyrYzSkKmCzHXltY Srw/ADlhaVwpymctZovCFmnuCb//mXltO5PW9JARPLdt26FC4ZkMctw3hR75XuRouj aoZUwKktH2FxbifI6e+c4zyVuETMrDDrivPJVC9wd4PDvxGcBk5m2VEokwvJWcyNgY UcQwuP2r/iFDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54FBB691E6 for ; Thu, 8 Jan 2026 18:54:20 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id RqJbg2JOI9_l for ; Thu, 8 Jan 2026 18:54:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923660; bh=6TakBt6QTNZsbBU8lVqCzURYojp57TJoG39i8GbGFGk=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SXVWmAmVRHkBh75kJ6NJPnUeD8poEW1+QqYOhu1K+LL54WOj4wxaFSWJj9IPnG7KK snz9i5UFou3F4sZzOpN6Zyse9NOneIm2L5zmwwDuWYR6/iZmHWl0wCJgc1GQHSsnbJ EIVVZFRikLmEt+44XmHiKpJvi/0x72RXXaz25wL6ukgUfd6WV1SyrYzSkKmCzHXltY Srw/ADlhaVwpymctZovCFmnuCb//mXltO5PW9JARPLdt26FC4ZkMctw3hR75XuRouj aoZUwKktH2FxbifI6e+c4zyVuETMrDDrivPJVC9wd4PDvxGcBk5m2VEokwvJWcyNgY UcQwuP2r/iFDA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4434169130 for ; Thu, 8 Jan 2026 18:54:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923658; bh=e5k0Ds36UzT1g2CNg/Im9xGy377TNjIeUJYFn0uwm6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxZvBTdMMmA9F3oguy2KR9oRNOewi12Ho3mZ1d7p7i6VedSeIrIodvlUDP++eJRzd hOEvKANqLaEarwv9VU2GpzaU5H0erThZCW7GBAzvrMmmJgnbDMVLww8qt6DAkw1n7u XgXsBR6YkIlWE1wBef9h80nk9V+ExvcVUFWot3AFsILMMZ0bKct/DI1RwJYAg3c40g UANNVwrUEfaxGrnU3LoOKXgg1WG4dEg2D33GqRiYkk72HRNHnmBBpsLqfdfiAeE6Hj x/QEbwveKp4DuyUOkr5MXCSAlsMx5mRFCxXfGgnL1QL+ZrYTUm3lCDtB8rvrbn44sL +NfnHeAWMTR/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D7C169130; Thu, 8 Jan 2026 18:54:18 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id KgvSJLjt6cw5; Thu, 8 Jan 2026 18:54:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923654; bh=ezlrDbCAnyqY5Tek4ZnItAfNQASDQPtnQEri78vOJCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xevr+DyzC4gCv2FWxppwsDe/bhmaoNOpj+T4XpxxJ4w5q62H/sxqFERuBDU90G/Ib x/um92smwQ+bkVdrrLM43iMGRpiWVFwjr6OswafmGDNGIZ8RFVIY0fk9RJfIU6o/FX iSvL5xIUhmUhOcL16uJISz35vI9VJvAvFhaF3jpRB30/5Mgm7GS41WuedQVN/frpt9 G6kO2RIOiBjjb+MyocFdsSrnonSqthwKdGqWDl6qa3gvA0n8vEnQibr6Iyo3WC7uqc 2Jxu4XEADtkl7M/2tHNrBWBVUBkjzXztSnPHotz4VI1xbFh4PpAPGWxgQWruiVYgAF nukoHrx5LxEEQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 499FB6912D; Thu, 8 Jan 2026 18:54:14 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:10 -0700 Message-ID: <20260109015323.3411528-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EHVPGHNAQXLTBSQXUO5N3KNR3TSWJG5T X-Message-ID-Hash: EHVPGHNAQXLTBSQXUO5N3KNR3TSWJG5T X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/16] boot: pxe: Add a test for FDT error-handling List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that verifies error-handling when FDT files are missing: 1. Explicit FDT not found - when a label specifies an explicit fdt= path that doesn't exist, the label fails and sysboot moves to the next label 2. fdtdir FDT not found - when fdtdir is specified but the constructed FDT path doesn't exist, sysboot warns but continues to boot attempt The test uses sysboot and verifies behaviour through console output. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 72 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 68 ++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index a924247bf98..3ccb0c977e9 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -411,3 +411,75 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_fdtdir_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test error handling for missing FDT files via sysboot + * + * This test verifies error handling by running sysboot and checking + * console output: + * 1. Explicit FDT not found - label fails with error, tries next label + * 2. fdtdir FDT not found - warns but continues to boot attempt + */ +static int pxe_test_errors_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set up environment for loading */ + ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); + ut_assertok(env_set("fdtfile", "missing.dtb")); /* For fdtdir test */ + ut_assertok(env_set("bootfile", cfg_path)); + + /* + * Run sysboot - it will try labels in sequence: + * 1. missing-fdt: fails because explicit FDT doesn't exist + * 2. missing-fdtdir: warns about missing FDT but attempts boot + * 3. missing-overlay: loads FDT, warns about missing overlay, boots + */ + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + /* + * Test 1: Explicit FDT file not found + * First label (missing-fdt) has fdt=/dtb/nonexistent.dtb + * Should fail and move to next label + */ + ut_assert_skip_to_line("Enter choice: 1:\tMissing explicit FDT"); + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /dtb/nonexistent.dtb"); + ut_assert_nextline("Skipping missing-fdt for failure retrieving FDT"); + + /* + * Test 2: fdtdir with missing FDT file + * Second label (missing-fdtdir) has fdtdir=/dtb/ but fdtfile=missing.dtb + * Should warn but continue to boot attempt + */ + ut_assert_nextline("2:\tMissing fdtdir FDT"); + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /dtb/missing.dtb"); + ut_assert_nextline("Skipping fdtdir /dtb/ for failure retrieving dts"); + + /* + * Boot attempt without FDT - sandbox can't boot, but this verifies + * that label loading continued despite missing fdtdir FDT + */ + ut_assert_nextline("Unrecognized zImage"); + ut_assert_nextlinen(" unmap_physmem"); + + /* Clean up env vars */ + env_set("fdtfile", NULL); + + return 0; +} +PXE_TEST_ARGS(pxe_test_errors_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index ee8acb8c674..2afe3a93b86 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -327,6 +327,67 @@ def pxe_fdtdir_image(u_boot_config): fsh.cleanup() +@pytest.fixture +def pxe_error_image(u_boot_config): + """Create a filesystem image for testing error handling + + This tests various error conditions: + - Explicit FDT file that doesn't exist (should fail label) + - fdtdir with missing FDT file (should continue) + - Missing overlay file (should continue) + """ + fsh = FsHelper(u_boot_config, 'vfat', 4, prefix='pxe_error') + fsh.setup() + + labels = [ + { + # Explicit FDT that doesn't exist - should fail this label + 'name': 'missing-fdt', + 'menu': 'Missing explicit FDT', + 'kernel': '/vmlinuz', + 'fdt': '/dtb/nonexistent.dtb', + 'default': True, + }, + { + # fdtdir with missing FDT - should warn but continue + 'name': 'missing-fdtdir', + 'menu': 'Missing fdtdir FDT', + 'kernel': '/vmlinuz', + 'fdtdir': '/dtb/', + }, + { + # Valid FDT but missing overlay - should continue + 'name': 'missing-overlay', + 'menu': 'Missing overlay', + 'kernel': '/vmlinuz', + 'fdt': '/dtb/board.dtb', + 'fdtoverlays': '/dtb/nonexistent.dtbo /dtb/overlay1.dtbo', + }, + ] + + cfg_path = create_extlinux_conf(fsh.srcdir, labels) + + # Create DTB directory with only some files + dtbdir = os.path.join(fsh.srcdir, 'dtb') + os.makedirs(dtbdir, exist_ok=True) + + # Only create board.dtb and overlay1.dtbo - others are missing + compile_dts(BASE_DTS, os.path.join(dtbdir, 'board.dtb')) + compile_dts(OVERLAY1_DTS, os.path.join(dtbdir, 'overlay1.dtbo'), + is_overlay=True) + + # Create dummy kernel + with open(os.path.join(fsh.srcdir, 'vmlinuz'), 'wb') as fd: + fd.write(b'kernel') + fd.write(b'\x00' * (1024 - 6)) + + fsh.mk_fs() + + yield fsh.fs_img, cfg_path + + fsh.cleanup() + + @pytest.mark.boardspec('sandbox') @pytest.mark.requiredtool('dtc') class TestPxeParser: @@ -352,3 +413,10 @@ class TestPxeParser: with ubman.log.section('Test PXE fdtdir'): ubman.run_ut('pxe', 'pxe_test_fdtdir', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_errors(self, ubman, pxe_error_image): + """Test error handling for missing FDT and overlay files""" + fs_img, cfg_path = pxe_error_image + with ubman.log.section('Test PXE errors'): + ubman.run_ut('pxe', 'pxe_test_errors', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 01:53:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1372 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923661; bh=dmgDb3ryLAz5zuOJdUQblEs1XvaCy5VbeYNVNnbqW/M=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ltSHi6FwJ3he1V8dSBHsB6GGM0pNfRfJhgLrE2nxtexiIVe6KY7+yWFMfCxZac3Sg NrSy2nYHoO/8O0zK5VzhPria3L/QFNfUV0ZNWnN+9wBR1KIJb5rSq1BhLgME7KN0SF oMgMJVByko6R05uiclbKdvzsexpC0wwCJrt5zodORLaRwFMhNjeokWYWMG+chPEVgQ zCRtLfR2JaYn+5/K5pVa8eq+1xAZFLkFWH37r4ioEXmNE/w4ttNjE8kWWLn+ZVsqEc Q1MGJkXg8dGaXce9HupCKm0zEOqkUV6P230wPg1JlFwXWUF1csWggbrZ3QNWnBWWfx FGJCfrCU7PVwA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52E63691E6 for ; Thu, 8 Jan 2026 18:54:21 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zn9PhKWp1lgi for ; Thu, 8 Jan 2026 18:54:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923661; bh=dmgDb3ryLAz5zuOJdUQblEs1XvaCy5VbeYNVNnbqW/M=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ltSHi6FwJ3he1V8dSBHsB6GGM0pNfRfJhgLrE2nxtexiIVe6KY7+yWFMfCxZac3Sg NrSy2nYHoO/8O0zK5VzhPria3L/QFNfUV0ZNWnN+9wBR1KIJb5rSq1BhLgME7KN0SF oMgMJVByko6R05uiclbKdvzsexpC0wwCJrt5zodORLaRwFMhNjeokWYWMG+chPEVgQ zCRtLfR2JaYn+5/K5pVa8eq+1xAZFLkFWH37r4ioEXmNE/w4ttNjE8kWWLn+ZVsqEc Q1MGJkXg8dGaXce9HupCKm0zEOqkUV6P230wPg1JlFwXWUF1csWggbrZ3QNWnBWWfx FGJCfrCU7PVwA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 411AB691E7 for ; Thu, 8 Jan 2026 18:54:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923659; bh=IrkPD4s8siJgkd8WOs7cRb/PxmC9X7tG07YAx81dssQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vKO/6lNhQkwYX98fPaZJK4reB30+64GBNg0Ilp/0LduRmc+IlMPbdXeE72/ueWeGH gcxngwFEAjstmDYNN75fXpSgpporgj2TxGqRkBl0IMW7PaTsPTlCjTbNYczjHbncBa 2W6jKS8JK7poOVv+VtP9RZbfL23ahmUW4ON4j4bvt2H+EUfi2FxEyeBcdjzXpqwSqL 2u+lHpokGpKq97oBq2lS/2MvbvX4Sp/2UZGJ8uWFnN8U8LDY7Dt14bevQEUPxo7xm1 7jnHwTIE7xx1FPtdxbFTCOIaJpwej9+hGuQvn1vGDCY3n0dN7A6m5SO4TIqVecNBfA vEX8ShsLh4PrQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 88EA069130; Thu, 8 Jan 2026 18:54:19 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id ZB6s8SU0NxOq; Thu, 8 Jan 2026 18:54:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923659; bh=LcMQFL5lOlaN60lXYjT+NIpfXKQVx7rjGRVXbIGQ+U4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JD5Rkcw56Xz5wZkQkCgfmh/Vd1OotRrYv7dhWI+iHos2srCX1P3Ri9ge/1+fmXnwo koZ+d5p6IFP6J1xicseznRRAWWdEVKSHBNPDYsalO07o9IaXOX5uEwA94R2X/HRbme SSArRZzhnv6r2tQ3FOHdX9e21FwaAKphJnhtwge/1AbTpuS1faOb0FDk5b7NyY9gaK dSbFo6zFN35zGV7wlJ8XRyhK2FT7rhFHnLCN682b47Eb5exgws5F3aJzAf7WetLyc3 2BEsu+r/Edgwx2f6tYG1XXwHJTUeB1V+nWM55iYGnJjRHgC6PHkcfBGLBdU/DS/rpx G30buny7Wpvwg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E429D6912D; Thu, 8 Jan 2026 18:54:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:11 -0700 Message-ID: <20260109015323.3411528-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: X4VMEZWFUX3AISQJQZK42LGE3RDJDFKY X-Message-ID-Hash: X4VMEZWFUX3AISQJQZK42LGE3RDJDFKY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/16] test: pxe: Add a few tests for pxe functions List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add some tests for: - pxe_get_file_size(): missing env var, valid hex values, invalid format - format_mac_pxe(): buffer too small, valid MAC format verification - get_pxelinux_path(): path too long error Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 107 ++++++++++++++++++++++++++++++- test/py/tests/test_pxe_parser.py | 7 ++ 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 3ccb0c977e9..e6d95d07d41 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -13,11 +13,14 @@ #include #include #include +#include #include #include #include -/* Define test macro for pxe suite - no init function needed */ +/* Define test macros for pxe suite */ +#define PXE_TEST(_name, _flags) \ + UNIT_TEST(_name, _flags, pxe) #define PXE_TEST_ARGS(_name, _flags, ...) \ UNIT_TEST_ARGS(_name, _flags, pxe, __VA_ARGS__) @@ -483,3 +486,105 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_errors_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test pxe_get_file_size() function + * + * This tests reading the filesize from the environment variable. + */ +static int pxe_test_get_file_size(struct unit_test_state *uts) +{ + ulong size; + + /* Test with no filesize set - should return -ENOENT */ + env_set("filesize", NULL); + ut_asserteq(-ENOENT, pxe_get_file_size(&size)); + + /* Test with valid hex filesize */ + env_set("filesize", "1234"); + ut_assertok(pxe_get_file_size(&size)); + ut_asserteq(0x1234, size); + + /* Test with larger value */ + env_set("filesize", "abcdef"); + ut_assertok(pxe_get_file_size(&size)); + ut_asserteq(0xabcdef, size); + + /* Test with invalid (non-hex) value */ + env_set("filesize", "not_hex"); + ut_asserteq(-EINVAL, pxe_get_file_size(&size)); + + /* Clean up */ + env_set("filesize", NULL); + + return 0; +} +PXE_TEST(pxe_test_get_file_size, 0); + +/** + * Test format_mac_pxe() function + * + * This tests MAC address formatting for PXE boot paths. + */ +static int pxe_test_format_mac(struct unit_test_state *uts) +{ + char buf[21]; + + /* Test with buffer too small */ + ut_asserteq(-ENOSPC, format_mac_pxe(buf, 20)); + ut_asserteq(-ENOSPC, format_mac_pxe(buf, 1)); + + /* Test with valid buffer - sandbox has an ethernet device */ + ut_asserteq(1, format_mac_pxe(buf, sizeof(buf))); + + /* Verify format: 01-xx-xx-xx-xx-xx-xx */ + ut_asserteq(20, strlen(buf)); + ut_asserteq('0', buf[0]); + ut_asserteq('1', buf[1]); + ut_asserteq('-', buf[2]); + ut_asserteq('-', buf[5]); + ut_asserteq('-', buf[8]); + ut_asserteq('-', buf[11]); + ut_asserteq('-', buf[14]); + ut_asserteq('-', buf[17]); + + return 0; +} +PXE_TEST(pxe_test_format_mac, UTF_ETH_BOOTDEV); + +/** + * Test get_pxelinux_path() with path too long + * + * This tests the path length check in get_pxelinux_path(). + */ +static int pxe_test_pxelinux_path_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + struct pxe_test_info info; + struct pxe_context ctx; + char path[600]; + + ut_assertnonnull(fs_image); + info.uts = uts; + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set up the PXE context */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, false, "/", + false, false, NULL)); + + /* Create a path that's too long (> 512 - 13 for "pxelinux.cfg/") */ + memset(path, 'a', sizeof(path) - 1); + path[sizeof(path) - 1] = '\0'; + + /* Should fail with -ENAMETOOLONG */ + ut_asserteq(-ENAMETOOLONG, get_pxelinux_path(&ctx, path, + PXE_LOAD_ADDR)); + + pxe_destroy_ctx(&ctx); + + return 0; +} +PXE_TEST_ARGS(pxe_test_pxelinux_path_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index 2afe3a93b86..0d957c08219 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -420,3 +420,10 @@ class TestPxeParser: with ubman.log.section('Test PXE errors'): ubman.run_ut('pxe', 'pxe_test_errors', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_pxelinux_path(self, ubman, pxe_image): + """Test get_pxelinux_path() path length checking""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE pxelinux path'): + ubman.run_ut('pxe', 'pxe_test_pxelinux_path', + fs_image=fs_img) From patchwork Fri Jan 9 01:53:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1373 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923665; bh=lIlmz371570bQHHg4oURW4ouQ2oAk0+scn66RPi5bXc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UJhcEJBcMKsrjpkMKvOtLhaH7kaPRIDn3Np0y7KbGc6Ja8c0pPvLLKRYuwepvWH/2 Pl3qcapiOwVRT6Cog3dSA5JojEXJC1xhedqhflsMrtw4MuI5NSN/X6qmhKGdK0TB9F 8f3OWha/AkxwntK2qWc/u5E8lfM88uutGNmyu+a4AnRIBojp3nHYr/gRPrtTkTn3qn JJ+icITm2Ijo5gebwQXZMBp/px+9GUJWjP3mKCRIH1+BUhYqqCjC1fKzrlB/Jgm8Ch QzBFVF9fJDuEG8/z7AbqbE/nQUWzi8vkDcIq4gqJzo/PIrudbfXG73b7BtaipLWM48 yUbM33cbmpD3A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C3165691E9 for ; Thu, 8 Jan 2026 18:54:25 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BP_vDqjW9-s6 for ; Thu, 8 Jan 2026 18:54:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923665; bh=lIlmz371570bQHHg4oURW4ouQ2oAk0+scn66RPi5bXc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UJhcEJBcMKsrjpkMKvOtLhaH7kaPRIDn3Np0y7KbGc6Ja8c0pPvLLKRYuwepvWH/2 Pl3qcapiOwVRT6Cog3dSA5JojEXJC1xhedqhflsMrtw4MuI5NSN/X6qmhKGdK0TB9F 8f3OWha/AkxwntK2qWc/u5E8lfM88uutGNmyu+a4AnRIBojp3nHYr/gRPrtTkTn3qn JJ+icITm2Ijo5gebwQXZMBp/px+9GUJWjP3mKCRIH1+BUhYqqCjC1fKzrlB/Jgm8Ch QzBFVF9fJDuEG8/z7AbqbE/nQUWzi8vkDcIq4gqJzo/PIrudbfXG73b7BtaipLWM48 yUbM33cbmpD3A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B1C3A691E6 for ; Thu, 8 Jan 2026 18:54:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923664; bh=RbHoS8vpOlhJuN3HycdUyesUIz2pKOAjHIm2EZhlkno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=twiXaTWfvJG0E0SYLKFLb2xjQuSmtG2djMsrzpV8daG5rsRfh+7cRyTQbS6BF0KzX C6v82ymdbEHorCtnk6wmHBJ0x1+GErQPvlcYbYOTcwRgjPcBKjnrEak3mhBpJH2Xvd kNthgCE8hVqxA3Ne6ipE9fEodr84g+2tCCGe/SubCj7+qgQVHF15obCEtkXaSDfRGG 0Iv0qfZjgG0LR/lWH/L8ESqoyqqfKDVD1h3vVQCWYB2CKIpZ5SiexILlS7NNRf1Euy lfvnu7S0jfS+xWm2EAMI5uvH8UzHvIrfp8+r1ZnamQmBra6Qfl8k8L1hElzpg/gl84 7v5lHwQ9kDOhQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1EA6669130; Thu, 8 Jan 2026 18:54:24 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id if_TfCFSsoIc; Thu, 8 Jan 2026 18:54:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923660; bh=+98jAgcI+/dFbc6c5OFq2nGpQIzCySdeoDyTyNsL9qc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZYCDA3jUuhr+NCPHUJd+NQa3LeG+TfTYZlwl0OIsSmxcj1FQZ4a+ULR7ZftDfCAy 2ve50lnnjTIcWI5kiKMtF7m9RZ2Fm4Z9ywg4zx8tSZnWlAyrOa8m+Pn2NFevKCSIXF BUxEEyxGjfcVo/XhRo8sRO52TnelP9xDBxKfAs5qtzUb2kmrZwpF+/N8+p1V03rscQ QvTU6JKNbiG8GU4ISt8ksJgWI7KT+74OXlmbTD8K1n2VXxrOihUl8WS+cztvViMuw6 PTBLaLyZfeEga5emwIjV5RKwP2V1tlD6PuqHN/u2YTQ9QUNmu8KbvxvusqjbY8mFwv IoKqEe5lnpLFA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C62BE6912D; Thu, 8 Jan 2026 18:54:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:12 -0700 Message-ID: <20260109015323.3411528-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JXQWP4BTHVQVMF5GN3KRHWXZ4E434WS5 X-Message-ID-Hash: JXQWP4BTHVQVMF5GN3KRHWXZ4E434WS5 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/16] test: pxe: Add a note about ontimeout keyword testing List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The ontimeout keyword is exercised via the test fixtures but cannot be verified separately from the default keyword since both set the same cfg->default_label field. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index e6d95d07d41..8c526e1ba59 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -5,6 +5,11 @@ * Copyright 2026 Canonical Ltd * * These tests verify the extlinux.conf parser APIs. + * + * Note: The 'ontimeout' keyword is tested via the test fixtures which include + * it. Since ontimeout is handled identically to 'default' (both set + * cfg->default_label), it cannot be distinguished after parsing. + * */ #include From patchwork Fri Jan 9 01:53:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1374 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923669; bh=qOOQSI0+48ajW0XqKAqm0+avRy04ZfJ17swSgA211jM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BZS6ezb0T5zXnfsjAF/VAea1nfiQIg237X56lNISS4Z4uZwlegqR9Nuif5ssMIDz2 GLA0sHh4vRd/xQaWEpqYPhc0fZbYBMvyN7dOcYRk3AdsVB0LRfniGbvbDmTiC7JNrU lGsJzSADTsxLHnyrHLWLf3HtOdj7FcV+2WwHw3mQS201rOFSbaq54M2Xu+AUPEATXP uQ9b4KEt3QQApf8BmQCrFRDVsbY8xw3Bdm1PFxC/PsjUqYTeSZeo0h8MH0pl8VH2su Y5btx3SEPkumYsnunHSWF3N18etxssObTVXgveZ6Ex0NQ6VLUPGfvrd6uehVHb1PSK m0BgTJftLjL8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93BB9691E7 for ; Thu, 8 Jan 2026 18:54:29 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id LIYuq-f18ZZ1 for ; Thu, 8 Jan 2026 18:54:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923669; bh=qOOQSI0+48ajW0XqKAqm0+avRy04ZfJ17swSgA211jM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BZS6ezb0T5zXnfsjAF/VAea1nfiQIg237X56lNISS4Z4uZwlegqR9Nuif5ssMIDz2 GLA0sHh4vRd/xQaWEpqYPhc0fZbYBMvyN7dOcYRk3AdsVB0LRfniGbvbDmTiC7JNrU lGsJzSADTsxLHnyrHLWLf3HtOdj7FcV+2WwHw3mQS201rOFSbaq54M2Xu+AUPEATXP uQ9b4KEt3QQApf8BmQCrFRDVsbY8xw3Bdm1PFxC/PsjUqYTeSZeo0h8MH0pl8VH2su Y5btx3SEPkumYsnunHSWF3N18etxssObTVXgveZ6Ex0NQ6VLUPGfvrd6uehVHb1PSK m0BgTJftLjL8w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7410969130 for ; Thu, 8 Jan 2026 18:54:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923668; bh=vo8lAo2R4BWnLWri90DL+I8fAO5i4on2vUJwhdZMp04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c2ZPSyYflSUTc3piVWAvJSKuNgeUDrUumMdql/DuA33H10MEX8zY9FeLq3e3TXH10 YRkClb1nQoaR+5wLDwANA44FVYLIjVReJ3bQ7B2vWz1qzZhKTYlNHvtB4Ye0K1ssTJ TnjVTQLdY11LpA5bb7a9cWV4qFH/8zthfNlZLgWamAEYoSWKBmW0d/aNcio/9mcIxU WuwA/Juql1r3PDK4rQ6dUkSgzo6BhEpZFxBRX+bpLz3lzs0CWKKMsaI007N5QpDtda OK8QFdqv8D+uyJE2JKW8/Ld23xrMcegtLhGvU503S5NksjZfONsAKy6uj96r5ywwxb 5tR1fZcugdMYA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A8F0B691E6; Thu, 8 Jan 2026 18:54:28 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 0ndP11R_P3bS; Thu, 8 Jan 2026 18:54:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923664; bh=ZNnfPDImU4D8I1Q4dj7QS6vtYVvfxA0yHZvyVw9rzS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uwA2JcbQhBxlovBl3zMToFaRFv/Bpx38aTpe0OyNYmnHFbBTVGsFFM4dLYXkY+S/M 1HTpmyPTwiAwP77YOurB293s3WQoAT75oKqpZWvChqGMIxq145QjmB021MQ8JP03Xy 1KEAeVEfmeBp0NGVRSrXGr2EG+tZ3EoF5eRDXGllA5ZI2IPcRbQ4YNnvTIxQ6MXY3J BTH5oeq4crg1HEzv73xyv1ZV5CKrfUL+pMyM0oNwtEgVNg3yD35WQnSEkNpP1CALGE 1xQMntZaXux+eqbyYwNRvwRhmYpUihlS6Dge81aA2cmBsZ43Xoaz5QcKgm4RikNbsY H9xDzXVymO4gg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6019E6912D; Thu, 8 Jan 2026 18:54:24 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:13 -0700 Message-ID: <20260109015323.3411528-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JTUCNABBBN4IGA4RVZB7NOPGT5IT6JHI X-Message-ID-Hash: JTUCNABBBN4IGA4RVZB7NOPGT5IT6JHI X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/16] boot: pxe: Add a pxe_timeout env variable for menu timeout List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The PXE menu timeout is configured in extlinux.conf, but tests need a way to override it to avoid long delays. Add a pxe_timeout environment variable that, when set, overrides the configured timeout value. The test uses pxe_timeout=1 to reduce the menu wait from 5 seconds to 1 second. Ideally the test would be instant, but this is good enough for now. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 5 ++++- test/boot/pxe.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index ba1f7c41512..fbe4a111453 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -929,11 +929,14 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) int i = 1; char *default_num = NULL; char *override_num = NULL; + int timeout; + + timeout = env_get_ulong("pxe_timeout", 10, DIV_ROUND_UP(cfg->timeout, 10)); /* * Create a menu and add items for all the labels. */ - m = menu_create(cfg->title, DIV_ROUND_UP(cfg->timeout, 10), + m = menu_create(cfg->title, timeout, cfg->prompt, NULL, label_print, NULL, NULL, NULL); if (!m) return NULL; diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 8c526e1ba59..36e1f5519f4 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -276,6 +276,7 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); ut_assertok(env_set("bootfile", cfg_path)); + ut_assertok(env_set("pxe_timeout", "1")); /* * Run sysboot - it will try all labels and return 0 after failing From patchwork Fri Jan 9 01:53:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1375 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923671; bh=UrYYCb+wEyzz8KGmWsiASyMrldxU/hRAM3U2k+nTeIg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=N6CdnxFR7jl991/0HLcMTP6u4W3LgsLbEpyRLnXljs+d4kr+jicfvs7nDFnS00N9x VpiFB9ew7fi/pQqQLOqcVNwrX8OJx/X2XdwEgcerxXYyN8vFDNIpqVG+fD9/bsR5FV Ex+H8CqN7Bcvc3t/PNw/YamAzAecsvlJXNjaL2amRgTDu+UC4WBGKiBQWQ2ptYZFzO PUePJHylCjSbNEh3uSUGn+POk1/JjyO/pu1tPyr8nzICQqp6x3Oj8QhdnaZxXfyf2m Ka5TK+1l182RGtnBXteQPxYe2uvpHE54KDewdZU97QS27PcLlDqgsUDQQQgFKGmf9L qiiJ+hGTPHqsg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 72E1D691E7 for ; Thu, 8 Jan 2026 18:54:31 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id LKkG2A1G_qE0 for ; Thu, 8 Jan 2026 18:54:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923671; bh=UrYYCb+wEyzz8KGmWsiASyMrldxU/hRAM3U2k+nTeIg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=N6CdnxFR7jl991/0HLcMTP6u4W3LgsLbEpyRLnXljs+d4kr+jicfvs7nDFnS00N9x VpiFB9ew7fi/pQqQLOqcVNwrX8OJx/X2XdwEgcerxXYyN8vFDNIpqVG+fD9/bsR5FV Ex+H8CqN7Bcvc3t/PNw/YamAzAecsvlJXNjaL2amRgTDu+UC4WBGKiBQWQ2ptYZFzO PUePJHylCjSbNEh3uSUGn+POk1/JjyO/pu1tPyr8nzICQqp6x3Oj8QhdnaZxXfyf2m Ka5TK+1l182RGtnBXteQPxYe2uvpHE54KDewdZU97QS27PcLlDqgsUDQQQgFKGmf9L qiiJ+hGTPHqsg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5EA92691F5 for ; Thu, 8 Jan 2026 18:54:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923669; bh=nZRJQ9nhWz36Du82aMQ+LEt/LSa79K14fMCbkEbpM+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cij+KdbjpGfTldhma30A6RqO+rqtxjSo/MyuQPqxf9h0b/SEABioK8UtmQwVi9L+J SByle27Q6670BBdvLDxMUxrZwT1LPSIkbUZU2TyrCUMBzVEOQocIiw4sMDEa2cfqVE XHR02+Brd6FDXaWw7Qq3lTSqqUtfGUb0h2lDCGmal3HYx3/QJX9ZY7t1xNBx0T+0lP TxGe09432x/+hjyAAXc98R35/4u0VZCd0cyS6V1WigZRfRDRn0IDzDW9qvT7p3ADgI zWbUjhjrTxCOrg6B7C+AqLcO0xg9BtQ+GAk6kaXRCaz+QW6wdDlhIpO8uV0uS4hLnf C1McKh5Awer/g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DDC17691FA; Thu, 8 Jan 2026 18:54:29 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id D8V-0stJYjoP; Thu, 8 Jan 2026 18:54:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923669; bh=WhMD61/vyeEnEkJY1XnyTJyxrK5GrBO/X5aQqG8v9NI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fa8LaYfJGSCUCo+rH6x6uK7NeDQKP2kSGRxAJjxZeJoFu2spY9FHKemWRMdD4G4O+ WvmVUNCGIZ4FZjaIHbCZ4vIjK1ZzZaK5xQpknyH5iIbavTcQoKKQ+mQF5def0mguQH D/WFeD5wLjyd+ofTQwNQQtI6zKH5k6VPxT9ahcLKkZX8blG2W/Kq3q9wac7eo5sTp6 iY9+ipYKKWkfB3Sob5uFAITkNtwrstR6xNyjUUlXb8VhtWkEVJGRGk6QOMWLrVJXr3 lePBcvv1wTaI/FaMkt9BFzmfcgpxNp4AgaFZ4tvP/Mfn7u+Vry7HCe9dVuxgIMTceC cMw61fWnnDpJA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EBBCB6912D; Thu, 8 Jan 2026 18:54:28 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:14 -0700 Message-ID: <20260109015323.3411528-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NIKDLI5XG45A7IO45ANSMKU4DQBFLH3L X-Message-ID-Hash: NIKDLI5XG45A7IO45ANSMKU4DQBFLH3L X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/16] test: pxe: Add a test for the ipappend functionality List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that verifies ipappend correctly appends IP and MAC info to the bootargs environment variable. The test boots the rescue label which has ipappend=3, enabling both: - bit 0: ip=::: - bit 1: BOOTIF=01-xx-xx-xx-xx-xx-xx Also add the vmlinuz-rescue kernel file to the test fixture. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 66 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 9 +++++ 2 files changed, 75 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 36e1f5519f4..fec2361c27f 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -594,3 +594,69 @@ static int pxe_test_pxelinux_path_norun(struct unit_test_state *uts) } PXE_TEST_ARGS(pxe_test_pxelinux_path_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * Test ipappend functionality + * + * This tests that ipappend correctly appends IP and MAC information to + * bootargs. The rescue label has ipappend=3 which enables both: + * - bit 0x1: ip=::: + * - bit 0x2: BOOTIF=01-xx-xx-xx-xx-xx-xx + */ +static int pxe_test_ipappend_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set environment variables for file loading */ + ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set("bootfile", cfg_path)); + + /* Set network environment variables for ipappend */ + ut_assertok(env_set("ipaddr", "192.168.1.10")); + ut_assertok(env_set("serverip", "192.168.1.1")); + ut_assertok(env_set("gatewayip", "192.168.1.254")); + ut_assertok(env_set("netmask", "255.255.255.0")); + + /* Override to boot the rescue label which has ipappend=3 */ + ut_assertok(env_set("pxe_label_override", "rescue")); + ut_assertok(env_set("pxe_timeout", "1")); + + /* Run sysboot */ + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + /* Skip to the rescue label boot */ + ut_assert_skip_to_line("Retrieving file: /vmlinuz-rescue"); + + /* + * Verify ipappend output - should have: + * - original append: "single" + * - ip= string from ipappend bit 0x1 + * - BOOTIF= string from ipappend bit 0x2 + */ + ut_assert_nextlinen("append: single ip=192.168.1.10:192.168.1.1:" + "192.168.1.254:255.255.255.0 BOOTIF=01-"); + + /* Clean up */ + env_set("ipaddr", NULL); + env_set("serverip", NULL); + env_set("gatewayip", NULL); + env_set("netmask", NULL); + env_set("pxe_label_override", NULL); + env_set("pxe_timeout", NULL); + + return 0; +} +PXE_TEST_ARGS(pxe_test_ipappend_norun, UTF_CONSOLE | UTF_MANUAL | UTF_ETH_BOOTDEV, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index 0d957c08219..f3ae3ff9f78 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -256,6 +256,8 @@ def pxe_image(u_boot_config): # Create dummy kernel and initrd files with identifiable content with open(os.path.join(fsh.srcdir, 'vmlinuz'), 'wb') as fd: fd.write(b'kernel') + with open(os.path.join(fsh.srcdir, 'vmlinuz-rescue'), 'wb') as fd: + fd.write(b'rescue') with open(os.path.join(fsh.srcdir, 'initrd.img'), 'wb') as fd: fd.write(b'ramdisk') @@ -427,3 +429,10 @@ class TestPxeParser: with ubman.log.section('Test PXE pxelinux path'): ubman.run_ut('pxe', 'pxe_test_pxelinux_path', fs_image=fs_img) + + def test_pxe_ipappend(self, ubman, pxe_image): + """Test ipappend functionality for IP and MAC appending""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE ipappend'): + ubman.run_ut('pxe', 'pxe_test_ipappend', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 01:53:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1376 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923676; bh=z9JBBYMHVskff4sS9I8H1b+e2YESgp+dWIpj0VzKi8E=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=u7Bs9XxaaDHMiUzmmQOHmyxG2Knzay11Sw2E7t3boEbEOw0FmHWA7Rev5hA5zNhHR f1AnA9XaiIzmJs8aRwDHjtQQAJODCkb5PczdOlo3bJdUJRYlRZtwn376Rwte18Bsxk DqHjPzuexggk6LXg5zoa3s4T639euOdXpfeY0iWWm6ngFveFZQiokgAX2dKKMZ6aib IJHslV2apxrYbgvEJKZCcy+nl+C+3emXjPsdckd9SeuEApYxTfEfgLWoGnpSMpgcFj /IDuvVCWziwzjMR9+XQI10Btqq1rhd9aNxRQs30DrzHBcvo5XqZvezB9Z6vfvirO3b IhcyZfvMqWC9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 77AAC691F5 for ; Thu, 8 Jan 2026 18:54:36 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 54WgYamJbUsc for ; Thu, 8 Jan 2026 18:54:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923676; bh=z9JBBYMHVskff4sS9I8H1b+e2YESgp+dWIpj0VzKi8E=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=u7Bs9XxaaDHMiUzmmQOHmyxG2Knzay11Sw2E7t3boEbEOw0FmHWA7Rev5hA5zNhHR f1AnA9XaiIzmJs8aRwDHjtQQAJODCkb5PczdOlo3bJdUJRYlRZtwn376Rwte18Bsxk DqHjPzuexggk6LXg5zoa3s4T639euOdXpfeY0iWWm6ngFveFZQiokgAX2dKKMZ6aib IJHslV2apxrYbgvEJKZCcy+nl+C+3emXjPsdckd9SeuEApYxTfEfgLWoGnpSMpgcFj /IDuvVCWziwzjMR9+XQI10Btqq1rhd9aNxRQs30DrzHBcvo5XqZvezB9Z6vfvirO3b IhcyZfvMqWC9w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 65EFA691E6 for ; Thu, 8 Jan 2026 18:54:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923674; bh=dcGiN4hAIejx/FmBYoAqtbDV8wUNhxsCtbDbMoS/EgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkFGQ6eUbR5I3B15ToRsd0K+uMo0TzgPOjVa09E6VprQSeMGVElJt+CfK9+LW74nn 6CAu4OHAdySdDbhzp/qlu2UZIlYqaJqSttfbaTr1Zy/R/5PdJIzC5/Tb7VNQtochAJ VlO+yR460Ue99qFqXrYK7qCFYCEKdU9L4R7WMswn3G9H/VUjqTmjDoPXcKHiUFwVQv ojouk032gu1Xq+fI9HXe6TKxBCHUAGyUYdiOSkVfJ5JD7O9G2tXi1wYDwU9U5P41Pb UPD3fyN6FOQekBtkRxl1bptrGxW5/TheSKg8mDVVi+Zqgz6yw5pt7TW1mE6+NwcW4F 16N6d4fIf0YvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 75A4269130; Thu, 8 Jan 2026 18:54:34 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id CGKiiNtIZ5Kc; Thu, 8 Jan 2026 18:54:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923670; bh=M8n5S0oXX7y/lg2BjHRNbPT/DB8qZRWc12RPA6kgEsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYxtWGoc9Vl8mUxkG11SesTUKWvwdKe9J/U3y8An9WH88AqeMxQx9SgeUmBBXOlBy +ijc6h7aLxak9qyYSyd41B+BUqq3nhF6cVtPypsv4ubkVNPN72S5cgyHWczGezRPcH gO013a5ubJOxxnoboU0pobW3d/okfEaHBsPINgxhfvd7veS6o2ZglLqrJ+vOECMtak Rp2qO7Hb4rwAJyIV24wdDbb+112T1yLfI6fdVV1RJijTXap9ey2WL9zwG08nTiFFVu pkyGjEs+cINCu32xXqHydbAAHnf+wjMtgCqoNTsCb2IHL+2fHVaOhWxtJo31EoWJf1 Fvm05uoq6fjTw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1E7436912D; Thu, 8 Jan 2026 18:54:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:15 -0700 Message-ID: <20260109015323.3411528-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UZQE67BVJSXY2AS7STPMWUJUV2W2IBDC X-Message-ID-Hash: UZQE67BVJSXY2AS7STPMWUJUV2W2IBDC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/16] boot: pxe: Extract FDT fallback logic and add test List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Extract the FDT address fallback logic from label_boot() into a new exported function pxe_get_fdt_fallback(). This determines the FDT address when a label doesn't specify an FDT file: 1. First tries fdt_addr environment variable 2. Falls back to fdtcontroladdr (unless kernel is FIT format) Add a test that verifies the fallback priority and behaviour. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 55 +++++++++++++++++++++++++++------------------ include/pxe_utils.h | 14 ++++++++++++ test/boot/pxe.c | 49 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 22 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index fbe4a111453..9034c3d86e7 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -396,6 +396,37 @@ skip_overlay: } #endif +const char *pxe_get_fdt_fallback(struct pxe_label *label, ulong kern_addr) +{ + const char *conf_fdt_str = NULL; + void *buf; + + /* + * Fallback to fdt_addr env var if label doesn't specify FDT + * and it's not ATAG mode (fdt="-") + */ + if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || + !label->fdt || strcmp("-", label->fdt)) { + conf_fdt_str = env_get("fdt_addr"); + if (conf_fdt_str) + return conf_fdt_str; + } + + /* + * Fallback to fdtcontroladdr if not a FIT image and not ATAG mode + */ + buf = map_sysmem(kern_addr, 0); + if (genimg_get_format(buf) != IMAGE_FORMAT_FIT) { + if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || + !label->fdt || strcmp("-", label->fdt)) { + conf_fdt_str = env_get("fdtcontroladdr"); + } + } + unmap_sysmem(buf); + + return conf_fdt_str; +} + /* * label_process_fdt() - Process FDT for the label * @@ -789,28 +820,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (ret) return ret; - if (!conf_fdt_str) { - if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || - strcmp("-", label->fdt)) { - conf_fdt_str = env_get("fdt_addr"); - log_debug("using fdt_addr '%s'\n", conf_fdt_str); - } - } - - if (!conf_fdt_str) { - void *buf; - - buf = map_sysmem(kern_addr, 0); - if (genimg_get_format(buf) != IMAGE_FORMAT_FIT) { - if (!IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS) || - strcmp("-", label->fdt)) { - conf_fdt_str = env_get("fdtcontroladdr"); - log_debug("using fdtcontroladdr '%s'\n", - conf_fdt_str); - } - } - unmap_sysmem(buf); - } + if (!conf_fdt_str) + conf_fdt_str = pxe_get_fdt_fallback(label, kern_addr); if (conf_fdt_str) conf_fdt = hextoul(conf_fdt_str, NULL); log_debug("conf_fdt %lx\n", conf_fdt); diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 7ecb5788d0b..9629f051a91 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -306,6 +306,20 @@ int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); */ int pxe_get_file_size(ulong *sizep); +/** + * pxe_get_fdt_fallback() - Get the FDT address using fallback logic + * + * When a label doesn't specify an FDT file (via 'fdt' or 'fdtdir'), this + * function determines the FDT address using fallback environment variables: + * 1. fdt_addr - if set, use this address + * 2. fdtcontroladdr - if set and kernel is not FIT format + * + * @label: Label being processed + * @kern_addr: Address where kernel is loaded + * Return: FDT address string from environment, or NULL if no fallback available + */ +const char *pxe_get_fdt_fallback(struct pxe_label *label, ulong kern_addr); + /** * pxe_get() - Get the PXE file from the server * diff --git a/test/boot/pxe.c b/test/boot/pxe.c index fec2361c27f..505628ab92d 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -660,3 +660,52 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_ipappend_norun, UTF_CONSOLE | UTF_MANUAL | UTF_ETH_BOOTDEV, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test pxe_get_fdt_fallback() function + * + * This tests the FDT address fallback logic when a label doesn't specify + * an FDT file via 'fdt' or 'fdtdir' keywords. + */ +static int pxe_test_fdt_fallback(struct unit_test_state *uts) +{ + const char *orig_fdt_addr, *orig_fdtcontroladdr; + ulong kern_addr = 0x1000000; + struct pxe_label label; + void *kern_buf; + + /* Create a dummy kernel buffer (not FIT format) */ + kern_buf = map_sysmem(kern_addr, 64); + memset(kern_buf, '\0', 64); + unmap_sysmem(kern_buf); + + memset(&label, '\0', sizeof(label)); + + /* Save and clear env vars (fdtcontroladdr is set by U-Boot) */ + orig_fdt_addr = env_get("fdt_addr"); + orig_fdtcontroladdr = env_get("fdtcontroladdr"); + ut_assertok(env_set("fdt_addr", NULL)); + ut_assertok(env_set("fdtcontroladdr", NULL)); + + /* Test 1: No fallback env vars set - should return NULL */ + ut_assertnull(pxe_get_fdt_fallback(&label, kern_addr)); + + /* Test 2: fdt_addr set - should return fdt_addr */ + ut_assertok(env_set_hex("fdt_addr", 0x2000000)); + ut_asserteq_str("2000000", pxe_get_fdt_fallback(&label, kern_addr)); + + /* Test 3: Both set - fdt_addr takes priority */ + ut_assertok(env_set_hex("fdtcontroladdr", 0x3000000)); + ut_asserteq_str("2000000", pxe_get_fdt_fallback(&label, kern_addr)); + + /* Test 4: Only fdtcontroladdr set - should return fdtcontroladdr */ + ut_assertok(env_set("fdt_addr", NULL)); + ut_asserteq_str("3000000", pxe_get_fdt_fallback(&label, kern_addr)); + + /* Restore env vars */ + ut_assertok(env_set("fdt_addr", orig_fdt_addr)); + ut_assertok(env_set("fdtcontroladdr", orig_fdtcontroladdr)); + + return 0; +} +PXE_TEST(pxe_test_fdt_fallback, 0); From patchwork Fri Jan 9 01:53:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1377 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923680; bh=lWwu9ZC4QYedr8IxSDyc716amCpO0pAoWSsPoekOrNQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ScOOwxkcIbOp2cb6gYReUVNoe0s4P9o5onJODw7I/gv4fXWATULHrHNykmYodJ7EB lOcmKZM6rMMKII9rg7qyJt9kmE0vePVnpfY2/inNSHOCSCe4Nm/ivbyeGr+CxEJeiH CbSQHfknowkQoZom3bwLhBkdsA9WGvMhL1hIp5jC/pSiGP5Od8/y83Sf/wKdn9Ls/N hleAKtXQwmhlFGPFiooyuHKZiOfPy2Y92KF3rxKzX3SeusLeMTOXO2UwiPN5FNWAh1 XAZHxeFBQT78EdMfhyscGuwIrM5a6MQ2N6Mg70+9HkrBhe1unsT52k3JrMBNSNiuUx EFRtCiZflQU9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EDFF469130 for ; Thu, 8 Jan 2026 18:54:40 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zxMy5ekbdmRu for ; Thu, 8 Jan 2026 18:54:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923680; bh=lWwu9ZC4QYedr8IxSDyc716amCpO0pAoWSsPoekOrNQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ScOOwxkcIbOp2cb6gYReUVNoe0s4P9o5onJODw7I/gv4fXWATULHrHNykmYodJ7EB lOcmKZM6rMMKII9rg7qyJt9kmE0vePVnpfY2/inNSHOCSCe4Nm/ivbyeGr+CxEJeiH CbSQHfknowkQoZom3bwLhBkdsA9WGvMhL1hIp5jC/pSiGP5Od8/y83Sf/wKdn9Ls/N hleAKtXQwmhlFGPFiooyuHKZiOfPy2Y92KF3rxKzX3SeusLeMTOXO2UwiPN5FNWAh1 XAZHxeFBQT78EdMfhyscGuwIrM5a6MQ2N6Mg70+9HkrBhe1unsT52k3JrMBNSNiuUx EFRtCiZflQU9g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DE1BF691E6 for ; Thu, 8 Jan 2026 18:54:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923679; bh=twaF0KH3hQskJyLeGxMnx4SoPRGvHzWWXkV06ebyMaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZcES3Mx+cvVztbOmMyfnnYWQhwVh4mTCPrVONoD1qDtcTkqTliE9o5U2gtsMHyt8E aI8Rgi5jowwg9kwSSJFO+g6s4chdICUGyJCun+PZ4T3sr/VLVazoKjphMSQ2Xskqah tf6/MYZkgeUsGExk8StazN2V1TuEQAAgNWbIrap3hJBoAx4evaTsdskruw3KVAM2qQ qb9nopyIeOrvmCssjaDft2b/BQC5kXu13asBFtB/jgZb7WKVgcuHnexU3wAjCulZvb Y8bpYXnGDrn4c0dUbcDR5je4H/EONKyP3YyW+NqiGCuxGFbsDzj1qbsBUqqYrHFpzx lgTw1FVOb+inQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12E0869130; Thu, 8 Jan 2026 18:54:39 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bKmPwIHrOCBJ; Thu, 8 Jan 2026 18:54:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923675; bh=WYi/V2kIyP2106m9Buvgl1b9izfMkml7mI4yNSjkVto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fND1h6dn7QurPNrR3Fwo0rGGRmrSt5hP5IjGNVbzkF+zRchTojmR607D7R2Anq8Pe KJMCULvtW46vsvR+TSA/71Mhg4nf7KVdzOisBvEzO+slPmjKoVI9pHx+77cIDFzQq2 y4XGQWGppw6kC4Xl5F/pbd0vTYmWIewqtq6E4J+Qtzn+69qtKb0ccpfEkkKSQ+5++2 kso5r1AqsPLDAl/G0Sq33rSRqwj4nceabTVnbfc1pECzErsH0hCgjxRH3+ewhyop/K ECVQmq/PsQDqnqCHSD9Gvx5b41ZEaFGTOqN/gMb5u0CD2PQOrP/jCY1/KH6z0lI2+a eNUWFETZdEiLw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B8B9D6912D; Thu, 8 Jan 2026 18:54:34 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:16 -0700 Message-ID: <20260109015323.3411528-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CG2D6RFASEV4Z2ONSQEWI25XTDH2SXFM X-Message-ID-Hash: CG2D6RFASEV4Z2ONSQEWI25XTDH2SXFM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/16] test: pxe: Add test for tpxe_label_override List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that verifies that pxe_label_override can override the default boot label, and that an invalid override prints an error message. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 51 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 7 +++++ 2 files changed, 58 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 505628ab92d..a6761ecc447 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -709,3 +709,54 @@ static int pxe_test_fdt_fallback(struct unit_test_state *uts) return 0; } PXE_TEST(pxe_test_fdt_fallback, 0); + +/** + * Test pxe_label_override environment variable + * + * This tests that pxe_label_override can override the default label, + * and that an invalid override prints an error message. + */ +static int pxe_test_label_override_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set environment variables for file loading */ + ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set("bootfile", cfg_path)); + ut_assertok(env_set("pxe_timeout", "1")); + + /* Test 1: Override to 'local' label (localboot) */ + ut_assertok(env_set("pxe_label_override", "local")); + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + /* Should boot 'local' label instead of default 'linux' */ + ut_assert_skip_to_line("3:\tLocal Boot"); + ut_assert_skip_to_line("missing environment variable: localcmd"); + + /* Test 2: Invalid override - should print error */ + ut_assertok(env_set("pxe_label_override", "nonexistent")); + ut_assertok(run_commandf("sysboot host 0:0 any %x %s", + PXE_LOAD_ADDR, cfg_path)); + + ut_assert_skip_to_line("Missing override pxe label: nonexistent"); + + /* Clean up */ + ut_assertok(env_set("pxe_label_override", NULL)); + ut_assertok(env_set("pxe_timeout", NULL)); + + return 0; +} +PXE_TEST_ARGS(pxe_test_label_override_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index f3ae3ff9f78..8462b53c8d8 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -436,3 +436,10 @@ class TestPxeParser: with ubman.log.section('Test PXE ipappend'): ubman.run_ut('pxe', 'pxe_test_ipappend', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_label_override(self, ubman, pxe_image): + """Test pxe_label_override environment variable""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE label override'): + ubman.run_ut('pxe', 'pxe_test_label_override', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 01:53:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1378 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923685; bh=8wWBCSkb6WkFJ7kMJpTW+JF1oXyFHSbLiRm3gTwNhR4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LUTa7gviEZiQL/4stN1Ym5lkMzm73HMlvGPT4EMOGj27vTZCrttsWFBchGMWXNAC4 g2Vh0cMg+qR5CV3WcsuzelJpPNo8p5iXn7mn/7+Azz2Xch2Eg0kMx7NI1UshJdGK6A 00wHcfcbqpLogbMsX9pE5TS9gDcpemzoQnWMzbWHjdP3rGI4MIYsMJi7eCDHvxcVSn 3H67/DldznyVThxb6jE/VoqYKaMl5ASO92UOFJ4sxvEVLlaeEIo0UOvtWl7Cx33pfZ Q+hKIluP1lNnUjRQ3artO47dPf/vH3qJ+nHykpkn7glJM/D6pLe+eEtRYpzkncoh6D LSh8/kLIOfdcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC5D96912D for ; Thu, 8 Jan 2026 18:54:45 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id oNYRProeC3HA for ; Thu, 8 Jan 2026 18:54:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923685; bh=8wWBCSkb6WkFJ7kMJpTW+JF1oXyFHSbLiRm3gTwNhR4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LUTa7gviEZiQL/4stN1Ym5lkMzm73HMlvGPT4EMOGj27vTZCrttsWFBchGMWXNAC4 g2Vh0cMg+qR5CV3WcsuzelJpPNo8p5iXn7mn/7+Azz2Xch2Eg0kMx7NI1UshJdGK6A 00wHcfcbqpLogbMsX9pE5TS9gDcpemzoQnWMzbWHjdP3rGI4MIYsMJi7eCDHvxcVSn 3H67/DldznyVThxb6jE/VoqYKaMl5ASO92UOFJ4sxvEVLlaeEIo0UOvtWl7Cx33pfZ Q+hKIluP1lNnUjRQ3artO47dPf/vH3qJ+nHykpkn7glJM/D6pLe+eEtRYpzkncoh6D LSh8/kLIOfdcA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B9B8269130 for ; Thu, 8 Jan 2026 18:54:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923683; bh=kB2AxMf1ib1/mJmSxmytJMVdLTeYtQVHyJzyeuOSEVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RHByOxgzoOGazEToMZmmUhaVkkONwDcIQLR/dNJ+/Q7jogcpND02VnE6Er0NDveEG +rbad3LhcaOHKXiTuochURH4sNZ4Gimo+8t8pwLcWyr/uvJy932UYXI/D5EAWq/K05 FTxN/nlEmRitqbOAG6KG89RkRxquo/IlinFPsLcPd4phD51joCt782zR49DNE6pebQ H3YAYUmRY03muXdF4mWbq703afyReS6k+Ur8zLdGEQ5i+jssHB3fRdbICJxTpGqwUv wkOFt7ldhwC2suLlDtWPNj+t0myOE9dnN7DvRK5CjHbhh6PAGuY//qvWsKS7MBMmWv 5yjM/Kj5HOsiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D5E2E69130; Thu, 8 Jan 2026 18:54:43 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id PFQaDcHLgNQV; Thu, 8 Jan 2026 18:54:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767923679; bh=mGm0MHfq/weIUZu9qa0/El1GoIM0Da8jGPzxiv2y6nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YQiCHYpBvENdbhpZ5WH0SMZIYguy4/YUXxN7TH5R3qxK18mRDUNUJb7wl552UwjW5 yuQ6d9k7sN/hEmJD86Eez/wYs58Gx3WuNi5mh4iai4xXjb29gy8DtJgS2NILuNaN/A 38nbqNSsJQjQuR+reKbT6NZSSMZ7AlZvdSuAjy2h51Khum3UyMrboBKa4k7JoNEep5 fMo0xNuYYsPVBqFPDTM7kqDvZhunvaButaaLw0T+7psPkUOa9Fi5t7jwoqx5zTlbWM hTBeYCWPxEveJSpoHT/Gwir7IPnHyriTkHPyb0jeH07QC42MNnsgaW2/ChgAGZu92b EdbbICgwA27UA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8066E6912D; Thu, 8 Jan 2026 18:54:39 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 18:53:17 -0700 Message-ID: <20260109015323.3411528-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109015323.3411528-1-sjg@u-boot.org> References: <20260109015323.3411528-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UJFI46OKANGCLNBVNALALA56J5ESBB3U X-Message-ID-Hash: UJFI46OKANGCLNBVNALALA56J5ESBB3U X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/16] test: pxe: Add test for the address-allocation path List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test that verifies the LMB allocation path works correctly when no address environment variables are set. The test uses a custom getfile callback that: - Checks if *addrp is 0 (no env var was provided) - Assigns incrementing addresses (0x100, 0x200, etc.) to simulate LMB allocation The test verifies all pxe_context fields are set correctly after pxe_probe(): - Context setup fields (getfile, userdata, allow_abs_path, etc.) - Label selection (correct label chosen) - Kernel address and size - Initrd address and size - FDT fields (NULL/0 since fdt_addr_r not set) - Boot flags (restart, fake_go) Also reduce test fixture file sizes to minimal (just the identifier strings, without padding). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 162 +++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 9 +- 2 files changed, 169 insertions(+), 2 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index a6761ecc447..9398cf5757f 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -760,3 +761,164 @@ static int pxe_test_label_override_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_label_override_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * struct pxe_alloc_info - context for the alloc test getfile callback + * + * @uts: Unit test state for assertions + * @next_addr: Next address to allocate (increments by 0x100 each call) + */ +struct pxe_alloc_info { + struct unit_test_state *uts; + ulong next_addr; +}; + +/** + * pxe_alloc_getfile() - Read a file, allocating address if not provided + * + * For files loaded via env vars (kernel, initrd, fdt), this verifies that + * *addrp is 0 (no environment variable set), then assigns an incrementing + * address to simulate LMB allocation. For the config file (which is loaded + * with a direct address), it just uses the provided address. + */ +static int pxe_alloc_getfile(struct pxe_context *ctx, const char *file_path, + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *sizep) +{ + struct pxe_alloc_info *info = ctx->userdata; + loff_t len_read; + int ret; + + /* + * Config file is loaded with direct address (non-zero). + * Kernel/initrd/fdt/overlays come through env vars - if not set, + * addrp will be 0 and we need to allocate. + */ + if (!*addrp) { + *addrp = info->next_addr; + info->next_addr += 0x100; + } + + ret = fs_set_blk_dev("host", "0:0", FS_TYPE_ANY); + if (ret) + return ret; + ret = fs_legacy_read(file_path, *addrp, 0, 0, &len_read); + if (ret) + return ret; + *sizep = len_read; + + return 0; +} + +/** + * Test file loading with no address environment variables + * + * This tests the LMB allocation path where if no address env var is set, + * the getfile callback receives *addrp == 0 and must allocate memory. + * Our test callback assigns incrementing addresses (0x100, 0x200, etc.) + * and verifies the addresses are then stored in ctx. + */ +static int pxe_test_alloc_norun(struct unit_test_state *uts) +{ + const char *orig_fdt_addr, *orig_fdtcontroladdr; + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + struct pxe_alloc_info info; + struct pxe_context ctx; + ulong addr; + int ret; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + info.uts = uts; + info.next_addr = 0x100; + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Save and clear FDT fallback env vars (fdtcontroladdr is set at boot) */ + orig_fdt_addr = env_get("fdt_addr"); + orig_fdtcontroladdr = env_get("fdtcontroladdr"); + ut_assertok(env_set("fdt_addr", NULL)); + ut_assertok(env_set("fdtcontroladdr", NULL)); + + /* Ensure address env vars are NOT set */ + ut_assertok(env_set("kernel_addr_r", NULL)); + ut_assertok(env_set("ramdisk_addr_r", NULL)); + ut_assertok(env_set("fdt_addr_r", NULL)); + ut_assertok(env_set("fdtoverlay_addr_r", NULL)); + ut_assertok(env_set("pxe_timeout", "1")); + + /* Set up the PXE context with our allocating getfile */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_alloc_getfile, &info, true, + cfg_path, false, false, NULL)); + + /* Read the config file - use a fixed address for parsing */ + addr = PXE_LOAD_ADDR; + ret = get_pxe_file(&ctx, cfg_path, addr); + ut_asserteq(1, ret); + + /* Parse and probe - this triggers file loading */ + ut_assertok(pxe_probe(&ctx, addr, false)); + + /* + * Verify all pxe_context fields are set correctly. + * + * The background BMP is loaded first (0x100), then the default + * label 'linux' loads: kernel (0x200), initrd (0x300). + * + * Note: FDT loading requires fdt_addr_r to be set (checked in + * label_process_fdt before attempting to load), so conf_fdt_str + * and conf_fdt are NULL/0. + */ + + /* Context setup fields */ + ut_asserteq_ptr(pxe_alloc_getfile, ctx.getfile); + ut_asserteq_ptr(&info, ctx.userdata); + ut_asserteq(true, ctx.allow_abs_path); + ut_assertnonnull(ctx.bootdir); + ut_asserteq(0, ctx.pxe_file_size); /* only set by cmd/pxe.c */ + ut_asserteq(false, ctx.use_ipv6); + ut_asserteq(false, ctx.use_fallback); + ut_asserteq(true, ctx.no_boot); + ut_assertnull(ctx.bflow); + ut_assertnonnull(ctx.cfg); + + /* BMP loaded first */ + ut_asserteq(0x100, image_load_addr); + + /* Label selection */ + ut_assertnonnull(ctx.label); + ut_asserteq_str("linux", ctx.label->name); + + /* Kernel */ + ut_asserteq_str("200", ctx.kern_addr_str); + ut_asserteq(0x200, ctx.kern_addr); + ut_asserteq(6, ctx.kern_size); + + /* Initrd */ + ut_asserteq(0x300, ctx.initrd_addr); + ut_asserteq(7, ctx.initrd_size); + ut_asserteq_str("300:7", ctx.initrd_str); + + /* FDT (not loaded - no fdt_addr_r env var) */ + ut_assertnull(ctx.conf_fdt_str); + ut_asserteq(0, ctx.conf_fdt); + + /* Boot flags */ + ut_asserteq(false, ctx.restart); + ut_asserteq(false, ctx.fake_go); + + /* Clean up */ + destroy_pxe_menu(ctx.cfg); + pxe_destroy_ctx(&ctx); + ut_assertok(env_set("pxe_timeout", NULL)); + ut_assertok(env_set("fdt_addr", orig_fdt_addr)); + ut_assertok(env_set("fdtcontroladdr", orig_fdtcontroladdr)); + + return 0; +} +PXE_TEST_ARGS(pxe_test_alloc_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index 8462b53c8d8..de01f219244 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -320,7 +320,6 @@ def pxe_fdtdir_image(u_boot_config): # Create dummy kernel with open(os.path.join(fsh.srcdir, 'vmlinuz'), 'wb') as fd: fd.write(b'kernel') - fd.write(b'\x00' * (1024 - 6)) fsh.mk_fs() @@ -381,7 +380,6 @@ def pxe_error_image(u_boot_config): # Create dummy kernel with open(os.path.join(fsh.srcdir, 'vmlinuz'), 'wb') as fd: fd.write(b'kernel') - fd.write(b'\x00' * (1024 - 6)) fsh.mk_fs() @@ -443,3 +441,10 @@ class TestPxeParser: with ubman.log.section('Test PXE label override'): ubman.run_ut('pxe', 'pxe_test_label_override', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_alloc(self, ubman, pxe_image): + """Test file loading with no address env vars (LMB allocation path)""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE alloc'): + ubman.run_ut('pxe', 'pxe_test_alloc', + fs_image=fs_img, cfg_path=cfg_path)