Skip to content

Commit a94f97b

Browse files
spoorthiknashif
authored andcommitted
tests: kernel: Validate set thread name to current thread
Enhance test to validate a scenario where k_thread_name_set() with NULL as thread ID should set thread name to current thread. Signed-off-by: Spoorthi K <[email protected]>
1 parent 73c7cd1 commit a94f97b

File tree

1 file changed

+9
-1
lines changed
  • tests/kernel/threads/thread_apis/src

1 file changed

+9
-1
lines changed

tests/kernel/threads/thread_apis/src/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ void test_thread_name_get_set(void)
115115
int ret;
116116
const char *thread_name;
117117

118+
/* Set and get current thread's name */
119+
k_thread_name_set(NULL, "parent_thread");
120+
thread_name = k_thread_name_get(k_current_get());
121+
122+
ret = strcmp(thread_name, "parent_thread");
123+
zassert_equal(ret, 0, "parent thread name does not match");
124+
125+
/* Set and get child thread's name */
118126
k_tid_t tid = k_thread_create(&tdata_name, tstack_name, STACK_SIZE,
119127
(k_thread_entry_t)thread_name_entry,
120128
NULL, NULL, NULL,
@@ -127,7 +135,7 @@ void test_thread_name_get_set(void)
127135
thread_name = k_thread_name_get(tid);
128136

129137
ret = strcmp(thread_name, "customdata");
130-
zassert_equal(ret, 0, "thread name does not match");
138+
zassert_equal(ret, 0, "child thread name does not match");
131139

132140
/* cleanup environment */
133141
k_thread_abort(tid);

0 commit comments

Comments
 (0)