[PATCH 40/43] test: Record and show the totals for all test runs
Simon Glass
sjg at chromium.org
Wed Jan 15 14:31:10 CET 2025
With 'ut all' multiple test suites are run. Add a way to collect totals
and show them at the end.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
include/test/test.h | 3 +++
test/cmd_ut.c | 2 ++
test/test-main.c | 9 +++++++--
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/test/test.h b/include/test/test.h
index f7087ab4eea..58023f6eafb 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -27,6 +27,7 @@ struct ut_stats {
* struct unit_test_state - Entire state of test system
*
* @cur: Statistics for the current run
+ * @run_count: Number of times ut_run_list() has been called
* @start: Store the starting mallinfo when doing leak test
* @of_live: true to use livetree if available, false to use flattree
* @of_root: Record of the livetree root node (used for setting up tests)
@@ -48,6 +49,8 @@ struct ut_stats {
*/
struct unit_test_state {
struct ut_stats cur;
+ struct ut_stats total;
+ int run_count;
struct mallinfo start;
struct device_node *of_root;
bool of_live;
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f315c442abf..f33918ddd00 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -206,6 +206,8 @@ static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp,
any_fail = retval;
}
}
+ if (uts->run_count > 1)
+ ut_report(&uts->total, "Total tests");
return any_fail;
}
diff --git a/test/test-main.c b/test/test-main.c
index a0a3f6086ef..6010c24207c 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -690,6 +690,8 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
bool has_dm_tests = false;
int ret;
+ memset(&uts->cur, '\0', sizeof(struct ut_stats));
+
if (!CONFIG_IS_ENABLED(OF_PLATDATA) &&
ut_list_has_dm_tests(tests, count, prefix, select_name)) {
has_dm_tests = true;
@@ -727,8 +729,11 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
dm_test_restore(uts->of_root);
ut_report(&uts->cur, "Tests");
- if (ret == -ENOENT)
- printf("Test '%s' not found\n", select_name);
+
+ uts->total.skip_count += uts->cur.skip_count;
+ uts->total.fail_count += uts->cur.fail_count;
+ uts->total.test_count += uts->cur.test_count;
+ uts->run_count++;
return ret;
}
--
2.34.1
More information about the U-Boot
mailing list