summaryrefslogtreecommitdiff
path: root/include/test
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-01-20 14:25:26 -0700
committerTom Rini <[email protected]>2025-01-24 14:34:39 -0600
commit94b5284398e52c44bde977aa8b1fa1f5992955a2 (patch)
tree639569f14c1112aaa4af1249c515d5d47982f877 /include/test
parent7b576f0847659c22bd938e4f4885324f88a16e74 (diff)
test: Pass the test-state into ut_run_list()
Pass this into the function so that callers can inspect the state afterwards. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'include/test')
-rw-r--r--include/test/ut.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/include/test/ut.h b/include/test/ut.h
index 2e4d8edf826..a51defc3b90 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -480,11 +480,33 @@ struct unit_test_state *ut_get_state(void);
void ut_set_state(struct unit_test_state *uts);
/**
+ * ut_init_state() - Set up a new test state
+ *
+ * This must be called before using the test state with ut_run_tests()
+ *
+ * @uts: Test state to init
+ */
+void ut_init_state(struct unit_test_state *uts);
+
+/**
+ * ut_uninit_state() - Free memory used by test state
+ *
+ * This must be called before after the test state with ut_run_tests(). To later
+ * reuse the test state to run more tests, call test_state_init() first
+ *
+ * @uts: Test state to uninit
+ */
+void ut_uninit_state(struct unit_test_state *uts);
+
+/**
* ut_run_tests() - Run a set of tests
*
* This runs the test, handling any preparation and clean-up needed. It prints
* the name of each test before running it.
*
+ * @uts: Unit-test state, which must be ready for use, i.e. ut_init_state()
+ * has been called. The caller is responsible for calling
+ * ut_uninit_state() after this function returns
* @category: Category of these tests. This is a string printed at the start to
* announce the the number of tests
* @prefix: String prefix for the tests. Any tests that have this prefix will be
@@ -503,8 +525,9 @@ void ut_set_state(struct unit_test_state *uts);
* Pass NULL to disable this
* Return: 0 if all tests passed, -1 if any failed
*/
-int ut_run_list(const char *name, const char *prefix, struct unit_test *tests,
- int count, const char *select_name, int runs_per_test,
- bool force_run, const char *test_insert);
+int ut_run_list(struct unit_test_state *uts, const char *category,
+ const char *prefix, struct unit_test *tests, int count,
+ const char *select_name, int runs_per_test, bool force_run,
+ const char *test_insert);
#endif