diff options
author | Simon Glass <sjg@chromium.org> | 2022-10-20 18:22:48 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-10-31 11:02:44 -0400 |
commit | 1facaadea1871c1b6962272dd21569a4aafda18c (patch) | |
tree | 2c90c6e6d2e27ab0cb609e6937062b90039872e6 /test | |
parent | d2afb9edce0089f06d8f353cf88d8f5dec984914 (diff) | |
download | u-boot-1facaadea1871c1b6962272dd21569a4aafda18c.tar.gz |
test: Report skippped tests
At present it is possible for a test to skip itself by returning -EAGAIN
but this is not recorded. An existing example is in test_pre_run() with
the "Console recording disabled" check.
Keep a track of skipped tests and report the total at the end.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/test-main.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/test/test-main.c b/test/test-main.c index a98a77d68f..2323cbaece 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -357,6 +357,19 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) } /** + * skip_test() - Handle skipping a test + * + * @uts: Test state to update + * @return -EAGAIN (always) + */ +static int skip_test(struct unit_test_state *uts) +{ + uts->skip_count++; + + return -EAGAIN; +} + +/** * ut_run_test() - Run a single test * * This runs the test, handling any preparation and clean-up needed. It prints @@ -386,11 +399,13 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, ret = test_pre_run(uts, test); if (ret == -EAGAIN) - return -EAGAIN; + return skip_test(uts); if (ret) return ret; - test->func(uts); + ret = test->func(uts); + if (ret == -EAGAIN) + skip_test(uts); ret = test_post_run(uts, test); if (ret) @@ -424,7 +439,7 @@ static int ut_run_test_live_flat(struct unit_test_state *uts, int runs; if ((test->flags & UT_TESTF_OTHER_FDT) && !IS_ENABLED(CONFIG_SANDBOX)) - return -EAGAIN; + return skip_test(uts); /* Run with the live tree if possible */ runs = 0; @@ -558,6 +573,8 @@ int ut_run_list(const char *category, const char *prefix, os_free(uts.other_fdt); } + if (uts.skip_count) + printf("Skipped: %d, ", uts.skip_count); if (ret == -ENOENT) printf("Test '%s' not found\n", select_name); else |