From patchwork Sat Mar 14 23:15:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 131 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=1773530197; bh=q9rMmh7C1VioLjG9SUR82hPItj/R9OkduUr2GKi2qEU=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=QcIMlALrdmSQXJp4aK0LffwI9fbs/sqZgtTltAi8pv39yo89RLdF26U4hwSvQcY9S RCkJGBUtIcWo2N2qni3revF37jX0HrjQJ2h6xLE5OWwbpIFgWf14EMW168FbVJF2/J GbczOrEiH5g5fPfEtzhUpimu1cxVHVgAe1O9ECUByOrH+T1GNJlSdZXiC3/VjfBrNv FsPOTvcqTmmFKH13c3blKcKw6MJDD2tBS+UQDP1YLkEi2PTgUE2U+Y0V5xQWI3MNpK bOKG97y6XK4ifEdtOFDdau+HIz0MsOO7n09eQtGNKTcuawUaOBTWdTjEbJ9/RqAjqk VHSJTUl48bMHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98EE66A033 for ; Sat, 14 Mar 2026 17:16:37 -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 2u-sjBEWA0m7 for ; Sat, 14 Mar 2026 17:16:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530197; bh=q9rMmh7C1VioLjG9SUR82hPItj/R9OkduUr2GKi2qEU=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=QcIMlALrdmSQXJp4aK0LffwI9fbs/sqZgtTltAi8pv39yo89RLdF26U4hwSvQcY9S RCkJGBUtIcWo2N2qni3revF37jX0HrjQJ2h6xLE5OWwbpIFgWf14EMW168FbVJF2/J GbczOrEiH5g5fPfEtzhUpimu1cxVHVgAe1O9ECUByOrH+T1GNJlSdZXiC3/VjfBrNv FsPOTvcqTmmFKH13c3blKcKw6MJDD2tBS+UQDP1YLkEi2PTgUE2U+Y0V5xQWI3MNpK bOKG97y6XK4ifEdtOFDdau+HIz0MsOO7n09eQtGNKTcuawUaOBTWdTjEbJ9/RqAjqk VHSJTUl48bMHA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 88B6F69FF7 for ; Sat, 14 Mar 2026 17:16:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530193; bh=DoMJh+ss5UAuUtJfweLQI51nVq5ObNs7k53BCGimX90=; h=From:To:Cc:Subject:Date:From; b=NH+ePlwbmhbeLAlVtNjJ95UYJuP8lWCAMJPf87BnyZbpNfQYgtaBXj1rggLwjX96I jZ6GsXsSvDj/Lh+gTgw1s4zRcwAIyGTe1llo5/lQGmtDpcd0w4suwH8Nt4VissZJfU m+yMHWAnYk3dLH0pPh7dbVvi5kQvx9NPg1pMmF7GxWNh6ymh5G3XYm5XfnH7I0F8+L 8widwyQpkFycoBKtkFIebS7kxErsfkkr2bOaTJ4gO9pflmc1GgwdSja4qauOskH6kv I5/uZh4wmg6gqfcuVIZgWO9xVOYnak4dja4ODAXo9kFSfgwt+eP1UIpDZkvuFfzZZ7 vrGyExWwZ8GLQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EDBA269FF7; Sat, 14 Mar 2026 17:16: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 10026) with ESMTP id EEgkqM9BbFCE; Sat, 14 Mar 2026 17:16:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773530189; bh=AW4HdpWGXT9ZsYQVhVZov1rl79PwnjhVc3j8Oo+7nNw=; h=From:To:Cc:Subject:Date:From; b=pfDIjPmwKKjbKScgtbSn92D0LaInjiRyLY5mTnvwdiOwldpR5dXc/xxVoQgkTimJ9 4DLEBueyG8fwdesWG507YqB8FhZMsoz1CCOB0bOVJKpMhzcj0dCjA572Kzh4WEnYar RVVxjq0dEhiQTuJ0QFvX+i62TXsms8GFPm8H/OUUwVY5yOQVtoYZInxdwqZ+B5ZFZq iJSJILBPp2fGBVOxdP4NBUEYRM83jo+163CD9PZfqfticd/8vfRldIGEhLOfxOGKF/ 7kZcxzTlmLqXng71qO3/XXjuYesKkYtz7eIqNWbaBu3A9MtFnwwl9SVLgnjHX6YMuw l/wpF3vJzOdTA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 624E669ECF; Sat, 14 Mar 2026 17:16:29 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 14 Mar 2026 17:15:51 -0600 Message-ID: <20260314231618.338113-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: YHH5HHRDZ52MH6HOSIOZSD7WWWPFYQSB X-Message-ID-Hash: YHH5HHRDZ52MH6HOSIOZSD7WWWPFYQSB 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 00/19] test: Fix pytest inter-test side effects 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 Several pytest tests leave behind state that breaks later tests in the same session. This series fixes memory leaks, stale environment variables, dangling pointers, EFI log pollution and bootstage exhaustion, and adds a 'restart' marker for tests that restart U-Boot. It also adds --malloc-dump support for debugging heap issues. Simon Glass (19): sandbox: Pass exit code through sandbox_exit() sandbox: Use sandbox_exit() for -c command path sandbox: Add a command-line option to dump malloc state sandbox: Move malloc_dump_to_file() prototype to os.h bootstd: Fix memory leak in bootflow scanning test: py: Add a marker for tests that restart U-Boot test: py: Restore default log format after test_log_format() test: pxe: Fix dangling pointer in FDT env save/restore test: pxe: Fix ipappend test to clear board env var test: py: Fix PersistentFileHelperCtxMgr with stale .pyc test: common: Fix memory leak in malloc_fill_pool test test: py: Fix test_source breaking later tests test: boot: Reset EFI log at start of bootflow_efi test: py: Mark slow EFI selftest tests test: py: Add --malloc-dump support to pytest test: py: Send poweroff on every sandbox shutdown test: boot: Restore default addr env vars in extlinux tests bootstage: Add save/restore subcommands test: Save and restore bootstage record count in FIT tests arch/sandbox/cpu/cpu.c | 5 +- arch/sandbox/cpu/start.c | 13 ++- arch/sandbox/cpu/state.c | 3 + arch/sandbox/include/asm/state.h | 1 + arch/sandbox/include/asm/u-boot-sandbox.h | 2 +- arch/sandbox/lib/interrupts.c | 2 +- boot/Kconfig | 11 +++ boot/bootflow.c | 2 + cmd/bootstage.c | 28 ++++++ doc/develop/malloc.rst | 18 ++++ doc/develop/pytest/usage.rst | 20 ++++- doc/usage/cmd/bootstage.rst | 86 +++++++++++++++++++ doc/usage/index.rst | 1 + drivers/sysreset/sysreset_sandbox.c | 4 +- include/bootstage.h | 9 ++ include/malloc.h | 11 --- include/os.h | 11 +++ include/test/test.h | 2 + test/boot/bootflow.c | 17 +++- test/boot/pxe.c | 77 +++++++++++++---- test/cmd/bootstage.c | 24 ++++++ test/common/malloc.c | 16 ++-- test/py/conftest.py | 3 + test/py/console_sandbox.py | 35 ++++++++ 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 | 9 ++ test/py/tests/test_eficonfig.py | 1 + test/py/tests/test_fit.py | 6 ++ 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 | 3 + 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_source.py | 10 +++ 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 + test/py/utils.py | 31 ++++++- test/test-main.c | 5 ++ 55 files changed, 452 insertions(+), 47 deletions(-) create mode 100644 doc/usage/cmd/bootstage.rst