tests: kernel: context: test k_cpu_idle for tickless kernel
We fix the kernel.context test, so it tests the implementation of k_cpu_idle for tickless kernel. As most platforms now support tickless kernel by default, this extension of the test is essential to get coverage on k_cpu_idle() API. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
24f77ca167
commit
703e8444af
1 changed files with 33 additions and 6 deletions
|
@ -229,16 +229,42 @@ void irq_enable_wrapper(int irq)
|
||||||
irq_enable(irq);
|
irq_enable(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAS_POWERSAVE_INSTRUCTION)
|
||||||
#if defined(CONFIG_TICKLESS_KERNEL)
|
#if defined(CONFIG_TICKLESS_KERNEL)
|
||||||
static void test_kernel_cpu_idle(void)
|
static struct k_timer idle_timer;
|
||||||
|
|
||||||
|
static void idle_timer_expiry_function(struct k_timer *timer_id)
|
||||||
{
|
{
|
||||||
ztest_test_skip();
|
k_timer_stop(&idle_timer);
|
||||||
}
|
}
|
||||||
static void test_kernel_cpu_idle_atomic(void)
|
|
||||||
|
static void _test_kernel_cpu_idle(int atomic)
|
||||||
{
|
{
|
||||||
ztest_test_skip();
|
int tms, tms2;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Set up a time to trigger events to exit idle mode */
|
||||||
|
k_timer_init(&idle_timer, idle_timer_expiry_function, NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++) { /* Repeat the test five times */
|
||||||
|
k_timer_start(&idle_timer, 1, 0);
|
||||||
|
tms = k_uptime_get_32();
|
||||||
|
if (atomic) {
|
||||||
|
unsigned int key = irq_lock();
|
||||||
|
|
||||||
|
k_cpu_atomic_idle(key);
|
||||||
|
} else {
|
||||||
|
k_cpu_idle();
|
||||||
|
}
|
||||||
|
tms += 1;
|
||||||
|
tms2 = k_uptime_get_32();
|
||||||
|
zassert_false(tms2 < tms, "Bad ms value computed,"
|
||||||
|
"got %d which is less than %d\n",
|
||||||
|
tms2, tms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#elif defined(HAS_POWERSAVE_INSTRUCTION)
|
|
||||||
|
#else /* CONFIG_TICKLESS_KERNEL */
|
||||||
static void _test_kernel_cpu_idle(int atomic)
|
static void _test_kernel_cpu_idle(int atomic)
|
||||||
{
|
{
|
||||||
int tms, tms2;; /* current time in millisecond */
|
int tms, tms2;; /* current time in millisecond */
|
||||||
|
@ -269,6 +295,7 @@ static void _test_kernel_cpu_idle(int atomic)
|
||||||
tms2, tms);
|
tms2, tms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_TICKLESS_KERNEL */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -300,7 +327,7 @@ static void test_kernel_cpu_idle(void)
|
||||||
_test_kernel_cpu_idle(0);
|
_test_kernel_cpu_idle(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else /* HAS_POWERSAVE_INSTRUCTION */
|
||||||
static void test_kernel_cpu_idle(void)
|
static void test_kernel_cpu_idle(void)
|
||||||
{
|
{
|
||||||
ztest_test_skip();
|
ztest_test_skip();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue