diff options
author | Simon Glass <sjg@chromium.org> | 2025-02-07 11:30:38 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-02-11 20:10:58 -0600 |
commit | c908ecb7b51e886469c4fc8eb5492bdbda55b871 (patch) | |
tree | b668412c69689e5a9c9ebe4dc762789a9c830a4e /test | |
parent | 63adc40d4c18b3a39df68289cd6cf4d38e8dd5ad (diff) |
test: Support an init/uninit functions for test suites
Some suites need things to be set up before they can run. Add a way to
declare an init function using the UNIT_TEST_INIT() macro. The init
function is just like any other test, but is always placed first so that
it runs before all the other test functions in the suite.
Add an uninit function as well, to clean up after the test.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/test-main.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/test-main.c b/test/test-main.c index 8c0d820032c..ee855bfe2ed 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -620,7 +620,8 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, const char *test_name = test->name; int ret, i, old_fail_count; - if (!test_matches(prefix, test_name, select_name)) + if (!(test->flags & (UTF_INIT | UTF_UNINIT)) && + !test_matches(prefix, test_name, select_name)) continue; if (test->flags & UTF_MANUAL) { |