summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-01-20 14:25:59 -0700
committerTom Rini <[email protected]>2025-01-24 14:34:41 -0600
commit0925659a5226ee70dab8b4d3e9c8aba9ec586548 (patch)
tree652ca8bf305fdbb1263636f96a482aeacc8e0e10 /test
parentbbff0b165c170598c100dac81a5ee58fb07ed3ae (diff)
test: Move stats into a struct
Use a struct to hold the stats, since we also want to have the same stats for all runs as we have for each suite. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/test-main.c29
-rw-r--r--test/ut.c4
2 files changed, 17 insertions, 16 deletions
diff --git a/test/test-main.c b/test/test-main.c
index 391d4e7bb0e..e8aecd267c7 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -448,7 +448,7 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test)
*/
static int skip_test(struct unit_test_state *uts)
{
- uts->skip_count++;
+ uts->cur.skip_count++;
return -EAGAIN;
}
@@ -460,7 +460,7 @@ static int skip_test(struct unit_test_state *uts)
* the name of each test before running it.
*
* @uts: Test state to update. The caller should ensure that this is zeroed for
- * the first call to this function. On exit, @uts->fail_count is
+ * the first call to this function. On exit, @uts->cur.fail_count is
* incremented by the number of failures (0, one hopes)
* @test_name: Test to run
* @name: Name of test, possibly skipping a prefix that should not be displayed
@@ -510,7 +510,7 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test,
* SPL.
*
* @uts: Test state to update. The caller should ensure that this is zeroed for
- * the first call to this function. On exit, @uts->fail_count is
+ * the first call to this function. On exit, @uts->cur.fail_count is
* incremented by the number of failures (0, one hopes)
* @test: Test to run
* Return: 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if
@@ -574,7 +574,7 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,
* the name of each test before running it.
*
* @uts: Test state to update. The caller should ensure that this is zeroed for
- * the first call to this function. On exit, @uts->fail_count is
+ * the first call to this function. On exit, @uts->cur.fail_count is
* incremented by the number of failures (0, one hopes)
* @prefix: String prefix for the tests. Any tests that have this prefix will be
* printed without the prefix, so that it is easier to see the unique part
@@ -632,7 +632,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
if (len < 6 || strcmp(test_name + len - 6, "_norun")) {
printf("Test '%s' is manual so must have a name ending in _norun\n",
test_name);
- uts->fail_count++;
+ uts->cur.fail_count++;
return -EBADF;
}
if (!uts->force_run) {
@@ -641,23 +641,24 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
continue;
}
}
- old_fail_count = uts->fail_count;
+ old_fail_count = uts->cur.fail_count;
if (one && upto == pos) {
ret = ut_run_test_live_flat(uts, one);
- if (uts->fail_count != old_fail_count) {
+ if (uts->cur.fail_count != old_fail_count) {
printf("Test '%s' failed %d times (position %d)\n",
one->name,
- uts->fail_count - old_fail_count, pos);
+ uts->cur.fail_count - old_fail_count,
+ pos);
}
return -EBADF;
}
for (i = 0; i < uts->runs_per_test; i++)
ret = ut_run_test_live_flat(uts, test);
- if (uts->fail_count != old_fail_count) {
+ if (uts->cur.fail_count != old_fail_count) {
printf("Test '%s' failed %d times\n", test_name,
- uts->fail_count - old_fail_count);
+ uts->cur.fail_count - old_fail_count);
}
found++;
if (ret == -EAGAIN)
@@ -668,7 +669,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
if (select_name && !found)
return -ENOENT;
- return uts->fail_count ? -EBADF : 0;
+ return uts->cur.fail_count ? -EBADF : 0;
}
int ut_run_list(struct unit_test_state *uts, const char *category,
@@ -716,12 +717,12 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
if (has_dm_tests)
dm_test_restore(uts->of_root);
- if (uts->skip_count)
- printf("Skipped: %d, ", uts->skip_count);
+ if (uts->cur.skip_count)
+ printf("Skipped: %d, ", uts->cur.skip_count);
if (ret == -ENOENT)
printf("Test '%s' not found\n", select_name);
else
- printf("Failures: %d\n", uts->fail_count);
+ printf("Failures: %d\n", uts->cur.fail_count);
return ret;
}
diff --git a/test/ut.c b/test/ut.c
index 7454da3e001..a16fdfb3a93 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -21,7 +21,7 @@ void ut_fail(struct unit_test_state *uts, const char *fname, int line,
{
gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
printf("%s:%d, %s(): %s\n", fname, line, func, cond);
- uts->fail_count++;
+ uts->cur.fail_count++;
}
void ut_failf(struct unit_test_state *uts, const char *fname, int line,
@@ -35,7 +35,7 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line,
vprintf(fmt, args);
va_end(args);
putc('\n');
- uts->fail_count++;
+ uts->cur.fail_count++;
}
ulong ut_check_free(void)