test: Keep a track of the numbers of tests run
authorSimon Glass <sjg@chromium.org>
Mon, 20 Jan 2025 21:26:00 +0000 (14:26 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 24 Jan 2025 20:34:41 +0000 (14:34 -0600)
This is useful information and is not always the same as the 'count' arg
to ut_run_list() so add it as a separate stat.

Signed-off-by: Simon Glass <sjg@chromium.org>
include/test/test.h
test/test-main.c

index bc8f0bb..f7087ab 100644 (file)
  *
  * @fail_count: Number of tests that failed
  * @skip_count: Number of tests that were skipped
+ * @test_count: Number of tests run. If a test is run muiltiple times, only one
+ *     is counted
  */
 struct ut_stats {
        int fail_count;
        int skip_count;
+       int test_count;
 };
 
 /*
index e8aecd2..e36bc37 100644 (file)
@@ -643,6 +643,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
                }
                old_fail_count = uts->cur.fail_count;
 
+               uts->cur.test_count++;
                if (one && upto == pos) {
                        ret = ut_run_test_live_flat(uts, one);
                        if (uts->cur.fail_count != old_fail_count) {
@@ -717,6 +718,7 @@ 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);
        if (ret == -ENOENT)