Skip to content

Commit d837b64

Browse files
nashifkartben
authored andcommitted
tests: kernel: threads: improve doxygen comments, layout
Fix grouping and general doxygen fixups. Signed-off-by: Anas Nashif <[email protected]>
1 parent f3ea832 commit d837b64

File tree

7 files changed

+134
-50
lines changed

7 files changed

+134
-50
lines changed

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

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void customdata_entry(void *p1, void *p2, void *p3)
7878

7979
/**
8080
* @ingroup kernel_thread_tests
81-
* @brief test thread custom data get/set from coop thread
81+
* @brief Test thread custom data get/set from coop thread
8282
*
8383
* @see k_thread_custom_data_get(), k_thread_custom_data_set()
8484
*/
@@ -101,7 +101,7 @@ static void thread_name_entry(void *p1, void *p2, void *p3)
101101

102102
/**
103103
* @ingroup kernel_thread_tests
104-
* @brief test thread name get/set from supervisor thread
104+
* @brief Test thread name get/set from supervisor thread
105105
* @see k_thread_name_get(), k_thread_name_copy(), k_thread_name_set()
106106
*/
107107
ZTEST(threads_lifecycle, test_thread_name_get_set)
@@ -142,7 +142,7 @@ struct k_sem sem;
142142

143143
/**
144144
* @ingroup kernel_thread_tests
145-
* @brief test thread name get/set from user thread
145+
* @brief Test thread name get/set from user thread
146146
* @see k_thread_name_copy(), k_thread_name_set()
147147
*/
148148
ZTEST_USER(threads_lifecycle, test_thread_name_user_get_set)
@@ -211,7 +211,7 @@ ZTEST_USER(threads_lifecycle, test_thread_name_user_get_set)
211211

212212
/**
213213
* @ingroup kernel_thread_tests
214-
* @brief test thread custom data get/set from preempt thread
214+
* @brief Test thread custom data get/set from preempt thread
215215
* @see k_thread_custom_data_get(), k_thread_custom_data_set()
216216
*/
217217
ZTEST_USER(threads_lifecycle_1cpu, test_customdata_get_set_preempt)
@@ -243,7 +243,7 @@ static void umode_entry(void *thread_id, void *p2, void *p3)
243243

244244
/**
245245
* @ingroup kernel_thread_tests
246-
* @brief Test k_thread_user_mode_enter() to cover when userspace
246+
* @brief Test k_thread_user_mode_enter to cover when userspace
247247
* is not supported/enabled
248248
* @see k_thread_user_mode_enter()
249249
*/
@@ -392,6 +392,11 @@ static inline int join_scenario(enum control_method m)
392392
return join_scenario_interval(m, NULL);
393393
}
394394

395+
/**
396+
* @ingroup kernel_thread_tests
397+
* @brief Test thread join
398+
*
399+
*/
395400
ZTEST_USER(threads_lifecycle, test_thread_join)
396401
{
397402
int64_t interval;
@@ -415,6 +420,13 @@ ZTEST_USER(threads_lifecycle, test_thread_join)
415420

416421
}
417422

423+
/**
424+
* @ingroup kernel_thread_tests
425+
* @brief Test thread join from ISR
426+
*
427+
* @see k_thread_join()
428+
* @see k_thread_abort()
429+
*/
418430
ZTEST(threads_lifecycle, test_thread_join_isr)
419431
{
420432
zassert_equal(join_scenario(ISR_RUNNING), -EBUSY, "failed isr running");
@@ -447,6 +459,21 @@ static void deadlock2_entry(void *p1, void *p2, void *p3)
447459
zassert_equal(ret, 0, "couldn't join deadlock2_thread");
448460
}
449461

462+
463+
464+
/**
465+
* @brief Test case for thread join deadlock scenarios.
466+
*
467+
* This test verifies the behavior of the `k_thread_join` API in scenarios
468+
* that could lead to deadlocks. It includes the following checks:
469+
*
470+
* - Ensures that a thread cannot join itself, which would result in a
471+
* self-deadlock. The API should return `-EDEADLK` in this case.
472+
* - Creates two threads (`deadlock1_thread` and `deadlock2_thread`) and
473+
* verifies that they can be joined successfully without causing a deadlock.
474+
*
475+
* @ingroup kernel_thread_tests
476+
*/
450477
ZTEST_USER(threads_lifecycle, test_thread_join_deadlock)
451478
{
452479
/* Deadlock scenarios */
@@ -476,6 +503,11 @@ static void user_start_thread(void *p1, void *p2, void *p3)
476503
{
477504
/* do nothing */
478505
}
506+
/**
507+
* @brief Test case for verifying thread timeout expiration and remaining time.
508+
*
509+
* @ingroup kernel_thread_tests
510+
*/
479511

480512
ZTEST_USER(threads_lifecycle, test_thread_timeout_remaining_expires)
481513
{
@@ -528,10 +560,16 @@ static void foreach_callback(const struct k_thread *thread, void *user_data)
528560
stats.execution_cycles;
529561
}
530562

531-
/* This case accumulates every thread's execution_cycles first, then
563+
/**
564+
* @brief Test case for thread runtime statistics retrieval in Zephyr kernel
565+
*
566+
* This case accumulates every thread's execution_cycles first, then
532567
* get the total execution_cycles from a global
533568
* k_thread_runtime_stats_t to see that all time is reflected in the
534569
* total.
570+
*
571+
* @ingroup kernel_thread_tests
572+
* @see k_thread_runtime_stats_get()
535573
*/
536574
ZTEST(threads_lifecycle, test_thread_runtime_stats_get)
537575
{
@@ -551,6 +589,13 @@ ZTEST(threads_lifecycle, test_thread_runtime_stats_get)
551589
zassert_true(stats.execution_cycles <= stats_all.execution_cycles);
552590
}
553591

592+
593+
/**
594+
* @brief Test the behavior of k_busy_wait with thread runtime statistics.
595+
*
596+
* This test verifies the accuracy of the `k_busy_wait` function by checking
597+
* the thread's execution cycle statistics before and after calling the function.
598+
*/
554599
ZTEST(threads_lifecycle, test_k_busy_wait)
555600
{
556601
uint64_t cycles, dt;
@@ -589,6 +634,12 @@ static void tp_entry(void *p1, void *p2, void *p3)
589634
tp = 100;
590635
}
591636

637+
/**
638+
* @brief Test the behavior of k_busy_wait with thread runtime statistics
639+
* in user mode.
640+
*
641+
* @ingroup kernel_thread_tests
642+
*/
592643
ZTEST_USER(threads_lifecycle_1cpu, test_k_busy_wait_user)
593644
{
594645

@@ -624,9 +675,14 @@ static int small_stack(size_t *space)
624675
return k_thread_stack_space_get(k_current_get(), space);
625676
}
626677

627-
/* test k_thread_stack_sapce_get(), unused stack space in large_stack_space()
678+
/**
679+
* @brief Test k_thread_stack_sapce_get
680+
*
681+
* Test k_thread_stack_sapce_get unused stack space in large_stack_space()
628682
* is smaller than that in small_stack() because the former function has a
629683
* large local variable
684+
*
685+
* @ingroup kernel_thread_tests
630686
*/
631687
ZTEST_USER(threads_lifecycle, test_k_thread_stack_space_get_user)
632688
{

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ ZTEST(threads_lifecycle, test_essential_thread_abort)
114114
zassert_true(fatal_error_signaled, "fatal error was not signaled");
115115
}
116116

117+
/**
118+
* @brief Abort an essential thread from itself
119+
*
120+
* @details The kernel shall raise a fatal system error if an essential thread
121+
* aborts, implement k_sys_fatal_error_handler to handle this error.
122+
*
123+
* @ingroup kernel_thread_tests
124+
*
125+
* @see #K_ESSENTIAL(x)
126+
*/
117127
ZTEST(threads_lifecycle, test_essential_thread_abort_self)
118128
{
119129
/* This test case needs to be able to handle a k_panic() call

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void thread_entry_abort(void *p1, void *p2, void *p3)
3232
}
3333
/**
3434
* @ingroup kernel_thread_tests
35-
* @brief Validate k_thread_abort() when called by current thread
35+
* @brief Validate aborting a thread when called by current thread
3636
*
3737
* @details Create a user thread and let the thread execute.
3838
* Then call k_thread_abort() and check if the thread is terminated.
@@ -52,7 +52,7 @@ ZTEST_USER(threads_lifecycle, test_threads_abort_self)
5252

5353
/**
5454
* @ingroup kernel_thread_tests
55-
* @brief Validate k_thread_abort() when called by other thread
55+
* @brief Validate aborting a thread when called by other thread
5656
*
5757
* @details Create a user thread and abort the thread before its
5858
* execution. Create a another user thread and abort the thread
@@ -85,7 +85,7 @@ ZTEST_USER(threads_lifecycle, test_threads_abort_others)
8585

8686
/**
8787
* @ingroup kernel_thread_tests
88-
* @brief Test abort on a terminated thread
88+
* @brief Test abort on an already terminated thread
8989
*
9090
* @see k_thread_abort()
9191
*/

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ void child_fn(void *a, void *b, void *c)
2222
child_has_run = true;
2323
}
2424

25+
26+
/**
27+
* @brief Test the CPU mask APIs for thread lifecycle management
28+
*
29+
* This test verifies the behavior of the CPU mask APIs in the Zephyr kernel
30+
* for thread lifecycle management. It ensures that the APIs behave as expected
31+
* when operating on both running and non-running threads.
32+
*
33+
* @note This test is only executed if `CONFIG_SCHED_CPU_MASK` is enabled.
34+
* Otherwise, the test is skipped.
35+
*
36+
* @ingroup kernel_thread_tests
37+
*/
2538
ZTEST(threads_lifecycle_1cpu, test_threads_cpu_mask)
2639
{
2740
#ifdef CONFIG_SCHED_CPU_MASK

0 commit comments

Comments
 (0)