Skip to content

Commit e696c65

Browse files
mengxianglinxnashif
authored andcommitted
test: context: Refine descriptions for some test cases
Add or refine comments for some test cases for readability Signed-off-by: Meng xianglin <[email protected]>
1 parent 9796313 commit e696c65

File tree

2 files changed

+147
-7
lines changed

2 files changed

+147
-7
lines changed

tests/kernel/common/src/clock.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,43 @@ void test_clock_uptime(void)
8585
/**
8686
* @brief Test clock cycle functionality
8787
*
88+
* @details
89+
* Test Objectve:
90+
* - The kernel architecture provide a 32bit monotonically increasing
91+
* cycle counter
92+
* - This routine tests the k_cycle_get_32() and k_uptime_get_32()
93+
* k_cycle_get_32() get cycles by accessing hardware clock.
94+
* k_uptime_get_32() return cycles by transforming ticks into cycles.
95+
*
96+
* Testing techniques
97+
* - Functional and black box testing
98+
*
99+
* Prerequisite Condition:
100+
* - N/A
101+
*
102+
* Input Specifications:
103+
* - N/A
104+
*
105+
* Expected Test Result:
106+
* - The timer increases monotonically
107+
*
108+
* Pass/Fail criteria:
109+
* - Success if cycles increase monotonically, failure otherwise.
110+
*
111+
* Test Procedure:
112+
* -# At mili-second boundary, get cycles repeatedly by k_cycle_get_32()
113+
* till cycles increased
114+
* -# At mili-second boundary, get cycles repeatedly by k_uptime_get_32()
115+
* till cycles increased
116+
* -# Cross check cycles gotten by k_cycle_get_32() and k_uptime_get_32(),
117+
* the delta cycle should be greater than 1 milli-second.
118+
*
119+
* Assumptions and Constraints
120+
* - N/A
121+
*
88122
* @see k_cycle_get_32(), k_uptime_get_32()
89123
*/
124+
90125
void test_clock_cycle(void)
91126
{
92127
uint32_t c32, c0, c1, t32;
@@ -125,7 +160,6 @@ void test_clock_cycle(void)
125160
}
126161
}
127162

128-
129163
/*
130164
*help function
131165
*/

tests/kernel/context/src/main.c

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,84 @@ static struct k_thread thread_data3;
136136

137137
static ISR_INFO isr_info;
138138

139+
/**
140+
* @brief Test cpu idle function
141+
*
142+
* @details
143+
* Test Objectve:
144+
* - The kernel architecture provide an idle function to be run when the system
145+
* has no work for the current CPU
146+
* - This routine tests the k_cpu_idle() routine
147+
*
148+
* Testing techniques
149+
* - Functional and black box testing
150+
* - Interface testing
151+
*
152+
* Prerequisite Condition:
153+
* - HAS_POWERSAVE_INSTRUCTION is set
154+
*
155+
* Input Specifications:
156+
* - N/A
157+
*
158+
* Test Procedure:
159+
* -# Record system time before cpu enters idle state
160+
* -# Enter cpu idle state by k_cpu_idle()
161+
* -# Record system time after cpu idle state is interrupted
162+
* -# Compare the two system time values.
163+
*
164+
* Expected Test Result:
165+
* - cpu enters idle state for a given time
166+
*
167+
* Pass/Fail criteria:
168+
* - Success if the cpu enters idle state, failure otherwise.
169+
*
170+
* Assumptions and Constraints
171+
* - N/A
172+
*
173+
* @see k_cpu_idle()
174+
* @ingroup kernel_context_tests
175+
*/
176+
static void test_kernel_cpu_idle(void);
177+
178+
/**
179+
* @brief Test cpu idle function
180+
*
181+
* @details
182+
* Test Objectve:
183+
* - The kernel architecture provide an idle function to be run when the system
184+
* has no work for the current CPU
185+
* - This routine tests the k_cpu_atomic_idle() routine
186+
*
187+
* Testing techniques
188+
* - Functional and black box testing
189+
* - Interface testing
190+
*
191+
* Prerequisite Condition:
192+
* - HAS_POWERSAVE_INSTRUCTION is set
193+
*
194+
* Input Specifications:
195+
* - N/A
196+
*
197+
* Test Procedure:
198+
* -# Record system time befor cpu enters idle state
199+
* -# Enter cpu idle state by k_cpu_atomic_idle()
200+
* -# Record system time after cpu idle state is interrupted
201+
* -# Compare the two system time values.
202+
*
203+
* Expected Test Result:
204+
* - cpu enters idle state for a given time
205+
*
206+
* Pass/Fail criteria:
207+
* - Success if the cpu enters idle state, failure otherwise.
208+
*
209+
* Assumptions and Constraints
210+
* - N/A
211+
*
212+
* @see k_cpu_atomic_idle()
213+
* @ingroup kernel_context_tests
214+
*/
215+
static void test_kernel_cpu_idle_atomic(void);
216+
139217
/**
140218
* @brief Handler to perform various actions from within an ISR context
141219
*
@@ -546,16 +624,43 @@ static void test_kernel_timer_interrupts(void)
546624
}
547625

548626
/**
627+
* @brief Test some context routines
549628
*
550-
* @brief Test some context routines from a preemptible thread
629+
* @details
630+
* Test Objectve:
631+
* - Thread context handles derived from context switches must be able to be
632+
* restored upon interrupt exit
551633
*
552-
* @ingroup kernel_context_tests
634+
* Testing techniques
635+
* - Functional and black box testing
636+
* - Interface testing
553637
*
554-
* This routines tests the k_current_get() and
555-
* k_is_in_isr() routines from both a preemptible thread and an ISR (that
556-
* interrupted a preemptible thread). Checking those routines with cooperative
557-
* threads are done elsewhere.
638+
* Prerequisite Condition:
639+
* - N/A
640+
*
641+
* Input Specifications:
642+
* - N/A
558643
*
644+
* Test Procedure:
645+
* -# Set priority of current thread to 0 as a preemptible thread
646+
* -# Trap to interrupt context, get thread id of the interrupted thread and
647+
* pass back to that thread.
648+
* -# Return to thread context and make sure this context is interrupted by
649+
* comparing its thread ID and the thread ID passed by isr.
650+
* -# Pass command to isr to check whether the isr is executed in interrupt
651+
* context
652+
* -# When return to thread context, check the return value of command.
653+
*
654+
* Expected Test Result:
655+
* - Thread context restored upon interrupt exit
656+
*
657+
* Pass/Fail criteria:
658+
* - Success if context of thread restored correctly, failure otherwise.
659+
*
660+
* Assumptions and Constraints
661+
* - N/A
662+
*
663+
* @ingroup kernel_context_tests
559664
* @see k_current_get(), k_is_in_isr()
560665
*/
561666
static void test_kernel_ctx_thread(void)
@@ -1039,6 +1144,7 @@ void test_k_yield(void)
10391144
*
10401145
* @see k_thread_create
10411146
*/
1147+
10421148
void test_kernel_thread(void)
10431149
{
10441150

0 commit comments

Comments
 (0)