Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/utest/mutex_pi_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,37 @@
* Change Logs:
* Date Author Notes
*/

/**
* Test Case Name: RT-Thread Mutex Priority Inheritance & Timeout Behavior Test
Comment on lines +10 to +11
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Description Incomplete / PR 描述不完整

English: The PR description references issue #10895 but does not explain:

  1. What changes were made (adding standardized documentation blocks to two test files)
  2. Why these changes are needed (improving test documentation consistency)
  3. List of modified files (src/utest/mutex_tc.c and src/utest/mutex_pi_tc.c)

Please update the PR description to include these details as per RT-Thread contribution guidelines.

中文:PR 描述引用了 issue #10895,但未说明:

  1. 做了什么修改(为两个测试文件添加标准化文档块)
  2. 为什么需要这些修改(提高测试文档的一致性)
  3. 修改文件列表(src/utest/mutex_tc.csrc/utest/mutex_pi_tc.c

请根据 RT-Thread 贡献指南更新 PR 描述以包含这些详细信息。

Copilot generated this review using guidance from repository custom instructions.
* Test Objectives:
* - Verify RT-Thread mutex behavior under priority inheritance (PI)
* - Validate timeout, wake-up, chained mutex dependency, and recursive PI updates
* - Test APIs: rt_mutex_init/detach, rt_mutex_take/trytake/release,
* rt_thread_create/startup, rt_thread_resume, rt_timer usage
* Test Scenarios:
* - Multiple threads contending for shared mutexes with different priorities
* - Main thread holding chained mutexes to trigger multi-level PI updates
* - Mutex timeout behavior (RT_ETIMEOUT) with concurrent holder priority changes
* - Wake-up of a waiting high-priority thread via external resume event
* - Recursive dependency chain causing full-chain PI propagation and restoration
* Verification Metrics:
* - Correct return codes (RT_EOK, -RT_ETIMEOUT, -RT_EINTR)
* - Correct priority inheritance and rollback to init_priority
* - Expected thread scheduling order and priority transitions
* - All synchronization flags increment to expected values
* Dependencies:
* - RT-Thread kernel with mutex and IPC components enabled
* - Preemptive scheduler with priority-based dispatching
* - System tick timer accuracy for delay/timeout verification
* - Sufficient thread stack size for multi-thread test
* Expected Results:
* - PI activates and restores correctly across simple and recursive mutex chains
* - Timeout and wake-up tests return expected error codes
* - All test units complete successfully with correct thread priorities
* - Console/log confirms all UTEST cases pass
*/

#define __RT_IPC_SOURCE__

#include <rtthread.h>
Expand Down
31 changes: 31 additions & 0 deletions src/utest/mutex_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,37 @@
* 2021-09.01 luckyzjq the first version
* 2023-09-15 xqyjlj change stack size in cpu64
*/

/**
* Test Case Name: RT-Thread Mutex Functional and Scheduling Validation
Comment on lines +12 to +13
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Title Specificity Issue / PR 标题具体性问题

English: The PR title mentions "mutex_tc" but this PR modifies two files: mutex_tc.c and mutex_pi_tc.c. The title should accurately reflect all modified files. Consider revising to:
[docs] Add standardized function comment blocks for mutex test cases

中文:PR 标题提到 "mutex_tc",但此 PR 修改了两个文件:mutex_tc.cmutex_pi_tc.c。标题应准确反映所有修改的文件。建议修改为:
[docs] Add standardized function comment blocks for mutex test cases

Note: While the prefix format [docs] is correct, the description should cover both files being modified.

注意:虽然前缀格式 [docs] 是正确的,但描述应涵盖正在修改的两个文件。

Copilot generated this review using guidance from repository custom instructions.
* Test Objectives:
* - Verify correctness of static and dynamic mutex operations
* - Validate priority inheritance, recursive locking, timeout handling, and error cases
* - Test core mutex APIs: rt_mutex_init/detach, rt_mutex_create/delete,
* rt_mutex_take/trytake/release, and related thread scheduling functions
* Test Scenarios:
* - Mutex acquisition under contention with multi-thread scheduling
* - Try-take on locked mutex, timeout-based take, recursive take sequence
* - Priority inheritance when high-priority threads are blocked by lower-priority holders
* - Behavior differences between static and dynamic mutexes
* - Mutex release error handling, invalid release, and cleanup
* Verification Metrics:
* - Correct return codes for all mutex operations (RT_EOK, timeouts, error states)
* - Proper priority inheritance and restoration during contention
* - Expected thread wake-up and state transition behavior
* - Successful thread synchronization via _sync_flag
* Dependencies:
* - RT-Thread kernel with IPC and mutex support enabled
* - Heap availability when testing dynamic mutex creation
* - Scheduler operating normally with multi-thread preemption
* - Accurate system tick for timeout and delay validation
* Expected Results:
* - All mutex APIs behave according to RT-Thread specifications
* - Static and dynamic mutex tests complete successfully
* - Priority inversion resolved via priority inheritance
* - Console/log output indicates all UTEST cases pass
*/

#define __RT_IPC_SOURCE__

#include <rtthread.h>
Expand Down