From 1d60a3e86f6b10e2a41cead1450e60f39e6f3acc Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 5 Aug 2020 08:21:39 -0400 Subject: [PATCH] ztest: set thread name If thread names are enabled, set thread name for the ztest thread for tracing purposes. Signed-off-by: Anas Nashif --- subsys/testsuite/ztest/src/ztest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index 23213f493d2..6011282b11d 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -130,7 +130,9 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3) void z_impl_z_test_1cpu_start(void) { cpuhold_active = 1; - +#ifdef CONFIG_THREAD_NAME + char tname[CONFIG_THREAD_MAX_NAME_LEN]; +#endif k_sem_init(&cpuhold_sem, 0, 999); /* Spawn N-1 threads to "hold" the other CPUs, waiting for @@ -145,6 +147,10 @@ void z_impl_z_test_1cpu_start(void) cpuhold_stacks[i], CPUHOLD_STACK_SZ, (k_thread_entry_t) cpu_hold, NULL, NULL, NULL, K_HIGHEST_THREAD_PRIO, 0, K_NO_WAIT); +#ifdef CONFIG_THREAD_NAME + snprintk(tname, CONFIG_THREAD_MAX_NAME_LEN, "cpuhold%02d", i); + k_thread_name_set(&cpuhold_threads[i], tname); +#endif k_sem_take(&cpuhold_sem, K_FOREVER); } } @@ -328,6 +334,7 @@ static int run_test(struct unit_test *test) test->thread_options | K_INHERIT_PERMS, K_NO_WAIT); + k_thread_name_set(&ztest_thread, "ztest_thread"); k_thread_join(&ztest_thread, K_FOREVER); phase = TEST_PHASE_TEARDOWN;