Skip to content
Open
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
42 changes: 40 additions & 2 deletions src/utest/mempool_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,47 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-09-03 Rbb666 the first version for mempool utest
* Date Author Notes
* 2025-09-03 Rbb666 the first version for mempool utest
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core MemPool Functional Test
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] 🟡 [naming]: Inconsistent naming with RT-Thread conventions / 命名与 RT-Thread 约定不一致

English: The test case name uses "MemPool" instead of the full term "Memory Pool" which is used elsewhere in RT-Thread documentation and in other test files. For consistency and clarity, use "Memory Pool" in the title.

Current: "Kernel Core MemPool Functional Test"
Suggested: "Kernel Core Memory Pool Functional Test"

中文: 测试用例名称使用了 "MemPool" 而不是在 RT-Thread 文档和其他测试文件中使用的完整术语 "Memory Pool"。为了保持一致性和清晰度,标题中应使用 "Memory Pool"。

当前:"Kernel Core MemPool Functional Test"
建议:"Kernel Core Memory Pool Functional Test"

Suggested change
* Test Case Name: Kernel Core MemPool Functional Test
* Test Case Name: Kernel Core Memory Pool Functional Test

Copilot uses AI. Check for mistakes.
*
* Test Objectives:
* - Validate static/dynamic memory pool functionality
* - Verify critical APIs: rt_mp_init, rt_mp_detach, rt_mp_alloc, rt_mp_free, rt_mp_create, rt_mp_delete
* - Test boundary conditions and stress scenarios
*
* Test Scenarios:
* - **Static Init**: Predefined block size/count; verify name/total/free counts
* - **Dynamic Create**: rt_mp_create; verify pool metadata
* - **Static Alloc/Free**: 3-block allocation; verify count changes
* - **Dynamic Alloc/Free**: Identical to static pool operations
* - **Exhaustion Test**: Full allocation → free=0 → next alloc=NULL
* - **Invalid Free**: NULL pointer free; no crash, count unchanged
* - **Stress Test**: 100x full alloc/free cycles; count restored each time
*
* Verification Metrics:
* - API returns: RT_EOK (success) / NULL (failure)
* - Block counts match expected values
* - Exhaustion: Allocation fails correctly
* - NULL free: Safe without crash
* - Stress: 0 errors/memory leaks
*
* Dependencies:
* - RT_USING_MEMPOOL must be enabled
* - RT_USING_UTEST framework must be enabled
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.mempool)
* - All 7 scenarios pass
* - 0 memory leaks
* - Stress test <10ms
* - Execute via: `utest_run core.mempool` in msh
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] 🟡 [spelling]: Inconsistent terminology / 术语不一致

English: The term "Execute via" is used here, while other documentation blocks in the same PR use "Executable via". For consistency across all test documentation, please use the same wording. Recommended: "Executable via: utest_run core.mempool in msh"

中文: 此处使用了 "Execute via",而同一 PR 中的其他文档块使用 "Executable via"。为了所有测试文档的一致性,请使用相同的措辞。建议使用:"Executable via: utest_run core.mempool in msh"

Suggested change
* - Execute via: `utest_run core.mempool` in msh
* - Executable via: `utest_run core.mempool` in msh

Copilot uses AI. Check for mistakes.
*/

#include <rtthread.h>
#include <stdlib.h>
#include "utest.h"
Expand Down
37 changes: 35 additions & 2 deletions src/utest/perf/context_switch_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for context_switch
* Date Author Notes
* 2025-07-03 rcitach test case for context_switch
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/*
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

🟠 [documentation]: Incorrect comment block format / 注释块格式错误

English: The documentation block uses /* instead of /** for the opening delimiter. RT-Thread code documentation should use Doxygen-style comment blocks starting with /** for proper documentation generation.

Please change:

/*
 * Test Case Name: ...

To:

/**
 * Test Case Name: ...

中文: 文档块使用了 /* 而不是 /** 作为开始分隔符。RT-Thread 代码文档应使用以 /** 开头的 Doxygen 风格注释块,以便正确生成文档。

请将:

/*
 * Test Case Name: ...

改为:

/**
 * Test Case Name: ...
Suggested change
/*
/**

Copilot uses AI. Check for mistakes.
* Test Case Name: Kernel Core Context Switch Performance Test
*
* Test Objectives:
* - Measures thread context switch overhead using semaphore synchronization
* - Validates interrupt-to-thread response time in switch scenarios
* - Provides quantitative results in microseconds (us)
*
* Test Scenarios:
* - **Thread Switch Simulation**: Two threads alternate using semaphores
* - **High-Resolution Timing**: Hardware timer measures switch duration
* - **Stress Cycles**: Repeated switch operations (RT_UTEST_SYS_PERF_TC_COUNT times)
* - **Priority Handling**: Higher-priority thread execution (THREAD_PRIORITY+1)
*
* Verification Metrics:
* - Switch time within reasonable limits (< 100 us)
* - Consistent results across multiple test cycles
* - No memory leaks during test execution
* - Correct thread priority handling
*
* Dependencies:
* - RT_USING_PERF_TEST must be enabled
* - RT_USING_UTEST framework must be enabled
* - Hardware timer support (for high-resolution timing)
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.context_switch)
* - Performance data printed in structured table format
* - Final line: "=== Context Switch Test Results End ==="
* - Test executed via: `utest_run core.context_switch` in msh
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] 🟡 [spelling]: Inconsistent terminology / 术语不一致

English: The term "Test executed via" is used here, while other documentation blocks in the same PR use "Executable via". For consistency across all test documentation, please use the same wording. Recommended: "Executable via: utest_run core.context_switch in msh"

中文: 此处使用了 "Test executed via",而同一 PR 中的其他文档块使用 "Executable via"。为了所有测试文档的一致性,请使用相同的措辞。建议使用:"Executable via: utest_run core.context_switch in msh"

Suggested change
* - Test executed via: `utest_run core.context_switch` in msh
* - Executable via: `utest_run core.context_switch` in msh

Copilot uses AI. Check for mistakes.
*/

#include <rtthread.h>
Expand Down
38 changes: 36 additions & 2 deletions src/utest/perf/irq_latency_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,42 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for irq latency
* Date Author Notes
* 2025-07-03 rcitach test case for irq latency
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core IRQ Latency Performance Test
*
* Test Objectives:
* - Measure interrupt-to-thread response time using hardware timer
* - Validate high-resolution timing accuracy (us level)
* - Verify consistent latency under repeated testing
*
* Test Scenarios:
* - **Hardware Timer ISR**: Triggered every 50μs via RT_UTEST_HWTIMER_DEV_NAME
* - **Latency Measurement**: Time from ISR entry to thread wake-up
* - **Stress Test**: 100+ repeated measurements (RT_UTEST_SYS_PERF_TC_COUNT)
* - **Priority Handling**: High-priority thread response validation
*
* Verification Metrics:
* - Latency < 1000μs (system-dependent threshold)
* - Max/Min/Avg deviation < 10% of average value
* - 0 errors in hardware timer setup
* - No memory leaks during test
*
* Dependencies:
* - RT_USING_PERF_TEST enabled
* - RT_USING_UTEST framework
* - Hardware timer device "hwtimer0" (or defined RT_UTEST_HWTIMER_DEV_NAME)
* - rt_device_find/open/close support
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.irq_latency)
* - Structured output with Min/Max/Avg latency (μs)
* - Final line: "=== IRQ Latency Test Results End ==="
* - Executable via: `utest_run core.irq_latency` in msh
*/

#include <rtthread.h>
Expand Down
44 changes: 42 additions & 2 deletions src/utest/perf/perf_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,50 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for irq latency
* Date Author Notes
* 2025-07-03 rcitach test case for irq latency
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core Performance Benchmark Suite
*
* Test Objectives:
* - Measures key kernel performance metrics using high-resolution hardware timer
* - Validates context switch and IPC mechanism latency
* - Tests interrupt-to-thread response time (IRQ latency)
* - Provides quantitative results in microseconds (us)
*
* Test Scenarios:
* - **Context Switch Overhead**: Thread-to-thread switch time
* - **Semaphore Performance**: rt_sem_take/rt_sem_release round-trip latency
* - **Event Performance**: rt_event_recv/rt_event_send latency
* - **Message Queue Performance**: rt_mq_send/rt_mq_recv latency
* - **Mailbox Performance**: rt_mb_send/rt_mb_recv latency
* - **IRQ Latency**: Time from hardware timer interrupt to thread wakeup
*
* Verification Metrics:
* - All tests complete without crash or timeout
* - Measured times are within reasonable system limits (e.g., < 1000 us for IRQ)
* - Performance data is printed in structured table format
* - No memory leaks during test execution
*
* Dependencies:
* - RT_USING_PERF_TEST must be enabled
* - RT_USING_UTEST framework enabled
* - Hardware timer device named "hwtimer0" (or defined by RT_UTEST_HWTIMER_DEV_NAME)
* - System must support rt_device_find/open/close for HWTIMER
* - Sufficient heap memory for dynamic allocation in test runner
*
* Expected Results:
* - Console output shows a formatted table with:
* Test No | Test Name | Count | Total/Max/Min/Avg Time (us)
* - Final line: "=== Performance Test Results End ==="
* - utest framework reports: [ PASSED ] [ result ] testcase (core.perf_test)
* - Test runs via: `utest_run core.perf_test` in msh
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] 🟡 [spelling]: Inconsistent terminology / 术语不一致

English: The term "Test runs via" is used here, while other documentation blocks in the same PR use "Executable via". For consistency across all test documentation, please use the same wording. Recommended: "Executable via: utest_run core.perf_test in msh"

中文: 此处使用了 "Test runs via",而同一 PR 中的其他文档块使用 "Executable via"。为了所有测试文档的一致性,请使用相同的措辞。建议使用:"Executable via: utest_run core.perf_test in msh"

Suggested change
* - Test runs via: `utest_run core.perf_test` in msh
* - Executable via: `utest_run core.perf_test` in msh

Copilot uses AI. Check for mistakes.
*/


Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

🟡 [best_practices]: Trailing whitespace / 尾随空格

English: Line 50 contains trailing whitespace. This violates RT-Thread coding standards which require clean code without unnecessary whitespace.

Please remove the trailing space on this line.

中文: 第 50 行包含尾随空格。这违反了 RT-Thread 编码标准,要求代码整洁,不包含不必要的空格。

请删除此行的尾随空格。

Suggested change

Copilot uses AI. Check for mistakes.
#include <rtthread.h>
#include <rtdevice.h>
#include <rtservice.h>
Expand Down
37 changes: 35 additions & 2 deletions src/utest/perf/thread_event_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for event
* Date Author Notes
* 2025-07-03 rcitach test case for event
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core Event Performance Test
*
* Test Objectives:
* - Measures event object synchronization performance
* - Validates event flag handling (OR/CLEAR) and priority
* - Provides latency metrics for event-based thread communication
*
* Test Scenarios:
* - **Event Flag Handling**: EVENT_FLAG with OR/CLEAR operation
* - **Priority Synchronization**: Higher-priority thread (THREAD_PRIORITY+1) response
* - **Stress Test**: Repeated event signaling (RT_UTEST_SYS_PERF_TC_COUNT times)
* - **Thread Coordination**: Two threads exchanging events via semaphores
*
* Verification Metrics:
* - Latency < 50μs (event recv/send cycle)
* - 0 errors in event flag handling
* - Consistent results across test cycles
* - No memory leaks during test
*
* Dependencies:
* - RT_USING_EVENT must be enabled
* - RT_USING_UTEST framework
* - Hardware timer support (for high-precision timing)
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.event)
* - Structured performance data table (Min/Max/Avg latency)
* - Final line: "=== Event Performance Test Results End ==="
* - Executable via: `utest_run core.event` in msh
*/

#include <rtthread.h>
Expand Down
37 changes: 35 additions & 2 deletions src/utest/perf/thread_mbox_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for mbox
* Date Author Notes
* 2025-07-03 rcitach test case for mbox
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core Mailbox Performance Test
*
* Test Objectives:
* - Measures mailbox object synchronization performance
* - Validates mailbox message passing with priority handling
* - Provides latency metrics for inter-thread communication
*
* Test Scenarios:
* - **Mailbox Message Passing**: Single message (1) sent/received
* - **Priority Handling**: Higher-priority thread (THREAD_PRIORITY+1) response
* - **Stress Test**: Repeated message passing (RT_UTEST_SYS_PERF_TC_COUNT times)
* - **Thread Coordination**: Two threads exchanging messages via semaphores
*
* Verification Metrics:
* - Message passing latency < 40μs
* - 0 errors in mailbox operations
* - Consistent results across test cycles
* - No memory leaks during test
*
* Dependencies:
* - RT_USING_MAILBOX must be enabled
* - RT_USING_UTEST framework
* - Hardware timer support (for high-precision timing)
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.mbox)
* - Structured performance data table (Min/Max/Avg latency)
* - Final line: "=== Mailbox Performance Test Results End ==="
* - Executable via: `utest_run core.mbox` in msh
*/

#include <rtthread.h>
Expand Down
37 changes: 35 additions & 2 deletions src/utest/perf/thread_mq_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for messagequeue
* Date Author Notes
* 2025-07-03 rcitach test case for messagequeue
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core Message Queue Performance Test
*
* Test Objectives:
* - Measures message queue synchronization performance
* - Validates message passing with data payload (char 'A')
* - Provides latency metrics for inter-thread communication
*
* Test Scenarios:
* - **Message Queue Operation**: Single char message ('A') transfer
* - **Priority Handling**: Higher-priority thread (THREAD_PRIORITY+1) response
* - **Stress Test**: Repeated message passing (RT_UTEST_SYS_PERF_TC_COUNT times)
* - **Thread Coordination**: Two threads exchanging messages via semaphores
*
* Verification Metrics:
* - Message passing latency < 45μs
* - 0 errors in message content verification
* - Consistent results across test cycles
* - No memory leaks during test
*
* Dependencies:
* - RT_USING_MESSAGEQUEUE must be enabled
* - RT_USING_UTEST framework
* - Hardware timer support (for high-precision timing)
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.mq)
* - Structured performance data table (Min/Max/Avg latency)
* - Final line: "=== Message Queue Performance Test Results End ==="
* - Executable via: `utest_run core.mq` in msh
*/

#include <rtthread.h>
Expand Down
37 changes: 35 additions & 2 deletions src/utest/perf/thread_sem_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-07-03 rcitach test case for semaphore
* Date Author Notes
* 2025-07-03 rcitach test case for semaphore
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
*/

/**
* Test Case Name: Kernel Core Semaphore Performance Test
*
* Test Objectives:
* - Measures semaphore synchronization performance
* - Validates priority inheritance in semaphore operations
* - Provides latency metrics for thread synchronization
*
* Test Scenarios:
* - **Semaphore Operation**: Counting semaphore (initial value 0) for thread coordination
* - **Priority Inheritance**: Higher-priority thread (THREAD_PRIORITY+1) response
* - **Stress Test**: Repeated synchronization (RT_UTEST_SYS_PERF_TC_COUNT times)
* - **Thread Coordination**: Two threads exchanging events for timing control
*
* Verification Metrics:
* - Synchronization latency < 35μs
* - 0 errors in thread coordination
* - Consistent results across test cycles
* - No priority inversion issues
*
* Dependencies:
* - RT_USING_SEMAPHORE must be enabled
* - RT_USING_UTEST framework
* - Hardware timer support (for high-precision timing)
*
* Expected Results:
* [ PASSED ] [ result ] testcase (core.sem)
* - Structured performance data table (Min/Max/Avg latency)
* - Final line: "=== Semaphore Performance Test Results End ==="
* - Executable via: `utest_run core.sem` in msh
*/

#include <rtthread.h>
Expand Down
Loading
Loading