Allow to define an init function for the test suite. It could help us
to initialize global variable once, and use them in multiple test cases
after the initialization.
For instance, if multiple test cases use the same atomic_t var, it
could be helpful to call ATOMIC_INIT once during the suite
initialization.
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
struct sbiunit_test_suite {
const char *name;
+ void (*init)(void);
struct sbiunit_test_case *cases;
};
#define SBIUNIT_TEST_SUITE(suite_name, cases_arr) \
struct sbiunit_test_suite suite_name = { \
.name = #suite_name, \
+ .init = NULL, \
.cases = cases_arr \
}
sbi_printf("## Running test suite: %s\n", suite->name);
+ if (suite->init)
+ suite->init();
+
s_case = suite->cases;
while (s_case->test_func) {
s_case->test_func(s_case);