Skip to content

Commit 55b365c

Browse files
committed
[docs]:Add standardized function comment blocks for mutex_tc
1 parent 703930f commit 55b365c

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/utest/mutex_pi_tc.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,42 @@
66
* Change Logs:
77
* Date Author Notes
88
*/
9+
10+
/**
11+
* Test Case Name: RT-Thread Mutex Priority Inheritance & Timeout Behavior Test
12+
*
13+
* Test Objectives:
14+
* - Verify RT-Thread mutex behavior under priority inheritance (PI)
15+
* - Validate timeout, wake-up, chained mutex dependency, and recursive PI updates
16+
* - Test APIs: rt_mutex_init/detach, rt_mutex_take/trytake/release,
17+
* rt_thread_create/startup, rt_thread_resume, rt_timer usage
18+
*
19+
* Test Scenarios:
20+
* - Multiple threads contending for shared mutexes with different priorities
21+
* - Main thread holding chained mutexes to trigger multi-level PI updates
22+
* - Mutex timeout behavior (RT_ETIMEOUT) with concurrent holder priority changes
23+
* - Wake-up of a waiting high-priority thread via external resume event
24+
* - Recursive dependency chain causing full-chain PI propagation and restoration
25+
*
26+
* Verification Metrics:
27+
* - Correct return codes (RT_EOK, -RT_ETIMEOUT, -RT_EINTR)
28+
* - Correct priority inheritance and rollback to init_priority
29+
* - Expected thread scheduling order and priority transitions
30+
* - All synchronization flags increment to expected values
31+
*
32+
* Dependencies:
33+
* - RT-Thread kernel with mutex and IPC components enabled
34+
* - Preemptive scheduler with priority-based dispatching
35+
* - System tick timer accuracy for delay/timeout verification
36+
* - Sufficient thread stack size for multi-thread test
37+
*
38+
* Expected Results:
39+
* - PI activates and restores correctly across simple and recursive mutex chains
40+
* - Timeout and wake-up tests return expected error codes
41+
* - All test units complete successfully with correct thread priorities
42+
* - Console/log confirms all UTEST cases pass
43+
*/
44+
945
#define __RT_IPC_SOURCE__
1046

1147
#include <rtthread.h>

src/utest/mutex_tc.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,42 @@
88
* 2021-09.01 luckyzjq the first version
99
* 2023-09-15 xqyjlj change stack size in cpu64
1010
*/
11+
12+
/**
13+
* Test Case Name: RT-Thread Mutex Functional and Scheduling Validation
14+
*
15+
* Test Objectives:
16+
* - Verify correctness of static and dynamic mutex operations
17+
* - Validate priority inheritance, recursive locking, timeout handling, and error cases
18+
* - Test core mutex APIs: rt_mutex_init/detach, rt_mutex_create/delete,
19+
* rt_mutex_take/trytake/release, and related thread scheduling functions
20+
*
21+
* Test Scenarios:
22+
* - Mutex acquisition under contention with multi-thread scheduling
23+
* - Try-take on locked mutex, timeout-based take, recursive take sequence
24+
* - Priority inheritance when high-priority threads are blocked by lower-priority holders
25+
* - Behavior differences between static and dynamic mutexes
26+
* - Mutex release error handling, invalid release, and cleanup
27+
*
28+
* Verification Metrics:
29+
* - Correct return codes for all mutex operations (RT_EOK, timeouts, error states)
30+
* - Proper priority inheritance and restoration during contention
31+
* - Expected thread wake-up and state transition behavior
32+
* - Successful thread synchronization via _sync_flag
33+
*
34+
* Dependencies:
35+
* - RT-Thread kernel with IPC and mutex support enabled
36+
* - Heap availability when testing dynamic mutex creation
37+
* - Scheduler operating normally with multi-thread preemption
38+
* - Accurate system tick for timeout and delay validation
39+
*
40+
* Expected Results:
41+
* - All mutex APIs behave according to RT-Thread specifications
42+
* - Static and dynamic mutex tests complete successfully
43+
* - Priority inversion resolved via priority inheritance
44+
* - Console/log output indicates all UTEST cases pass
45+
*/
46+
1147
#define __RT_IPC_SOURCE__
1248

1349
#include <rtthread.h>

0 commit comments

Comments
 (0)