Skip to content

Commit c5c4281

Browse files
cl2tclaude
authored andcommitted
[utest] Add standardized documentation blocks for mm and lwp test cases
Add functional description comment blocks to 5 test case files that were missing them, following the format specified in issue #10895: - mm/mm_memblock_tc.c: memory block management tests - mm/rt_ioremap.c: I/O remap tests - lwp/condvar_broadcast_tc.c: condition variable broadcast tests - lwp/condvar_signal_tc.c: condition variable signal tests - lwp/condvar_timedwait_tc.c: condition variable timed wait tests Closes #10895 (partial) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2b58dec commit c5c4281

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

examples/utest/testcases/lwp/condvar_broadcast_tc.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,40 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2023-11-20 Shell add test suites
9+
* 2026-03-19 cl2t Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Condition Variable Broadcast Test
14+
*
15+
* Test Objectives:
16+
* - Verify that rt_condvar_broadcast() correctly wakes up all threads
17+
* waiting on a condition variable.
18+
* - Test core APIs: rt_condvar_broadcast(), rt_condvar_timedwait(),
19+
* rt_mutex_take(), rt_mutex_release(), rt_mutex_get_owner().
20+
*
21+
* Test Scenarios:
22+
* - Creates 8 worker threads, each acquiring a mutex and then waiting on
23+
* a condition variable via rt_condvar_timedwait().
24+
* - The main thread calls rt_condvar_broadcast() to wake all waiters.
25+
* - Each woken thread verifies it re-acquired the mutex, increments a
26+
* counter, and releases the mutex.
27+
* - The main thread verifies all 8 threads were successfully woken.
28+
*
29+
* Verification Metrics:
30+
* - All waiting threads must be woken after broadcast (waken_num == THREAD_NUM).
31+
* - Each woken thread must hold the mutex (verified via rt_mutex_get_owner()).
32+
* - rt_condvar_timedwait() must return 0 on successful wake.
33+
* - Mutex release must succeed for each woken thread.
34+
*
35+
* Dependencies:
36+
* - Software configuration: RT_USING_SMART must be enabled.
37+
* - Environmental assumptions: The platform must support multi-threading
38+
* with at least 8 concurrent threads.
39+
*
40+
* Expected Results:
41+
* - Final output: "[ PASSED ] [ result ] testcase (testcases.ipc.condvar.broadcast)"
42+
* - No assertion failures during test execution.
943
*/
1044

1145
#include "common.h"

examples/utest/testcases/lwp/condvar_signal_tc.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,40 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2023-11-20 Shell add test suites
9+
* 2026-03-19 cl2t Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Condition Variable Signal Test
14+
*
15+
* Test Objectives:
16+
* - Verify that rt_condvar_signal() correctly wakes up a single thread
17+
* waiting on a condition variable.
18+
* - Test core APIs: rt_condvar_signal(), rt_condvar_timedwait(),
19+
* rt_mutex_take(), rt_mutex_release(), rt_thread_create().
20+
*
21+
* Test Scenarios:
22+
* - The main thread acquires a mutex, creates a waker thread, then waits
23+
* on a condition variable with a 100-tick timeout.
24+
* - The waker thread acquires the mutex and calls rt_condvar_signal() to
25+
* wake the main thread.
26+
* - The main thread verifies it was woken successfully and releases the
27+
* mutex.
28+
*
29+
* Verification Metrics:
30+
* - rt_condvar_signal() must return 0 on success.
31+
* - rt_condvar_timedwait() must return 0 when signaled before timeout.
32+
* - Timeout (-ETIMEDOUT) or interrupt (-EINTR) are acceptable non-fatal
33+
* outcomes.
34+
* - Mutex acquire and release must succeed without errors.
35+
*
36+
* Dependencies:
37+
* - Software configuration: RT_USING_SMART must be enabled.
38+
* - Environmental assumptions: The platform must support multi-threading.
39+
*
40+
* Expected Results:
41+
* - Final output: "[ PASSED ] [ result ] testcase (testcases.ipc.condvar.signal)"
42+
* - No assertion failures during test execution.
943
*/
1044

1145
#include "common.h"

examples/utest/testcases/lwp/condvar_timedwait_tc.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2023-11-20 Shell add test suites
9+
* 2026-03-19 cl2t Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Condition Variable Timed Wait Test
14+
*
15+
* Test Objectives:
16+
* - Verify that rt_condvar_timedwait() correctly times out when no signal
17+
* is received within the specified timeout period.
18+
* - Test core APIs: rt_condvar_timedwait(), rt_mutex_take(),
19+
* rt_mutex_init(), rt_condvar_init().
20+
*
21+
* Test Scenarios:
22+
* - The main thread acquires a mutex and calls rt_condvar_timedwait()
23+
* with a 100-tick timeout.
24+
* - Since no other thread signals the condition variable, the call is
25+
* expected to time out with -ETIMEDOUT or be interrupted with -EINTR.
26+
*
27+
* Verification Metrics:
28+
* - rt_condvar_timedwait() must return -ETIMEDOUT or -EINTR when no
29+
* signal is received.
30+
* - Any other non-zero return value indicates a test failure.
31+
* - Mutex initialization and acquisition must succeed.
32+
*
33+
* Dependencies:
34+
* - Software configuration: RT_USING_SMART must be enabled.
35+
* - Environmental assumptions: The platform must support condition
36+
* variables and mutexes.
37+
*
38+
* Expected Results:
39+
* - Final output: "[ PASSED ] [ result ] testcase (testcases.ipc.condvar.timedwait)"
40+
* - No assertion failures during test execution.
941
*/
1042

1143
#include "common.h"

examples/utest/testcases/mm/mm_memblock_tc.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,42 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2023-09-28 zmshahaha the first version
9+
* 2026-03-19 cl2t Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Memory Block Management Test
14+
*
15+
* Test Objectives:
16+
* - Validate the memblock subsystem for early boot memory region management.
17+
* - Test core APIs: rt_memblock_add_memory(), rt_memblock_reserve_memory(),
18+
* rt_memblock_merge(), rt_memblock_next_free_region().
19+
*
20+
* Test Scenarios:
21+
* - Add Test (test_memblock_add): Verifies adding memory regions in various
22+
* configurations including simple addition, adjacent regions (top/bottom),
23+
* insertion between existing regions, and merging of contiguous regions
24+
* with the same flags.
25+
* - Reserve Test (test_memblock_reserve): Verifies reserving memory within
26+
* existing regions at start/end positions, multiple reservations within
27+
* a single region, and large reservations spanning multiple regions.
28+
* Also validates free region iteration with MEMBLOCK_NOMAP filtering.
29+
*
30+
* Verification Metrics:
31+
* - Region count after add/merge operations matches expected value.
32+
* - Region start/end addresses and flags are correctly maintained.
33+
* - Merge correctly combines adjacent regions with identical flags.
34+
* - Free region iterator correctly skips reserved and NOMAP regions.
35+
*
36+
* Dependencies:
37+
* - Software configuration: RT_USING_SMART and RT_UTEST_MM_MEMBLOCK must
38+
* be enabled.
39+
* - Environmental assumptions: MMU support must be available on the target
40+
* platform.
41+
*
42+
* Expected Results:
43+
* - Final output: "[ PASSED ] [ result ] testcase (testcases.mm.memblock_tc)"
44+
* - No assertion failures during test execution.
945
*/
1046

1147
#include <mm_memblock.h>

examples/utest/testcases/mm/rt_ioremap.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,37 @@
77
* Date Author Notes
88
* 2022-12-14 WangXiaoyao the first version
99
* 2023-03-20 WangXiaoyao Format & add more testcases for API under mm_aspace.h
10+
* 2026-03-19 cl2t Add standardized utest documentation block
11+
*/
12+
13+
/**
14+
* Test Case Name: I/O Remap Test
15+
*
16+
* Test Objectives:
17+
* - Verify the rt_ioremap_cached() API for mapping physical addresses to
18+
* virtual addresses with cached memory access.
19+
* - Test core APIs: rt_pages_alloc(), rt_ioremap_cached(), rt_iounmap(),
20+
* rt_pages_free().
21+
*
22+
* Test Scenarios:
23+
* - Allocates a physical page (4KB), maps it to a virtual address using
24+
* rt_ioremap_cached(), verifies data consistency between the physical
25+
* and virtual addresses, then unmaps and frees the resources.
26+
*
27+
* Verification Metrics:
28+
* - The value read through the virtual address must equal the value at the
29+
* corresponding physical address.
30+
* - No memory leaks after unmap and free operations (validated via
31+
* CONSIST_HEAP wrapper).
32+
*
33+
* Dependencies:
34+
* - Software configuration: RT_USING_SMART must be enabled.
35+
* - Environmental assumptions: MMU support must be available on the target
36+
* platform.
37+
*
38+
* Expected Results:
39+
* - Final output: "[ PASSED ] [ result ] testcase (testcases.mm.ioremap)"
40+
* - No assertion failures during test execution.
1041
*/
1142

1243
#include "common.h"

0 commit comments

Comments
 (0)