[PATCH v4 12/14] test: add wolfTPM C unit tests and Python integration tests
Simon Glass
sjg at chromium.org
Fri May 15 16:15:16 CEST 2026
Hi Aidan,
On Tue, 12 May 2026 at 18:27, Aidan Garske <aidan at wolfssl.com> wrote:
>
> From: Aidan <aidan at wolfssl.com>
>
> Add comprehensive test suites for wolfTPM commands, modeled after
> the existing TPM2 test infrastructure.
>
> test/cmd/wolftpm.c (C unit tests):
> 18 tests using U-Boot's unit test framework (CMD_TEST macro):
> - autostart, init, info, state, device: basic lifecycle
> - self_test (full and continue): TPM self-test verification
> - startup_clear, startup_state: TPM2_Startup modes
> - get_capability: read TPM properties
> - caps: wolfTPM-enhanced capabilities display
> - clear: TPM state reset via LOCKOUT hierarchy
> - pcr_read, pcr_extend, pcr_print: PCR operations
> - pcr_allocate: PCR bank reconfiguration
> - dam_reset, dam_parameters: dictionary attack mitigation
> - change_auth: hierarchy password change (requires wolfCrypt)
> - cleanup: reset TPM state after tests
> Run with: ut cmd cmd_test_wolftpm_*
>
> test/cmd/Makefile:
> Adds wolftpm.o when CONFIG_TPM_WOLF is enabled.
>
> test/py/tests/test_wolftpm.py (Python integration tests):
> 21 tests using pytest with the U-Boot test framework:
> - Requires QEMU + swtpm (not sandbox) because wolfTPM bypasses
> U-Boot's driver model and communicates directly with TPM
> hardware via its own SPI/MMIO HAL
> - Tests mirror the C tests but run end-to-end through the U-Boot
> console, checking return codes via 'echo $?'
> - Includes force_init() helper for TPM reinitialization after
> test failures
> - Skippable via env__wolftpm_device_test_skip config
> - Verified: 19 passed, 2 skipped (change_auth requires wolfCrypt,
> get_capability may skip on some platforms)
>
> Signed-off-by: Aidan Garske <aidan at wolfssl.com>
> ---
> test/cmd/Makefile | 1 +
> test/cmd/wolftpm.c | 364 +++++++++++++++++++++++++++++++++
> test/py/tests/test_wolftpm.py | 375 ++++++++++++++++++++++++++++++++++
> 3 files changed, 740 insertions(+)
> create mode 100644 test/cmd/wolftpm.c
> create mode 100644 test/py/tests/test_wolftpm.py
Thank you for writing tests here. For the cmd tests it is a good idea
to check the console output - see the UTF_CONSOLE flag and things like
ut_assert_nextline()
Regards,
Simon
More information about the U-Boot
mailing list