Skip to content

Commit e90e1ce

Browse files
committed
docs(utest): Add standardized documentation for core.irq (irq_tc.c)
Most test cases in `src/utest` lack standardized functional documentation, as tracked in issue #10895. This leads to high maintenance costs, difficulty for new contributors, and inefficient code reviews. Solution: This patch adds the full, standardized documentation block to `src/utest/irq_tc.c`, following the approved template. The documentation details: - Test Objectives and tested APIs - Test Scenarios (for `irq_test` and `interrupt_test`) - Verification Metrics (the `uassert` criteria) - Dependencies (Kconfig options and hardware) - Test Execution command and Expected Results This makes the test case's purpose and behavior immediately clear to future maintainers and reviewers. Relates to #10895 Signed-off-by: lhxj <[email protected]>
1 parent 44cf90a commit e90e1ce

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/utest/irq_tc.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,63 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2021-08-15 supperthomas add irq_test
9+
* 2025-11-09 lhxj Add standardized utest documentation block
10+
*/
11+
12+
/**
13+
* Test Case Name: Kernel Core IRQ Test
14+
*
15+
* Test Objectives:
16+
* - Clearly specify the core functional module being validated by this test
17+
* - Validates the core kernel interrupt handling mechanisms.
18+
* - List specific functions or APIs to be tested
19+
* - rt_interrupt_enter_sethook()
20+
* - rt_interrupt_leave_sethook()
21+
* - rt_interrupt_get_nest()
22+
* - rt_hw_interrupt_disable()
23+
* - rt_hw_interrupt_enable()
24+
*
25+
* Test Scenarios:
26+
* - Describe usage scenarios or boundary conditions being simulated
27+
* - **Scenario 1 (Hook Test / irq_test):**
28+
* 1. Set interrupt enter/leave hooks that increment a counter (`irq_count`).
29+
* 2. Delay the thread (`rt_thread_mdelay`) to allow a SysTick interrupt to occur.
30+
* 3. Check if the hooks were triggered by the interrupt.
31+
* - **Scenario 2 (Global Disable Test / interrupt_test):**
32+
* 1. Set the same interrupt hooks.
33+
* 2. Globally disable CPU interrupts using `rt_hw_interrupt_disable()`.
34+
* 3. Execute a busy-wait loop.
35+
* 4. Check if the hooks were *not* triggered, proving interrupts were masked.
36+
*
37+
* Verification Metrics:
38+
* - List specific pass/fail criteria
39+
* - Expected return values, state changes, resource usage, etc.
40+
* - **Pass (Scenario 1):** `uassert_int_not_equal(0, irq_count)`
41+
* (The hook counter must be non-zero after the delay).
42+
* - **Pass (Scenario 1):** `uassert_int_not_equal(0, max_get_nest_count)`
43+
* (The recorded nesting level must be non-zero).
44+
* - **Pass (Scenario 2):** `uassert_int_equal(0, irq_count)`
45+
* (The hook counter must remain zero while interrupts are disabled).
46+
*
47+
* Dependencies:
48+
* - Hardware requirements (e.g., specific peripherals)
49+
* - Requires a hardware timer to generate the SysTick (system tick) interrupt.
50+
* (This is met by the qemu-virt64-riscv BSP).
51+
* - Software configuration (e.g., kernel options, driver initialization)
52+
* - `RT_USING_UTEST` must be enabled (`RT-Thread Utestcases`).
53+
* - `IRQ Test` must be enabled (`RT-Thread Utestcases` -> `Kernel Core` -> 'IRQ Test').
54+
* - Environmental assumptions
55+
* - Assumes the system is idle enough for `rt_thread_mdelay(2)` to
56+
* be interrupted by at least one SysTick.
57+
* - Run the test case from the msh prompt:
58+
* `utest_run core.irq`
59+
*
60+
* Expected Results:
61+
* - System behavior and performance after test execution
62+
* - The test case completes without errors or failed assertions.
63+
* - Observable outcomes like console output, log records, etc.
64+
* - The utest framework prints:
65+
* `[ PASSED ] [ result ] testcase (core.irq)`
966
*/
1067

1168
#include <rtthread.h>

0 commit comments

Comments
 (0)