Skip to content

Commit 6d249b1

Browse files
committed
[docs][utest]:Add standardized utest documentation block for memheap_tc
1 parent 02d8380 commit 6d249b1

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

src/utest/memheap_tc.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,63 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2019-01-16 flybreak the first version
9+
* 2025-11-11 CYFS Add standardized utest documentation block
910
*/
1011

12+
/**
13+
* Test Case Name: Kernel Core Memory Heap Test
14+
*
15+
* Test Objectives:
16+
* - Validates the core kernel memory heap management module functionality
17+
* - Verify core APIs: rt_memheap_init, rt_memheap_alloc, rt_memheap_free, rt_memheap_realloc, rt_memheap_detach
18+
*
19+
* Test Scenarios:
20+
* - **Scenario 1 (Memory Heap Stress Test / memheap_test):**
21+
* 1. Initialize memory heap with 64KB aligned memory buffer (4-byte alignment)
22+
* 2. Allocate 40 memory blocks with random sizes (0 to HEAP_SIZE/SLICE_NUM)
23+
* 3. Perform 100000 random operations on the memory heap
24+
* 4. Each operation randomly selects one of 40 memory blocks and performs either:
25+
* - Free and reallocate with new random size (50% probability)
26+
* - Reallocate existing block with new random size (50% probability)
27+
* 5. Verify memory heap stability and correctness under high-frequency operations
28+
*
29+
* Verification Metrics:
30+
* - List specific pass/fail criteria
31+
* - Expected return values, state changes, resource usage, etc.
32+
* - **Pass (Scenario 1):** Memory heap initialization succeeds with 64KB aligned buffer
33+
* - **Pass (Scenario 1):** All 40 initial allocations complete successfully
34+
* - **Pass (Scenario 1):** All 100000 random operations complete without system crash or assertion failure
35+
* - **Pass (Scenario 1):** Memory heap operations (alloc/free/realloc) execute correctly throughout stress test
36+
* - **Pass (Scenario 1):** Progress indicators (>) printed at regular intervals (every 10000 operations)
37+
* - **Pass (Scenario 1):** Test completes successfully with "test OK!" message
38+
* - **Pass (Scenario 1):** Memory heap properly detached and resources cleaned up
39+
*
40+
* Dependencies:
41+
* - Hardware requirements (e.g., specific peripherals)
42+
* - No specific hardware requirements, runs on any RT-Thread supported platform
43+
* - Software configuration (e.g., kernel options, driver initialization)
44+
* - `RT_USING_UTEST` must be enabled (`RT-Thread Utestcases`).
45+
* - `Memory Heap Test` must be enabled (`RT-Thread Utestcases` -> `Kernel Core` -> 'Memory Heap Test').
46+
* - RT-Thread kernel with memory heap management enabled
47+
* - rt_malloc_align and rt_free_align functions available for test buffer allocation
48+
* - Random number generator (rand function) available for random operations
49+
* - Sufficient system memory to allocate 64KB aligned buffer
50+
* - Environmental assumptions
51+
* - System can handle high-frequency memory operations (100000 operations)
52+
* - Memory heap can manage 40 concurrent memory blocks
53+
* - Run the test case from the msh prompt:
54+
* `utest_run core.memheap`
55+
*
56+
* Expected Results:
57+
* - System behavior and performance after test execution
58+
* - The test case completes without errors or failed assertions.
59+
* - Progress indicators (>) printed at regular intervals during stress test
60+
* - "test OK!" message printed upon successful completion
61+
* - Observable outcomes like console output, log records, etc.
62+
* - The utest framework prints:
63+
* `[ PASSED ] [ result ] testcase (core.memheap)`
64+
* - Memory heap properly cleaned up and no memory leaks detected
65+
*/
1166
#include <rtthread.h>
1267
#include <stdlib.h>
1368
#include "utest.h"

0 commit comments

Comments
 (0)