ztest: Add skipping for non-kernel tests
Add ztest_test_skip() support to non-kernel tests by implementing long jump buffer and TC_SKIP result collection. Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
This commit is contained in:
parent
d74cb2a3df
commit
995ce7a226
1 changed files with 18 additions and 1 deletions
|
@ -223,6 +223,7 @@ static void run_test_functions(struct unit_test *test)
|
|||
#define FAIL_FAST 0
|
||||
|
||||
static jmp_buf test_fail;
|
||||
static jmp_buf test_skip;
|
||||
static jmp_buf test_pass;
|
||||
static jmp_buf stack_fail;
|
||||
|
||||
|
@ -231,6 +232,11 @@ void ztest_test_fail(void)
|
|||
raise(SIGABRT);
|
||||
}
|
||||
|
||||
void ztest_test_skip(void)
|
||||
{
|
||||
longjmp(test_skip, 1);
|
||||
}
|
||||
|
||||
void ztest_test_pass(void)
|
||||
{
|
||||
longjmp(test_pass, 1);
|
||||
|
@ -271,6 +277,7 @@ static void init_testing(void)
|
|||
static int run_test(struct unit_test *test)
|
||||
{
|
||||
int ret = TC_PASS;
|
||||
int skip = 0;
|
||||
|
||||
TC_START(test->name);
|
||||
|
||||
|
@ -279,6 +286,11 @@ static int run_test(struct unit_test *test)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (setjmp(test_skip)) {
|
||||
skip = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (setjmp(test_pass)) {
|
||||
ret = TC_PASS;
|
||||
goto out;
|
||||
|
@ -287,7 +299,12 @@ static int run_test(struct unit_test *test)
|
|||
run_test_functions(test);
|
||||
out:
|
||||
ret |= cleanup_test(test);
|
||||
Z_TC_END_RESULT(ret, test->name);
|
||||
|
||||
if (skip) {
|
||||
Z_TC_END_RESULT(TC_SKIP, test->name);
|
||||
} else {
|
||||
Z_TC_END_RESULT(ret, test->name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue