@@ -136,6 +136,84 @@ static struct k_thread thread_data3;
136136
137137static 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 */
561666static void test_kernel_ctx_thread (void )
@@ -1039,6 +1144,7 @@ void test_k_yield(void)
10391144 *
10401145 * @see k_thread_create
10411146 */
1147+
10421148void test_kernel_thread (void )
10431149{
10441150
0 commit comments