test: Add parallel test execution support

Running the full test suite takes a long time. It would be useful to
distribute tests across multiple sandbox instances to speed up testing.

Add support for running tests in parallel across multiple sandbox
instances. Each worker runs a subset of tests based on its worker ID.

Add -P<n>:<w> option to the ut command where n is the total number of
workers and w is this worker's ID (0 to n-1). Tests are distributed
by index modulo number of workers.

Series-to: u-boot
Series-cc: heinrich
Cover-letter:
test: Various improvements to unit-test infrastructure

This series adds several improvements to the unit-test infrastructure:

- Move disk images to the persistent-data directory so they don't
  pollute the source tree
- Add a way to keep pytest-created artefacts for faster iteration on
  C tests
- Add a helper to simplify running manual unit tests from Python
- Allow combined flags with the ut command (e.g. -Efm)
- Add a -E flag to emit machine-readable result lines
- Add a -P flag to distribute tests across parallel workers
- Add -m as an alias for -f (force manual tests)

These changes make it easier to run and debug tests, especially when
iterating on C test code.
END

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-12-29 08:04:01 -07:00
committed by Simon Glass
parent dc6bbb7bdf
commit 20a8d1869b
5 changed files with 58 additions and 2 deletions

View File

@@ -89,6 +89,8 @@ struct ut_arg {
* @of_other: Live tree for the other FDT
* @runs_per_test: Number of times to run each test (typically 1)
* @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_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
@@ -121,6 +123,8 @@ struct unit_test_state {
struct device_node *of_other;
int runs_per_test;
bool force_run;
int workers;
int worker_id;
void *old_bloblist;
bool soft_fail;
char expect_str[1024];