Skip to content

Commit 4e7a78e

Browse files
ruanqiuqiuRbb666
authored andcommitted
[docs]:Add standardized function comment blocks for mutex_tc
1 parent 29fb860 commit 4e7a78e

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/utest/mutex_pi_tc.c

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

1142
#include <rtthread.h>

src/utest/mutex_tc.c

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

1344
#include <rtthread.h>

0 commit comments

Comments
 (0)