Skip to content

Commit 85cc902

Browse files
committed
Revert "ztest: migrate error_hook tests to new API"
This reverts commit fa13d57. Signed-off-by: Anas Nashif <[email protected]>
1 parent c3c026e commit 85cc902

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

tests/ztest/error_hook/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
CONFIG_ZTEST=y
2-
CONFIG_ZTEST_NEW_API=y
32
CONFIG_TEST_USERSPACE=y
43
CONFIG_IRQ_OFFLOAD=y
54
CONFIG_ZTEST_FATAL_HOOK=y
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
CONFIG_ZTEST=y
2-
CONFIG_ZTEST_NEW_API=y
32
CONFIG_IRQ_OFFLOAD=y
43
CONFIG_ZTEST_FATAL_HOOK=y
54
CONFIG_ZTEST_ASSERT_HOOK=y

tests/ztest/error_hook/src/main.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int run_trigger_thread(int i)
262262
* If the fatal error happened and the program enter assert_post_handler,
263263
* that means fatal error triggered as expected.
264264
*/
265-
ZTEST_USER(error_hook_tests, test_catch_fatal_error)
265+
void test_catch_fatal_error(void)
266266
{
267267
#if defined(CONFIG_USERSPACE)
268268
run_trigger_thread(ZTEST_CATCH_FATAL_ACCESS);
@@ -287,20 +287,15 @@ ZTEST_USER(error_hook_tests, test_catch_fatal_error)
287287
* fail happened and the program enter assert_post_handler, that means
288288
* assert works as expected.
289289
*/
290-
ZTEST_USER(error_hook_tests, test_catch_assert_fail)
290+
void test_catch_assert_fail(void)
291291
{
292292
case_type = ZTEST_CATCH_ASSERT_FAIL;
293293

294-
printk("1\n");
295294
ztest_set_assert_valid(false);
296295

297-
printk("2\n");
298296
ztest_set_assert_valid(true);
299-
300-
printk("3\n");
301297
trigger_assert_fail(NULL);
302298

303-
printk("4\n");
304299
ztest_test_fail();
305300
}
306301

@@ -318,7 +313,7 @@ static void tIsr_assert(const void *p)
318313
* fail happened and the program enter assert_post_handler, that means
319314
* assert works as expected.
320315
*/
321-
ZTEST(error_hook_tests, test_catch_assert_in_isr)
316+
void test_catch_assert_in_isr(void)
322317
{
323318
case_type = ZTEST_CATCH_ASSERT_IN_ISR;
324319
irq_offload(tIsr_assert, NULL);
@@ -342,7 +337,7 @@ static void trigger_z_oops(void)
342337
* that means z_oops triggered as expected. This test only for
343338
* userspace.
344339
*/
345-
ZTEST(error_hook_tests, test_catch_z_oops)
340+
void test_catch_z_oops(void)
346341
{
347342
case_type = ZTEST_CATCH_USER_FATAL_Z_OOPS;
348343

@@ -352,11 +347,25 @@ ZTEST(error_hook_tests, test_catch_z_oops)
352347
#endif
353348

354349

355-
static void *error_hook_tests_setup(void)
350+
void test_main(void)
356351
{
352+
357353
#if defined(CONFIG_USERSPACE)
358354
k_thread_access_grant(k_current_get(), &tdata, &tstack);
355+
356+
ztest_test_suite(error_hook_tests,
357+
ztest_user_unit_test(test_catch_assert_fail),
358+
ztest_user_unit_test(test_catch_fatal_error),
359+
ztest_unit_test(test_catch_z_oops),
360+
ztest_unit_test(test_catch_assert_in_isr)
361+
);
362+
ztest_run_test_suite(error_hook_tests);
363+
#else
364+
ztest_test_suite(error_hook_tests,
365+
ztest_unit_test(test_catch_fatal_error),
366+
ztest_unit_test(test_catch_assert_fail),
367+
ztest_unit_test(test_catch_assert_in_isr)
368+
);
369+
ztest_run_test_suite(error_hook_tests);
359370
#endif
360-
return NULL;
361371
}
362-
ZTEST_SUITE(error_hook_tests, NULL, error_hook_tests_setup, NULL, NULL, NULL);

0 commit comments

Comments
 (0)