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)