summaryrefslogtreecommitdiff
path: root/test/test-main.c
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-01-20 14:26:01 -0700
committerTom Rini <[email protected]>2025-01-24 14:34:41 -0600
commit15c39587cf8a977df33aba37715b6ce3e17536d7 (patch)
tree2c050dc91a50176da754fabc9580e92436056f7a /test/test-main.c
parent561320beffd10d133a316aacaf3170387324bdae (diff)
test: Move stat-printing into its own function
Add a function to show the stats, so we can decide when to print it. This slightly adjusts the output, so that any 'test not found' message appears on its own line after all other output. The 'failures' message now appears in lower case so update pytest accordingly. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'test/test-main.c')
-rw-r--r--test/test-main.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/test-main.c b/test/test-main.c
index e36bc37d29e..d02ab791b5a 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -673,6 +673,18 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
return uts->cur.fail_count ? -EBADF : 0;
}
+void ut_report(struct ut_stats *stats, int run_count)
+{
+ if (run_count > 1)
+ printf("Suites run: %d, total tests", run_count);
+ else
+ printf("Tests");
+ printf(" run: %d, ", stats->test_count);
+ if (stats->skip_count)
+ printf("skipped: %d, ", stats->skip_count);
+ printf("failures: %d\n", stats->fail_count);
+}
+
int ut_run_list(struct unit_test_state *uts, const char *category,
const char *prefix, struct unit_test *tests, int count,
const char *select_name, int runs_per_test, bool force_run,
@@ -718,13 +730,9 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
if (has_dm_tests)
dm_test_restore(uts->of_root);
- printf("Tests run: %d, ", uts->cur.test_count);
- if (uts->cur.skip_count)
- printf("Skipped: %d, ", uts->cur.skip_count);
+ ut_report(&uts->cur, 1);
if (ret == -ENOENT)
printf("Test '%s' not found\n", select_name);
- else
- printf("Failures: %d\n", uts->cur.fail_count);
return ret;
}