From 7c80746bc6296856bee79035574d37bd94a8d4a2 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Thu, 22 Feb 2024 14:44:58 -0800 Subject: [PATCH] tests: kernel: use TC_END_REPORT for faults Use TC_END_REPORT() to report "PROJECT EXECUTION FAILED" instead of a call to printk() for ZTEST enabled tests. as this prints the failed message as well as the RunID (and whatever will be added in future). Signed-off-by: Daniel Leung --- tests/kernel/fatal/exception/src/main.c | 6 +++--- tests/kernel/mem_protect/demand_paging/src/main.c | 2 +- tests/kernel/mem_protect/mem_map/src/main.c | 2 +- tests/kernel/mem_protect/mem_protect/src/common.c | 2 +- tests/kernel/mem_protect/stackprot/src/main.c | 2 +- tests/kernel/mem_protect/sys_sem/src/main.c | 2 +- tests/kernel/mem_protect/syscalls/src/main.c | 2 +- tests/kernel/mem_protect/userspace/src/main.c | 4 ++-- tests/kernel/pipe/pipe/src/test_pipe.c | 2 +- tests/kernel/smp/src/main.c | 2 +- tests/kernel/threads/dynamic_thread/src/main.c | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/kernel/fatal/exception/src/main.c b/tests/kernel/fatal/exception/src/main.c index 07ac26ffc5..5a44b215b4 100644 --- a/tests/kernel/fatal/exception/src/main.c +++ b/tests/kernel/fatal/exception/src/main.c @@ -56,20 +56,20 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) if (expected_reason == -1) { printk("Was not expecting a crash\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } if (k_current_get() != &alt_thread) { printk("Wrong thread crashed\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } if (reason != expected_reason) { printk("Wrong crash type got %d expected %d\n", reason, expected_reason); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } diff --git a/tests/kernel/mem_protect/demand_paging/src/main.c b/tests/kernel/mem_protect/demand_paging/src/main.c index 7b733bfc34..fab82b68f7 100644 --- a/tests/kernel/mem_protect/demand_paging/src/main.c +++ b/tests/kernel/mem_protect/demand_paging/src/main.c @@ -73,7 +73,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) ztest_test_pass(); } else { printk("Unexpected fault during test"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } diff --git a/tests/kernel/mem_protect/mem_map/src/main.c b/tests/kernel/mem_protect/mem_map/src/main.c index 93ba040669..46fa5d4543 100644 --- a/tests/kernel/mem_protect/mem_map/src/main.c +++ b/tests/kernel/mem_protect/mem_map/src/main.c @@ -42,7 +42,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) ztest_test_pass(); } else { printk("Unexpected fault during test\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } diff --git a/tests/kernel/mem_protect/mem_protect/src/common.c b/tests/kernel/mem_protect/mem_protect/src/common.c index c6f4f00d4e..a0addcbda5 100644 --- a/tests/kernel/mem_protect/mem_protect/src/common.c +++ b/tests/kernel/mem_protect/mem_protect/src/common.c @@ -16,7 +16,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) valid_fault = false; /* reset back to normal */ } else { printk("fatal error was unexpected, aborting\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } diff --git a/tests/kernel/mem_protect/stackprot/src/main.c b/tests/kernel/mem_protect/stackprot/src/main.c index 94877687c4..cb927670ea 100644 --- a/tests/kernel/mem_protect/stackprot/src/main.c +++ b/tests/kernel/mem_protect/stackprot/src/main.c @@ -19,7 +19,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) { if (reason != K_ERR_STACK_CHK_FAIL) { printk("wrong error type\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } diff --git a/tests/kernel/mem_protect/sys_sem/src/main.c b/tests/kernel/mem_protect/sys_sem/src/main.c index 5304c435e1..f7bcbfd21d 100644 --- a/tests/kernel/mem_protect/sys_sem/src/main.c +++ b/tests/kernel/mem_protect/sys_sem/src/main.c @@ -572,7 +572,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) { printk("Caught system error -- reason %d\n", reason); printk("Unexpected fault during test\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } diff --git a/tests/kernel/mem_protect/syscalls/src/main.c b/tests/kernel/mem_protect/syscalls/src/main.c index ed57d7e912..5ba99e2f72 100644 --- a/tests/kernel/mem_protect/syscalls/src/main.c +++ b/tests/kernel/mem_protect/syscalls/src/main.c @@ -40,7 +40,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) { printk("Caught system error -- reason %d\n", reason); printk("Unexpected fault during test\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } diff --git a/tests/kernel/mem_protect/userspace/src/main.c b/tests/kernel/mem_protect/userspace/src/main.c index c1dadbecfa..5a54494063 100644 --- a/tests/kernel/mem_protect/userspace/src/main.c +++ b/tests/kernel/mem_protect/userspace/src/main.c @@ -82,12 +82,12 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) } else { printk("Wrong fault reason, expecting %d\n", expected_reason); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } else { printk("Unexpected fault during test\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } diff --git a/tests/kernel/pipe/pipe/src/test_pipe.c b/tests/kernel/pipe/pipe/src/test_pipe.c index 37cb78fb0b..04d1f7ec14 100644 --- a/tests/kernel/pipe/pipe/src/test_pipe.c +++ b/tests/kernel/pipe/pipe/src/test_pipe.c @@ -681,7 +681,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf) valid_fault = false; /* reset back to normal */ ztest_test_pass(); } else { - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } } diff --git a/tests/kernel/smp/src/main.c b/tests/kernel/smp/src/main.c index 698acb16af..2749d76fb3 100644 --- a/tests/kernel/smp/src/main.c +++ b/tests/kernel/smp/src/main.c @@ -763,7 +763,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) if (reason != K_ERR_KERNEL_OOPS) { printk("wrong error reason\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } diff --git a/tests/kernel/threads/dynamic_thread/src/main.c b/tests/kernel/threads/dynamic_thread/src/main.c index 0321aa792c..f7e4a93d2d 100644 --- a/tests/kernel/threads/dynamic_thread/src/main.c +++ b/tests/kernel/threads/dynamic_thread/src/main.c @@ -20,12 +20,12 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) { if (reason != K_ERR_KERNEL_OOPS) { printk("wrong error reason\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } if (k_current_get() != dyn_thread) { printk("wrong thread crashed\n"); - printk("PROJECT EXECUTION FAILED\n"); + TC_END_REPORT(TC_FAIL); k_fatal_halt(reason); } }