summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCYFS <[email protected]>2025-11-12 14:09:50 +0800
committerR b b666 <[email protected]>2025-11-14 12:43:09 +0800
commit832fe803df350c15f7dd65e8d0a13fd4c0273a87 (patch)
tree91c523287202e09beae1360271448572b1ef5ec3 /src
parent8286196d9ff01fa62987a688bd6c98ec35a83b6d (diff)
[docs][utest]:Add standardized utest documentation block for memheap_tc
Diffstat (limited to 'src')
-rw-r--r--src/utest/memheap_tc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/utest/memheap_tc.c b/src/utest/memheap_tc.c
index 16eff6ec17..cb78934270 100644
--- a/src/utest/memheap_tc.c
+++ b/src/utest/memheap_tc.c
@@ -6,8 +6,58 @@
* Change Logs:
* Date Author Notes
* 2019-01-16 flybreak the first version
+ * 2025-11-11 CYFS Add standardized utest documentation block
*/
+/**
+ * Test Case Name: Kernel Core Memory Heap Test
+ *
+ * Test Objectives:
+ * - Validates the core kernel memory heap management module functionality
+ * - Verify core APIs: rt_memheap_init, rt_memheap_alloc, rt_memheap_free, rt_memheap_realloc, rt_memheap_detach
+ *
+ * Test Scenarios:
+ * - **Scenario 1 (Memory Heap Stress Test / memheap_test):**
+ * 1. Initialize memory heap with 64KB aligned memory buffer (4-byte alignment)
+ * 2. Allocate 40 memory blocks with random sizes (0 to HEAP_SIZE/SLICE_NUM)
+ * 3. Perform 100000 random operations on the memory heap
+ * 4. Each operation randomly selects one of 40 memory blocks and performs either:
+ * - Free and reallocate with new random size (50% probability)
+ * - Reallocate existing block with new random size (50% probability)
+ * 5. Verify memory heap stability and correctness under high-frequency operations
+ *
+ * Verification Metrics:
+ * - **Pass (Scenario 1):** Memory heap initialization succeeds with 64KB aligned buffer
+ * - **Pass (Scenario 1):** All 40 initial allocations complete successfully
+ * - **Pass (Scenario 1):** All 100000 random operations complete without system crash or assertion failure
+ * - **Pass (Scenario 1):** Memory heap operations (alloc/free/realloc) execute correctly throughout stress test
+ * - **Pass (Scenario 1):** Progress indicators (>) printed at regular intervals (every 10000 operations)
+ * - **Pass (Scenario 1):** Test completes successfully with "test OK!" message
+ * - **Pass (Scenario 1):** Memory heap properly detached and resources cleaned up
+ *
+ * Dependencies:
+ * - No specific hardware requirements, runs on any RT-Thread supported platform
+ * - Software configuration (e.g., kernel options, driver initialization)
+ * - `RT_USING_UTEST` must be enabled (`RT-Thread Utestcases`).
+ * - `Memory Heap Test` must be enabled (`RT-Thread Utestcases` -> `Kernel Core` -> 'Memory Heap Test').
+ * - RT-Thread kernel with memory heap management enabled
+ * - rt_malloc_align and rt_free_align functions available for test buffer allocation
+ * - Random number generator (rand function) available for random operations
+ * - Sufficient system memory to allocate 64KB aligned buffer
+ * - Environmental assumptions
+ * - System can handle high-frequency memory operations (100000 operations)
+ * - Memory heap can manage 40 concurrent memory blocks
+ * - Run the test case from the msh prompt:
+ * `utest_run core.memheap`
+ *
+ * Expected Results:
+ * - The test case completes without errors or failed assertions.
+ * - Progress indicators (>) printed at regular intervals during stress test
+ * - "test OK!" message printed upon successful completion
+ * - The utest framework prints:
+ * `[ PASSED ] [ result ] testcase (core.memheap)`
+ * - Memory heap properly cleaned up and no memory leaks detected
+ */
#include <rtthread.h>
#include <stdlib.h>
#include "utest.h"