Skip to content
Permalink
Browse files

tests/kernel/schedule_api: also test without time slicing

This extends the schedule_api test to cover situations when
time slicing is disabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
  • Loading branch information...
dcpleung authored and nashif committed Mar 27, 2019
1 parent 149cc7f commit 3fa90938fe2c7d1f3c786e8416e84c6f9a99c321
@@ -1,6 +1,5 @@
CONFIG_ZTEST=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_TIMESLICING=y
CONFIG_NUM_PREEMPT_PRIORITIES=30
CONFIG_SCHED_SCALABLE=y
CONFIG_QEMU_TICKLESS_WORKAROUND=y
@@ -1,4 +1,3 @@
CONFIG_ZTEST=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_TIMESLICING=y
CONFIG_SCHED_MULTIQ=y
@@ -239,6 +239,7 @@ void test_pending_thread_wakeup(void)
*/
void test_time_slicing_preemptible(void)
{
#ifdef CONFIG_TIMESLICING
/* set current thread to a preemptible priority */
init_prio = 0;
setup_threads();
@@ -257,6 +258,9 @@ void test_time_slicing_preemptible(void)
/* restore environment */
k_sched_time_slice_set(0, 0); /* disable time slice */
teardown_threads();
#else /* CONFIG_TIMESLICING */
ztest_test_skip();
#endif /* CONFIG_TIMESLICING */
}

/**
@@ -274,6 +278,7 @@ void test_time_slicing_preemptible(void)
*/
void test_time_slicing_disable_preemptible(void)
{
#ifdef CONFIG_TIMESLICING
/* set current thread to a preemptible priority */
init_prio = 0;
setup_threads();
@@ -289,6 +294,9 @@ void test_time_slicing_disable_preemptible(void)
}
/* restore environment */
teardown_threads();
#else /* CONFIG_TIMESLICING */
ztest_test_skip();
#endif /* CONFIG_TIMESLICING */
}

/**
@@ -7,6 +7,8 @@
#include <ztest.h>
#include "test_sched.h"

#ifdef CONFIG_TIMESLICING

#define NUM_THREAD 3

BUILD_ASSERT(NUM_THREAD <= MAX_NUM_THREAD);
@@ -118,3 +120,10 @@ void test_slice_reset(void)
}
k_thread_priority_set(k_current_get(), old_prio);
}

#else /* CONFIG_TIMESLICING */
void test_slice_reset(void)
{
ztest_test_skip();
}
#endif /* CONFIG_TIMESLICING */
@@ -7,6 +7,8 @@
#include <ztest.h>
#include "test_sched.h"

#ifdef CONFIG_TIMESLICING

/* nrf 51 has lower ram, so creating less number of threads */
#if CONFIG_SRAM_SIZE <= 24
#define NUM_THREAD 2
@@ -58,7 +60,6 @@ static void thread_tslice(void *p1, void *p2, void *p3)
spin_for_ms(BUSY_MS);
k_sem_give(&sema1);
}

}

/*test cases*/
@@ -122,3 +123,10 @@ void test_slice_scheduling(void)

k_thread_priority_set(k_current_get(), old_prio);
}

#else /* CONFIG_TIMESLICING */
void test_slice_scheduling(void)
{
ztest_test_skip();
}
#endif /* CONFIG_TIMESLICING */
@@ -1,8 +1,23 @@
tests:
kernel.sched:
extra_configs:
- CONFIG_TIMESLICING=y
min_ram: 32
tags: kernel threads sched
kernel.sched_no_timeslicing:
extra_configs:
- CONFIG_TIMESLICING=n
min_ram: 32
tags: kernel threads sched
kernel.sched.native_posix:
extra_args: CONF_FILE=prj_native_posix.conf
extra_configs:
- CONFIG_TIMESLICING=y
platform_whitelist: native_posix
tags: kernel threads sched
kernel.sched.native_posix_no_timeslicing:
extra_args: CONF_FILE=prj_native_posix.conf
extra_configs:
- CONFIG_TIMESLICING=n
platform_whitelist: native_posix
tags: kernel threads sched

0 comments on commit 3fa9093

Please sign in to comment.
You can’t perform that action at this time.