@@ -133,7 +133,15 @@ void condvar_wait_wake_task(void *p1, void *p2, void *p3)
133
133
134
134
k_mutex_unlock (& test_mutex );
135
135
}
136
-
136
+ /**
137
+ * @defgroup kernel_condvar_tests Condition Variables
138
+ * @ingroup all_tests
139
+ * @{
140
+ * @}
141
+ *
142
+ * @addtogroup kernel_condvar_tests
143
+ * @{
144
+ */
137
145
/**
138
146
* @brief Test k_condvar_wait() and k_condvar_wake()
139
147
*/
@@ -163,7 +171,9 @@ ZTEST_USER(condvar_tests, test_condvar_wait_forever_wake)
163
171
k_thread_abort (& condvar_tid );
164
172
}
165
173
166
-
174
+ /**
175
+ * @brief Test k_condvar_wait() and k_condvar_wake() with timeout
176
+ */
167
177
ZTEST_USER (condvar_tests , test_condvar_wait_timeout_wake )
168
178
{
169
179
woken = 1 ;
@@ -191,6 +201,9 @@ ZTEST_USER(condvar_tests, test_condvar_wait_timeout_wake)
191
201
k_thread_abort (& condvar_tid );
192
202
}
193
203
204
+ /**
205
+ * @brief Test k_condvar_wait() and k_condvar_wake() with timeout
206
+ */
194
207
ZTEST_USER (condvar_tests , test_condvar_wait_timeout )
195
208
{
196
209
timeout = k_ms_to_ticks_ceil32 (50 );
@@ -224,7 +237,9 @@ ZTEST_USER(condvar_tests, test_condvar_wait_forever)
224
237
k_thread_abort (& condvar_tid );
225
238
}
226
239
227
-
240
+ /**
241
+ * @brief Test k_condvar_wait() with no wait
242
+ */
228
243
ZTEST_USER (condvar_tests , test_condvar_wait_nowait )
229
244
{
230
245
timeout = 0 ;
@@ -240,6 +255,12 @@ ZTEST_USER(condvar_tests, test_condvar_wait_nowait)
240
255
}
241
256
242
257
258
+ /**
259
+ * @brief Test case for conditional variable wait and wake functionality.
260
+ *
261
+ * This test validates the behavior of conditional variables when a thread
262
+ * waits on a condition and another thread wakes it up.
263
+ */
243
264
ZTEST_USER (condvar_tests , test_condvar_wait_nowait_wake )
244
265
{
245
266
woken = 0 ;
@@ -266,6 +287,13 @@ ZTEST_USER(condvar_tests, test_condvar_wait_nowait_wake)
266
287
}
267
288
268
289
290
+ /**
291
+ * @brief Test case for condition variable wait and wake functionality.
292
+ *
293
+ * This test verifies the behavior of a thread waiting on a condition variable
294
+ * with an infinite timeout and being woken up from an interrupt service routine (ISR).
295
+ *
296
+ */
269
297
ZTEST (condvar_tests , test_condvar_wait_forever_wake_from_isr )
270
298
{
271
299
timeout = K_TICKS_FOREVER ;
@@ -285,6 +313,15 @@ ZTEST(condvar_tests, test_condvar_wait_forever_wake_from_isr)
285
313
k_thread_abort (& condvar_tid );
286
314
}
287
315
316
+ /**
317
+ * @brief Test case for multiple threads waiting and waking on a condition variable.
318
+ *
319
+ * This test initializes a condition variable and creates multiple threads that
320
+ * wait on the condition variable. Another thread is created to wake up the
321
+ * waiting threads. The test ensures proper synchronization and behavior of
322
+ * threads waiting and waking on the condition variable.
323
+
324
+ */
288
325
ZTEST_USER (condvar_tests , test_condvar_multiple_threads_wait_wake )
289
326
{
290
327
timeout = K_TICKS_FOREVER ;
@@ -353,6 +390,15 @@ void condvar_multiple_wake_task(void *p1, void *p2, void *p3)
353
390
ret_value , woken_num );
354
391
}
355
392
393
+
394
+ /**
395
+ * @brief Test multiple threads waiting and waking on a condition variable.
396
+ *
397
+ * This test creates multiple threads that wait on a condition variable and
398
+ * another set of threads that wake them up. It ensures that the condition
399
+ * variable mechanism works correctly when multiple threads are involved.
400
+
401
+ */
356
402
ZTEST_USER (condvar_tests , test_multiple_condvar_wait_wake )
357
403
{
358
404
woken = 1 ;
@@ -404,6 +450,14 @@ static void cond_init_null(void *p1, void *p2, void *p3)
404
450
ztest_test_fail ();
405
451
}
406
452
453
+
454
+ /**
455
+ * @brief Test case for conditional variable initialization with a null parameter.
456
+ *
457
+ * This test verifies the behavior of the conditional variable initialization
458
+ * when a null parameter is passed. It creates a thread to execute the
459
+ * `cond_init_null` function and ensures the thread completes execution.
460
+ */
407
461
ZTEST_USER (condvar_tests , test_condvar_init_null )
408
462
{
409
463
k_tid_t tid = k_thread_create (& condvar_tid , stack_1 , STACK_SIZE ,
@@ -460,7 +514,13 @@ static void cond_wait_null(void *p1, void *p2, void *p3)
460
514
/* should not go here*/
461
515
ztest_test_fail ();
462
516
}
463
-
517
+ /**
518
+ * @brief Test case for signaling a condition variable with a NULL parameter.
519
+ *
520
+ * This test creates a thread that attempts to signal a condition variable
521
+ * with a NULL parameter. It ensures that the system handles this scenario
522
+ * gracefully without causing unexpected behavior or crashes.
523
+ */
464
524
ZTEST_USER (condvar_tests , test_condvar_signal_null )
465
525
{
466
526
k_tid_t tid = k_thread_create (& condvar_tid , stack_1 , STACK_SIZE ,
@@ -470,6 +530,14 @@ ZTEST_USER(condvar_tests, test_condvar_signal_null)
470
530
K_USER | K_INHERIT_PERMS , K_NO_WAIT );
471
531
k_thread_join (tid , K_FOREVER );
472
532
}
533
+
534
+ /**
535
+ * @brief Test case for broadcasting a condition variable with a NULL parameter.
536
+ *
537
+ * This test creates a thread that attempts to broadcast a condition variable
538
+ * with a NULL parameter. It verifies that the system can handle this edge case
539
+ * correctly and does not result in undefined behavior.
540
+ */
473
541
ZTEST_USER (condvar_tests , test_condvar_broadcast_null )
474
542
{
475
543
k_tid_t tid = k_thread_create (& condvar_tid , stack_1 , STACK_SIZE ,
@@ -480,6 +548,14 @@ ZTEST_USER(condvar_tests, test_condvar_broadcast_null)
480
548
481
549
k_thread_join (tid , K_FOREVER );
482
550
}
551
+
552
+ /**
553
+ * @brief Test case for waiting on a condition variable with a NULL parameter.
554
+ *
555
+ * This test creates a thread that attempts to wait on a condition variable
556
+ * with a NULL parameter. It ensures that the system properly handles this
557
+ * invalid operation and maintains stability.
558
+ */
483
559
ZTEST_USER (condvar_tests , test_condvar_wait_null )
484
560
{
485
561
k_tid_t tid = k_thread_create (& condvar_tid , stack_1 , STACK_SIZE ,
@@ -575,11 +651,20 @@ void _condvar_usecase(long multi)
575
651
576
652
}
577
653
654
+
655
+ /**
656
+ * @brief Test case for conditional variable use case with signal
657
+ *
658
+ * This test verifies the behavior of a conditional variable in a specific
659
+ * use case where a signal is used. It ensures that the conditional variable
660
+ * operates correctly when signaled, validating synchronization mechanisms.
661
+ */
578
662
ZTEST_USER (condvar_tests , test_condvar_usecase_signal )
579
663
{
580
664
_condvar_usecase (0 );
581
665
}
582
666
667
+
583
668
ZTEST_USER (condvar_tests , test_condvar_usecase_broadcast )
584
669
{
585
670
_condvar_usecase (1 );
@@ -604,4 +689,8 @@ static void *condvar_tests_setup(void)
604
689
return NULL ;
605
690
}
606
691
692
+ /**
693
+ * @}
694
+ */
695
+
607
696
ZTEST_SUITE (condvar_tests , NULL , condvar_tests_setup , NULL , NULL , NULL );
0 commit comments