From 20475bff0e2006c20e245aa1ea431d0afa36989d Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 9 Aug 2022 22:12:37 -0600 Subject: [PATCH] ztest: move get_friendly_phase_name to common code Move the function used for printing the phase name up so its available for both unittest and KERNEL mode of tests. Signed-off-by: Yuval Peress --- subsys/testsuite/ztest/src/ztest_new.c | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztest_new.c b/subsys/testsuite/ztest/src/ztest_new.c index 3ca659a9ef8..67596f2720c 100644 --- a/subsys/testsuite/ztest/src/ztest_new.c +++ b/subsys/testsuite/ztest/src/ztest_new.c @@ -256,27 +256,6 @@ static int get_final_test_result(const struct ztest_unit_test *test, int ret) return ret; } -#ifndef KERNEL - -/* Static code analysis tool can raise a violation that the standard header - * shall not be used. - * - * setjmp is using in a test code, not in a runtime code, it is acceptable. - * It is a deliberate deviation. - */ -#include /* parasoft-suppress MISRAC2012-RULE_21_4-a MISRAC2012-RULE_21_4-b*/ -#include -#include -#include - -#define FAIL_FAST 0 - -static jmp_buf test_fail; -static jmp_buf test_pass; -static jmp_buf test_skip; -static jmp_buf stack_fail; -static jmp_buf test_suite_fail; - /** * @brief Get a friendly name string for a given test phrase. * @@ -303,6 +282,27 @@ static inline const char *get_friendly_phase_name(enum ztest_phase phase) } } +#ifndef KERNEL + +/* Static code analysis tool can raise a violation that the standard header + * shall not be used. + * + * setjmp is using in a test code, not in a runtime code, it is acceptable. + * It is a deliberate deviation. + */ +#include /* parasoft-suppress MISRAC2012-RULE_21_4-a MISRAC2012-RULE_21_4-b*/ +#include +#include +#include + +#define FAIL_FAST 0 + +static jmp_buf test_fail; +static jmp_buf test_pass; +static jmp_buf test_skip; +static jmp_buf stack_fail; +static jmp_buf test_suite_fail; + void ztest_test_fail(void) { switch (phase) {