From patchwork Sat Mar 14 23:15:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1974 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=1773530247; bh=gatashKvGBYtnnP5Cohtywo53lnck1DqYTaV901p81Q=; 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=HmMrxoB9qM5edmotYqiPSyj9UwDXhblCfClibwqcgUz4Sl+NA8g7h5JjdEzpC55rU cxZUfYkZyV27kRGKYk8R7KfloP1JeufRgoyJdRVVg0mm/uqVuOuZku9F1pAf+tWQno iBrykcPO/JFHD/D7H3A6N5MBdr6dml8am+F8A92awQb8/rE0PZUkgXaPmAa/NnaMnZ cyJeI2IajzTAdZ2rEkcv+2eii1nfA2wvv2v4yZkozT/7+hNTKtSQ/tBlCMvSjZ90UR Ht8nm97YR1n/Ciek7JZJltIy0qgRUgK3ps8hXaBw2FYAEcXT+q46N7WLQ99FwKnxqb gOEyqvceCCmDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 235D76A033 for ; Sat, 14 Mar 2026 17:17:27 -0600 (MDT) 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 D4xxRDrClbZd for ; Sat, 14 Mar 2026 17:17:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530247; bh=gatashKvGBYtnnP5Cohtywo53lnck1DqYTaV901p81Q=; 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=HmMrxoB9qM5edmotYqiPSyj9UwDXhblCfClibwqcgUz4Sl+NA8g7h5JjdEzpC55rU cxZUfYkZyV27kRGKYk8R7KfloP1JeufRgoyJdRVVg0mm/uqVuOuZku9F1pAf+tWQno iBrykcPO/JFHD/D7H3A6N5MBdr6dml8am+F8A92awQb8/rE0PZUkgXaPmAa/NnaMnZ cyJeI2IajzTAdZ2rEkcv+2eii1nfA2wvv2v4yZkozT/7+hNTKtSQ/tBlCMvSjZ90UR Ht8nm97YR1n/Ciek7JZJltIy0qgRUgK3ps8hXaBw2FYAEcXT+q46N7WLQ99FwKnxqb gOEyqvceCCmDg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 101D769FF7 for ; Sat, 14 Mar 2026 17:17:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530245; bh=Alsjox4IhapxWSp9pueIEDvFUxz6O3TSTotAoirtx/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gVpwEuCIlma6N8fwonPIrF7oN6n7moxNYJiORog3Wk/1UPzl1zygMNpUANv75eZs2 CCmNVMKfI8dG7thzpEUdrgtVN3fua0bnzcVEFnMixb7YV8TcaZ4Tzvbr3K4ueqtLbM f0thdITg8zxQAmzrtgjAVaYwjjR5miwel4qXIrYEpgbFvt1KangHyicphbqwFnk9AV +qGgb1xIUq120OLVUSEXT6PbAm5T+LcjTeo5RzXQNp1GjeEjqf79gLA9ZH3ihJlR5Q gYWGn2WiaR7PKbKIsi61SVTuE85ZzIMvZrYXMsGD/B8vM9zVoRqE4u3IX6Gi5Kk+mM TrLaDHH1ymcVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A7D6E69FF7; Sat, 14 Mar 2026 17:17:25 -0600 (MDT) 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 yQn9MA5yL-lf; Sat, 14 Mar 2026 17:17:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530245; bh=cZ3IqyNu75VuSyxUYIdRPG35ZXbl1llvyl/WIF+Fago=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTCp4PEgpEVgNOJR3buBd+mWsJh9w42iQ7lBY22G38WGRZ82UMm66RddL7F0gjlpW RBdiBOPJIhTrMCXlbqzM4WVhjjOm7twU2I4uqQwADcbUk5EV+20RJlcJvy5WJKMZwN ahlJsJ4jYti8tebFJOuqln32jaHTbfqs4AUDqP3nCzkU22RHqsgbaIDaqZDSr1xnHa RjK66sGERsCDLXVaQb/x4bMJxf+wejRN3dXUaIL+bpckw/JkFHyREGNVydFQmSgRTH Sk/TjcZicmrOgEz8TTzVHwSJkD6ykKtwrW/9SKpf1UfnYbPQC7wagf79MOYlfgkP2b Oibv5a2MJ9nmw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0F73169ECF; Sat, 14 Mar 2026 17:17:25 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:52 -0600 Message-ID: <20260314231618.338113-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: F2ZM6S47ANM6NJ3TWL2N36GGTGGAIHYR X-Message-ID-Hash: F2ZM6S47ANM6NJ3TWL2N36GGTGGAIHYR 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/19] sandbox: Pass exit code through sandbox_exit() 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_exit() always exits with code 0, discarding any error from the caller. The -c command path worked around this by calling os_exit() directly, bypassing state_uninit() and losing cleanup such as writing the malloc dump. Add an exit_code parameter to sandbox_exit() so callers can propagate errors while still getting a clean shutdown. Update all callers to pass 0 except sandbox_main_loop_init() which passes the command return value. Signed-off-by: Simon Glass --- arch/sandbox/cpu/cpu.c | 5 ++--- arch/sandbox/include/asm/u-boot-sandbox.h | 2 +- arch/sandbox/lib/interrupts.c | 2 +- drivers/sysreset/sysreset_sandbox.c | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index d6177fbbd14..791af49464b 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR; -void __noreturn sandbox_exit(void) +void __noreturn sandbox_exit(int exit_code) { /* Do this here while it still has an effect */ os_fd_restore(); @@ -28,8 +28,7 @@ void __noreturn sandbox_exit(void) if (state_uninit()) os_exit(2); - /* This is considered normal termination for now */ - os_exit(0); + os_exit(exit_code); } /* delay x useconds */ diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 941f35f9e69..60fb300f623 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -41,7 +41,7 @@ struct udevice; void sandbox_reset(void); /* Exit sandbox (quit U-Boot) */ -void __noreturn sandbox_exit(void); +void __noreturn sandbox_exit(int exit_code); /** * sandbox_init() - init sandbox diff --git a/arch/sandbox/lib/interrupts.c b/arch/sandbox/lib/interrupts.c index 3f6583e11f0..e9207b82032 100644 --- a/arch/sandbox/lib/interrupts.c +++ b/arch/sandbox/lib/interrupts.c @@ -53,6 +53,6 @@ void os_signal_action(int sig, unsigned long pc) printf("resetting ...\n\n"); sandbox_reset(); } else { - sandbox_exit(); + sandbox_exit(0); } } diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index d126fad0372..6739ecbd92f 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -63,13 +63,13 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) state->last_sysreset = type; if (!state->sysreset_allowed[type]) return -EACCES; - sandbox_exit(); + sandbox_exit(0); case SYSRESET_POWER: case SYSRESET_HOT: case SYSRESET_TO_FIRMWARE_UI: if (!state->sysreset_allowed[type]) return -EACCES; - sandbox_exit(); + sandbox_exit(0); default: return -EPROTONOSUPPORT; } From patchwork Sat Mar 14 23:15:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1975 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=1773530251; bh=imyl06+0O+tINyF/l8ltI/lVExxyA9oAy0v7i+ctajY=; 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=Fov/D/LHiL13E0ady/IXAW2NrNkB7POY3hX+03j7OQpRj7W+EFIfZaEW5SpP9OMks UqJ1QG2r3ZwVQZ13tVe1HqR4BcSNwpxaM9bsGhKm3FLCNNw4M3Lw/z7J7zbVUjM0PB bLUUaTEBu7vUWcr1lZ9UBeYNx+6NpW4HppJ/96W3CvtslN9yi30jp8KeGNHYDjIMIB WQ9UFsTdw2osIWFvMb9zjJrs9eeoHNXkG23wabEps3rvzu8775YVYkRRy/ngOqfEiq 3+4zbNN+xp/m9439VuhRGY6R+vVFPQH3m8kSw3Ws0V4VKUOCHn5k6M6abYoy8B4zO3 GeBgyZ/4WwbGA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B84A06A033 for ; Sat, 14 Mar 2026 17:17:31 -0600 (MDT) 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 jIt6d6zJ0J2u for ; Sat, 14 Mar 2026 17:17:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530251; bh=imyl06+0O+tINyF/l8ltI/lVExxyA9oAy0v7i+ctajY=; 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=Fov/D/LHiL13E0ady/IXAW2NrNkB7POY3hX+03j7OQpRj7W+EFIfZaEW5SpP9OMks UqJ1QG2r3ZwVQZ13tVe1HqR4BcSNwpxaM9bsGhKm3FLCNNw4M3Lw/z7J7zbVUjM0PB bLUUaTEBu7vUWcr1lZ9UBeYNx+6NpW4HppJ/96W3CvtslN9yi30jp8KeGNHYDjIMIB WQ9UFsTdw2osIWFvMb9zjJrs9eeoHNXkG23wabEps3rvzu8775YVYkRRy/ngOqfEiq 3+4zbNN+xp/m9439VuhRGY6R+vVFPQH3m8kSw3Ws0V4VKUOCHn5k6M6abYoy8B4zO3 GeBgyZ/4WwbGA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A6E6C69FF7 for ; Sat, 14 Mar 2026 17:17:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530249; bh=eT5xQ5yqjCly0rOKn4BpzsLdSwaw3S8tQEG+Z8g673E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iO3KXD7TWJ1l93H9hlCqd2Fe1yNkcdAry2RIvqvkWoY+Mph2BFzLaREx132H5rUmz aBaFuN/gHF/KAe8H24tr3IqVVqdFGZRYftfbVXeyHeWIEpTRSBdEujJJjsTMvs/wWz I7q+MeQxz6Fta11YNtEe0jk/oZsyG2xsK24VKdO5irZMdPEY5/5JxVcXo0/Cfzf+KS F0nRsCJptpzyiXXC3tNYw1XKaUQ9gblWtYbpxMhTpYs+SR1dlPHBgKBzkrmuLuayBQ gN76OVK1B9St83+h48cVKO9+1n0Yf5V12yKiT1VrigFUF+97Fmiy4nkuD+GfF3p796 SSxDoDYKaCZ9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 81E026A033; Sat, 14 Mar 2026 17:17:29 -0600 (MDT) 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 BSGyyafa7fnh; Sat, 14 Mar 2026 17:17:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530249; bh=rmrLZbhZEpLhvg+58PehJttkr5el9YAZLdHhOSXZn98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCjN19xDkI0TMLgRQfHPiMmnTiAUeGtJ3sVNaDXIxTD+SjP5BhfyJnZx+MEyoYCms f2HC6EpUmwakKmrDSrJY2OU/mPXm0g6nk/1zwYHN5SL53Ap01kK3YIRcWY1vSZTr2T 3gU0PuZvKsanpx4rZZ0Y2vBgpvHF5831S7NRyMMDIZLgMie40mesx+CamjRbPkVdge R9k5KM62rJ06UvboGwOwX3CuNE3vvUKzk1RWD5BYxgGjPmHS3Imo0IILCqeS6JCE0A DHtPDpkdx4LPYVqhFJ/tyysMDxJMGmMlueLZKoKorGW4dDQY+ZprZRaBuJP3ls17ir BEgZaNckaIM8Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CA5B46A032; Sat, 14 Mar 2026 17:17:28 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:53 -0600 Message-ID: <20260314231618.338113-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2XS5YVUWDMQADSUN7UDJRDWXLQNFWNMF X-Message-ID-Hash: 2XS5YVUWDMQADSUN7UDJRDWXLQNFWNMF 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/19] sandbox: Use sandbox_exit() for -c command 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 The -c command path calls os_exit() directly, bypassing state_uninit(). This means cleanup actions like writing the malloc dump are skipped. Use sandbox_exit() instead, which calls state_uninit() before exiting. Now that sandbox_exit() accepts an exit code, the command return value is still propagated correctly. Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index b9f48376d22..7c9f0a99654 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -158,7 +158,7 @@ int sandbox_main_loop_init(void) 0); #endif if (!state->interactive) - os_exit(retval); + sandbox_exit(retval); } return 0; @@ -583,7 +583,7 @@ void __efi_runtime EFIAPI efi_reset_system( unsigned long data_size, void *reset_data) { if (reset_type == EFI_RESET_SHUTDOWN) - sandbox_exit(); + sandbox_exit(0); else sandbox_reset(); } From patchwork Sat Mar 14 23:15:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1976 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=1773530253; bh=t8209i1v4/yArbq9lPzKTuM/60Zid2S416JV2NT0f9E=; 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=Wj6NL8duWGRUVl7GkecrZRnVOyP/5TrEELMtQ3t06VnRkA4JHxCSHNlg19hB7HnDC 1u3bWvJq5pAlakrT3hFr4c9caHBAhjebVp5MHPcVntRp56lHkSvQ812ao4SoISCIS4 rKG5Kw2jj+Nctj6Uiu+80s115BMUr6hzmCvDzSEb6WQ8zptCH0nt4uV4MYmiPzC2bv 4XVi7t39Vqhda4TxuIGdYsfNQT7Wz4MJIYRWL8UV9fwEVH1nVj1SsZyt20EnT4anVt KsqRt8WY0X6jypNmM5grJR40bb0K5prT5WR4Qi9/XgneEAHtKDvqgtyA0auyIP74wG 4emAMUnymX//Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4778C6A042 for ; Sat, 14 Mar 2026 17:17:33 -0600 (MDT) 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 jH694yIR1xMU for ; Sat, 14 Mar 2026 17:17:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530252; bh=t8209i1v4/yArbq9lPzKTuM/60Zid2S416JV2NT0f9E=; 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=D3d6PlQFhxptd1dT1KW+ipeGL24ItPBip2EpwPBZAXRiXzJEBUvvOnPShKwSoZNm6 Z/UoWBO9h86fQcln0H1ORcd8/kb3x/7qwtw2jAp+P+GPbli/Yb1MgJph7glJR9WyWC hH2epU9tYZOk2updcr4wMS3iXfiMWSWz0iHMtVePasR6DEqQK65yLeGx87rhQYF4fe +A9Pipfe+1LsT8h+D9irKSxiGekFcfzGGxVGx/FjNGwHRigQZHkbop6HJRL2IJESPb E5d75qMGuEaw1HEyg3MX+XQ+DLuCiy4PR6+Iuq4EoJI38c4kVHv6hs2a/vai+Ad4Hk nhgMfMhIEbjsw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D46716A036 for ; Sat, 14 Mar 2026 17:17:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530250; bh=xHHeRURUh/kKkfxdFhY6yDkCpQTcstT94tRYzzK/Us8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOr4tlPbJJ/0nk+O828N9+KxvHCaBDCIpWDunfu/GPruADDXjzR2uYuUqRHqJxkdv ELPnQ8YEsv5OJnc/yyx1/afFYNEYqqYyxDpgjvS2K5u84jOcSH0g6/DHYrXH9erOeK eoINQMsojEjF9aepMie3bQ9gGbQS0JABvPONquC9t6rmYQ4Wv+w2AI58yaU/Xn+pME RcBf/YY9VZbGtJ3iw8WT+lRMtvAYxya2qeFhjgvgRUYlzy5jqyDS8lCl1/YPGHvZ+N BuxfEPSqcmTzdzOuT73XbdDjrMtSeavkgF6ek7hHIQQkmd4lB4bk3h0zpBcHW2uWIy ULuMcHja2loAg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 128E869ECF; Sat, 14 Mar 2026 17:17:30 -0600 (MDT) 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 kX-xQxqZfWaJ; Sat, 14 Mar 2026 17:17:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530249; bh=lHtDSCIhTNxayIm1o3gYvn37XP6NQfsUr0aJbYCKJcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ofbE7q8EbcAIBob35L0+iiF39hwNPnW7tj4RWK8t0GogwWBvFeaTecc67IGeCaRri WFEOl2kfZAtB2jmNhnrHCp4PWDCHFwRptYpH4Cl3lSzXaKWm0nm1bzKD19bIzNExrI Ktu4YebFiVjflnlC4W+xPqBA9aqSVWjtO9RuGNUGZ6sasG5OlQy9qE/TD5yD3bp8fw YR3/z+n08e/3gNmi4EK8/IYPK/wFwpRYwsawyCCWIzbZnglUGRNhQasXwgQJKxxchi KeGq1jZL2RbYqVc2lEXDTWii7oM6q8BDbqf+IA3ggbOcIVZkIf2Wtms3Mz+JntCRCe 6o9YsuGxkuRww== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8376B6A036; Sat, 14 Mar 2026 17:17:29 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:54 -0600 Message-ID: <20260314231618.338113-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DBTTNQNJ4SMPLF7GQCPZYS7LBQF6HAWZ X-Message-ID-Hash: DBTTNQNJ4SMPLF7GQCPZYS7LBQF6HAWZ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/19] sandbox: Add a command-line option to dump malloc state 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 --malloc_dump option that writes the heap dump to a file on exit. This is useful for debugging memory leaks in test sessions. The dump is written from state_uninit() which runs on clean shutdown (poweroff, reset). The prototype for malloc_dump_to_file() comes from os.h, avoiding the asm/malloc.h conflict. Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/cpu/state.c | 3 +++ arch/sandbox/include/asm/state.h | 1 + 3 files changed, 13 insertions(+) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 7c9f0a99654..caa9b61dcd9 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -553,6 +553,15 @@ static int sandbox_cmdline_cb_pager_bypass(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(pager_bypass, 'P', 0, "Enable pager bypass mode"); +static int sandbox_cmdline_cb_malloc_dump(struct sandbox_state *state, + const char *arg) +{ + state->malloc_dump_fname = arg; + + return 0; +} +SANDBOX_CMDLINE_OPT(malloc_dump, 1, "Write malloc dump to file on exit"); + static int sandbox_cmdline_cb_bind(struct sandbox_state *state, const char *arg) { if (state->num_binds >= SB_MAX_BINDS) { diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index e492855755b..fd31d93c500 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -544,6 +544,9 @@ int state_uninit(void) if (state->jumped_fname) os_unlink(state->jumped_fname); + if (state->malloc_dump_fname) + malloc_dump_to_file(state->malloc_dump_fname); + /* Disable tracing before unmapping RAM */ if (IS_ENABLED(CONFIG_TRACE)) trace_set_enabled(0); diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 001d780aec8..8707d798d8d 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -184,6 +184,7 @@ struct sandbox_state { int video_test; /* ms to wait before next assert */ const char *video_frames_dir; /* Directory to write video frames */ int video_frame_count; /* Number of frames written */ + const char *malloc_dump_fname; /* File to write malloc dump on exit */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] From patchwork Sat Mar 14 23:15:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1977 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=1773530253; bh=mkgZu8V8WwA8P2o+0mklPAesgql1sOdk+u/uCZzKRjs=; 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=rTBhP7ksIALTnVmSCiQYFuB2VeQ/TZxwNPovYLG4FclT9J3OWu6GmmWs0RZt887gl XLFr6O0dYzPmePHUxni4vTnmw1rHTad8l0n8OFt0NlWDn26MOCU3lWnmwQZpCalQiX arxX5jb1H4zJBMnf1HYhlq3a1avnhrCCCOFy0eJ7tojZJhOWlWxfov3PzoDcr3Rp+F pJK9kY+U6Tvv3uf+/ZnnpYgiyRBWZWao79wc2clwy76yIUlLR8AwcBNqL2EMUyZUTh XKRwXY/KcS7ZQjCt33EJXES1uaK7BlsCZWm4vI2BwzezSvfBT/AgJ89HpdL+13oyfa YUsQC6W2mxT2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CB6AE6A033 for ; Sat, 14 Mar 2026 17:17:33 -0600 (MDT) 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 AtPr1ooqXRwR for ; Sat, 14 Mar 2026 17:17:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530253; bh=mkgZu8V8WwA8P2o+0mklPAesgql1sOdk+u/uCZzKRjs=; 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=rTBhP7ksIALTnVmSCiQYFuB2VeQ/TZxwNPovYLG4FclT9J3OWu6GmmWs0RZt887gl XLFr6O0dYzPmePHUxni4vTnmw1rHTad8l0n8OFt0NlWDn26MOCU3lWnmwQZpCalQiX arxX5jb1H4zJBMnf1HYhlq3a1avnhrCCCOFy0eJ7tojZJhOWlWxfov3PzoDcr3Rp+F pJK9kY+U6Tvv3uf+/ZnnpYgiyRBWZWao79wc2clwy76yIUlLR8AwcBNqL2EMUyZUTh XKRwXY/KcS7ZQjCt33EJXES1uaK7BlsCZWm4vI2BwzezSvfBT/AgJ89HpdL+13oyfa YUsQC6W2mxT2A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 67F106A03A for ; Sat, 14 Mar 2026 17:17:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530250; bh=0yMS5iUD2FCgULW3JgYPbrwE6HLLEGefgzb/OfT6HfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWrr6znYHY95WAlA3ilCdKnN/JuG6Neqyf52bcLfduNijwsbwzyzdvZqBDFgGPO32 wZFP9oKzWGhE5EaeCHM+LgDqT1rZ9BbQMnINertyk+f6QmYrmEoc2YIfxpSEkNC8qF hGDnwzVGVE5ZoQgEk79wYISGvrPHFqSB1aUaqfvINFN3/jsdIqj1ZyW+nUBzF9EgS9 zgxwpk6Uno/b0koWXGeKiVYWM94LVBMOUyMYhmyLMlf4mdif42sAHLvEi79kDHxx+F N9ku0Bavb2V+L4C20WEqtG2Fw00NjpoX936Wvowq5y0PninxFwFB87cz8GOaJd5dcY NvcjpPtn9Rq/g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BC6A769ECF; Sat, 14 Mar 2026 17:17:30 -0600 (MDT) 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 5eExhYeDbI4a; Sat, 14 Mar 2026 17:17:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530250; bh=/de3gpSlObIRDTMSufbUgeqdfK9cUK17u8OXWptI4zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiyUOnuAdJL7iVxlXVK1wVzDWERW/jFRrK2guQMHulJJ2TWAcE2Bl+yjJXireGARb q9H5HBni+4xeQaf5CrQTzXMV6DNAK9bkXm4Mf+sENFUOZ6DKL6UALioGUfMQTYJ+c5 aiYBrtVS+x+siiLjfCrzvdY4XV+kCh9EVcGrqbKu1Z1aYUBf3a0Akn3UUv7N/pi6ew TcrPkMxP/6yDtvgLw37GXe3D1xBpiMgONbUCGeDy+sEjCTpWERzSQuDnimtnSItkV7 GNdmBQAKlkgZeslHTGGY/xBAqsA7cJdrLIltDn002oRvv+wCGyySGgE13CIvPfZCvU 1OOjbYDEcJ/5w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 50D1C69FF7; Sat, 14 Mar 2026 17:17:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:55 -0600 Message-ID: <20260314231618.338113-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3OQK6TWO7DZIKRCRT6SDOTNCBKHUB5GY X-Message-ID-Hash: 3OQK6TWO7DZIKRCRT6SDOTNCBKHUB5GY 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/19] sandbox: Move malloc_dump_to_file() prototype to os.h 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 This function is only available in sandbox builds and uses os_open() and os_write(). Move its declaration from malloc.h (which conflicts with asm/malloc.h in sandbox files) to os.h where it fits naturally alongside other sandbox host-file operations. This allows sandbox code that includes asm/malloc.h to call malloc_dump_to_file() via os.h without a forward declaration. Signed-off-by: Simon Glass --- include/malloc.h | 11 ----------- include/os.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/malloc.h b/include/malloc.h index 3deb90b2a0b..610289f3a6c 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -712,17 +712,6 @@ void malloc_disable_testing(void); */ void malloc_dump(void); -/** - * malloc_dump_to_file() - Write heap dump to a host file - * - * @fname: Path to the output file on the host filesystem - * Return: 0 on success, negative error code on failure - * - * This is only available in sandbox builds. It writes the same information - * as malloc_dump() but to a file instead of the console. - */ -int malloc_dump_to_file(const char *fname); - /** * malloc_log_start() - Start logging malloc traffic * diff --git a/include/os.h b/include/os.h index bc556f2195f..41e3022657c 100644 --- a/include/os.h +++ b/include/os.h @@ -546,6 +546,17 @@ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep); */ int os_unmap(void *buf, int size); +/** + * malloc_dump_to_file() - Write heap dump to a host file + * + * This is only available in sandbox builds. It writes the same information + * as malloc_dump() but to a file instead of the console. + * + * @fname: Path to the output file on the host filesystem + * Return: 0 on success, negative error code on failure + */ +int malloc_dump_to_file(const char *fname); + /* * os_find_text_base() - Find the text section in this running process * From patchwork Sat Mar 14 23:15:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1978 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=1773530256; bh=6oU/3eF1r4dCXecOmamHG3y0ucii5cIc9Xu9Ad+imqE=; 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=QTJRSpDFiYFW4J6qeboPe54ViE4KsCwtg/MCwpJGrfOrjBRKRIH1ETcrlWbtgkkDh lymzaz371pMIOjaP4bPF2oKIxJwh4ptiNF1+UWH8MeOrNN7vEA06nxYhW8lv29P96M Ak9PNMVnSJ5gZFaRxr7shYI7cmnYaR/sqhChysKhW5B78qMKi6/rSyOym4c184jj33 5EJ9Cm6mYjf6tVFp9aXlwLLhMd9YUATsZ8KxfGnPkKEX0+ltm1I6eolHpxYncMoKXf y0aExM6fc5Dpu+K1/C1evisC+QTxpqHEqF34mBWMPBoHNW+GuGVwv9d/szCW7D8Vr0 XhLmzgHtCJuYA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 647F56A031 for ; Sat, 14 Mar 2026 17:17:36 -0600 (MDT) 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 QdxRQBjJ1uxX for ; Sat, 14 Mar 2026 17:17:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530254; bh=6oU/3eF1r4dCXecOmamHG3y0ucii5cIc9Xu9Ad+imqE=; 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=JiFc3Fg4dxgbSE1YjeqHAT/E4N8GT6Th2eWp+QsgLfXVQUl8GCZURu4ppfCmZTUhT B4K/eG0ascDxq4f0NELmlinOlXY18j2MP2W0xW6QGik5rwBVGP5h9UjUvFDD0cvHJV MUJibEEOQY7lLyOcmjq3I/Rz+58t3NzMzD7dUozrPiGwx7hzQkRdwXwLU6HvGsgQB1 7QpJZF8TK3EbmHwU+WUeyTcRsDfjTAcdzErLg1o/rm9t3vZSwGK2wSQGvSW/CfSBjb 2AQWS4cKIT3n2Ec1kUCSJMfUoGEs49Vwijqnj+CB41y+8X/m8/zLew6dBDKF87KcdZ 5L6IVG0Mz0wJg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3BF0B6A03F for ; Sat, 14 Mar 2026 17:17:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530251; bh=8p+FcmxmqZKewUu0alPHC+ENvQcSiVZ+jDs0CiD1A74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IoN3AU48gbQI7xI2sLbZNcTCa2m/vBANAhOvpEI2hOJCnG2gjfCKb/6Yr05CdjDn6 v1mRVGpndnMnR/N4231T46Uwwe0EwuqDnhsgUvf0jkXD2CkoC0ebNRW+2gFFYKAkB0 pWS6DqUUryc3zdimsP3HValRGAHhNzhu4o8gqmSIC+lt+xpGm7JkYFxHPHyZe+Bljf VdmKJuJmxV8EdtvVbApvce8fAV4/kXJuMMKd7RyM/zEJJvSS5WySzoH9L0VunqZhDB T+QlhDJ7eguEJ/5WubyCowG4ErQlbdxeSzDLG4Kov2uvdLukZ9VuwcX1hs3MfCkoSV HZtRVc4n6QUEw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98D2C6A031; Sat, 14 Mar 2026 17:17:31 -0600 (MDT) 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 apIFwciFBKoV; Sat, 14 Mar 2026 17:17:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530251; bh=9p7XhBRfK4UwfORhjXK0GHPAfsw02HHpkbx7QpKidnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZK4F/bDfeAg6uX6WBM0kzkxtJz64P2SpvOoX800Y8xHrbLk0Ux8DagaQSSQztRnH 1coGwD6hPvEVRxWt1QHKmH+/JPuczOdJU+AGzC8NA9TmElNsqe3pL15x7Oup9urFi9 iGgRP9RVdoOXMfRW6QwnG1C9SvEvYZBV4a+aioSUvQ2LbmTTlnjo6+PogKMMhswC1+ VYzPs3dkeooGGFrrHWtMEaT4jqLG6Omj5gDkkRtgmway3D/Ke8XgkcAkyUCplr59ht dLIJYrl8mryf+w4NuZC2JBRUFzce1M9pXjr+SoqY0kc/M0R7qp100cWg9Fz7MoF5pe jTx0/EPZeO3SQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 08D3A69FF7; Sat, 14 Mar 2026 17:17:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:56 -0600 Message-ID: <20260314231618.338113-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6KVHUE42V2JPTVFB3WRC5C4CEMVIXER7 X-Message-ID-Hash: 6KVHUE42V2JPTVFB3WRC5C4CEMVIXER7 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/19] bootstd: Fix memory leak in bootflow scanning 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 When bootflow_check() fails during scanning, bflow->name and other fields allocated by bootdev_find_in_blk() are not freed before the next iteration overwrites them. This causes a memory leak of about 1.2 MB across ~7,280 iterations in a typical sandbox test run. Add bootflow_free() calls in bootflow_scan_first() and bootflow_scan_next() to release the failed bootflow's resources before retrying. Place the free after the BOOTFLOWIF_ALL early return so that callers requesting all bootflows still receive the populated bflow. The subsequent bootflow_check() reinitialises the bflow via bootflow_init(), so there is no use-after-free risk. Signed-off-by: Simon Glass --- boot/bootflow.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index 0511d7f6cb8..befe507af96 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -660,6 +660,7 @@ int bootflow_scan_first(struct udevice *dev, const char *label, return log_msg_ret("all", ret); } iter->err = ret; + bootflow_free(bflow); ret = bootflow_scan_next(iter, bflow); if (ret) return log_msg_ret("get", ret); @@ -693,6 +694,7 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) if (iter->flags & BOOTFLOWIF_ALL) return log_msg_ret("all", ret); } + bootflow_free(bflow); } else { log_debug("incr failed, err=%d\n", ret); iter->err = ret; From patchwork Sat Mar 14 23:15:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1980 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=1773530259; bh=T2bdfk7VlG6gY5NzSfRBVpAE/FQdjwXW55qay+Rjba8=; 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=ZNyObd287YNjebET7d+JolDUxHKu1fT/djKUhmy6fWpykwFE3CYukgP8+lUrrRqug PiwbJJtxYmmTN2XPpaLqOFXgpGcQKh3Ct/9jj81g5Ml/EcMEBjf0DWbJZXcBwn6K7w U5/ZGiMVoxqhPhm6EXWtBR970FUwV2eaZdHjvQqdUSEdppOtQRlJZjqFSfpn334h8f vmxsygN89EywLfxiMMN7pzSbaP1Y+2kzm7uyIzgS0m8ZD4rLYPyOPUiJJ3ZyfWC18X IvIJvRcLIfMk5ps/7CL9fVL3MMsBomaK71mSe5TOGWC6MuehzejFaOGv0y8mGJKyGI Ed5AzXVrxJ4oA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E92B6A031 for ; Sat, 14 Mar 2026 17:17:39 -0600 (MDT) 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 78qC4uQvkt0a for ; Sat, 14 Mar 2026 17:17:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530259; bh=T2bdfk7VlG6gY5NzSfRBVpAE/FQdjwXW55qay+Rjba8=; 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=ZNyObd287YNjebET7d+JolDUxHKu1fT/djKUhmy6fWpykwFE3CYukgP8+lUrrRqug PiwbJJtxYmmTN2XPpaLqOFXgpGcQKh3Ct/9jj81g5Ml/EcMEBjf0DWbJZXcBwn6K7w U5/ZGiMVoxqhPhm6EXWtBR970FUwV2eaZdHjvQqdUSEdppOtQRlJZjqFSfpn334h8f vmxsygN89EywLfxiMMN7pzSbaP1Y+2kzm7uyIzgS0m8ZD4rLYPyOPUiJJ3ZyfWC18X IvIJvRcLIfMk5ps/7CL9fVL3MMsBomaK71mSe5TOGWC6MuehzejFaOGv0y8mGJKyGI Ed5AzXVrxJ4oA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 086836A042 for ; Sat, 14 Mar 2026 17:17:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530256; bh=ubYCvsU/UyxsCRhbt+C+eErxlakF8LkQ7stJ4vxdwOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y7nPwqUWTXuQeL9lztdLd7zhDI2pM4THlPlKMdukP3jBCcYpLZRnanDRZh77QmRkC 63qyKiAoPQF1HTGKDo+Vyncymy25ogUf9gJmoFEhl5SwJojxLcyujWXyLUWLP10WKn UggV1EyW5cjl3L7GbaO9sdrUum3K+wkKQnzlOHs7CbrVqGizEL2u8+Dq63ZFlW+8ou USJVV6xUjvvuUgHY2nRb5cR940RmItEJLBLs97FJL0zmZLy39k04sUZcwvE+Gsfq8j KhjbcNKYkDNzOlnSfLxH3DKA9dxpcB3vUDuFHObX4K3Z3hhsI4bH7DzCmJiZEq3TZV g2Rnd5ESKGqKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 320AC6A03C; Sat, 14 Mar 2026 17:17:36 -0600 (MDT) 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 HvcJ_srlgzqn; Sat, 14 Mar 2026 17:17:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530252; bh=tgAdAsw7BYTVgsbR/WJ3eDP1Rpbf/tMj3UlL0CQZhtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MkrsLfXn7Kx6zFwXKnnMk96hUnpsQVu4Fnnn9yx6VVbweiiPnQAzs8CO/BVbsPoRA UcNh3Jbxv/azw3I4ktvEmQ5Gll/dGv9ORcV5+dgUgU/Z11C8CQL45LPUVNyyhv6v66 GKVdHuMLlsjQUJtSCtciFmEeitXqP0EYOOTvY8nyn+5zmXTtOGfhU/6Nupc2ElaoQA 1rR7xVY0oEbLdnZ/fHcfvKU3CdIPjv49BweQn9nngrgLgFFO/aEgD0SnC9NBqqqVwR gF5ooe/0p1RKdSJM4dAPY6oZPgLv1aAgpPLQoLAl4Go1uuVE2Oogl7Wx2KlRsb3BR5 GCILi9g3TwOmQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D1ED66A037; Sat, 14 Mar 2026 17:17:31 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:57 -0600 Message-ID: <20260314231618.338113-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DDE65ZEA3JZ5LN2VCFS5LDLSO76PBMRD X-Message-ID-Hash: DDE65ZEA3JZ5LN2VCFS5LDLSO76PBMRD 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/19] test: py: Add a marker for tests that restart U-Boot 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 Some pytest tests restart the U-Boot process during execution via ubman.restart_uboot() or ubman.restart_uboot_with_flags() This can be undesirable when debugging the pytests, since you have to reconnect gdb many times. Add a 'restart' pytest marker to all such tests, allowing them to be excluded with some like -k 'not restart' The marker is applied to individual test functions or to test classes where all methods perform a restart. Signed-off-by: Simon Glass --- doc/develop/pytest/usage.rst | 20 ++++++++++++++++--- test/py/pytest.ini | 1 + test/py/tests/test_distro.py | 4 ++++ .../test_capsule_firmware_fit.py | 1 + .../test_capsule_firmware_raw.py | 1 + .../test_capsule_firmware_signed_fit.py | 1 + .../test_capsule_firmware_signed_raw.py | 1 + test/py/tests/test_efi_fit.py | 1 + .../py/tests/test_efi_secboot/test_authvar.py | 1 + test/py/tests/test_efi_secboot/test_signed.py | 1 + .../test_efi_secboot/test_signed_intca.py | 1 + .../tests/test_efi_secboot/test_unsigned.py | 1 + test/py/tests/test_efi_selftest.py | 6 ++++++ test/py/tests/test_eficonfig.py | 1 + test/py/tests/test_fpga.py | 1 + test/py/tests/test_fs/test_erofs.py | 2 +- .../test_fs/test_squashfs/test_sqfs_ls.py | 1 + test/py/tests/test_help.py | 2 ++ test/py/tests/test_log.py | 1 + test/py/tests/test_reset.py | 2 ++ test/py/tests/test_sandbox_exit.py | 4 ++++ test/py/tests/test_saveenv.py | 1 + test/py/tests/test_spl.py | 1 + test/py/tests/test_stackprotector.py | 1 + test/py/tests/test_upl.py | 1 + test/py/tests/test_vbe_vpl.py | 1 + test/py/tests/test_vboot.py | 1 + test/py/tests/test_vpl.py | 1 + 28 files changed, 57 insertions(+), 4 deletions(-) diff --git a/doc/develop/pytest/usage.rst b/doc/develop/pytest/usage.rst index 9e9cc38c9b2..087acded0d8 100644 --- a/doc/develop/pytest/usage.rst +++ b/doc/develop/pytest/usage.rst @@ -236,9 +236,10 @@ protocol, or any graphical wrapper around gdb. Some tests deliberately cause the sandbox process to exit, e.g. to test the reset command, or sandbox's CTRL-C handling. When this happens, you will need -to attach the debugger to the new sandbox instance. If these tests are not -relevant to your debugging session, you can skip them using pytest's ``-k`` -command-line option; see the next section. +to attach the debugger to the new sandbox instance. These tests are marked +with the ``restart`` pytest marker, so you can skip them all with:: + + test/py/test.py -B sandbox --gdbserver localhost:1234 -m "not restart" Command-line options -------------------- @@ -606,3 +607,16 @@ set), since the locally launched QEMU is not available in that environment: .. code-block:: python @pytest.mark.localqemu + +The restart marker indicates that a test restarts the U-Boot process +during execution, e.g. via ``ubman.restart_uboot()`` or +``ubman.restart_uboot_with_flags()``. This can be used to skip these tests +when a restart is not desirable: + +.. code-block:: python + + @pytest.mark.restart + +To exclude these tests from a test run:: + + test/py/test.py -B sandbox -m "not restart" diff --git a/test/py/pytest.ini b/test/py/pytest.ini index bebb22cd3d6..a3a8aaf74b5 100644 --- a/test/py/pytest.ini +++ b/test/py/pytest.ini @@ -15,3 +15,4 @@ markers = singlethread: Cannot run in parallel role: U-Boot: Indicates the lab 'role' which can execute this test localqemu: U-Boot: Test launches its own QEMU, skip in lab mode + restart: U-Boot: Test restarts U-Boot during execution diff --git a/test/py/tests/test_distro.py b/test/py/tests/test_distro.py index bc3b511af63..0a0ab8269cc 100644 --- a/test/py/tests/test_distro.py +++ b/test/py/tests/test_distro.py @@ -10,6 +10,7 @@ CONSOLE = 'earlycon=uart8250,io,0x3f8 console=uart8250,io,0x3f8' @pytest.mark.boardspec('qemu-x86_64') @pytest.mark.role('qemu-x86_64') +@pytest.mark.restart def test_distro(ubman): """Test booting into Ubuntu 24.04""" with ubman.log.section('boot'): @@ -64,6 +65,7 @@ def test_distro(ubman): @pytest.mark.boardspec('colibri-imx8x') @pytest.mark.role('colibrimx8') +@pytest.mark.restart def test_distro_script(ubman): """Test that a selected board can boot into Llinux using a script""" with ubman.log.section('boot'): @@ -79,6 +81,7 @@ def test_distro_script(ubman): @pytest.mark.boardspec('efi-arm_app64') @pytest.mark.role('efi-aarch64') +@pytest.mark.restart def test_distro_arm_app_extlinux(ubman): """Test that the ARM EFI app can boot into Ubuntu 25.04 via extlinux""" with ubman.log.section('boot'): @@ -98,6 +101,7 @@ def test_distro_arm_app_extlinux(ubman): @pytest.mark.boardspec('efi-arm_app64') @pytest.mark.role('efi-aarch64') +@pytest.mark.restart def test_distro_arm_app_efi(ubman): """Test that the ARM EFI app can boot into Ubuntu 25.04 via EFI""" with ubman.log.section('boot'): diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py index 016274533cd..338554291c1 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py @@ -28,6 +28,7 @@ from capsule_common import ( @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow +@pytest.mark.restart class TestEfiCapsuleFirmwareFit(): """Test capsule-on-disk firmware update for FIT images """ diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py index b8cb483b380..42fb1ae9954 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py @@ -29,6 +29,7 @@ from capsule_common import ( @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow +@pytest.mark.restart class TestEfiCapsuleFirmwareRaw: """ Tests verifying capsule-on-disk firmware update for raw images """ diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py index 29545c5080a..f0ad67e2468 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py @@ -31,6 +31,7 @@ from capsule_common import ( @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow +@pytest.mark.restart class TestEfiCapsuleFirmwareSignedFit(): """Capsule-on-disk firmware update test """ diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py index a500c499bb9..8456f39454f 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py @@ -29,6 +29,7 @@ from capsule_common import ( @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow +@pytest.mark.restart class TestEfiCapsuleFirmwareSignedRaw(): """Firmware Update (Signed capsule with raw images) Test """ diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py index 63ee8e6cef2..efa9ebf5adf 100644 --- a/test/py/tests/test_efi_fit.py +++ b/test/py/tests/test_efi_fit.py @@ -159,6 +159,7 @@ FDT_DATA = ''' @pytest.mark.buildconfigspec('fit') @pytest.mark.notbuildconfigspec('generate_acpi_table') @pytest.mark.requiredtool('dtc') +@pytest.mark.restart def test_efi_fit_launch(ubman): """Test handling of UEFI binaries inside FIT images. diff --git a/test/py/tests/test_efi_secboot/test_authvar.py b/test/py/tests/test_efi_secboot/test_authvar.py index 3750f302dba..03caec65fec 100644 --- a/test/py/tests/test_efi_secboot/test_authvar.py +++ b/test/py/tests/test_efi_secboot/test_authvar.py @@ -16,6 +16,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_fat') @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.slow +@pytest.mark.restart class TestEfiAuthVar(object): def test_efi_var_auth1(self, ubman, efi_boot_env): """ diff --git a/test/py/tests/test_efi_secboot/test_signed.py b/test/py/tests/test_efi_secboot/test_signed.py index e8aaef7090c..78ed2a08fe2 100644 --- a/test/py/tests/test_efi_secboot/test_signed.py +++ b/test/py/tests/test_efi_secboot/test_signed.py @@ -17,6 +17,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_fat') @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.slow +@pytest.mark.restart class TestEfiSignedImage(object): def test_efi_signed_image_auth1(self, ubman, efi_boot_env): """ diff --git a/test/py/tests/test_efi_secboot/test_signed_intca.py b/test/py/tests/test_efi_secboot/test_signed_intca.py index 58f7be03b8b..6e0d7800305 100644 --- a/test/py/tests/test_efi_secboot/test_signed_intca.py +++ b/test/py/tests/test_efi_secboot/test_signed_intca.py @@ -19,6 +19,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_fat') @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.slow +@pytest.mark.restart class TestEfiSignedImageIntca(object): def test_efi_signed_image_intca1(self, ubman, efi_boot_env_intca): """ diff --git a/test/py/tests/test_efi_secboot/test_unsigned.py b/test/py/tests/test_efi_secboot/test_unsigned.py index bd6e1b2dadd..f5624806d88 100644 --- a/test/py/tests/test_efi_secboot/test_unsigned.py +++ b/test/py/tests/test_efi_secboot/test_unsigned.py @@ -17,6 +17,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_fat') @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.slow +@pytest.mark.restart class TestEfiUnsignedImage(object): def test_efi_unsigned_image_auth1(self, ubman, efi_boot_env): """ diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 5f29157ae15..2a959ae3406 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -7,6 +7,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.restart def test_efi_selftest_base(ubman): """Run UEFI unit tests @@ -24,6 +25,7 @@ def test_efi_selftest_base(ubman): @pytest.mark.buildconfigspec('hush_parser') @pytest.mark.buildconfigspec('of_control') @pytest.mark.notbuildconfigspec('generate_acpi_table') +@pytest.mark.restart def test_efi_selftest_device_tree(ubman): """Test the device tree support in the UEFI sub-system @@ -44,6 +46,7 @@ def test_efi_selftest_device_tree(ubman): ubman.restart_uboot() @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.restart def test_efi_selftest_watchdog_reboot(ubman): """Test the watchdog timer @@ -61,6 +64,7 @@ def test_efi_selftest_watchdog_reboot(ubman): ubman.run_command(cmd='', send_nl=False, wait_for_reboot=True) @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.restart def test_efi_selftest_text_input(ubman): """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL @@ -116,6 +120,7 @@ def test_efi_selftest_text_input(ubman): ubman.restart_uboot() @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.restart def test_efi_selftest_text_input_ex(ubman): """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL @@ -180,6 +185,7 @@ def test_efi_selftest_text_input_ex(ubman): @pytest.mark.buildconfigspec('cmd_bootefi_selftest') @pytest.mark.buildconfigspec('efi_tcg2_protocol') @pytest.mark.notbuildconfigspec('sandbox') +@pytest.mark.restart def test_efi_selftest_tcg2(ubman): """Test the EFI_TCG2 PROTOCOL diff --git a/test/py/tests/test_eficonfig.py b/test/py/tests/test_eficonfig.py index 20ea8d9f28f..171c8ec6cc8 100644 --- a/test/py/tests/test_eficonfig.py +++ b/test/py/tests/test_eficonfig.py @@ -12,6 +12,7 @@ from tests import fs_helper @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_eficonfig') @pytest.mark.buildconfigspec('cmd_bootefi_bootmgr') +@pytest.mark.restart def test_efi_eficonfig(ubman): def prepare_image(u_boot_config): diff --git a/test/py/tests/test_fpga.py b/test/py/tests/test_fpga.py index 299a8653f74..84998dc2de2 100644 --- a/test/py/tests/test_fpga.py +++ b/test/py/tests/test_fpga.py @@ -97,6 +97,7 @@ expected_usage = 'fpga - loadable FPGA image support' @pytest.mark.xfail @pytest.mark.buildconfigspec('cmd_fpga') +@pytest.mark.restart def test_fpga_fail(ubman): # Test non valid fpga subcommand expected = 'fpga: non existing command' diff --git a/test/py/tests/test_fs/test_erofs.py b/test/py/tests/test_fs/test_erofs.py index a2bb6b505f2..5150cb5cb1f 100644 --- a/test/py/tests/test_fs/test_erofs.py +++ b/test/py/tests/test_fs/test_erofs.py @@ -189,7 +189,7 @@ def erofs_run_all_tests(ubman): @pytest.mark.buildconfigspec('fs_erofs') @pytest.mark.requiredtool('mkfs.erofs') @pytest.mark.requiredtool('md5sum') - +@pytest.mark.restart def test_erofs(ubman): """ Executes the erofs test suite. diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py index adda3b98cda..50522c31d02 100644 --- a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py +++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py @@ -106,6 +106,7 @@ def sqfs_run_all_ls_tests(ubman): @pytest.mark.buildconfigspec('fs_squashfs') @pytest.mark.requiredtool('mksquashfs') @pytest.mark.singlethread +@pytest.mark.restart def test_sqfs_ls(ubman): """ Executes the sqfsls test suite. diff --git a/test/py/tests/test_help.py b/test/py/tests/test_help.py index afb57201ba3..ff8de8e8124 100644 --- a/test/py/tests/test_help.py +++ b/test/py/tests/test_help.py @@ -15,6 +15,7 @@ def test_help(ubman): assert lines.splitlines()[0] == "? - alias for 'help'" @pytest.mark.boardspec('sandbox') +@pytest.mark.restart def test_help_no_devicetree(ubman): try: ubman.restart_uboot_with_flags([], use_dtb=False) @@ -26,6 +27,7 @@ def test_help_no_devicetree(ubman): ubman.restart_uboot() @pytest.mark.boardspec('sandbox_vpl') +@pytest.mark.restart def test_vpl_help(ubman): try: ubman.restart_uboot() diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py index 4558b037e2a..3fc61e258a0 100644 --- a/test/py/tests/test_log.py +++ b/test/py/tests/test_log.py @@ -41,6 +41,7 @@ def test_log_format(ubman): @pytest.mark.buildconfigspec('debug_uart') @pytest.mark.boardspec('sandbox') +@pytest.mark.restart def test_log_dropped(ubman): """Test dropped 'log' message when debug_uart is activated""" diff --git a/test/py/tests/test_reset.py b/test/py/tests/test_reset.py index af079a70664..4423baee9c3 100644 --- a/test/py/tests/test_reset.py +++ b/test/py/tests/test_reset.py @@ -41,6 +41,7 @@ def setup_reset_env(ubman): pytest.skip('skipping reset test due to jtag bootmode') @pytest.mark.buildconfigspec('hush_parser') +@pytest.mark.restart def test_reset(ubman): """Test the reset command in non-JTAG bootmode. It does COLD reset, which resets CPU, DDR and peripherals @@ -52,6 +53,7 @@ def test_reset(ubman): test_000_version.test_version(ubman) @pytest.mark.buildconfigspec('hush_parser') +@pytest.mark.restart def test_reset_w(ubman): """Test the reset -w command in non-JTAG bootmode. It does WARM reset, which resets CPU but keep DDR/peripherals active. diff --git a/test/py/tests/test_sandbox_exit.py b/test/py/tests/test_sandbox_exit.py index 849fd477941..eb95558f09e 100644 --- a/test/py/tests/test_sandbox_exit.py +++ b/test/py/tests/test_sandbox_exit.py @@ -7,6 +7,7 @@ import signal @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('sysreset_cmd_poweroff') +@pytest.mark.restart def test_poweroff(ubman): """Test that the "poweroff" command exits sandbox process.""" @@ -14,6 +15,7 @@ def test_poweroff(ubman): assert(ubman.validate_exited()) @pytest.mark.boardspec('sandbox') +@pytest.mark.restart def test_ctrl_c(ubman): """Test that sending SIGINT to sandbox causes it to exit.""" @@ -23,6 +25,7 @@ def test_ctrl_c(ubman): @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_exception') @pytest.mark.buildconfigspec('sandbox_crash_reset') +@pytest.mark.restart def test_exception_reset(ubman): """Test that SIGILL causes a reset.""" @@ -38,6 +41,7 @@ def test_exception_reset(ubman): @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_exception') @pytest.mark.notbuildconfigspec('sandbox_crash_reset') +@pytest.mark.restart def test_exception_exit(ubman): """Test that SIGILL causes a reset.""" diff --git a/test/py/tests/test_saveenv.py b/test/py/tests/test_saveenv.py index 555284906da..0fb8dcaf1d8 100644 --- a/test/py/tests/test_saveenv.py +++ b/test/py/tests/test_saveenv.py @@ -73,6 +73,7 @@ def set_env(ubman, var_name, var_value): @pytest.mark.buildconfigspec('cmd_saveenv') @pytest.mark.buildconfigspec('hush_parser') +@pytest.mark.restart def test_saveenv(ubman): """Test the saveenv command in non-JTAG bootmode. It saves the U-Boot environment in persistent storage. diff --git a/test/py/tests/test_spl.py b/test/py/tests/test_spl.py index 48407399039..b3a2de9801c 100644 --- a/test/py/tests/test_spl.py +++ b/test/py/tests/test_spl.py @@ -15,6 +15,7 @@ def test_ut_spl_init(ubman): with open(fn, 'wb') as fh: fh.write(data) +@pytest.mark.restart def test_spl(ubman, ut_spl_subtest): """Execute a "ut" subtest. diff --git a/test/py/tests/test_stackprotector.py b/test/py/tests/test_stackprotector.py index a7e20d6307c..2a99ba7b9c9 100644 --- a/test/py/tests/test_stackprotector.py +++ b/test/py/tests/test_stackprotector.py @@ -6,6 +6,7 @@ import signal @pytest.mark.buildconfigspec('cmd_stackprotector_test') @pytest.mark.notbuildconfigspec('asan') +@pytest.mark.restart def test_stackprotector(ubman): """Test that the stackprotector function works.""" diff --git a/test/py/tests/test_upl.py b/test/py/tests/test_upl.py index f2b69078cf1..ea921e0c005 100644 --- a/test/py/tests/test_upl.py +++ b/test/py/tests/test_upl.py @@ -9,6 +9,7 @@ import pytest import utils @pytest.mark.boardspec('sandbox_vpl') +@pytest.mark.restart def test_upl_handoff(ubman): """Test of UPL handoff diff --git a/test/py/tests/test_vbe_vpl.py b/test/py/tests/test_vbe_vpl.py index f011b034f63..6ecd03086cc 100644 --- a/test/py/tests/test_vbe_vpl.py +++ b/test/py/tests/test_vbe_vpl.py @@ -10,6 +10,7 @@ import utils @pytest.mark.boardspec('sandbox_vpl') @pytest.mark.requiredtool('dtc') +@pytest.mark.restart def test_vbe_vpl(ubman): #cmd = [ubman.config.build_dir + fname, '-v'] ram = os.path.join(ubman.config.build_dir, 'ram.bin') diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py index a2545ab3b60..820c8059be3 100644 --- a/test/py/tests/test_vboot.py +++ b/test/py/tests/test_vboot.py @@ -141,6 +141,7 @@ TESTDATA += [pytest.param(*v, marks=pytest.mark.slow) for v in TESTDATA_IN[1:]] @pytest.mark.requiredtool('fdtget') @pytest.mark.requiredtool('fdtput') @pytest.mark.requiredtool('openssl') +@pytest.mark.restart @pytest.mark.parametrize("name,sha_algo,padding,sign_options,required,full_test,algo_arg,global_sign", TESTDATA) def test_vboot_base(ubman, name, sha_algo, padding, sign_options, required, diff --git a/test/py/tests/test_vpl.py b/test/py/tests/test_vpl.py index a269c7c262e..2ea1f0c399d 100644 --- a/test/py/tests/test_vpl.py +++ b/test/py/tests/test_vpl.py @@ -5,6 +5,7 @@ import os.path import pytest +@pytest.mark.restart def test_vpl(ubman, ut_vpl_subtest): """Execute a "ut" subtest. From patchwork Sat Mar 14 23:15:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1979 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=1773530258; bh=DQdZmpsLpjRXNoGLtaWpNXuq5zbH8u1a6kMqy0NNr40=; 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=Z9jFAFO4fjIPl94muwkyA+SFy9phjfCPGiztIlfzxFeAD3Xq36tzIgelj3hvcwZ/j xGwef2g2RDLGjSfTERCYw3UFZyUst6r2V5xsqMVe+dTKafQyT/OXc66ehIb5qW1MOb dkpajPeUj7oqexRyjof8xxxPbd2CM2ajBlDXntvgi1hLRFp4wpjI9YenkgNH/d7kxS hdCQ6QnGsprEGEu1gBT8saatxwpCNA7C/c9RxpBkWykuZZSt/OdDWyZPQ6gfPshGJb ooKfIALEAYni4Wdj1qHj+Ah3RkpTaeiHl/jpgaXuVCt76k/rfmRraRUVqMFEM9e7p1 XwmSJMzgXLbgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C50A569ECF for ; Sat, 14 Mar 2026 17:17:38 -0600 (MDT) 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 aJI-fyNRT2sR for ; Sat, 14 Mar 2026 17:17:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530257; bh=DQdZmpsLpjRXNoGLtaWpNXuq5zbH8u1a6kMqy0NNr40=; 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=jnEyRd+bwm3LFXfIu5tMM8oMS3UIt/kTUuNTUfN2OT1ZIeESG7u1Hj/W31F+XTC2R NhwrbtaFxYi4C6nYOJJyhbsqIxItj9MeOi6jFCGQTZPpEU1iIsKreuRb3DBW8MroBS VirOQsLhssRYMd5nuncT7DqxlMdKdhQYCB3UeFbhONl1+mhhqePfaK3ZgEUgKOMQ3o Y/+dcmUe7nTvRR0x9ctyjseWkB8pxJ6lFKiJ0X07mxoBDbakz1KOzyrVk5JKa5kyav cBwzylaMyaWjRbvbtWoCcbypcIYuBAf1JJoMQNs0LkVSIo4HbWfjul7JrUnNhyPE2Z qcD/1enVJgW7g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B63516A031 for ; Sat, 14 Mar 2026 17:17:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530256; bh=Oms3No2dBjbyqq1/s1bBOnWCf2J7VwNhrnbd7gCbg/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bs1aEUjFRyGQ+w6UhTanPS3B6tpRrAGz5/lCAf6lWwZypwY4FGh2tgu0HMkCxW/al JAToyS/agdTvKAsDQHarnW33fUop6WfzTchvXa/qu64HLs7qiAsHQaXzqOMrcq1DLN UQM71xdJvYQo6HJgnk+yJ4jRjVzGx3A+K7K+QMmyRVKaXKYihwjnNcR9BNCejgQxVR XmuCHnyfLBB3uQnioFEU70V157z1G9pBAqOqE9Bg9XcjvnS/sSsp5i9IEPcEg9byJ3 IZ3Gjfr2vltekeA1IBpd6YYrDzvRA7FLWZ+J/uyRrsYckbFNlcc17uTNEzVQ7WIZcY vdIqhU2eQ5LgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2EDE06A033; Sat, 14 Mar 2026 17:17:36 -0600 (MDT) 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 DwcDk-IPGbNK; Sat, 14 Mar 2026 17:17:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530253; bh=vYHZjt8p5kSczk+YFaCLsAoNPTuZYcVokn8erkEkVeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhem2R9FI9PmTrG3XMS0pMSkXdOKa9CMA87/3BYuWIqWKgK6bhHu5hAqKgmQb/uKp RDpS4P9i9yuTForvrj9P6EmLDKRNg7zrh+nJkLAxgaYi7FV46yTgJX3oftj89tkiTQ inaiu5l+NS2OZSOcpQwcZ79grBYkzrgH8bVGMj3o0JO0DwriVdoPpeV67ZQG2JdNOj MHQ22D/L8X2q6WqitsGAUTPBDtkNoF5IfuT5XFb99qxrwkUIxJXSfn9ERZ7XZwjs/g Z+u7BVis4+XM9i1aMJMKekUiQCl1F0mCNXYNFcQua0ivj63nGT/TZgJucCOzchphcD 3jIr1LUaP309Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 696576A03B; Sat, 14 Mar 2026 17:17:33 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:58 -0600 Message-ID: <20260314231618.338113-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: THXZFE4HGL7IRMIJNOFRC2I4KSWFUUUK X-Message-ID-Hash: THXZFE4HGL7IRMIJNOFRC2I4KSWFUUUK 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/19] test: py: Restore default log format after test_log_format() 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_log_format() changes the log format to various values but does not restore the default at the end. This can affect later tests that depend on the default format. Add 'log format default' at the end of the test to restore it. Signed-off-by: Simon Glass --- test/py/tests/test_log.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py index 3fc61e258a0..c1b7e1d6b1b 100644 --- a/test/py/tests/test_log.py +++ b/test/py/tests/test_log.py @@ -39,6 +39,8 @@ def test_log_format(ubman): run_with_format('lm', 'NOTICE. msg') run_with_format('m', 'msg') + ubman.run_command('log format default') + @pytest.mark.buildconfigspec('debug_uart') @pytest.mark.boardspec('sandbox') @pytest.mark.restart From patchwork Sat Mar 14 23:15:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1981 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=1773530266; bh=yc396pXtAOTJyahhOlbxFIzXFKDPUX8HZoP6LugTJnw=; 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=KD0uCFD62xe4oRxCZJC7WW4Fl+8rUaWbdrjWyPECYLfRYHigOlFW9irI4n/NHvDFI WRAkK+Fj9C/AphJ0qn/zygxWC/oKRC1VhpxbfyIUfsgZV5Hs8dNReRKxu/fS8q6LYJ a1VfoqfQI83G9RgYTkAopMosddSgZqtazrLt+nPZYDALY6gmtZFbomjSzNAd84il7u 5TCZ7eM12WOyqiJDsG/YXRnQrefRX13JHd9KKecXIxXvqVcOAZKHqA9FhFZQGxom9l 5IlR3tB86dFURoYzDnYOToi/0MvOHCz5W+OZcrmPn9OoKDgKBplWkxFTUTb5iVWH09 Raskex64o8NaQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9998F6A04F for ; Sat, 14 Mar 2026 17:17:46 -0600 (MDT) 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 JujRS1nnMkGs for ; Sat, 14 Mar 2026 17:17:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=yc396pXtAOTJyahhOlbxFIzXFKDPUX8HZoP6LugTJnw=; 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=RGauagIoq8OBAeEJDzZZ+bigb/x3AoCGAWuibDayb2SXuR6/UMaRD1l/QleajROkq C0aPXKRObyxRaVolySrrvkVCR1DShQu48m/zPH6wIPHsda4UnIEIwncXa3kt7/jS7c 2UqePH8OstOHsGGazETnqUFOaAUTn7ykx9jfYXUBtX4LVWfBu7c0Q1Z4T94TZOC+k8 IN+iLUmtA4db8lezxDaOjBrTYURd99N84o/WxRHxdaty5P69My/14fk23/D9Utri03 jyRGzB8XGUZrRiVaaBdQsoS7Bu4Qpoel1qqgbMxeo8ZeQYPFgRV5M1CewndOB2w6TZ VsTNlrcJRr0Yw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 429F86A031 for ; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530261; bh=5F1GQMLNcdawiuv+Uy++o4zhjya8stifeJcThQ65Rh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1OWDsZQ1eXxWHgNVtSX2wwuWPFGn+yWy0S0tSQHn+UY6VVBM2BEgAF1/r+65dOyQ jusPt6/xV790/FSOsuxzIGhIFyH4PeiJ7rM2x055GHqdT2QRRzjrG3bs+cWSDDyqRN 4iBHgX9Nefb/6lCsWtG3IuaPvm/zi7hAfmFKk9c0ZvkRgsfZC1mukDucBsHR95xMSY IGtfNDkSvmAbr6tmrq4UbfNOlWWbxzQI/mc8e0dn8H1PwvP7BwZ4Z19kjdXwfcntwx Tle8e4Mgllmbi3buedT6AOhnNJdSJms+FhPPM6TJ2gBYIcEdE/MLAsp0ccg37tKzu2 UQKdIuRYmtUgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC2826A033; Sat, 14 Mar 2026 17:17:41 -0600 (MDT) 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 hnxeZJ3AbdFY; Sat, 14 Mar 2026 17:17:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530254; bh=rK7ZTZzrp2N5/5TpwJhAUdd5bRRoefrN8zqxtXwhf2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zw2Wtba5SGimQD7Q/7dmmt/Twt9sM6SqK3tbjEY8yxWSEcLxotsikucpfMueG8PDv zYaYKO2/meOc0CaazS+8Ly2gl9dCJxNnWvVh8egHujR3Y0jIkL8apd7TQymn5ydkEB JUJ6zEojWRcwmniMC7FhtV1rIDOSRKlsXrB1bRLq36DBGILysyYtT9+3q2Oyvx/N1N aKVRUD+hJmlybVgNZeWDK+O3JzbqOmPt6jsBDm9H05FIfrREE188oi2p+aJmp5+UDQ BsZgbnb8j6+kpNzG9RhjcyGcTUYxy6D9xVoqx8MLIHyQMdsXp4Z98r7VjtROf2Do1D Fbu37CfmTqMkw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 34D7D6A038; Sat, 14 Mar 2026 17:17:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:59 -0600 Message-ID: <20260314231618.338113-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: A3EDTIGLGA3XVCAEXCJZAK7N5AZVFQPA X-Message-ID-Hash: A3EDTIGLGA3XVCAEXCJZAK7N5AZVFQPA 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/19] test: pxe: Fix dangling pointer in FDT env save/restore 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 pxe_test_fdt_fallback() and pxe_test_alloc_norun() save the values of fdt_addr and fdtcontroladdr using env_get(), which returns a pointer into the environment hash table. When the variable is then cleared with env_set(name, NULL), the hash entry is freed, leaving the saved pointer dangling. Restoring from this pointer writes corrupt data, breaking later tests like bootflow_efi that depend on fdtcontroladdr Fix by using strdup() to save env values. Extract the save/restore logic into pxe_save_and_clear_fdt_env() and pxe_restore_fdt_env() helpers shared by both tests. Signed-off-by: Simon Glass --- test/boot/pxe.c | 70 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index cd831807b94..e691ceebc61 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -35,6 +35,56 @@ #define PXE_ARG_FS_IMAGE 0 /* Path to filesystem image */ #define PXE_ARG_CFG_PATH 1 /* Path to config file within image */ +/** + * struct pxe_env_save - saved FDT-related environment variables + * + * @fdt_addr: Saved fdt_addr value (strdup'd, or empty string if unset) + * @fdtcontroladdr: Saved fdtcontroladdr value (strdup'd, or empty) + */ +struct pxe_env_save { + char *fdt_addr; + char *fdtcontroladdr; +}; + +/** + * pxe_save_and_clear_fdt_env() - save and clear FDT env vars + * + * Saves the current values of fdt_addr and fdtcontroladdr, then clears + * them. The values are strdup'd since env_set() frees the old value, + * which would leave saved env_get() pointers dangling. + * + * @save: Struct to save into + * Return: 0 on success, -ENOMEM on allocation failure + */ +static int pxe_save_and_clear_fdt_env(struct pxe_env_save *save) +{ + save->fdt_addr = strdup(env_get("fdt_addr") ?: ""); + save->fdtcontroladdr = strdup(env_get("fdtcontroladdr") ?: ""); + if (!save->fdt_addr || !save->fdtcontroladdr) { + free(save->fdt_addr); + free(save->fdtcontroladdr); + return -ENOMEM; + } + env_set("fdt_addr", NULL); + env_set("fdtcontroladdr", NULL); + + return 0; +} + +/** + * pxe_restore_fdt_env() - restore FDT env vars from saved state + * + * @save: Struct with saved values (freed after restore) + */ +static void pxe_restore_fdt_env(struct pxe_env_save *save) +{ + env_set("fdt_addr", *save->fdt_addr ? save->fdt_addr : NULL); + env_set("fdtcontroladdr", + *save->fdtcontroladdr ? save->fdtcontroladdr : NULL); + free(save->fdt_addr); + free(save->fdtcontroladdr); +} + /* Memory address for loading files */ #define PXE_LOAD_ADDR 0x01000000 #define PXE_KERNEL_ADDR 0x02000000 @@ -967,8 +1017,8 @@ PXE_TEST_ARGS(pxe_test_ipappend_norun, UTF_CONSOLE | UTF_MANUAL | UTF_ETH_BOOTDE */ static int pxe_test_fdt_fallback(struct unit_test_state *uts) { - const char *orig_fdt_addr, *orig_fdtcontroladdr; ulong kern_addr = 0x1000000; + struct pxe_env_save save; struct pxe_label label; void *kern_buf; @@ -980,10 +1030,7 @@ static int pxe_test_fdt_fallback(struct unit_test_state *uts) 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)); + ut_assertok(pxe_save_and_clear_fdt_env(&save)); /* Test 1: No fallback env vars set - should return NULL */ ut_assertnull(pxe_get_fdt_fallback(&label, kern_addr)); @@ -1001,8 +1048,7 @@ static int pxe_test_fdt_fallback(struct unit_test_state *uts) 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)); + pxe_restore_fdt_env(&save); return 0; } @@ -1144,10 +1190,10 @@ static int pxe_alloc_getfile(struct pxe_context *ctx, const char *file_path, */ 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_env_save save; struct pxe_context ctx; ulong addr; int ret; @@ -1162,10 +1208,7 @@ static int pxe_test_alloc_norun(struct unit_test_state *uts) 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)); + ut_assertok(pxe_save_and_clear_fdt_env(&save)); /* Ensure address env vars are NOT set */ ut_assertok(env_set("kernel_addr_r", NULL)); @@ -1238,8 +1281,7 @@ static int pxe_test_alloc_norun(struct unit_test_state *uts) pxe_menu_uninit(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)); + pxe_restore_fdt_env(&save); return 0; } From patchwork Sat Mar 14 23:16:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1982 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=1773530267; bh=xmJWCvxMZ04wHUx8p5WLoB91rQ95qmwOwzODIPIwfpQ=; 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=CwFmvYBSoOECsDh4UfLmFQbAU7xWC08MmEd5DyQCQ9rn1on+YCDkJB+MQA+ovUZDE 4KwTHgKjYyLt8sczrVA2vVklvv1geqEV92eBPc13Jo7Tb0QdYPTzxy+XsKSdzAwDlc DyItaZnliamm6ZaWbWWM3+XH+PR447ek5G98K1CCLleLZ9WUrSvGRxKUsA2R/RvkBa wfL42QMtygtIVn6sx2UmXhuraX4a/qhU7XCUnWzStTafwM2eBcdX3AneBgTurbuFVZ OGzf/d1NZfyYVGb0dUETQzDFLYWWSJfiLBZXvXONGjO6PC12vcA3742x62+OLnwCFy nBOU17EFqbF2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0D5DA6A03F for ; Sat, 14 Mar 2026 17:17:47 -0600 (MDT) 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 5cOtkLaIDkNk for ; Sat, 14 Mar 2026 17:17:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530265; bh=xmJWCvxMZ04wHUx8p5WLoB91rQ95qmwOwzODIPIwfpQ=; 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=PAAdJae1cZDwPVZG5igRFSwTpLatudChpTPVSaN43uVh8Sp8kMTe/weDoBsWi0iZl jU//ldBRD2H6cPC4X1kdqKufamA0ze/sW9xBgtxcckB0K5FP45ygDXrQtZFW7pIyQP Ay+YWA4LlfBeFWDN1Pwpw0OSRdfrnms5csIle4eUfLCsotjYi+KKOTIkWlNquPk7eF oorJjYtmGOTxDA8UH5G/8EtfgR3CSDbKwCJHGj5VOAv4uy9jK906DIfcV8ZNm/ZrwB Pb9B9XlKizxuE+CgseCF6m2xaKwfRbqhFq7lfFXxigZ8YrthD1SsamzfrtT1bUyLog 0MnYy9YSqS75Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 061336A033 for ; Sat, 14 Mar 2026 17:17:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530261; bh=tf0xnAmRveIFlqu+qYbPJEOK7qHTXXnl7lnvzelkFrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3pQTR5cf/emhXisf9ofMAjc5hI1NTGzchxvkdiA3soiyuHPURBF8P+uOaNd3vX1u izxlD0o0Zsnqlm7Pqg9JANjJY1T2twtwpIHc/o0iCFtyezyrdO+Xn3xrKYfoXK1QPR X4Fv8CyMJsWrU8oh3fIrA3KHqAB4SugydnJ55gq99APWutd+EVfCIZ/3gNH4uBoRcw hs7BAJ2FyIGacqXVvbVYzX14flNYOg3DnTX376AGYkLvZOz73xWwDU+4IE8JF7fKZU TNBqXaVZMUraB5PiNOekFUwRbXXI2fdpET0yZy6HIWejW1De7znMCQ0rdy4JXpSEm3 RlbwrJLV6A8dQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC7B16A037; Sat, 14 Mar 2026 17:17:41 -0600 (MDT) 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 BmzLAQwgTQYY; Sat, 14 Mar 2026 17:17:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530259; bh=ner+JehcoQCDke/tHS0w+5bR/Xf+3FS/YSiA0xPQFpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+p8TlUOdnoUApaOuLm4J1K0Pr4xJnyMK1tOMI5WVOE+NKlHX8NFMwkStUw5Npl2x v+MnLZpmPmZ6fMT/pI/CHt2DXkR4YPoKCI4TI4aXJtnnWefWN578jnX+md5+obKpPX uJ7PCSbDxKR3hWVdoQfnzflpOp/h0XjhjD7cSlt7i1bXXbM4qjkuEjALFP7Utp7+XQ 2acOymj7kzQ6D8tVaJk1eTY2JAlUXcKcyqBcR6uvDiWJwtHmNQD5IG0NRwbi8IRspP 7jOoWj5kAn4iN8bvTaQ/vX2eNcOodRAhekmBsItPw6thwNXoxX2TpULouPjcPn6VEu WL7MELQZd7+EA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C5E7F6A03F; Sat, 14 Mar 2026 17:17:38 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:00 -0600 Message-ID: <20260314231618.338113-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NC4FRJPV5OZY4N6EZUIW3G5PWXPCCEZG X-Message-ID-Hash: NC4FRJPV5OZY4N6EZUIW3G5PWXPCCEZG 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/19] test: pxe: Fix ipappend test to clear board env var 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 pxe_test_ipappend_norun() clears fdtfile to test the fdtdir fallback path, but the fallback code in pxe_utils.c constructs the DTB filename from the board env var (which is 'sandbox'). This causes the test to try /dtb/sandbox.dtb instead of /dtb/.dtb Clear the board env var alongside fdtfile, and restore it in the cleanup section. Signed-off-by: Simon Glass --- test/boot/pxe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index e691ceebc61..237481d5ee8 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -958,8 +958,12 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) ut_assertok(env_set("gatewayip", "192.168.1.254")); ut_assertok(env_set("netmask", "255.255.255.0")); - /* Clear fdtfile to ensure rescue label's fdtdir tries /dtb/.dtb */ + /* + * Clear fdtfile and board so the rescue label's fdtdir tries + * /dtb/.dtb (the fallback constructs soc-board.dtb from env) + */ ut_assertok(env_set("fdtfile", NULL)); + ut_assertok(env_set("board", NULL)); /* Override to boot the rescue label which has ipappend=3 */ ut_assertok(env_set("pxe_label_override", "rescue")); @@ -996,6 +1000,7 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) ut_assert_console_end(); /* Clean up */ + env_set("board", "sandbox"); env_set("ipaddr", NULL); env_set("serverip", NULL); env_set("gatewayip", NULL); From patchwork Sat Mar 14 23:16:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1984 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=1773530270; bh=obnkSMkfO1BVS57pYMJuPo14sHjbw6yZayoL8+NEDoo=; 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=FGFwpBOvEi3TosdChQ31Fo2WE4BKARChQDCKLDoTvILB+21rbTrUVXeO4hJ6IQmXe 8aSEfFzW5QWiz2TwbSV+gU9Y2uufxTxBBtSPklTMORyS0GWswbAL/fR8vKSUVFTqqY 8JB6zuMt1eRvDuRJxmAcwUOFO2kL+eqsxrU7SVUAkokqVKh7yNENFRR4UCCZJLqu0q bYuqebQfI7yhmw4OuS7Kypldbl5pvCKOor5+dWDV0dieKbwvDQnPH/GF3CiG2+55CF lSK34fA1a4MsHcVB2YX1M9Ly64jGAi+Kuh8wbD0U4jyH/l+rprWOzQ9/2vyd2pWL0+ efdedkJyl4lNw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98C5B6A04C for ; Sat, 14 Mar 2026 17:17:50 -0600 (MDT) 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 D6TCzGzYW7Dg for ; Sat, 14 Mar 2026 17:17:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530268; bh=obnkSMkfO1BVS57pYMJuPo14sHjbw6yZayoL8+NEDoo=; 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=rutjwI/baJvbLNCO0QGcZqbXSp/TqJbo9gIuc/TwS6dCaNizCy/PYCJN7SqKTgaVt z/x6x+S+QU+g4tdTtKjnBSC5ox0u0evK0Rkr2LhfrpgUbwFL4q5bfJzEt5kR2u1okI KTIz3L0n7QXfrbw2moR4J8Bc/vlKUULUSxfLuHWOuyIhSmJCVOQzhIhq1pQstfI07V nRNjrPDqPQDq6yk/4gmEhYcs77wQFvk7KL7/HJ60gnN1ITe1HqHdzwrnUKb4dZavn5 wi8JjfnOsIZ9CC8Gosh64C6v7D5IZ++e0cLactMt2lzhzb9O/NSYSqPV3fwcWvTRkr XClNR/rZj9iBw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC1996A038 for ; Sat, 14 Mar 2026 17:17:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=bLw1rihpM5Q90hz3dXziDB37vYqUc515kQ+gfjFAyUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnqQRdRclK7oLL89/VixVY7wmG4BYSnP4vlvNREELTeJUNurT2B/fEmseI8Hujirx iY7SMNtTWHtIPBY7sviDZa5S4g/liTuZMq3RR6bVKjkKfSfnZMH/4c3VYky5l0oiXb PoseNuWpJNQ8/HDq1AVq/hh+nfEjhUEoe4ECLrwzMgD+T0whVnaVknR94o2Ur7TFYw yspj53uq+m1g41KEjxOZ5B38LA497bz8Q2Kx7zpzgfZWDGgpuhwMtUbMfpHK7wJ0Z0 kVvnB9zMY8Ae0eDJd2qHxSoO0Gef/rj+Hq1BD4xAqLwhP09Nr6vqx6JPi6ztZIgmCL 1WfjRV82/dBXA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 17A3A6A03D; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) 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 nev4IWPuH8Yq; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530260; bh=sNdVeoQwkvTsBYaKBBTeJed0pZWGfa+DJcXdSEzHBhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMlZ5l7xp8+GbP4msWsytU0JZqmapfO2nU2pRjVW+LLwEuBgQTkfJ3IbUGLoGaoNF g7nxnsAA5k+UOrBmX9ME2/Yku3hWo65zpfIZucDqQyYV2bXVhgEYLrcprFJT11Q9eN t5bZECDvMFX0mpNgERWQ/zsgZVCB1HfscYVhaCgIy9Q2yJCqvai3OoPpekpsInnS33 lxn3osaSwi3RPkduY9OyN9c/c42d41RWCMQrGA42h5x7l442IAoSauFWxnh+PMZEGF 4KnKSi0uzZqx1DIucxhwbTn+wn9HM/Dm48l39302vus1jlO/joPfoTB1cyHh2qcN5w W6mEVrSIIQuOQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CCE3C6A03A; Sat, 14 Mar 2026 17:17:39 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:01 -0600 Message-ID: <20260314231618.338113-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5TMBCD5PBJ7SXAFF6EAIWVCYRAFH7RLY X-Message-ID-Hash: 5TMBCD5PBJ7SXAFF6EAIWVCYRAFH7RLY 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/19] test: py: Fix PersistentFileHelperCtxMgr with stale .pyc 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 inspect.getmodule() returns None when the .pyc file is compiled with a different source path, e.g. when running tests inside a container after building outside it, or vice versa. This causes an AttributeError on module.__file__ in PersistentFileHelperCtxMgr Fall back to the caller's filename from the stack frame when the module cannot be resolved. Signed-off-by: Simon Glass --- test/py/utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/py/utils.py b/test/py/utils.py index 7812b2a201b..083a3feddc2 100644 --- a/test/py/utils.py +++ b/test/py/utils.py @@ -303,8 +303,17 @@ class PersistentFileHelperCtxMgr(object): def __enter__(self): frame = inspect.stack()[1] module = inspect.getmodule(frame[0]) - self.module_filename = module.__file__ - self.module_timestamp = os.path.getmtime(self.module_filename) + if module is not None: + self.module_filename = module.__file__ + else: + self.module_filename = frame[1] + + if os.path.exists(self.module_filename): + self.module_timestamp = os.path.getmtime(self.module_filename) + else: + # The .pyc was compiled with a different source path + # (e.g. inside/outside a container). Skip staleness check. + self.module_timestamp = 0 if os.path.exists(self.filename): filename_timestamp = os.path.getmtime(self.filename) From patchwork Sat Mar 14 23:16:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1983 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=1773530269; bh=WUwUJFnFl860Aqb5NeR3Qt6tL9MrP7npRdaqPKbalGQ=; 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=F5MZCDttEuwuZr8TLnEMQlmJZiSDFePdD2ZeHLXlbanZ7VbRsSInPN1L3yJtQHhHc 46hqv5Kq594wR0EIBaqR/HTDy+LtX2zxiwWcng9MDCj5RZPBBn7AsICTKgGDRJ6sG5 A4rlLto1Zn9TVtHBu2KMc7oCP+mLI3a4x0ff+7JlvHKfsACryDM1MktbfKO8uJ/H5I YwDGA2YnnFhlBVjnAsmQIyA+VRgs7m38535qbCdtKncBsCfdaJN4P8a4RxBXf1QMLV LG9qaGGFk3WU6AYxOSTulhsSpio9HO8ilKpIHpA0Eb5W2bcJ6MkJXNeYxGI/UwC69r GcVpTLfEzSeNg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E026E6A059 for ; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) 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 P0spwjrlwDmi for ; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530266; bh=WUwUJFnFl860Aqb5NeR3Qt6tL9MrP7npRdaqPKbalGQ=; 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=esAOTwFe7pGr5Sy61Xvi1rAl0pocFQQU7+vqg6UEZX/+20YdidusUSiwKNCGNBzG/ 0w75RGszqr/SEuGSiWsMNhse/LLxvWRwAKST2Ox2OEwwFzJZ+WMLMLWr2M31Az7GOc xg3cJ0XuAQ3UGw8NH7Fy2ZNUg0XzQJmJ4ZSAzoILh49qXKNlHlZOjMjlkv47PCniDb VDx3gbHJ/o+WAaiSP4OO0y2qgq7wran5rvSeACCS0/o9JSJXPQk8YlOZlLSbDgsYQt xpVpzpH+nNS20f0q7IGjlaPuWQYuVU18hZ20hBqYXdtpSlBAP8205oeJnzcJ8P7raZ yb7UTZM1PBJJw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 80A896A04C for ; Sat, 14 Mar 2026 17:17:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=+ZVsaOwnTvv6FY5f/RZoYmeJAtdhYGtdqjRrVaYmFJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JiY+2fn1N2BOOLpns9OmvNFT+wjiU3jBH6+whB7bfUPT/XX+0uCF6aZ93NyxcgsKB fCockvgaHpRcVIYoYZ/VC1ICISJFlCVptW9RlrJ4mDaj+OoNO1SX+HkP9gH1nCApna Tbl8cB3AzZOAaQw5ECkmBE48PbQ96z5PI7KRk5RqKOjkOWkfR7cmwRlHgNs/5S0Ico plhH1W3dZ+R7zwJoo/nM1SHpLxQX0AKz3+w5gfOKonMf9sbNdUMBC+ZfL8NFGYdOzb +8zPqdeLRVRqwj5Oi2uYLTW2mVHEuI3uMBeUzqLHuK2Ns6f+A1mzuDKwRAzhx8iUjn 68zzeVKTSD1KQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 167126A03C; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) 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 rzFpQtnNvvlm; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530260; bh=wF8Yo77ENnvNjRk7o1+hHkK3+ErusmGFNisE/FiShvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcfys1Q+TAMLiMc5HDrVia3R+4mPWnW6XNe2o+s+M+n8hRJE2iapl8Ix9Ite0f9Li OGMseBVzBkET22EguJ6/PPRRyLlvqJGo09KkIsPalG1S/php6Ui4g0maBkUVRF6bSc V7xh/OBkIETNJVaP6uE2AOeVUHCpoL7oYDHW4KtykHgkAfnMoSVSFBizKQrowTWC7Y 5CcvlsbHs+Wa0EMt8JkNQrTuF1WaxOHUK4QDWjULv4UNEy/zeho3Awe3E7f3zRgOgZ J5w+n33kOSTFUwVAonJerdPb0kyQGEl5oIlXqzoLNIHMctcWVFbVC0ZAmFToSGPDhm Zd9oC1mKf6+Zw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 978EA69ECF; Sat, 14 Mar 2026 17:17:40 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:02 -0600 Message-ID: <20260314231618.338113-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ILZOIRWEYADMIIGMTUAXC77LM6CSPDCB X-Message-ID-Hash: ILZOIRWEYADMIIGMTUAXC77LM6CSPDCB 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/19] test: common: Fix memory leak in malloc_fill_pool 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 When common_test_malloc_fill_pool() fills the heap and then fails an assertion (e.g. because earlier tests leaked memory, reducing the available pool), it returns early without freeing the allocations. This leaks ~120 MB — the entire malloc pool — causing all subsequent tests that need malloc to fail. Free all allocations before checking the peak, so that a test failure does not leak the entire pool and break all subsequent tests. Signed-off-by: Simon Glass --- test/common/malloc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) -- 2.43.0 diff --git a/test/common/malloc.c b/test/common/malloc.c index af1a7326272..c4764a51f6b 100644 --- a/test/common/malloc.c +++ b/test/common/malloc.c @@ -616,18 +616,24 @@ static int common_test_malloc_fill_pool(struct unit_test_state *uts) ptr_table_size); /* - * Should have allocated most of the pool - if we can't allocate - * 1MB, then at most 1MB is available, so we must have allocated - * at least (pool_size - 1MB) + * Should have allocated most of the pool - if we can't allocate 1MB, + * then at most 1MB is available, so we must have allocated at least + * (pool_size - 1MB). Save the peak before freeing so an assertion + * failure does not leak the entire pool. */ ut_assert(count > 0); ut_assert(count < ptr_table_size / sizeof(void *)); - ut_assert(get_alloced_size() >= TOTAL_MALLOC_LEN - SZ_1M); + alloc_size = get_alloced_size(); - /* Free all allocations */ + /* + * Free all allocations before checking the peak, so that a failure does + * not leak the entire pool and break later tests + */ for (i = 0; i < count; i++) free(ptrs[i]); + ut_assert(alloc_size >= TOTAL_MALLOC_LEN - SZ_1M); + /* Should be back to starting state */ ut_asserteq(before, get_alloced_size()); From patchwork Sat Mar 14 23:16: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: 1986 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=1773530271; bh=b+x4P6VsTsySO0tv9AGHuCberh3HzQjWX2d3CXVm/NE=; 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=BT5eLOwtMHoFGfxJNchlKY8AoSubl333ITPdUHM62C0htEEql9PucqUDgTIhwVMwA DghbgSCVcOIgkrZas7qz+zLcN9buhExFGyskJShoXm10dO6O9rebdSzhTMwFkmDtGb 013AVHkCPiy3wr89R4dAkGJMl9mcyq28S5pkkBwl/6RMP9BTW1+EMiLqnYHkp0NAq/ GAfAUTu6vFEw9QyyAqksQCR25TxCWeJYlKjWMAdyze6bDtUyfJTpakmZ7AdJj6JiOm atYm88XiJwnBTamlzrwN82+2Kz4U74l/fcYXhDj+SNNHYAXv3N9G8AdtpHDO7k8TyN rvsnux/bXVGgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F05866A03C for ; Sat, 14 Mar 2026 17:17:51 -0600 (MDT) 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 ljpkTiiGrkf8 for ; Sat, 14 Mar 2026 17:17:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530269; bh=b+x4P6VsTsySO0tv9AGHuCberh3HzQjWX2d3CXVm/NE=; 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=SlC8xb+OmqZcFdgfgL5hdFALstlyVpEmW6uHNeXBZvfYIPgf4ijV+cRxtd4nB+L+A fR5IbxW2IuPE7id9frYbD+D6h8zgMEEJP0a0GXikNvIyoJQ7m8wH+lo1BptP2wyAo/ VqvPSyJJn05APsmkXR0p1/MPpfynQs8DQgAox3eBROw95TLwTqBJZ3e9cdLVHm7UjR MITQsW4TlcsQkwqX7+uS4DdIav5zG5V2+/HNdLetT0DXOdExsqfyTAiGYpM1Vn4Hpm T6CX8qFa3qEyasSFdyoBN0locCDLO0aNDOVzrkWfrk2PwtrhcUVwFS79ZWpbvmKB9H L+2NibHoWxoMQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D9D816A048 for ; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=O+l3jb0KEneZMRxYmCwnqSBOz7haYD5skz/mwT3yLmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=smN3aJ2QXRo2dd+8HGPMBo6EdW2qLZVnCYCoIdqZA6Dt0eMHKVkCMOcX6mP/8FFNg YCGzY8/Xk0W3yQZlGhZmH+i5E+UMGYVobTE648yo/4sFC6mNPHpDsZBCQGdfvWTHI1 rP/070ORZLZwZ+KX+5e+BHGut2VjmlnrywPcFnuvi7S75ugu46jnKK5OPWQB5jfKxO rrMjc4Wbo+1N3MOqt6o8A8lWuzpyyMVY/YzT9dapjEdYnqJJogQKmXXlcrQfygth+T mULpUSoLOh8ipTLdsEXp9BoVm8WWjJ/CSTobmgYUjHGbPm4oVPK0cjz4UpIGsyxJfV w+wp6yhtnkt7A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2B30669ECF; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) 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 bQpvHiZwXIkS; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530261; bh=EFEvUERBjvebStUtIt813wFD5oasqwk+NKcCmO/E5Hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j8hd7fwW/nAeB16FrCJhkldY+MdAXxXsO9ONJaLgSnLJxlA+UkM+R5X9jFXDdEqco 5A3aZrEyX/5nJt6BkpJJ0FulIquv94JHaer74nQetMaBZayYlGrdOaHxQWwp1qy2zb vZNnO9uIwcm88IoyGgudFTrA5MCi3y5VHt8zqR2OEaxw7vYys1GKRZfrLrxfXkXyoU H7d/ALqB2Fea8/CoJbxGKsmFuHyxh9WKJjiRhHm9S6pPm2gjg4e8FMGM0guhCiSvZ/ Wp/nvCjmurRjqkZeUjHtz1TW+7q2Mtz7SyYyonl5S1cEb5dpXtih5cy8CtVjYxbBbs FfAq61iWG+Z2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 63B756A031; Sat, 14 Mar 2026 17:17:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:03 -0600 Message-ID: <20260314231618.338113-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OHT2WOHUAKBF4T76HPITOOEHOJUZRZVK X-Message-ID-Hash: OHT2WOHUAKBF4T76HPITOOEHOJUZRZVK 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/19] test: py: Fix test_source breaking later tests 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 source command's ':' and '#' variants use the global image_load_addr variable, not the loadaddr env var. Prior tests (e.g. PXE) can change image_load_addr via load commands, causing test_source to look for the FIT at the wrong address. Fix this by explicitly setting loadaddr before loading the FIT, which triggers the env callback that synchronises image_load_addr. Also restore the control FDT and clean up loadaddr at the end so that later tests are not affected by the modified FDT pointer. Signed-off-by: Simon Glass --- test/py/tests/test_source.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/py/tests/test_source.py b/test/py/tests/test_source.py index 970d8c79869..4b9a12890c7 100644 --- a/test/py/tests/test_source.py +++ b/test/py/tests/test_source.py @@ -15,6 +15,12 @@ def test_source(ubman): its = os.path.join(ubman.config.source_dir, 'test/py/tests/source.its') fit = os.path.join(ubman.config.build_dir, 'source.itb') utils.run_and_log(ubman, (mkimage, '-f', its, fit)) + + # Set loadaddr to match CONFIG_SYS_LOAD_ADDR, in case a previous test + # (e.g. PXE) changed image_load_addr. The 'source :' and 'source #' + # variants use image_load_addr, which is synchronised via the loadaddr + # env-var callback. + ubman.run_command('setenv loadaddr 0') ubman.run_command(f'host load hostfs - $loadaddr {fit}') assert '2' in ubman.run_command('source') @@ -34,3 +40,7 @@ def test_source(ubman): ubman.run_command('fdt rm /images default') assert 'Fail' in ubman.run_command('source || echo Fail') assert 'Fail' in ubman.run_command('source \\# || echo Fail') + + # Restore the control FDT and clean up + ubman.run_command('fdt addr $fdtcontroladdr') + ubman.run_command('setenv loadaddr') From patchwork Sat Mar 14 23:16: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: 1985 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=1773530271; bh=7w/q90wF7BlmF4B3qAB9sp3Szx9UvnGcRmCZNV4KxI4=; 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=PACRWTnwr3DtElkF3BHszMCB/FAV7S/zDiC9hgAz3osoqLfqfCDsmtRlxF7iH0Gwv BCGidIDDwUGhV6jwkmmdh/UjfMg7VkJO4Nh9Lfsmou+90SM3fPD5i8AM85f8YEviE4 EcBLqz7Af5jIprN2ftVZezcTCs19+1+IKgc7ySK95TIJcsWRSH/4cnZ0ox8+dCOlVn fUq5PQ8+jhp8MLLmjwUmYCUOlUeQYvOZ8VR6xGO0lrlVeD3VdEGl8XIB2XhrTGEeAC 8LSp0iGYE/qanU/tizxGD/vBle9/bATKANv6QKIhR/3Ekrrr/IKLtKardp5vxyuqca jge+7dfSTYoXw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 49AF96A05C for ; Sat, 14 Mar 2026 17:17:51 -0600 (MDT) 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 SQTgXezTUBpW for ; Sat, 14 Mar 2026 17:17:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530269; bh=7w/q90wF7BlmF4B3qAB9sp3Szx9UvnGcRmCZNV4KxI4=; 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=nyePvsNGJRa6n//4imrdkMzvduqRklEj01+jGMxWOj7BrD+rHCJT1j19xecGdPBqX oafjoNhITI5jxEAM+gD84apqoJ3iZr5fxf+re6XjeTDyngkTucyXkdwVTrCN/BX3uN 0AydcB80Dtnq6P3eVBqZ8Zvj5S0locvWWwUyOlMadaVeJZQyxx9XyDL6vZYbpsz+ok DFaAxFvDHjdUGQFkuMRdJ912Qel857/28ovSSa+bCZYUOHsU0/A3ulX5LJVLYlFLAK zhCSSl4LkMXQCJzEdgey/J0OsKWejSwbv4ZDbSH5vlcmt47nRCYG4hqLgL05dJRbYj m86NiUAlpnyJw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5392B6A049 for ; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=bW1ocCo6oGuK5ndaQAQYJxuF6xsCQTFT8TghKZGV4gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AetmQbe3owpXkKRNy+8z23iw6vMqFF6NdHC2nnVPcVABNK4v6H+FTJukyGoSop2BN 8XU0r0PtFZCfuPW0kQNJTP7rT9yDR70q4bd1l/bcMVkGYoVg8bAMS5vo+0Auo6bJMi p7ukidGAaUqLqG7MAVdTWxUPnnHR8fbwzwmNF3X6fmtp5DBR9DnDYRZlfXIZ6+vbAr 9ZVS1X1uNVlg8pLHN8sjOAsOFQo2ZkMdfDtgRxmKdM/LvEsb5x4rwOTpLiN6QuZ7RN YC2BuNpeTYMwbM7wYEGta/sXcW9lMX41H0RYvQ6IMNM+U9Fc/r9wQay4H/nb99uzNY mbE35LUJ1HclA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2C0BA6A03A; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) 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 KhzEnBoWZ41Q; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530262; bh=Z+j3VKiHJ0gSqp/ypNXr2lzedLwgI/9Paah2iXNoQ4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLi5ZpPkwMdvxcEnGpitwPXerInyJxl01W4KnYmWQoYHbZk0LRB4jap66xbJV36Es 6NzAXkboAVVjhBDi3EFTimCKu+kXYPbnqNOMyGxrwJ7ZxJR+NHs6HjjYpSEvaGIxQk t9rUZxrbKgknkSYYgHC0Oe88xstrTRdUmFl51I3ZRCUxj2FxtJx0mzGpFXSt5lCWdj TPZzH+fpo4/4lrNj2Q21VvfWXQJBoIH6TMdF7WY9JyQA4vUgwZgBr4Zzz5ouEB2A4q 7aGhdD71geIZlQSChAkKK/GzPPKOijZdiKcmLefvKmj9qf5ZEPX1tPnCcf12Nl4fF+ vXAjYlfi+qd8A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3A8B76A036; Sat, 14 Mar 2026 17:17:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:04 -0600 Message-ID: <20260314231618.338113-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7UY67VML7465I3SGT3ZY4KJYIBUFINJ6 X-Message-ID-Hash: 7UY67VML7465I3SGT3ZY4KJYIBUFINJ6 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/19] test: boot: Reset EFI log at start of bootflow_efi 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 'host load' command calls efi_set_bootdev() which allocates EFI device-path pool memory and logs a free_pool(NULL) entry in the EFI log. If test_source (or another test using 'host load') runs first in the same session, these stale log entries cause bootflow_efi() to fail with EFI_INVALID_PARAMETER when it validates the log. Reset the EFI log at the start of bootflow_efi() so it only checks entries from its own operations. Also move the bloblist_find() call to just before the log-checking loop, since the log may not exist at function entry but may be created during the EFI boot sequence. Signed-off-by: Simon Glass --- test/boot/bootflow.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index e1e50319740..9aab3ea807a 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1393,8 +1393,8 @@ BOOTSTD_TEST(bootflow_android_image_v2, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT); /* Test EFI bootmeth */ static int bootflow_efi(struct unit_test_state *uts) { - struct efil_hdr *hdr = bloblist_find(BLOBLISTT_EFI_LOG, 0); static const char *order[] = {"mmc1", "usb", NULL}; + struct efil_hdr *hdr; struct efil_rec_hdr *rec_hdr; struct bootstd_priv *std; struct udevice *bootstd; @@ -1402,6 +1402,10 @@ static int bootflow_efi(struct unit_test_state *uts) struct udevice *usb; int i; + /* clear stale entries left by previous tests */ + if (IS_ENABLED(CONFIG_EFI_LOG)) + efi_log_reset(); + ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); std = dev_get_priv(bootstd); old_order = std->bootdev_order; @@ -1470,6 +1474,7 @@ static int bootflow_efi(struct unit_test_state *uts) ut_assert(!device_active(usb)); /* check memory allocations are as expected */ + hdr = bloblist_find(BLOBLISTT_EFI_LOG, 0); if (!hdr) return 0; From patchwork Sat Mar 14 23:16: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: 1987 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=1773530272; bh=AQmJietZcml71NRWxiUf9sZ9+eGSJO1DfjLD3MRVoaE=; 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=m+I3vybReceUHTwy70FUktsWbImvcKgIUNleUqWtkIlJj6PNQwM5ii8oVaA7PKLNf jl47yVF4lOPKjkmC/LUNyFlfpbR+rjUbSM+8Qxnm/qsogRTYyEc37vN+oAoR2AUR0E 3pw39uoI6Bj+dLhDnHzV3rMm0dWAVX9ESGoXRFbdxKdhchP2GUbp7iKINn/Y7ofFOt KRxaF/1gZJlBn6NJ2jSar9K3hJyLxnwjveoTexObmDUdCBgfJZSnGLwUbt22AfhlnS E8Hc/k0IUGMRHPcxFnASpvo/mJ+55EupT3t6UPO555e8X+41I6BxzuNHoJBt/az52d /XD08LStodS2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 67EB66A054 for ; Sat, 14 Mar 2026 17:17:52 -0600 (MDT) 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 Aptn73LNPJwz for ; Sat, 14 Mar 2026 17:17:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530270; bh=AQmJietZcml71NRWxiUf9sZ9+eGSJO1DfjLD3MRVoaE=; 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=cwLAjDOi2Sn14VruIZns2Mbokw+2AxrZB3S2RQotNzmcaU6ktnSyFma031aogES7O tv+/rpMhAXVIlm9zrxToUYO41E7rBO8zzHiHFKCMbuHT1gvseki8EEgFia9hIyeKVn MP1MxM2izYVuJLNkF3rkE/vb1FL3pXWSFzkz9M+Z9E1//0l2McEhdDTogeipjaOOZ7 g0z3Zy3KWpoMvVzEgqFVZs6EvHB2oQ7Aidpzw22BO4iELMXQMNssF6MwCo25voAUUO i5eomggUYGRNCLwm3p+IdaA9W7NWaLq1tCNJz6BRRIVOqlh5owSyZ+Ay5QukbOiXX/ 0MsHzZa4dSG0Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 870576A058 for ; Sat, 14 Mar 2026 17:17:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=EpGMmDEO8o2Gu5MqccqoDno83cLnxsvZ2djzhqStBMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpunPL6per5I4fG5wG7NWJp+ZzduwKHS3UJJwK9ZbX3yYmmryz8vWKPy3pP3faNP2 5Y7byxdkwafrkoTRpY43I2TOb+JJefRxZEfWw6yoW0z6ubTQoBdtHMyppIa2OtAlVH 8PaYIDeHzdg7E3PV5rSfkSejUtOJhiTLYS7JEp1XhC2xzB0e6DiVIEjNNgUz3vQzG3 3BgvzDWXxDpanThwHdeKQ8KLeEnT7QtaTb+N4tHShiqQPyKQfTQJc3N9w6X582BdOQ xQgz/s1Q7CMbASTYV1cSjANkiH6pRwI7yJNtEvO4hhxMMcH//PaK7Q4N/2YItL8vga bdxzmOBhX10wQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 42F716A036; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) 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 EEm97DAhFYAE; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530263; bh=sSfOMttqUBBEj+lxdpn/blmojpqDAiwuGRT7cXZ+GWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/E2iFRBWJhhvRpdPkmWx61LQT0Ib97AOJxNzFLjKiFl86tb24BXRu7h+o2yuqbDK VmjaEcG+JKuPwf/W1b7/mAmIrSYn7DE9Bb7UdF09zthKzW9ZG9TZIc+ctmuSC3QBy6 7/yOdS5gOVeNMciAqaQsr5tuuDh1ksONO9zCdszY9WFQTM5o6EMJGbml/9a+Znk/id 29PNG4fLComKS6KXic4t7HTw+3HRk5DcZJ3p4E3ie15hkTXrrWrnf2+oCYjII4eyYR WRZ1w/KPeBkAeh862zzP4Lr6hvSxRWrdlmIQGGImt9MA/Im0MvMD7q8nHfoSmwVGl2 JeLYNx+dcY7KQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F0EC26A033; Sat, 14 Mar 2026 17:17:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:05 -0600 Message-ID: <20260314231618.338113-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FWMBXH55FGMIPBJUH6JOHXDNAB6KTDVY X-Message-ID-Hash: FWMBXH55FGMIPBJUH6JOHXDNAB6KTDVY 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/19] test: py: Mark slow EFI selftest tests 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 These three tests take a long time to run (2-8s each) due to the interactive nature of the EFI selftest framework and the U-Boot restart they perform: 8.4s test_efi_selftest_text_input_ex 7.4s test_efi_selftest_text_input 2.4s test_efi_selftest_base Mark them as slow so they can be excluded with '-k not slow'. Signed-off-by: Simon Glass --- test/py/tests/test_efi_selftest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 2a959ae3406..ef1301f620e 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -7,6 +7,7 @@ import pytest @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.slow @pytest.mark.restart def test_efi_selftest_base(ubman): """Run UEFI unit tests @@ -64,6 +65,7 @@ def test_efi_selftest_watchdog_reboot(ubman): ubman.run_command(cmd='', send_nl=False, wait_for_reboot=True) @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.slow @pytest.mark.restart def test_efi_selftest_text_input(ubman): """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL @@ -120,6 +122,7 @@ def test_efi_selftest_text_input(ubman): ubman.restart_uboot() @pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.slow @pytest.mark.restart def test_efi_selftest_text_input_ex(ubman): """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL From patchwork Sat Mar 14 23:16: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: 1988 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=1773530272; bh=Nb86YYI8ZAn6Qj6EFy1GfPv5OYVQbQqa4WFXVPcEb+U=; 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=JzGi57IQZe6rKsIfsMAcymuBBbbo157OXrJHcfKrX44t98hIBClPme3twU1Z650Ao 5CMIF8YAoEAazv0KKhwkR4g+8X0YRDvL5TKC6axxEMnmeXztqQoV//Vle5C37KG7tf z3knAtmTX0Xd5F4bARBYTlWrU+AGw/VTUk9RgH9PClae+3j+z1e5vo/m/0W+LNKAPY ZicqidPv/p8a4uFmdmsY2Ty9JOq5Yoz4vrSQ03Ua3kAhX9iTJ/aDmNttIv0dLWsMRV x2m4NenmnLyYRo73tXrH5VbktOEVcKUO+4LxU4ow6PqRANufhNZ5FqKPmPbSQIDfaI KWHZwtLsU2YVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C91486A042 for ; Sat, 14 Mar 2026 17:17:52 -0600 (MDT) 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 Oco0rdIA1b6Y for ; Sat, 14 Mar 2026 17:17:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530271; bh=Nb86YYI8ZAn6Qj6EFy1GfPv5OYVQbQqa4WFXVPcEb+U=; 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=CugH9Y/po1moOUMU0nJTo63s4qmmRh6tHkAbAvwwyaUDD5HXzsiajo3JD3LdXeO44 TCOgjujB8za6s8n06Q0pmC35bAFss3G+LGupqr4YUIZZ8V8UBsRPrBYFppb3cociBo EsgA0YnSWPCwUalgX3QrOlyNXU/0yeu24R6SHTlHZLnzDFc2/nO8/by5QT/vwqiHot tkJ3OV8eMFGEPzn+oeNVf2e5jgzE/Tv1t7QrbVA303R8Ttd0URJRKNcIIKRLzDWqGC O43gk8t6KkrPjUE39eVsT2rQix4tzfvAL/r/venpYkIGfXJAMhIjDLjkugRuwqhY+z 9W7XqAr8EoWwQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 27E386A046 for ; Sat, 14 Mar 2026 17:17:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=OkxcP+ILq4se6hV6gq3JCZSESJRDM2GMM2OTIPVR0nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fJHy9y/k5P5qES3dKMywT4o1NnsIZN3VqQzVqUnhQpRMFvm7g+qZJ51nzOjAY8ofN LQEi45c9THl5W3RDudigLgAIKhP9NsUKkeYSuw82d5Oow7tOmrvw86PivZn9LcknAN 3Hei61XFLSJ/oBEIh1JMMgtJlJDRb91SvpPrbsyV0MMQNSmgZ6qthH41/mpFbqpm1r zwWuCVDdrlaCtSJlC6ITk1m2O8IxbLfjl4/zIS1usYzXGLMYMbMcuNFYn8vDy17qPM EzYOxjMA94ZeySIuyD/TNIULknx1tFbrYY3NEmaVElk+8o7FNF0lQ+2qq2GwmIcop9 CcBVaSjlL1hWQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 58B706A033; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) 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 YH25zUiqtObG; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530263; bh=loK6hRgLFQ6XjZeuNywCGaKboZ/LQxQ7HuE89JVbNm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czzkmMdeeTudfULUhIQ4SGF5JgsPRCAWO+P3Z6QbNF9F62S2H/3PT0mLq2UfZi+ET rMzf19VBItk/hBTEYJcc7VamXorRBgaLq4P3+NH8tv/v2QMSbJz/C2qRUXJgI0anSy bcHTOH1w8ySjTCPc5EozriZbLtexctQqL/A+YdYPAdj1HDQ0esffGO1fpyD+Ay/ECW o6/4zARI8Bhq+eoGgN86NBJydwZzQE/dS7aXOppRDyvUY9Uz/OIdpkUlQYKe3MLYC4 VAG8j0iDnscIZC3OxPWWOVLNUrAUNYbn6v+5Xfc8gzGkGBPPiEawbRTfUjg2C5kwr+ t9rAW2XDjkCeg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AEE986A037; Sat, 14 Mar 2026 17:17:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:06 -0600 Message-ID: <20260314231618.338113-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6Q2QYX3WZRVT65I4SUR3J272OEUT7CKE X-Message-ID-Hash: 6Q2QYX3WZRVT65I4SUR3J272OEUT7CKE 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/19] test: py: Add --malloc-dump support to pytest 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 --malloc-dump option to the pytest framework that passes --malloc_dump to the sandbox binary. The filename may contain '%d' which is replaced with a sequence number that increments on each U-Boot restart, so each instance produces a separate dump. Override close() in ConsoleSandbox to send 'poweroff' before closing the PTY when --malloc-dump is active, so that state_uninit() runs and writes the dump file. Signed-off-by: Simon Glass --- doc/develop/malloc.rst | 18 ++++++++++++++++++ test/py/conftest.py | 3 +++ test/py/console_sandbox.py | 26 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/doc/develop/malloc.rst b/doc/develop/malloc.rst index b5c84c4c3bd..7e46c05dfde 100644 --- a/doc/develop/malloc.rst +++ b/doc/develop/malloc.rst @@ -511,6 +511,24 @@ by checking ``malloc_get_info()`` before and after:: allocations during the operation 6. Fix the leak and verify the test passes +**Dumping heap state on exit** + +When running sandbox, the ``--malloc_dump`` command-line option writes a heap +dump to a file when U-Boot exits cleanly (via ``poweroff`` or ``reset``). This +is useful for capturing heap state at the end of a test session:: + + ./u-boot -Tf -c "poweroff" --malloc_dump /tmp/heap.txt + +The pytest framework also supports this via ``--malloc-dump``:: + + test/py/test.py -B sandbox --malloc-dump /tmp/heap.txt -k test_source + +The filename may contain ``%d`` which is replaced with a sequence number +that increments each time U-Boot restarts during the test session, so each +instance produces a separate dump:: + + test/py/test.py -B sandbox --malloc-dump /tmp/heap%d.txt -k test_vboot + API Reference ------------- diff --git a/test/py/conftest.py b/test/py/conftest.py index f4c5e390a93..47a0d112e51 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -106,6 +106,8 @@ def pytest_addoption(parser): help='Disable console timeout (useful for debugging)') parser.addoption('--no-full', default=False, action='store_true', help='Skip flat-tree tests (run live-tree only)') + parser.addoption('--malloc-dump', default=None, + help='Write malloc dump to file on exit') def run_build(config, source_dir, build_dir, board_type, log): @@ -362,6 +364,7 @@ def pytest_configure(config): ubconfig.allow_exceptions = config.getoption('allow_exceptions') ubconfig.no_timeout = config.getoption('no_timeout') ubconfig.no_full = config.getoption('no_full') + ubconfig.malloc_dump = config.getoption('malloc_dump') env_vars = ( 'board_type', diff --git a/test/py/console_sandbox.py b/test/py/console_sandbox.py index 3bd109acef5..424e3ad2dd7 100644 --- a/test/py/console_sandbox.py +++ b/test/py/console_sandbox.py @@ -25,6 +25,7 @@ class ConsoleSandbox(ConsoleBase): super().__init__(log, config, max_fifo_fill=1024) self.sandbox_flags = [] self.use_dtb = True + self.malloc_dump_seq = 0 def get_spawn(self): """Connect to a fresh U-Boot instance. @@ -57,6 +58,14 @@ class ConsoleSandbox(ConsoleBase): if self.config.no_full: cmd.append('-F') + if self.config.malloc_dump: + try: + fname = self.config.malloc_dump % self.malloc_dump_seq + except TypeError: + fname = self.config.malloc_dump + self.malloc_dump_seq += 1 + cmd += ['--malloc_dump', fname] + # Always disable the pager cmd.append('-P') @@ -84,6 +93,23 @@ class ConsoleSandbox(ConsoleBase): self.sandbox_flags = [] self.use_dtb = True + def close(self): + """Terminate the sandbox, using poweroff for a clean shutdown. + + When --malloc-dump is active we need state_uninit() to run, so + send 'poweroff' instead of just closing the PTY. + """ + if self.p and self.config.malloc_dump: + try: + self.p.send('poweroff\n') + for _ in range(50): + if not self.p.isalive(): + break + time.sleep(0.1) + except: + pass + super().close() + def kill(self, sig): """Send a specific Unix signal to the sandbox process. From patchwork Sat Mar 14 23:16: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: 1989 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=1773530273; bh=PoEwhhC58P3l+FBg08CLrEl07T/tsg5YYgPbJPa4EfQ=; 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=egAREJMXmsLAekPmlTU5qXQRzr9O/Ju1/ivsHngU5QOM8ocsL3zUWkzAG7libnbin JWEwwJOTAbq0N0TNgC+lew/1CgX4ePZEM+z1+uBXuPpCGQ5vj/pqgoekPPzmFsducc YDvFgamujBDJxi/BeTPdf/v3ORW1z09VLhVhPNu7rze2qhiLS9V/SgY2Xv4Natl2IF ViCSO+FDZ7ZkPxUycufIkqsBrTqFYS7AX3bM8PWqxVE+F44VhRPbL/UK9ntcD1EtoK I1HXhT6GbQU3SIhPh9yDN3G8bOLxHtQ/iyFtUebnOol9Wb4xVObSSnBf/O/GuGNAOK onxTTBKlaVJjg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 34D996A03F for ; Sat, 14 Mar 2026 17:17:53 -0600 (MDT) 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 vVLorRF6_lZu for ; Sat, 14 Mar 2026 17:17:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530272; bh=PoEwhhC58P3l+FBg08CLrEl07T/tsg5YYgPbJPa4EfQ=; 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=bcSG4vMRulZTNwWamQzlGW2iCNmWDmZ7biD0FK0x21UmX3463cHpWPWMcHlj/3Slu 6apcSEnnC0YU6f5PepeGyr6gD48AhsINiLf4+gXQe3E4gmDzAXdmk+LmYx7TTFpAR8 0cwUJsMlzEcNK1jU6uC0wxVkCLbYnM7S8OWRCj466rZT4jCa/jDbY781uoTrTqJ7mP 2sTqSPnXz4tPAj5YLlYB2m62Cpt385AyTJzZTwdeAGxGT2CAf0fldivjCHccr1QtVD vyEy3kV7rfYhYhNeDWvIdp9/er3yroz0RErZ3a7E8yN6xXeGJUbtWRBbsMQegT767D CXkFGEOLEUOMA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19FB56A04B for ; Sat, 14 Mar 2026 17:17:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530269; bh=xz7xrlttIYUIIq1SL2w/tkvGI/HUlLVKpftHpYvmTqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QkNd63R5Nww38Gh/hs0hbVWbhHMGnLle8UDqRtmq4JUjI6GxMxjM3vbDacT7XaNEY xdmXwX7X8w7K5/GuYETRQNsbdTdWW1N+KkvzRKIajEuJ4ydX1jh7btZPjCOxmI3Z7Q mG5VTm/YdL1QEkp4Z5n7uIyFP48DjbXF5evPBm78gGuqbnlQ2IZ3KNykX5BkXPjrXJ IFS8j+9wKJDui8R8hOgAjHkYrqdWx4UmrPfMJhrZHr38do4OHZlnAnykMgbWJEiFWy dipGJjNaenY8JDHo+vJM6hJTOXIwMJ2cPg8KsvFeK6JKw/g0L+Fz77zaw9oUK/rnjL x6Ec3N52PoQ9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B9F206A056; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) 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 eExYjXSmjF23; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530264; bh=WqV9CcqV8l++WVPD03T5n/3KzulQDIRGmb0NtTPgA/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqQ3mPjuywIwcZIsVAK/BptHGJ+lA5m5+F2mqEXLYNJiUE2dmhtNUdR4ELmfAZZC+ 11TCgbRK3WFJc8G1VcSTJGj4axs1EOKsXLS215jt5BX1G1pGO77M+HTuGd9wdt0lmF LslKMElPbhKFmepvGPioP/29OsIHsRz8CiqOIE6EnL8ItT1S3sfDQ855O5WPan02Wo 4zg9N/y+Cp8KiziB/B8jPZElgKSuMfHH5JdnKXoPZJLhTv6CLpweaZ98M1lsEN1t2y s8PdawQDhHj6vmS315ABsdC7xWYf/wWrpYh/TU/5K2wVSp/LXx+8TYum0FskKuD9bc 5/eIn+9i7TRaA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 911746A03C; Sat, 14 Mar 2026 17:17:44 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:07 -0600 Message-ID: <20260314231618.338113-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LREUB4M4HV6FNVEV72ZXF6M2KMY34P6B X-Message-ID-Hash: LREUB4M4HV6FNVEV72ZXF6M2KMY34P6B 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/19] test: py: Send poweroff on every sandbox shutdown 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 When --malloc-dump is active, only the final close() sends poweroff to trigger state_uninit(). Intermediate shutdowns from cleanup_spawn() (used by restart_uboot and failure cleanup) just close the PTY, so those sessions never write a dump file. Send poweroff before every shutdown path so each sandbox session produces a dump. This makes the dump sequence numbers sequential. Signed-off-by: Simon Glass --- test/py/console_sandbox.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/py/console_sandbox.py b/test/py/console_sandbox.py index 424e3ad2dd7..21625140dbb 100644 --- a/test/py/console_sandbox.py +++ b/test/py/console_sandbox.py @@ -93,8 +93,8 @@ class ConsoleSandbox(ConsoleBase): self.sandbox_flags = [] self.use_dtb = True - def close(self): - """Terminate the sandbox, using poweroff for a clean shutdown. + def _poweroff_if_needed(self): + """Send poweroff for a clean shutdown if malloc-dump is active. When --malloc-dump is active we need state_uninit() to run, so send 'poweroff' instead of just closing the PTY. @@ -108,6 +108,15 @@ class ConsoleSandbox(ConsoleBase): time.sleep(0.1) except: pass + + def cleanup_spawn(self): + """Shut down sandbox, using poweroff for a clean shutdown.""" + self._poweroff_if_needed() + super().cleanup_spawn() + + def close(self): + """Terminate sandbox, using poweroff for a clean shutdown.""" + self._poweroff_if_needed() super().close() def kill(self, sig): From patchwork Sat Mar 14 23:16: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: 1990 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=1773530275; bh=wP2ZjAO3DpgJbi+y+QEOmYdj+Xh/7tfiSz2JzCxf638=; 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=sZBcgBzwK0GyGqZN4U+8f3UvkBBj/SNV4rRV/1n6L8+SCOksUITPEMqUx3RWpTmHF GRdCJwpClLfh/VVtXTdtIBQyGcGDTI/b7qplgI+l3ZHYmIG+uxJW32QHajKSqdDVTl Nb4vCzBf+j/zv1sFvm5qJGPjccQ/I/2Yi/GcUHz5oYy0SPtfoQc/9MucOmCHz/VqyU fNaFIwtGAhP7KttEUyHxHxSMqLsaYqWZSQpakpPN8hz9afn5xXbgE4cyzZ/yrf/xwE SVQTfieRBixKgHNNsGj5wPjpB8NnGHsmun2VsGB8XR6ZO+5d7mW3f5nzs0oqKCdKCR 0RkBmPDyBASIw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8EF8B6A036 for ; Sat, 14 Mar 2026 17:17:55 -0600 (MDT) 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 jeguoWLIlaK2 for ; Sat, 14 Mar 2026 17:17:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530273; bh=wP2ZjAO3DpgJbi+y+QEOmYdj+Xh/7tfiSz2JzCxf638=; 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=XGPIB7j8zuOrw1NIne9xYGGdYwIOHlovGJxrfZL+VkJIov/08IllJFD5/tyijEPTw BWclP9kL4xExKHReem8IKUPXV0yGBbe4G/8g9G/H8Cy4XtCGJXLEMOYeZdPBYGCXqq +53KlbfXYDgKSZf40Srras9wEE/AYcaucZf81FaLP4o8MOF6Qa3aZ9lxAFUbOQKtAG Y4+eqypdICC3RdIslq8NBXhL5Cms6b6dyWlGE6qNBJqHfWAPP65JgQasOe987TPQ/5 Hx2dBZOuSko8YIHhoQMsJ38Qcf3fAkLwOyEipQPnAZq6/GWveqFwWfkuzfza9fATnn HwAS0Fvy0rL0Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DD7266A033 for ; Sat, 14 Mar 2026 17:17:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530269; bh=4r6lhAUYdiO5tR4Ly0NnbK2CIbuBRQdkOaK96eHjwx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JhD9oszBf23UjufuudAAkIt2phT8VZYPK8MPn1CAs7sqUBvMQy1l56tvCebyhhHCk jWuir/zaenKpYPvAIL66UilyZ0JNTemYqZQHJ5RhAudz1JcDuREg/klJgcSpxa12LQ AV2hB04Rp0wYECKhaxI02j3btd27y60Lxveo8kftojyAcLGSiXqdUsbVnsDpRLXpCe q2aF7J8FKOZfPMU62CDT6H/C8jbhxHunFuO0UG99PxshAvpOYVxUbss8kmvpviOFBF cvS16hiOC92UUC+haFVa8hI64FaRaYOyWvFxgelygtnlK1kJZakIzheZzIq32IAYbf ov3+URTF2IEJQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C6C736A057; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) 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 NgDvHs0dFtRv; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530265; bh=SaZ2dNZxAW+3B4lXobSN5iGYNhPAZUuwRGg6/mSyuu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfbbfLjETddxqxseS0VKFBSLMS6cJn3E8t9M0GpY4NF++tIqWeHRMSSKgNPl0gKMe wEOXWVqd/kQRZJoT1HU87TLG78+3FHYgGfg26fB4icGu99bpovWpnwBVsBS0pGoA9f fTu18f8ocUdbzqqQJbpWhou26iCVy7X+RATeB/ECDhcFiU+7XJQSA2Iyb9up7UAZGS zOu1OptBdTohzYC8HfN+rmGrpOWgsvPDI+5/U6RvwNUjMKwJrekdSZX8OfX600JJEs 9OzZ709UqZSAaEUbzoXBWOVkAtmf5N/JfsJFDD8z9Uf1a5DmcqNuoR92Ol3fsIv66e SsHN7C0H7wJaQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 570756A048; Sat, 14 Mar 2026 17:17:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:08 -0600 Message-ID: <20260314231618.338113-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ILAQTU5YK5ZUUE6DYUILSCUHG2VJSDGW X-Message-ID-Hash: ILAQTU5YK5ZUUE6DYUILSCUHG2VJSDGW 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/19] test: boot: Restore default addr env vars in extlinux tests 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 tests set kernel_addr_r to 0x2000000 and do not restore the original value. When bootflow_extlinux_localboot or bootflow_scan_extlinux run later, they read the wrong address from the environment and fail. Restore kernel_addr_r and ramdisk_addr_r to their default values at the start of each test so they do not depend on test ordering. Signed-off-by: Simon Glass --- test/boot/bootflow.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 9aab3ea807a..53fa88ae080 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1677,6 +1677,11 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts) const void *fdt; int node; + /* restore default addresses in case PXE tests changed them */ + ut_assertok(env_set("kernel_addr_r", "1000000")); + ut_assertok(env_set("ramdisk_addr_r", "2000000")); + ut_assertok(env_set("fdt_addr_r", "c00000")); + ut_assertok(run_command("bootflow scan", 0)); ut_assert_console_end(); ut_assertok(bootstd_get_priv(&std)); @@ -1745,6 +1750,11 @@ static int bootflow_extlinux_localboot(struct unit_test_state *uts) const char **old_order; struct bootflow *bflow; + /* restore default addresses in case PXE tests changed them */ + ut_assertok(env_set("kernel_addr_r", "1000000")); + ut_assertok(env_set("ramdisk_addr_r", "2000000")); + ut_assertok(env_set("fdt_addr_r", "c00000")); + ut_assertok(prep_mmc_bootdev(uts, "mmc9", false, &old_order)); ut_assertok(run_command("bootflow scan", 0)); From patchwork Sat Mar 14 23:16: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: 1991 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=1773530275; bh=Wnl6BheaKIaVw6H39EoXuuSWPuLSoLikhrQDHbu5PDg=; 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=StC00afyqy/N/Lx/dMCv7IyRsNbGPW6buhmbBoLhF7ekf/CLWObU02FuFXQ4TEPB1 +kFwd9O770QEVDo4EI2c00bBsfB5hDOHwXZLv+Hkc07GPc1SbE0GK3UaY3gVjbJZ6I +HJG9lSqV0B7x89q8TKwNiSRtzSWDf6ISnICgXktKdpgqbKcAqCBT2Htf24DmRBS5t ZFCy0c28zY6XgLAHj7ncCcXASTCn1ox5ZFwl+ftS6pfCrvFFZHfhx5nhTlkx77mN1p CQSQh+SdXVBf6XL+ol6V1txfCLG4LL9kuUlE4Ncu7ncE9v+vLHM14pZJrE25ScB1sK I88ZMTVONs2iw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D4AF46A046 for ; Sat, 14 Mar 2026 17:17:55 -0600 (MDT) 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 clDK163a3_gT for ; Sat, 14 Mar 2026 17:17:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530274; bh=Wnl6BheaKIaVw6H39EoXuuSWPuLSoLikhrQDHbu5PDg=; 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=YkNjhwdADaGNGd6mbYlwmCxmPquI8bnE5DRzdnB5FCCAPy6nPT4t1gFUN5q0lD98M jK0XI5pcW6GDg1nkv26ftkb4x0KZYa4tIaFM/TDthj+KIe2Egr6jQPwa4r98LUkz6c ATEpZq9W3KqpF5xkld+Qx1ZAXYdsRjQmMObZk3zzHamZidMJmYWRN34auFjeqhYAKa gQKJ0rwG6GMdfZdOVAIxuPR4gkEikIK2DgpOxa5DoJvdC4aIg13w1R0uLMeHPNf0Gz NPep4+uVXSNMXm67bwRtPMzbJHa6FropcvjTEeUyhed8bqBZDTU64yX2JTTkky5Xrl oy85UDIm4ZDow== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70D796A04A for ; Sat, 14 Mar 2026 17:17:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530270; bh=E8ByFbCmhicnqLrATLL8nDsYiesK5D0WvOW2AaJWan0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLiTXjBXaZlDOmcfZSyeB75SsGg1z5RQvM+8Rp8KisN1ivgVPPmwKBbv2/pdhitdX oOaqhp00KdlbWVLSxOMc5c9Q1Gk2nvI9MjZ1N8jB7B8uiEbdjEvPU/WMo6P3S9Y5tL dcQg4nd2Pf9jb5vRHoHsqBOC7odo8KNt6rv8MCMgfw9nnROQ2vbIPE5I2I9hz/TW0J eD6q1CEE+Ku0bonI/xW+Zi1hpDlcveIXYREGNIuTlwYfIocApIsZANehBR+hfwn7RE WmWwfVJxqfGTn82m3DkE4nZPzAWBof4vx2oresDuqMNz/1/ucvlP/Sa4OgDFp/zP8B nl3RPCcST0JUw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 05A506A05A; Sat, 14 Mar 2026 17:17:50 -0600 (MDT) 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 Ak-HJh8gke44; Sat, 14 Mar 2026 17:17:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530266; bh=FhBa3ZNThi9cn9zU6W3A6LrdOnYezCa1Y3Y+zMf/cSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DgPIvduAyDrKFJwhb5peKqPpUGMrYTLDd50Ww64lj5puXFfstamoBqiklC7TOq8L7 S44V0TlwTnNFQQWtepoCjOknqgrmYy6GZheub3rs761lnP6CPmbs+guO7EFo89Z2Zp FjLCUBaasRJK1nqM2/JwLZgFVqQ7DSN1BJJ1Dtdhg7CSGjRQAqVWPLXoWvYPuyAI8a TbtEnKubNRqOj+xdcBy094b0+fmn2+zm94+uE7uYh53/IlTnbGBvoP++rkFIj5mUrn vqta1R7TE866nB4ZiQwXAGQNPknQXy+dRy86uX50rug8wEfb++NzJzT3OvVxFUAF+e Jn7xO2hO7PNtw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1A61D6A04A; Sat, 14 Mar 2026 17:17:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:09 -0600 Message-ID: <20260314231618.338113-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OQGYOKSTCDUKM6SBME2MMTMLBMOHS47I X-Message-ID-Hash: OQGYOKSTCDUKM6SBME2MMTMLBMOHS47I 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 18/19] bootstage: Add save/restore subcommands 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 'bootstage save' and 'bootstage restore' subcommands behind a new BOOTSTAGE_SAVE Kconfig (default y when UNIT_TEST is enabled). These store and retrieve the record count via $bootstage_count. Some commands (e.g. bootm) add bootstage records with unique IDs. In a pytest session with many tests, these accumulate and fill the bootstage table. The new commands allow the test framework to save the count before a test and restore it afterwards. Also add inline stubs for bootstage_get_rec_count() and bootstage_set_rec_count() when BOOTSTAGE is disabled, along with a test and command documentation. Signed-off-by: Simon Glass --- boot/Kconfig | 11 +++++ cmd/bootstage.c | 28 ++++++++++++ doc/usage/cmd/bootstage.rst | 86 +++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + include/bootstage.h | 9 ++++ test/cmd/bootstage.c | 24 +++++++++++ 6 files changed, 159 insertions(+) create mode 100644 doc/usage/cmd/bootstage.rst diff --git a/boot/Kconfig b/boot/Kconfig index cd66060f4db..d9d5214ca0f 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -1479,6 +1479,17 @@ config BOOTSTAGE_FDT Code in the Linux kernel can find this in /proc/devicetree. +config BOOTSTAGE_SAVE + bool "Allow saving and restoring the bootstage record count" + depends on BOOTSTAGE + default y if UNIT_TEST + help + Provide 'bootstage save' and 'bootstage restore' subcommands + which store and retrieve the record count via the bootstage_count + environment variable. These are used by Python tests to prevent + records from accumulating across tests and filling the bootstage + table. + config BOOTSTAGE_STASH bool "Stash the boot timing information in memory before booting OS" depends on BOOTSTAGE diff --git a/cmd/bootstage.c b/cmd/bootstage.c index 5c6d5a3ab45..ce69097b96c 100644 --- a/cmd/bootstage.c +++ b/cmd/bootstage.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -62,8 +63,31 @@ static int do_bootstage_stash(struct cmd_tbl *cmdtp, int flag, int argc, } #endif +static int __maybe_unused do_bootstage_save(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + env_set_hex("bootstage_count", bootstage_get_rec_count()); + + return 0; +} + +static int __maybe_unused do_bootstage_restore(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + ulong count = env_get_hex("bootstage_count", 0); + + if (count) + bootstage_set_rec_count(count); + + return 0; +} + static struct cmd_tbl cmd_bootstage_sub[] = { U_BOOT_CMD_MKENT(report, 2, 1, do_bootstage_report, "", ""), +#if IS_ENABLED(CONFIG_BOOTSTAGE_SAVE) + U_BOOT_CMD_MKENT(save, 1, 0, do_bootstage_save, "", ""), + U_BOOT_CMD_MKENT(restore, 1, 0, do_bootstage_restore, "", ""), +#endif #if IS_ENABLED(CONFIG_BOOTSTAGE_STASH) U_BOOT_CMD_MKENT(stash, 4, 0, do_bootstage_stash, "", ""), U_BOOT_CMD_MKENT(unstash, 4, 0, do_bootstage_stash, "", ""), @@ -95,6 +119,10 @@ U_BOOT_CMD(bootstage, 4, 1, do_boostage, "Boot stage command", " - check boot progress and timing\n" "report - Print a report\n" +#if IS_ENABLED(CONFIG_BOOTSTAGE_SAVE) + "save - Save record count to $bootstage_count\n" + "restore - Restore record count from $bootstage_count\n" +#endif #if IS_ENABLED(CONFIG_BOOTSTAGE_STASH) "stash [ []] - Stash data into memory\n" "unstash [ []] - Unstash data from memory\n" diff --git a/doc/usage/cmd/bootstage.rst b/doc/usage/cmd/bootstage.rst new file mode 100644 index 00000000000..44069e6fedd --- /dev/null +++ b/doc/usage/cmd/bootstage.rst @@ -0,0 +1,86 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +.. index:: + single: bootstage (command) + +bootstage command +================= + +Synopsis +-------- + +:: + + bootstage report + bootstage save + bootstage restore + bootstage stash [ []] + bootstage unstash [ []] + +Description +----------- + +The *bootstage* command provides access to U-Boot's boot-timing records. + +bootstage report + Print a report of all bootstage records, showing the timestamp and elapsed + time for each stage. + +bootstage save + Save the current record count to the *bootstage_count* environment + variable. This can be used to snapshot the bootstage state before an + operation that adds records. + +bootstage restore + Restore the record count from *bootstage_count*, discarding any records + added since the last save. This is used by the Python test framework to + prevent records from accumulating across tests. + +bootstage stash + Stash bootstage data into memory at the given address and size. + Only available when ``CONFIG_BOOTSTAGE_STASH`` is enabled. + +bootstage unstash + Read back previously stashed bootstage data from memory. + Only available when ``CONFIG_BOOTSTAGE_STASH`` is enabled. + +Configuration +------------- + +The *bootstage* command is available when ``CONFIG_BOOTSTAGE`` is enabled. + +CONFIG_BOOTSTAGE_REPORT + Enable output of a boot-time report before booting the OS. + +CONFIG_BOOTSTAGE_RECORD_COUNT + Number of bootstage records to store (default 50). + +CONFIG_BOOTSTAGE_SAVE + Enable the *save* and *restore* subcommands. Default y when + ``CONFIG_UNIT_TEST`` is set. + +CONFIG_BOOTSTAGE_STASH + Enable the *stash* and *unstash* subcommands for passing bootstage + data to the OS via memory. + +Example +------- + +:: + + => bootstage report + Timer summary in microseconds (8 records): + Mark Elapsed Stage + 0 0 reset + 0 0 board_init_f + 29,743 29,743 board_init_r + 52,918 23,175 eth_common_init + 53,007 89 eth_initialize + + Accumulated time: + 1,235 dm_f + 670 of_live + 5,621 dm_r + + => bootstage save + => bootstage restore diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 05e1828bf01..ecf0ba16700 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -49,6 +49,7 @@ Shell commands cmd/bootm cmd/bootmenu cmd/bootmeth + cmd/bootstage cmd/bootstd cmd/bootz cmd/button diff --git a/include/bootstage.h b/include/bootstage.h index da57f9b81c5..30858cbfb3f 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -519,6 +519,15 @@ static inline int bootstage_init(bool first) return 0; } +static inline uint bootstage_get_rec_count(void) +{ + return 0; +} + +static inline void bootstage_set_rec_count(uint count) +{ +} + #endif /* ENABLE_BOOTSTAGE */ /* helpers for SPL */ diff --git a/test/cmd/bootstage.c b/test/cmd/bootstage.c index dee4a0671fa..29df4725d1f 100644 --- a/test/cmd/bootstage.c +++ b/test/cmd/bootstage.c @@ -30,3 +30,27 @@ static int cmd_bootstage_report(struct unit_test_state *uts) return 0; } CMD_TEST(cmd_bootstage_report, UTF_CONSOLE); + +static int cmd_bootstage_save_restore(struct unit_test_state *uts) +{ + uint count; + + count = bootstage_get_rec_count(); + ut_assert(count > 0); + + /* Save the current count */ + ut_assertok(run_command("bootstage save", 0)); + ut_assert_console_end(); + + /* Add a new record and check the count grows by one */ + bootstage_mark_name(BOOTSTAGE_ID_USER + 60, "test_save_restore"); + ut_asserteq(count + 1, bootstage_get_rec_count()); + + /* Restore should bring the count back */ + ut_assertok(run_command("bootstage restore", 0)); + ut_assert_console_end(); + ut_asserteq(count, bootstage_get_rec_count()); + + return 0; +} +CMD_TEST(cmd_bootstage_save_restore, UTF_CONSOLE); From patchwork Sat Mar 14 23:16: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: 1992 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=1773530276; bh=Np1QRghToR0/QNcA+b5pIH0gO0bo6CrCceDcEDcq5EM=; 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=ihYe+xRii4q8IcDrjxrsjj+XAjrcCqP2wIUGMl2hpYM3lWI8xCohm777QZ3SevoRC cHisY88gvQ2HnUStrY0dkHqyfvkC37rSwL4V+EptuR3lcr1VouOBFF1O1iaJkOOXEc H7ycp43jfKTexrXLd1eBe3h3yNdFEcGgjeAUmsVNKqGbSCisRrTq2I74oOLvLTATwm RLWarPm6N0mUow3jAfuQHHBCFz1+gNib8W3M3wA2nUxWoxmR7vxSZyuQq4Ao/OSI9W XyCjXsOq/9ThwUq7Tq2hnBzMRd7p6rms931p5fP/BkPrc8zjSkKA0dYW8Uzz/SgNU/ kMVXpcXgW/+yw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 31C346A03D for ; Sat, 14 Mar 2026 17:17:56 -0600 (MDT) 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 uvlOzrf517lB for ; Sat, 14 Mar 2026 17:17:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530274; bh=Np1QRghToR0/QNcA+b5pIH0gO0bo6CrCceDcEDcq5EM=; 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=W61UKCpMx6DgNkPIlYz1xwO9DICyUaEKrCfzAztnsTsy2dDISxZeyJ4DbYoZCX3bz KOTOQjy2L0U8UoQHvaCRvLBsquAon1wU9aSDT8ucLu07D1ctJCFANeWzmGik+d3y7q MMapVs0ogj6WRlTAcqVhZ0UOFvzfPNwoZudGRU8l2ztuV5wD3+s0c3ZV9dr1L+EPwn FmYPZJgEPUZEXuU+PgBzmEFCe528skODTbFkWKSrjC0qIX7PMdI98Nt4fDpfaKGFk1 XlYj3dBxi2Ls/IsS7B76/S36ediNbsq3mmn/VrlQXi0oNZHM8YpmLjjunJimQKqttK 9kv149uevixfQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF0E36A053 for ; Sat, 14 Mar 2026 17:17:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530270; bh=F8gvVED2ZyjEdFZ5f8pAZ5UhDDQ9nTw1pONmCMKl+KI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2TCgruD6BFKfn6HC+To+e1/Nxq++9mXn1FHv3wcNDlqxiG57Y2c3w3itVrKfPmZ8 bKr2KXRQFC0DPPqd3CwY9BSuLkCtBSeTjxrF911QLBOW00OHIj9ZhaYiKEXlvSGOy8 PjH6lo8m27XaYh/UTAmHIrWjOYZUfaMm7ES3rUPvI6gv26qqxdKa+CrfPYwo/Va8Lw XaAYrWVFs7ulrd7strT5I9SKenkQXYdfICqKBgcxZvBewJ11MvA1FLv9cEy2VeKN1Q 5J7Pvgs7vaC1+FnuM3n2eGRxoBBVFCx+5Mn+k/RRPlO2cnmyHz2eH4NmXarU2Yx3X7 9pPBvxhlrVEQw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 416716A057; Sat, 14 Mar 2026 17:17:50 -0600 (MDT) 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 S8JECGFKkk1y; Sat, 14 Mar 2026 17:17:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530267; bh=mBHzfWxCQ3inDr8mblE7vwNg93Wk9/Rjwn5Lxu1uAgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fa6eHHV7x8hdD0wdHIkhNYd0k+pBqcs9OET5GYnrB01zwh1BeNUnLMRSxmTnBC3oH vk86p1qW59vfqhcBzw1Ns8m+znFi2Iy7ZEYDYBoMQrwX0cTVxdT6r3tQgmLjawL5UF 7IAQjvATxFWqgUjAAbdfR8WM3IvWhceZfIyo4E82622KbBlFo0cr3JJjNxq9xaS8JW /zsXuepKiuyBN/IzgOiCu0Rn7HUPCtSLVykCLxoCwu+pIau+3b7mXKzsnPcpqWSwQG Cf9DbbT4/eOgmj8LZZmoO7bsv37xjNKKFBExwLJi6MIlA0vBI15dwQjN/DBfmPZyWd 9fglcSlqaU+lA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 221616A033; Sat, 14 Mar 2026 17:17:47 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:16:10 -0600 Message-ID: <20260314231618.338113-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260314231618.338113-1-sjg@u-boot.org> References: <20260314231618.338113-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: R4Q4AFQAGAXLU7266T6HYHE4PP6HHXLB X-Message-ID-Hash: R4Q4AFQAGAXLU7266T6HYHE4PP6HHXLB 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 19/19] test: Save and restore bootstage record count in FIT tests 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 preserve_bootstage() context-manager helper in the pytest utils module, and use it in TestFitImage which runs bootm and is the main consumer of bootstage records. Also save and restore the bootstage record count in test_pre_run() and test_post_run() for ut tests which run multiple tests within a single 'ut' command invocation. Signed-off-by: Simon Glass --- include/test/test.h | 2 ++ test/py/tests/test_fit.py | 6 ++++++ test/py/utils.py | 18 ++++++++++++++++++ test/test-main.c | 5 +++++ 4 files changed, 31 insertions(+) diff --git a/include/test/test.h b/include/test/test.h index c3b251e2cd4..b81cab4d7a4 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -92,6 +92,7 @@ struct ut_arg { * @force_run: true to run tests marked with the UTF_MANUAL flag * @workers: Number of parallel workers, 0 if not sharding tests * @worker_id: ID of this worker (0 to workers-1) + * @old_bootstage_count: bootstage record count saved before each test * @old_bloblist: stores the old gd->bloblist pointer * @soft_fail: continue execution of the test even after it fails * @expect_str: Temporary string used to hold expected string value @@ -128,6 +129,7 @@ struct unit_test_state { bool force_run; int workers; int worker_id; + uint old_bootstage_count; void *old_bloblist; bool soft_fail; char expect_str[1024]; diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index ed18ff68825..6fb76196e16 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -140,6 +140,12 @@ class TestFitImage: - run code coverage to make sure we are testing all the code """ + @pytest.fixture(autouse=True) + def save_bootstage(self, ubman): + """Save and restore bootstage around each test.""" + with utils.preserve_bootstage(ubman): + yield + def make_fname(self, ubman, leaf): """Make a temporary filename diff --git a/test/py/utils.py b/test/py/utils.py index 083a3feddc2..9097f158496 100644 --- a/test/py/utils.py +++ b/test/py/utils.py @@ -14,8 +14,26 @@ import signal import sys import time import re +from contextlib import contextmanager import pytest +@contextmanager +def preserve_bootstage(ubman): + """Context manager to save and restore bootstage record count. + + Some commands (e.g. bootm) add bootstage records with unique IDs. These + accumulate across tests in a pytest session and can fill the bootstage + table. Use this around tests that trigger such commands. + + Args: + ubman (ConsoleBase): U-Boot console connection + """ + ubman.run_command('bootstage save') + try: + yield + finally: + ubman.run_command('bootstage restore') + def md5sum_data(data): """Calculate the MD5 hash of some data. diff --git a/test/test-main.c b/test/test-main.c index 5db35b59760..77223cfbcb7 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -7,6 +7,7 @@ #define LOG_CATEGORY LOGC_TEST #include +#include #include #include #include @@ -560,6 +561,8 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) gd_set_bloblist(NULL); } + uts->old_bootstage_count = bootstage_get_rec_count(); + if (!(test->flags & UTF_NO_SILENT)) ut_silence_console(uts); @@ -589,6 +592,8 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) log_debug("restore bloblist %p\n", gd_bloblist()); } + bootstage_set_rec_count(uts->old_bootstage_count); + blkcache_free(); return 0;