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()