|
5 | 5 | * |
6 | 6 | * Change Logs: |
7 | 7 | * Date Author Notes |
8 | | - * 2021-09.01 yangjie the firet version |
| 8 | + * 2021-09.01 yangjie the first version |
9 | 9 | * 2021-10.11 mazhiyuan add idle, yield, suspend, control, priority, delay_until |
| 10 | + * 2025-11-12 Ze-Hou add standardized utest documentation block |
| 11 | + */ |
| 12 | + |
| 13 | +/** |
| 14 | + * Test Case Name: Kernel Core Thread Test |
| 15 | + * |
| 16 | + * Test Objectives: |
| 17 | + * - Validate the core thread management features of the RT-Thread kernel: |
| 18 | + * 1. Thread creation methods (dynamic and static) |
| 19 | + * 2. Timing accuracy (resolution) of the rt_thread_delay API |
| 20 | + * 3. Use of the idle hook |
| 21 | + * 4. RT-Thread’s thread yield mechanism |
| 22 | + * 5. RT-Thread’s thread control interfaces |
| 23 | + * 6. Thread priorities |
| 24 | + * 7. Absolute delay functionality |
| 25 | + * 8. Time-slice scheduling among threads with the same priority |
| 26 | + * |
| 27 | + * Test Scenarios: |
| 28 | + * - Create, start, and delete a dynamic thread to verify dynamic thread lifecycle management |
| 29 | + * - Initialize, start, and detach a static thread to verify static thread lifecycle management |
| 30 | + * - Delay a thread for a specific tick count and check timing accuracy |
| 31 | + * - Register and remove an idle hook, verifying it is called as expected |
| 32 | + * - Use thread yield to test scheduler fairness among threads of the same priority |
| 33 | + * - Use thread control APIs to start, change priority, and close a thread, verifying each operation |
| 34 | + * - Create a thread with a specific priority and verify it runs as expected |
| 35 | + * - Use rt_thread_delay_until to test absolute delay and periodic task timing |
| 36 | + * - Create multiple threads with the same priority and test time-slice scheduling fairness |
| 37 | + * |
| 38 | + * Verification Metrics: |
| 39 | + * - Threads are created, started, deleted, and detached successfully |
| 40 | + * - The precision of both relative delay and absolute delay is correct. |
| 41 | + * - Idle hook is invoked as expected during thread idle periods |
| 42 | + * - Thread yield causes correct scheduling among threads of the same priority |
| 43 | + * - Thread control APIs (startup, change priority, close) work as intended and update thread state correctly |
| 44 | + * - Time-slice scheduling distributes CPU time fairly among threads of the same priority (difference < 30%) |
| 45 | + * |
| 46 | + * Dependencies: |
| 47 | + * - Enable Thread Test (RT-Thread Utestcases -> Kernel Core -> Thread Test) |
| 48 | + * - Test on any RT-Thread supported platform (e.g., qemu-virt64-riscv) |
| 49 | + * |
| 50 | + * Expected Results: |
| 51 | + * - After executing this test in msh, the expected output should be: |
| 52 | + * "[ PASSED ] [ result ] testcase (core.thread_tc)" |
10 | 53 | */ |
11 | 54 |
|
12 | 55 | #define __RT_IPC_SOURCE__ /* include internal API for utest */ |
|
0 commit comments