@@ -262,7 +262,7 @@ static int run_trigger_thread(int i)
262
262
* If the fatal error happened and the program enter assert_post_handler,
263
263
* that means fatal error triggered as expected.
264
264
*/
265
- ZTEST_USER ( error_hook_tests , test_catch_fatal_error )
265
+ void test_catch_fatal_error ( void )
266
266
{
267
267
#if defined(CONFIG_USERSPACE )
268
268
run_trigger_thread (ZTEST_CATCH_FATAL_ACCESS );
@@ -287,20 +287,15 @@ ZTEST_USER(error_hook_tests, test_catch_fatal_error)
287
287
* fail happened and the program enter assert_post_handler, that means
288
288
* assert works as expected.
289
289
*/
290
- ZTEST_USER ( error_hook_tests , test_catch_assert_fail )
290
+ void test_catch_assert_fail ( void )
291
291
{
292
292
case_type = ZTEST_CATCH_ASSERT_FAIL ;
293
293
294
- printk ("1\n" );
295
294
ztest_set_assert_valid (false);
296
295
297
- printk ("2\n" );
298
296
ztest_set_assert_valid (true);
299
-
300
- printk ("3\n" );
301
297
trigger_assert_fail (NULL );
302
298
303
- printk ("4\n" );
304
299
ztest_test_fail ();
305
300
}
306
301
@@ -318,7 +313,7 @@ static void tIsr_assert(const void *p)
318
313
* fail happened and the program enter assert_post_handler, that means
319
314
* assert works as expected.
320
315
*/
321
- ZTEST ( error_hook_tests , test_catch_assert_in_isr )
316
+ void test_catch_assert_in_isr ( void )
322
317
{
323
318
case_type = ZTEST_CATCH_ASSERT_IN_ISR ;
324
319
irq_offload (tIsr_assert , NULL );
@@ -342,7 +337,7 @@ static void trigger_z_oops(void)
342
337
* that means z_oops triggered as expected. This test only for
343
338
* userspace.
344
339
*/
345
- ZTEST ( error_hook_tests , test_catch_z_oops )
340
+ void test_catch_z_oops ( void )
346
341
{
347
342
case_type = ZTEST_CATCH_USER_FATAL_Z_OOPS ;
348
343
@@ -352,11 +347,25 @@ ZTEST(error_hook_tests, test_catch_z_oops)
352
347
#endif
353
348
354
349
355
- static void * error_hook_tests_setup (void )
350
+ void test_main (void )
356
351
{
352
+
357
353
#if defined(CONFIG_USERSPACE )
358
354
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 );
359
370
#endif
360
- return NULL ;
361
371
}
362
- ZTEST_SUITE (error_hook_tests , NULL , error_hook_tests_setup , NULL , NULL , NULL );
0 commit comments