tests: kernel: scheule_api: move to new ztest API
Move tests/kernel/sched/schedule_api to new ztest API. Signed-off-by: Ming Shao <ming.shao@intel.com>
This commit is contained in:
parent
9c7ef8ea06
commit
ec8a3ba7a8
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_IRQ_OFFLOAD=y
|
||||
CONFIG_NUM_PREEMPT_PRIORITIES=30
|
||||
CONFIG_NUM_COOP_PRIORITIES=30
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_IRQ_OFFLOAD=y
|
||||
CONFIG_TEST_USERSPACE=y
|
||||
CONFIG_SCHED_DUMB=y
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_IRQ_OFFLOAD=y
|
||||
CONFIG_TEST_USERSPACE=y
|
||||
CONFIG_SCHED_MULTIQ=y
|
||||
|
|
|
@ -27,6 +27,16 @@ void spin_for_ms(int ms)
|
|||
}
|
||||
}
|
||||
|
||||
static void *threads_scheduling_tests_setup(void)
|
||||
{
|
||||
#ifdef CONFIG_USERSPACE
|
||||
k_thread_access_grant(k_current_get(), &user_thread, &user_sem,
|
||||
&ustack);
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test scheduling
|
||||
*
|
||||
|
@ -37,44 +47,6 @@ void spin_for_ms(int ms)
|
|||
* @{
|
||||
* @}
|
||||
*/
|
||||
/* test case main entry */
|
||||
void test_main(void)
|
||||
{
|
||||
#ifdef CONFIG_USERSPACE
|
||||
k_thread_access_grant(k_current_get(), &user_thread, &user_sem,
|
||||
&ustack);
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
ztest_test_suite(threads_scheduling,
|
||||
ztest_unit_test(test_bad_priorities),
|
||||
ztest_unit_test(test_priority_cooperative),
|
||||
ztest_unit_test(test_priority_preemptible),
|
||||
ztest_1cpu_unit_test(test_priority_preemptible_wait_prio),
|
||||
ztest_unit_test(test_yield_cooperative),
|
||||
ztest_unit_test(test_sleep_cooperative),
|
||||
ztest_unit_test(test_busy_wait_cooperative),
|
||||
ztest_unit_test(test_sleep_wakeup_preemptible),
|
||||
ztest_unit_test(test_pending_thread_wakeup),
|
||||
ztest_unit_test(test_time_slicing_preemptible),
|
||||
ztest_unit_test(test_time_slicing_disable_preemptible),
|
||||
ztest_unit_test(test_lock_preemptible),
|
||||
ztest_unit_test(test_unlock_preemptible),
|
||||
ztest_unit_test(test_unlock_nested_sched_lock),
|
||||
ztest_unit_test(test_sched_is_preempt_thread),
|
||||
ztest_unit_test(test_slice_reset),
|
||||
ztest_unit_test(test_slice_scheduling),
|
||||
ztest_unit_test(test_priority_scheduling),
|
||||
ztest_unit_test(test_wakeup_expired_timer_thread),
|
||||
ztest_user_unit_test(test_user_k_wakeup),
|
||||
ztest_user_unit_test(test_user_k_is_preempt),
|
||||
ztest_user_unit_test(test_k_thread_suspend_init_null),
|
||||
ztest_user_unit_test(test_k_thread_resume_init_null),
|
||||
ztest_user_unit_test(test_k_thread_priority_get_init_null),
|
||||
ztest_user_unit_test(test_k_thread_priority_set_init_null),
|
||||
ztest_user_unit_test(test_k_thread_priority_set_overmax),
|
||||
ztest_user_unit_test(test_k_thread_priority_set_upgrade),
|
||||
ztest_user_unit_test(test_k_wakeup_init_null),
|
||||
ztest_unit_test(test_slice_perthread)
|
||||
);
|
||||
ztest_run_test_suite(threads_scheduling);
|
||||
}
|
||||
ZTEST_SUITE(threads_scheduling, NULL, threads_scheduling_tests_setup, NULL, NULL, NULL);
|
||||
ZTEST_SUITE(threads_scheduling_1cpu, NULL, threads_scheduling_tests_setup,
|
||||
ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL);
|
||||
|
|
|
@ -65,7 +65,7 @@ static void thread_tslice(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_priority_scheduling(void)
|
||||
ZTEST(threads_scheduling, test_priority_scheduling)
|
||||
{
|
||||
k_tid_t tid[NUM_THREAD];
|
||||
int old_prio = k_thread_priority_get(k_current_get());
|
||||
|
|
|
@ -65,7 +65,7 @@ static void tcoop_ctx(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_sched_is_preempt_thread(void)
|
||||
ZTEST(threads_scheduling, test_sched_is_preempt_thread)
|
||||
{
|
||||
k_sem_init(&end_sema, 0, 1);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static void thread_entry_prio(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_priority_cooperative(void)
|
||||
ZTEST(threads_scheduling, test_priority_cooperative)
|
||||
{
|
||||
int old_prio = k_thread_priority_get(k_current_get());
|
||||
|
||||
|
@ -80,7 +80,7 @@ void test_priority_cooperative(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_priority_preemptible(void)
|
||||
ZTEST(threads_scheduling, test_priority_preemptible)
|
||||
{
|
||||
int old_prio = k_thread_priority_get(k_current_get());
|
||||
|
||||
|
@ -120,7 +120,7 @@ void test_priority_preemptible(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_priority_preemptible_wait_prio(void)
|
||||
ZTEST(threads_scheduling_1cpu, test_priority_preemptible_wait_prio)
|
||||
{
|
||||
int old_prio = k_thread_priority_get(k_current_get());
|
||||
k_tid_t tid[THREAD_NUM];
|
||||
|
@ -181,7 +181,7 @@ extern void idle(void *p1, void *p2, void *p3);
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_bad_priorities(void)
|
||||
ZTEST(threads_scheduling, test_bad_priorities)
|
||||
{
|
||||
struct prio_test {
|
||||
int prio;
|
||||
|
|
|
@ -96,7 +96,7 @@ static void thread_handler(void *p1, void *p2, void *p3)
|
|||
* Yield the main thread which is cooperative. Check
|
||||
* if all the threads gets executed.
|
||||
*/
|
||||
void test_yield_cooperative(void)
|
||||
ZTEST(threads_scheduling, test_yield_cooperative)
|
||||
{
|
||||
|
||||
/* set current thread to a cooperative priority */
|
||||
|
@ -123,7 +123,7 @@ void test_yield_cooperative(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_sleep_cooperative(void)
|
||||
ZTEST(threads_scheduling, test_sleep_cooperative)
|
||||
{
|
||||
/* set current thread to a cooperative priority */
|
||||
init_prio = -1;
|
||||
|
@ -140,7 +140,7 @@ void test_sleep_cooperative(void)
|
|||
teardown_threads();
|
||||
}
|
||||
|
||||
void test_busy_wait_cooperative(void)
|
||||
ZTEST(threads_scheduling, test_busy_wait_cooperative)
|
||||
{
|
||||
/* set current thread to a cooperative priority */
|
||||
init_prio = -1;
|
||||
|
@ -169,7 +169,7 @@ void test_busy_wait_cooperative(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_sleep_wakeup_preemptible(void)
|
||||
ZTEST(threads_scheduling, test_sleep_wakeup_preemptible)
|
||||
{
|
||||
/* set current thread to a preemptible priority */
|
||||
init_prio = 0;
|
||||
|
@ -204,7 +204,7 @@ static void coop_thread(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_pending_thread_wakeup(void)
|
||||
ZTEST(threads_scheduling, test_pending_thread_wakeup)
|
||||
{
|
||||
/* Make current thread preemptible */
|
||||
k_thread_priority_set(k_current_get(), K_PRIO_PREEMPT(1));
|
||||
|
@ -239,7 +239,7 @@ void test_pending_thread_wakeup(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_time_slicing_preemptible(void)
|
||||
ZTEST(threads_scheduling, test_time_slicing_preemptible)
|
||||
{
|
||||
#ifdef CONFIG_TIMESLICING
|
||||
/* set current thread to a preemptible priority */
|
||||
|
@ -278,7 +278,7 @@ void test_time_slicing_preemptible(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_time_slicing_disable_preemptible(void)
|
||||
ZTEST(threads_scheduling, test_time_slicing_disable_preemptible)
|
||||
{
|
||||
#ifdef CONFIG_TIMESLICING
|
||||
/* set current thread to a preemptible priority */
|
||||
|
@ -310,7 +310,7 @@ void test_time_slicing_disable_preemptible(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_lock_preemptible(void)
|
||||
ZTEST(threads_scheduling, test_lock_preemptible)
|
||||
{
|
||||
/* set current thread to a preemptible priority */
|
||||
init_prio = 0;
|
||||
|
@ -345,7 +345,7 @@ void test_lock_preemptible(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_unlock_preemptible(void)
|
||||
ZTEST(threads_scheduling, test_unlock_preemptible)
|
||||
{
|
||||
/* set current thread to a preemptible priority */
|
||||
init_prio = 0;
|
||||
|
@ -382,7 +382,7 @@ void test_unlock_preemptible(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_unlock_nested_sched_lock(void)
|
||||
ZTEST(threads_scheduling, test_unlock_nested_sched_lock)
|
||||
{
|
||||
/* set current thread to a preemptible priority */
|
||||
init_prio = 0;
|
||||
|
@ -431,7 +431,7 @@ void test_unlock_nested_sched_lock(void)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_wakeup_expired_timer_thread(void)
|
||||
ZTEST(threads_scheduling, test_wakeup_expired_timer_thread)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&tthread[0], tstack, STACK_SIZE,
|
||||
thread_handler, NULL, NULL, NULL,
|
||||
|
|
|
@ -124,7 +124,7 @@ static void thread_time_slice(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_slice_reset(void)
|
||||
ZTEST(threads_scheduling, test_slice_reset)
|
||||
{
|
||||
uint32_t t32;
|
||||
k_tid_t tid[NUM_THREAD];
|
||||
|
@ -199,7 +199,7 @@ void test_slice_reset(void)
|
|||
}
|
||||
|
||||
#else /* CONFIG_TIMESLICING */
|
||||
void test_slice_reset(void)
|
||||
ZTEST(threads_scheduling, test_slice_reset)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ static void thread_tslice(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @ingroup kernel_sched_tests
|
||||
*/
|
||||
void test_slice_scheduling(void)
|
||||
ZTEST(threads_scheduling, test_slice_scheduling)
|
||||
{
|
||||
k_tid_t tid[NUM_THREAD];
|
||||
int old_prio = k_thread_priority_get(k_current_get());
|
||||
|
@ -179,7 +179,7 @@ static void slice_perthread_fn(void *a, void *b, void *c)
|
|||
}
|
||||
}
|
||||
|
||||
void test_slice_perthread(void)
|
||||
ZTEST(threads_scheduling, test_slice_perthread)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_TIMESLICE_PER_THREAD)) {
|
||||
ztest_test_skip();
|
||||
|
@ -202,11 +202,11 @@ void test_slice_perthread(void)
|
|||
}
|
||||
|
||||
#else /* CONFIG_TIMESLICING */
|
||||
void test_slice_scheduling(void)
|
||||
ZTEST(threads_scheduling, test_slice_scheduling)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
void test_slice_perthread(void)
|
||||
ZTEST(threads_scheduling, test_slice_perthread)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ static void sleepy_thread(void *p1, void *p2, void *p3)
|
|||
k_sem_give(&user_sem);
|
||||
}
|
||||
|
||||
void test_user_k_wakeup(void)
|
||||
ZTEST_USER(threads_scheduling, test_user_k_wakeup)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE, sleepy_thread,
|
||||
NULL, NULL, NULL,
|
||||
|
@ -52,7 +52,7 @@ static void preempt_test_thread(void *p1, void *p2, void *p3)
|
|||
k_sem_give(&user_sem);
|
||||
}
|
||||
|
||||
void test_user_k_is_preempt(void)
|
||||
ZTEST_USER(threads_scheduling, test_user_k_is_preempt)
|
||||
{
|
||||
/* thread_was_preempt is volatile, and static analysis doesn't
|
||||
* like to see it being tested inside zassert_true, because
|
||||
|
@ -113,7 +113,7 @@ static void thread_suspend_init_null(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see k_thread_suspend()
|
||||
*/
|
||||
void test_k_thread_suspend_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_suspend_init_null)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_suspend_init_null,
|
||||
|
@ -124,7 +124,7 @@ void test_k_thread_suspend_init_null(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_thread_suspend_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_suspend_init_null)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ static void thread_resume_init_null(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see k_thread_resume()
|
||||
*/
|
||||
void test_k_thread_resume_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_resume_init_null)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_resume_init_null,
|
||||
|
@ -161,7 +161,7 @@ void test_k_thread_resume_init_null(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_thread_resume_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_resume_init_null)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ static void thread_priority_get_init_null(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see thread_k_thread_priority_get()
|
||||
*/
|
||||
void test_k_thread_priority_get_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_get_init_null)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_priority_get_init_null,
|
||||
|
@ -198,7 +198,7 @@ void test_k_thread_priority_get_init_null(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_thread_priority_get_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_get_init_null)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ static void thread_priority_set_init_null(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see k_thread_priority_set()
|
||||
*/
|
||||
void test_k_thread_priority_set_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_set_init_null)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_priority_set_init_null,
|
||||
|
@ -235,7 +235,7 @@ void test_k_thread_priority_set_init_null(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_thread_priority_set_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_set_init_null)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ static void thread_priority_set_overmax(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see k_thread_priority_set()
|
||||
*/
|
||||
void test_k_thread_priority_set_overmax(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_set_overmax)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_priority_set_overmax,
|
||||
|
@ -273,7 +273,7 @@ void test_k_thread_priority_set_overmax(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_thread_priority_set_overmax(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_set_overmax)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ static void thread_priority_set_upgrade(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see k_thread_priority_set()
|
||||
*/
|
||||
void test_k_thread_priority_set_upgrade(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_set_upgrade)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_priority_set_upgrade,
|
||||
|
@ -313,7 +313,7 @@ void test_k_thread_priority_set_upgrade(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_thread_priority_set_upgrade(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_thread_priority_set_upgrade)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ static void thread_wakeup_init_null(void *p1, void *p2, void *p3)
|
|||
*
|
||||
* @see k_wakeup()
|
||||
*/
|
||||
void test_k_wakeup_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_wakeup_init_null)
|
||||
{
|
||||
k_tid_t tid = k_thread_create(&user_thread, ustack, STACK_SIZE,
|
||||
(k_thread_entry_t)thread_wakeup_init_null,
|
||||
|
@ -350,7 +350,7 @@ void test_k_wakeup_init_null(void)
|
|||
k_thread_join(tid, K_FOREVER);
|
||||
}
|
||||
#else
|
||||
void test_k_wakeup_init_null(void)
|
||||
ZTEST_USER(threads_scheduling, test_k_wakeup_init_null)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue