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)