diff options
author | Simon Glass <sjg@chromium.org> | 2021-03-08 03:35:00 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-03-12 17:57:30 +0300 |
commit | 99a88fe1bd98ad800ec0460e3174c2a846a991fe (patch) | |
tree | 8ab083a1a48489090d3f315dbda4a55f5a251329 /test/test-main.c | |
parent | e77615d3a78f43793f27cd4dbe04efc6522a05ef (diff) | |
download | u-boot-99a88fe1bd98ad800ec0460e3174c2a846a991fe.tar.xz |
test: Move test running into a separate function
Add a function to handle the preparation for running a test and the
post-test clean-up.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/test-main.c')
-rw-r--r-- | test/test-main.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/test/test-main.c b/test/test-main.c index 3806c2ad89..dee28d35d8 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -121,6 +121,28 @@ int test_post_run(struct unit_test_state *uts, struct unit_test *test) return 0; } +int ut_run_test(struct unit_test_state *uts, struct unit_test *test, + const char *test_name) +{ + int ret; + + printf("Test: %s\n", test_name); + + ret = test_pre_run(uts, test); + if (ret == -EAGAIN) + return -EAGAIN; + if (ret) + return ret; + + test->func(uts); + + ret = test_post_run(uts, test); + if (ret) + return ret; + + return 0; +} + int ut_run_tests(struct unit_test_state *uts, const char *prefix, struct unit_test *tests, int count, const char *select_name) { @@ -138,20 +160,12 @@ int ut_run_tests(struct unit_test_state *uts, const char *prefix, if (select_name && strcmp(select_name, test_name)) continue; - printf("Test: %s\n", test_name); + ret = ut_run_test(uts, test, test_name); found++; - - ret = test_pre_run(uts, test); if (ret == -EAGAIN) continue; if (ret) return ret; - - test->func(uts); - - ret = test_post_run(uts, test); - if (ret) - return ret; } if (select_name && !found) return -ENOENT; |