Revert "ztest: migrate error_hook tests to new API"

This reverts commit fa13d57f01.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2022-04-26 18:07:21 -04:00
commit 85cc902a0d
3 changed files with 21 additions and 14 deletions

View file

@ -1,5 +1,4 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_TEST_USERSPACE=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_ZTEST_FATAL_HOOK=y

View file

@ -1,5 +1,4 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_ZTEST_FATAL_HOOK=y
CONFIG_ZTEST_ASSERT_HOOK=y

View file

@ -262,7 +262,7 @@ static int run_trigger_thread(int i)
* If the fatal error happened and the program enter assert_post_handler,
* that means fatal error triggered as expected.
*/
ZTEST_USER(error_hook_tests, test_catch_fatal_error)
void test_catch_fatal_error(void)
{
#if defined(CONFIG_USERSPACE)
run_trigger_thread(ZTEST_CATCH_FATAL_ACCESS);
@ -287,20 +287,15 @@ ZTEST_USER(error_hook_tests, test_catch_fatal_error)
* fail happened and the program enter assert_post_handler, that means
* assert works as expected.
*/
ZTEST_USER(error_hook_tests, test_catch_assert_fail)
void test_catch_assert_fail(void)
{
case_type = ZTEST_CATCH_ASSERT_FAIL;
printk("1\n");
ztest_set_assert_valid(false);
printk("2\n");
ztest_set_assert_valid(true);
printk("3\n");
trigger_assert_fail(NULL);
printk("4\n");
ztest_test_fail();
}
@ -318,7 +313,7 @@ static void tIsr_assert(const void *p)
* fail happened and the program enter assert_post_handler, that means
* assert works as expected.
*/
ZTEST(error_hook_tests, test_catch_assert_in_isr)
void test_catch_assert_in_isr(void)
{
case_type = ZTEST_CATCH_ASSERT_IN_ISR;
irq_offload(tIsr_assert, NULL);
@ -342,7 +337,7 @@ static void trigger_z_oops(void)
* that means z_oops triggered as expected. This test only for
* userspace.
*/
ZTEST(error_hook_tests, test_catch_z_oops)
void test_catch_z_oops(void)
{
case_type = ZTEST_CATCH_USER_FATAL_Z_OOPS;
@ -352,11 +347,25 @@ ZTEST(error_hook_tests, test_catch_z_oops)
#endif
static void *error_hook_tests_setup(void)
void test_main(void)
{
#if defined(CONFIG_USERSPACE)
k_thread_access_grant(k_current_get(), &tdata, &tstack);
ztest_test_suite(error_hook_tests,
ztest_user_unit_test(test_catch_assert_fail),
ztest_user_unit_test(test_catch_fatal_error),
ztest_unit_test(test_catch_z_oops),
ztest_unit_test(test_catch_assert_in_isr)
);
ztest_run_test_suite(error_hook_tests);
#else
ztest_test_suite(error_hook_tests,
ztest_unit_test(test_catch_fatal_error),
ztest_unit_test(test_catch_assert_fail),
ztest_unit_test(test_catch_assert_in_isr)
);
ztest_run_test_suite(error_hook_tests);
#endif
return NULL;
}
ZTEST_SUITE(error_hook_tests, NULL, error_hook_tests_setup, NULL, NULL, NULL);