[Concept,00/19] test: Fix pytest inter-test side effects

Message ID 20260314231618.338113-1-sjg@u-boot.org
Headers
Series test: Fix pytest inter-test side effects |

Message

Simon Glass March 14, 2026, 11:15 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

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