Skip to content

Commit 5a137f9

Browse files
committed
Add standardized utest documentation block
1 parent 75d6c1c commit 5a137f9

File tree

9 files changed

+330
-18
lines changed

9 files changed

+330
-18
lines changed

src/utest/mempool_tc.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,47 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-09-03 Rbb666 the first version for mempool utest
7+
* Date Author Notes
8+
* 2025-09-03 Rbb666 the first version for mempool utest
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
910
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core MemPool Functional Test
14+
*
15+
* Test Objectives:
16+
* - Validate static/dynamic memory pool functionality
17+
* - Verify critical APIs: rt_mp_init, rt_mp_detach, rt_mp_alloc, rt_mp_free, rt_mp_create, rt_mp_delete
18+
* - Test boundary conditions and stress scenarios
19+
*
20+
* Test Scenarios:
21+
* - **Static Init**: Predefined block size/count; verify name/total/free counts
22+
* - **Dynamic Create**: rt_mp_create; verify pool metadata
23+
* - **Static Alloc/Free**: 3-block allocation; verify count changes
24+
* - **Dynamic Alloc/Free**: Identical to static pool operations
25+
* - **Exhaustion Test**: Full allocation → free=0 → next alloc=NULL
26+
* - **Invalid Free**: NULL pointer free; no crash, count unchanged
27+
* - **Stress Test**: 100x full alloc/free cycles; count restored each time
28+
*
29+
* Verification Metrics:
30+
* - API returns: RT_EOK (success) / NULL (failure)
31+
* - Block counts match expected values
32+
* - Exhaustion: Allocation fails correctly
33+
* - NULL free: Safe without crash
34+
* - Stress: 0 errors/memory leaks
35+
*
36+
* Dependencies:
37+
* - RT_USING_MEMPOOL must be enabled
38+
* - RT_USING_UTEST framework must be enabled
39+
*
40+
* Expected Results:
41+
* [ PASSED ] [ result ] testcase (core.mempool)
42+
* - All 7 scenarios pass
43+
* - 0 memory leaks
44+
* - Stress test <10ms
45+
* - Execute via: `utest_run core.mempool` in msh
46+
*/
47+
1048
#include <rtthread.h>
1149
#include <stdlib.h>
1250
#include "utest.h"

src/utest/perf/context_switch_tc.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,41 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for context_switch
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for context_switch
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
10+
*/
11+
12+
/*
13+
* Test Case Name: Kernel Core Context Switch Performance Test
14+
*
15+
* Test Objectives:
16+
* - Measures thread context switch overhead using semaphore synchronization
17+
* - Validates interrupt-to-thread response time in switch scenarios
18+
* - Provides quantitative results in microseconds (us)
19+
*
20+
* Test Scenarios:
21+
* - **Thread Switch Simulation**: Two threads alternate using semaphores
22+
* - **High-Resolution Timing**: Hardware timer measures switch duration
23+
* - **Stress Cycles**: Repeated switch operations (RT_UTEST_SYS_PERF_TC_COUNT times)
24+
* - **Priority Handling**: Higher-priority thread execution (THREAD_PRIORITY+1)
25+
*
26+
* Verification Metrics:
27+
* - Switch time within reasonable limits (< 100 us)
28+
* - Consistent results across multiple test cycles
29+
* - No memory leaks during test execution
30+
* - Correct thread priority handling
31+
*
32+
* Dependencies:
33+
* - RT_USING_PERF_TEST must be enabled
34+
* - RT_USING_UTEST framework must be enabled
35+
* - Hardware timer support (for high-resolution timing)
36+
*
37+
* Expected Results:
38+
* [ PASSED ] [ result ] testcase (core.context_switch)
39+
* - Performance data printed in structured table format
40+
* - Final line: "=== Context Switch Test Results End ==="
41+
* - Test executed via: `utest_run core.context_switch` in msh
942
*/
1043

1144
#include <rtthread.h>

src/utest/perf/irq_latency_tc.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,42 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for irq latency
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for irq latency
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core IRQ Latency Performance Test
14+
*
15+
* Test Objectives:
16+
* - Measure interrupt-to-thread response time using hardware timer
17+
* - Validate high-resolution timing accuracy (us level)
18+
* - Verify consistent latency under repeated testing
19+
*
20+
* Test Scenarios:
21+
* - **Hardware Timer ISR**: Triggered every 50μs via RT_UTEST_HWTIMER_DEV_NAME
22+
* - **Latency Measurement**: Time from ISR entry to thread wake-up
23+
* - **Stress Test**: 100+ repeated measurements (RT_UTEST_SYS_PERF_TC_COUNT)
24+
* - **Priority Handling**: High-priority thread response validation
25+
*
26+
* Verification Metrics:
27+
* - Latency < 1000μs (system-dependent threshold)
28+
* - Max/Min/Avg deviation < 10% of average value
29+
* - 0 errors in hardware timer setup
30+
* - No memory leaks during test
31+
*
32+
* Dependencies:
33+
* - RT_USING_PERF_TEST enabled
34+
* - RT_USING_UTEST framework
35+
* - Hardware timer device "hwtimer0" (or defined RT_UTEST_HWTIMER_DEV_NAME)
36+
* - rt_device_find/open/close support
37+
*
38+
* Expected Results:
39+
* [ PASSED ] [ result ] testcase (core.irq_latency)
40+
* - Structured output with Min/Max/Avg latency (μs)
41+
* - Final line: "=== IRQ Latency Test Results End ==="
42+
* - Executable via: `utest_run core.irq_latency` in msh
943
*/
1044

1145
#include <rtthread.h>

src/utest/perf/perf_tc.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,50 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for irq latency
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for irq latency
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
910
*/
1011

12+
/**
13+
* Test Case Name: Kernel Core Performance Benchmark Suite
14+
*
15+
* Test Objectives:
16+
* - Measures key kernel performance metrics using high-resolution hardware timer
17+
* - Validates context switch and IPC mechanism latency
18+
* - Tests interrupt-to-thread response time (IRQ latency)
19+
* - Provides quantitative results in microseconds (us)
20+
*
21+
* Test Scenarios:
22+
* - **Context Switch Overhead**: Thread-to-thread switch time
23+
* - **Semaphore Performance**: rt_sem_take/rt_sem_release round-trip latency
24+
* - **Event Performance**: rt_event_recv/rt_event_send latency
25+
* - **Message Queue Performance**: rt_mq_send/rt_mq_recv latency
26+
* - **Mailbox Performance**: rt_mb_send/rt_mb_recv latency
27+
* - **IRQ Latency**: Time from hardware timer interrupt to thread wakeup
28+
*
29+
* Verification Metrics:
30+
* - All tests complete without crash or timeout
31+
* - Measured times are within reasonable system limits (e.g., < 1000 us for IRQ)
32+
* - Performance data is printed in structured table format
33+
* - No memory leaks during test execution
34+
*
35+
* Dependencies:
36+
* - RT_USING_PERF_TEST must be enabled
37+
* - RT_USING_UTEST framework enabled
38+
* - Hardware timer device named "hwtimer0" (or defined by RT_UTEST_HWTIMER_DEV_NAME)
39+
* - System must support rt_device_find/open/close for HWTIMER
40+
* - Sufficient heap memory for dynamic allocation in test runner
41+
*
42+
* Expected Results:
43+
* - Console output shows a formatted table with:
44+
* Test No | Test Name | Count | Total/Max/Min/Avg Time (us)
45+
* - Final line: "=== Performance Test Results End ==="
46+
* - utest framework reports: [ PASSED ] [ result ] testcase (core.perf_test)
47+
* - Test runs via: `utest_run core.perf_test` in msh
48+
*/
49+
50+
1151
#include <rtthread.h>
1252
#include <rtdevice.h>
1353
#include <rtservice.h>

src/utest/perf/thread_event_tc.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,41 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for event
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for event
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core Event Performance Test
14+
*
15+
* Test Objectives:
16+
* - Measures event object synchronization performance
17+
* - Validates event flag handling (OR/CLEAR) and priority
18+
* - Provides latency metrics for event-based thread communication
19+
*
20+
* Test Scenarios:
21+
* - **Event Flag Handling**: EVENT_FLAG with OR/CLEAR operation
22+
* - **Priority Synchronization**: Higher-priority thread (THREAD_PRIORITY+1) response
23+
* - **Stress Test**: Repeated event signaling (RT_UTEST_SYS_PERF_TC_COUNT times)
24+
* - **Thread Coordination**: Two threads exchanging events via semaphores
25+
*
26+
* Verification Metrics:
27+
* - Latency < 50μs (event recv/send cycle)
28+
* - 0 errors in event flag handling
29+
* - Consistent results across test cycles
30+
* - No memory leaks during test
31+
*
32+
* Dependencies:
33+
* - RT_USING_EVENT must be enabled
34+
* - RT_USING_UTEST framework
35+
* - Hardware timer support (for high-precision timing)
36+
*
37+
* Expected Results:
38+
* [ PASSED ] [ result ] testcase (core.event)
39+
* - Structured performance data table (Min/Max/Avg latency)
40+
* - Final line: "=== Event Performance Test Results End ==="
41+
* - Executable via: `utest_run core.event` in msh
942
*/
1043

1144
#include <rtthread.h>

src/utest/perf/thread_mbox_tc.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,41 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for mbox
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for mbox
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core Mailbox Performance Test
14+
*
15+
* Test Objectives:
16+
* - Measures mailbox object synchronization performance
17+
* - Validates mailbox message passing with priority handling
18+
* - Provides latency metrics for inter-thread communication
19+
*
20+
* Test Scenarios:
21+
* - **Mailbox Message Passing**: Single message (1) sent/received
22+
* - **Priority Handling**: Higher-priority thread (THREAD_PRIORITY+1) response
23+
* - **Stress Test**: Repeated message passing (RT_UTEST_SYS_PERF_TC_COUNT times)
24+
* - **Thread Coordination**: Two threads exchanging messages via semaphores
25+
*
26+
* Verification Metrics:
27+
* - Message passing latency < 40μs
28+
* - 0 errors in mailbox operations
29+
* - Consistent results across test cycles
30+
* - No memory leaks during test
31+
*
32+
* Dependencies:
33+
* - RT_USING_MAILBOX must be enabled
34+
* - RT_USING_UTEST framework
35+
* - Hardware timer support (for high-precision timing)
36+
*
37+
* Expected Results:
38+
* [ PASSED ] [ result ] testcase (core.mbox)
39+
* - Structured performance data table (Min/Max/Avg latency)
40+
* - Final line: "=== Mailbox Performance Test Results End ==="
41+
* - Executable via: `utest_run core.mbox` in msh
942
*/
1043

1144
#include <rtthread.h>

src/utest/perf/thread_mq_tc.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,41 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for messagequeue
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for messagequeue
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core Message Queue Performance Test
14+
*
15+
* Test Objectives:
16+
* - Measures message queue synchronization performance
17+
* - Validates message passing with data payload (char 'A')
18+
* - Provides latency metrics for inter-thread communication
19+
*
20+
* Test Scenarios:
21+
* - **Message Queue Operation**: Single char message ('A') transfer
22+
* - **Priority Handling**: Higher-priority thread (THREAD_PRIORITY+1) response
23+
* - **Stress Test**: Repeated message passing (RT_UTEST_SYS_PERF_TC_COUNT times)
24+
* - **Thread Coordination**: Two threads exchanging messages via semaphores
25+
*
26+
* Verification Metrics:
27+
* - Message passing latency < 45μs
28+
* - 0 errors in message content verification
29+
* - Consistent results across test cycles
30+
* - No memory leaks during test
31+
*
32+
* Dependencies:
33+
* - RT_USING_MESSAGEQUEUE must be enabled
34+
* - RT_USING_UTEST framework
35+
* - Hardware timer support (for high-precision timing)
36+
*
37+
* Expected Results:
38+
* [ PASSED ] [ result ] testcase (core.mq)
39+
* - Structured performance data table (Min/Max/Avg latency)
40+
* - Final line: "=== Message Queue Performance Test Results End ==="
41+
* - Executable via: `utest_run core.mq` in msh
942
*/
1043

1144
#include <rtthread.h>

src/utest/perf/thread_sem_tc.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,41 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2025-07-03 rcitach test case for semaphore
7+
* Date Author Notes
8+
* 2025-07-03 rcitach test case for semaphore
9+
* 2025-11-30 westcity-YOLO Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core Semaphore Performance Test
14+
*
15+
* Test Objectives:
16+
* - Measures semaphore synchronization performance
17+
* - Validates priority inheritance in semaphore operations
18+
* - Provides latency metrics for thread synchronization
19+
*
20+
* Test Scenarios:
21+
* - **Semaphore Operation**: Counting semaphore (initial value 0) for thread coordination
22+
* - **Priority Inheritance**: Higher-priority thread (THREAD_PRIORITY+1) response
23+
* - **Stress Test**: Repeated synchronization (RT_UTEST_SYS_PERF_TC_COUNT times)
24+
* - **Thread Coordination**: Two threads exchanging events for timing control
25+
*
26+
* Verification Metrics:
27+
* - Synchronization latency < 35μs
28+
* - 0 errors in thread coordination
29+
* - Consistent results across test cycles
30+
* - No priority inversion issues
31+
*
32+
* Dependencies:
33+
* - RT_USING_SEMAPHORE must be enabled
34+
* - RT_USING_UTEST framework
35+
* - Hardware timer support (for high-precision timing)
36+
*
37+
* Expected Results:
38+
* [ PASSED ] [ result ] testcase (core.sem)
39+
* - Structured performance data table (Min/Max/Avg latency)
40+
* - Final line: "=== Semaphore Performance Test Results End ==="
41+
* - Executable via: `utest_run core.sem` in msh
942
*/
1043

1144
#include <rtthread.h>

0 commit comments

Comments
 (0)