[PATCH v2 00/12] test: Add support for passing arguments to C unit tests

Simon Glass sjg at chromium.org
Mon Apr 13 17:40:24 CEST 2026


Hi Tom,

On Mon, 13 Apr 2026 at 09:29, Tom Rini <trini at konsulko.com> wrote:
>
> On Sun, Apr 12, 2026 at 05:19:37AM -0600, Simon Glass wrote:
>
> > Some tests have two parts: a Python test which handles setup, such as
> > creating filesystem images or configuring the environment, and a C
> > test which does the bulk of the work including assertions. At present
> > there is no way to pass information between these two parts, so
> > things like paths and device names must be hard-coded in the C test.
> >
> > This tends to make people write tests in Python, but this is not ideal
> > for several reasons:
> >
> > - Python lacks access to things like return codes and has to scan the
> >   console output to figure out what happened
> > - Python lacks access to internal state, so it cannot directly check
> >   the result of an operation
> > - Python is ~100x slower due to console interaction, etc.
> > - C tests can be stepped through in gdb, which is much harder with
> >   Python driving the console
> > - C tests can exercise internal APIs directly (e.g. fs_read(),
> >   fs_size()) rather than going through the command layer, so they
> >   test more precisely what they intend to
> >
> > This series adds infrastructure for passing typed, runtime arguments
> > from Python to C unit tests, using a name=value format on the ut
> > command line.
> >
> > The series includes:
> >
> > - Regex assertion helpers for matching variable output in tests
> >
> > - A private buffer in unit_test_state for test-local temporary data
> >
> > - Argument-type definitions (string, integer, boolean) with optional
> >   flags and default values
> >
> > - A new UNIT_TEST_ARGS() macro for declaring tests with typed
> >   arguments
> >
> > - Argument parsing in the test framework, accepting name=value format
> >
> > - Updates to the ut command to pass arguments through to tests
> >
> > - Type-checked accessor macros ut_str(), ut_int(), and ut_bool()
> >   with bounds validation
> >
> > - Tests for the argument feature covering type checking, optional
> >   arguments, and argument-parsing failures
> >
> > - Documentation for the test-parameter feature
> >
> > - C-based filesystem tests as an example of the hybrid approach,
> >   with Python wrappers that pass filesystem type, image path, and
> >   expected MD5 values to the C tests
> >
> > Note: This series depends on:
> >
> >    https://patchwork.ozlabs.org/project/uboot/list/?series=496972
> >
> > Changes in v2:
> > - Correct double signoff
>
> Reposting a series this large, on the weekend, the day after v1, because
> you made a trivial mistake is bad form. You should just acknowledge that
> in the cover letter and wait for feedback.

OK I'll do that if I make this mistake again.

> And since I'm seeing over 100 emails from you this weekend, this
> matters.

Yes, I was trying to catch up on various things.

Regards,
Simon


More information about the U-Boot mailing list