Skip to content

Commit d49b988

Browse files
committed
docs(utest):Add standardized documentation for IPC Completion Test Test
Signed-off-by: ChuanN-sudo <fjchuanil@gmail.com>
1 parent 11a2f7e commit d49b988

File tree

2 files changed

+61
-27
lines changed

2 files changed

+61
-27
lines changed

components/drivers/ipc/utest/completion_tc.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,40 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2024-04-30 Shell init ver.
9+
* 2025-11-16 ChuanN-sudo add standardized utest documentation block
910
*/
1011

1112
/**
12-
* Test Case for rt_completion API
13+
* Test Case Name: IPC Completion Basic Test
1314
*
14-
* The test simulates a producer-consumer interaction where a producer thread
15-
* generates data, and a consumer thread consumes the data after waiting for its
16-
* availability using rt_completion synchronization primitives.
15+
* Test Objectives:
16+
* - Validate rt_completion initialization, wait, and wake-up mechanisms.
17+
* - Verify thread synchronization in producer-consumer model.
18+
* - Test core APIs: rt_completion_init(), rt_completion_wait_flags(), rt_completion_wakeup()
1719
*
18-
* Test Criteria:
19-
* - The producer should correctly increment the test data and signal
20-
* completion.
21-
* - The consumer should correctly wait for data update, consume it, and signal
22-
* completion.
20+
* Test Scenarios:
21+
* - Producer thread generates incrementing data and notifies consumer.
22+
* - Consumer thread waits for data updates and validates integrity.
23+
* - Random delays simulate race conditions in synchronization.
24+
*
25+
* Verification Metrics:
26+
* - The producer should correctly increment the test data and signal completion.
27+
* - The consumer should correctly wait for data update, consume it, and signal completion.
2328
* - Data integrity should be maintained between producer and consumer.
2429
* - Synchronization is properly done so both can see consistent data.
2530
* - Random latency is introduced to simulate racing scenarios.
31+
*
32+
* Dependencies:
33+
* - Hardware requirements: QEMU emulator or any hardware platform that supports RT-Thread,
34+
* - Software configuration:
35+
* - RT_USING_UTEST must be enabled (select "RT-Thread Utestcases" in menuconfig).
36+
* - RT_UTEST_COMPLETION must be enabled (enable via: RT-Thread Utestcases -> Kernel Components -> Drivers -> IPC Test -> IPC Completion Test).
37+
* - Environmental Assumptions: System scheduler working normally.
38+
*
39+
* Expected Results:
40+
* - Progress logs: "[ INFO ] components.drivers.ipc.rt_completion_basic: Summary:...Test times:..."
41+
* - Final output: "[ PASSED ] [ result ] testcase (components.drivers.ipc.rt_completion_basic)"
42+
* - No assertions triggered.
2643
*/
2744

2845
#define TEST_LATENCY_TICK (1)
@@ -76,7 +93,8 @@ static void wait_safely(struct rt_completion *completion)
7693
{
7794
break;
7895
}
79-
} while (1);
96+
}
97+
while (1);
8098
}
8199

82100
static void producer_thread_entry(void *parameter)
@@ -108,7 +126,8 @@ static void _wait_until_edge(void)
108126
do
109127
{
110128
current = rt_tick_get();
111-
} while (current == entry_level);
129+
}
130+
while (current == entry_level);
112131

113132
/* give a random latency for test */
114133
random_latency = rand();

components/drivers/ipc/utest/completion_timeout_tc.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,43 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2024-04-30 Shell init ver.
9+
* 2025-11-16 ChuanN-sudo add standardized utest documentation block
910
*/
1011

1112
/**
12-
* Test Case for rt_completion API
13+
* Test Case Name: IPC Completion Timeout Test
1314
*
14-
* The test simulates a producer-consumer interaction where a producer thread
15-
* generates data, and a consumer thread consumes the data after waiting for its
16-
* availability using rt_completion synchronization primitives.
15+
* Test Objectives:
16+
* - VaValidate rt_completion initialization, wait with timeout, and wake-up mechanisms.
17+
* - Verify thread synchronization resilience in producer-consumer model under timing constraints.
18+
* - Test core APIs: rt_completion_init(), rt_completion_wait_flags(), rt_completion_wakeup()
19+
* - Verify proper handling of timeout and interrupt scenarios during synchronization.
1720
*
18-
* Test Criteria:
21+
* Test Scenarios:
22+
* - Producer thread generates incrementing data with small delays between productions.
23+
* - Consumer thread waits for data with timeout flags (RT_INTERRUPTIBLE) to simulate real-world interruptions.
24+
* - Test deliberately introduces random thread yields to simulate scheduling variations.
25+
* - Producer-consumer synchronization loop runs for extended duration to expose timing issues.
26+
* - System handles asynchronous interruptions during wait operations.
27+
*
28+
* Verification Metrics:
1929
* - The producer produces data correctly and notifies the consumer thread.
20-
* - The consumer receives data correctly and acknowledges receipt to the
21-
* producer.
30+
* - The consumer receives data correctly and acknowledges receipt to the producer.
2231
* - The producer and consumer threads synchronize their operations effectively.
23-
* - Verify the correctness of data production and consumption between producer
24-
* and consumer threads.
25-
* - The asynchronous woken of consumer thread was handled properly so the
26-
* consumer don't lose woken from producer.
32+
* - Verify the correctness of data production and consumption between producer and consumer threads.
33+
* - The asynchronous woken of consumer thread was handled properly so the consumer don't lose woken from producer.
34+
*
35+
* Dependencies:
36+
* - Hardware requirements: QEMU emulator or any hardware platform that supports RT-Thread.
37+
* - Software configuration:
38+
* - RT_USING_UTEST must be enabled (select "RT-Thread Utestcases" in menuconfig).
39+
* - RT_UTEST_COMPLETION must be enabled (enable via: RT-Thread Utestcases -> Kernel Components -> Drivers -> IPC Test -> IPC Completion Test).
40+
* - Environmental Assumptions: System clock interrupts and scheduler working normally
2741
*
28-
* Test APIs:
29-
* - rt_completion_init()
30-
* - rt_completion_wakeup()
31-
* - rt_completion_wait_flags()
42+
* Expected Results:
43+
* - Progress logs: "[ INFO ] components.drivers.ipc.rt_completion_timeout: Summary:...Test times:...Async interruption count:...".
44+
* - Final output: "[ PASSED ] [ result ] testcase (components.drivers.ipc.rt_completion_timeout)".
45+
* - No assertions triggered.
3246
*/
3347

3448
#define TEST_LATENCY_TICK (1)
@@ -100,7 +114,8 @@ static void wait_safely(struct rt_completion *completion)
100114
{
101115
break;
102116
}
103-
} while (try_times--);
117+
}
118+
while (try_times--);
104119

105120
if (error != RT_EOK)
106121
{

0 commit comments

Comments
 (0)