Skip to content

Commit 832fe80

Browse files
CYFS3Rbb666
authored andcommitted
[docs][utest]:Add standardized utest documentation block for memheap_tc
1 parent 8286196 commit 832fe80

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/utest/memheap_tc.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,58 @@
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+
* - **Pass (Scenario 1):** Memory heap initialization succeeds with 64KB aligned buffer
31+
* - **Pass (Scenario 1):** All 40 initial allocations complete successfully
32+
* - **Pass (Scenario 1):** All 100000 random operations complete without system crash or assertion failure
33+
* - **Pass (Scenario 1):** Memory heap operations (alloc/free/realloc) execute correctly throughout stress test
34+
* - **Pass (Scenario 1):** Progress indicators (>) printed at regular intervals (every 10000 operations)
35+
* - **Pass (Scenario 1):** Test completes successfully with "test OK!" message
36+
* - **Pass (Scenario 1):** Memory heap properly detached and resources cleaned up
37+
*
38+
* Dependencies:
39+
* - No specific hardware requirements, runs on any RT-Thread supported platform
40+
* - Software configuration (e.g., kernel options, driver initialization)
41+
* - `RT_USING_UTEST` must be enabled (`RT-Thread Utestcases`).
42+
* - `Memory Heap Test` must be enabled (`RT-Thread Utestcases` -> `Kernel Core` -> 'Memory Heap Test').
43+
* - RT-Thread kernel with memory heap management enabled
44+
* - rt_malloc_align and rt_free_align functions available for test buffer allocation
45+
* - Random number generator (rand function) available for random operations
46+
* - Sufficient system memory to allocate 64KB aligned buffer
47+
* - Environmental assumptions
48+
* - System can handle high-frequency memory operations (100000 operations)
49+
* - Memory heap can manage 40 concurrent memory blocks
50+
* - Run the test case from the msh prompt:
51+
* `utest_run core.memheap`
52+
*
53+
* Expected Results:
54+
* - The test case completes without errors or failed assertions.
55+
* - Progress indicators (>) printed at regular intervals during stress test
56+
* - "test OK!" message printed upon successful completion
57+
* - The utest framework prints:
58+
* `[ PASSED ] [ result ] testcase (core.memheap)`
59+
* - Memory heap properly cleaned up and no memory leaks detected
60+
*/
1161
#include <rtthread.h>
1262
#include <stdlib.h>
1363
#include "utest.h"

0 commit comments

Comments
 (0)