tests: tickless: Make use of ztest framework
Add appropriate ztest APIs to make this legacy test case to use ztest framework. Signed-off-by: Punit Vara <punit.vara@intel.com>
This commit is contained in:
parent
21510d4350
commit
9c1622a64a
@ -1 +1,2 @@
|
||||
CONFIG_SYS_POWER_MANAGEMENT=y
|
||||
CONFIG_ZTEST=y
|
||||
|
||||
@ -6,12 +6,10 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
Unit test for tickless idle feature.
|
||||
*/
|
||||
/* DESCRIPTION Unit test for tickless idle feature. */
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <ztest.h>
|
||||
|
||||
#include <misc/printk.h>
|
||||
#include <arch/cpu.h>
|
||||
@ -22,6 +20,9 @@ Unit test for tickless idle feature.
|
||||
|
||||
#define SLEEP_TICKS 10
|
||||
|
||||
static struct k_thread thread_tickless;
|
||||
static K_THREAD_STACK_DEFINE(thread_tickless_stack, STACKSIZE);
|
||||
|
||||
#ifdef CONFIG_TICKLESS_IDLE
|
||||
extern s32_t _sys_idle_threshold_ticks;
|
||||
#endif
|
||||
@ -173,7 +174,10 @@ void ticklessTestThread(void)
|
||||
printk("Cal time stamp: 0x%x\n", cal_tsc);
|
||||
#endif
|
||||
|
||||
/* Calculate percentage difference between calibrated TSC diff and measured result */
|
||||
/*
|
||||
* Calculate percentage difference between
|
||||
* calibrated TSC diff and measured result
|
||||
*/
|
||||
if (diff_tsc > cal_tsc) {
|
||||
diff_per = (100 * (diff_tsc - cal_tsc)) / cal_tsc;
|
||||
} else {
|
||||
@ -182,12 +186,8 @@ void ticklessTestThread(void)
|
||||
|
||||
printk("variance in time stamp diff: %d percent\n", (s32_t)diff_per);
|
||||
|
||||
if (diff_ticks != SLEEP_TICKS) {
|
||||
printk("* TEST FAILED. TICK COUNT INCORRECT *\n");
|
||||
TC_END_REPORT(TC_FAIL);
|
||||
} else {
|
||||
TC_END_REPORT(TC_PASS);
|
||||
}
|
||||
zassert_equal(diff_ticks, SLEEP_TICKS,
|
||||
"* TEST FAILED. TICK COUNT INCORRECT *");
|
||||
|
||||
/* release the timer, if necessary */
|
||||
_TIMESTAMP_CLOSE();
|
||||
@ -198,5 +198,19 @@ void ticklessTestThread(void)
|
||||
|
||||
}
|
||||
|
||||
K_THREAD_DEFINE(TICKLESS_THREAD, STACKSIZE, ticklessTestThread, NULL, NULL,
|
||||
NULL, PRIORITY, 0, K_NO_WAIT);
|
||||
void test_tickless(void)
|
||||
{
|
||||
k_thread_create(&thread_tickless, thread_tickless_stack,
|
||||
STACKSIZE,
|
||||
(k_thread_entry_t) ticklessTestThread,
|
||||
NULL, NULL, NULL,
|
||||
PRIORITY, 0, K_NO_WAIT);
|
||||
k_sleep(4000);
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(test_tick_less,
|
||||
ztest_unit_test(test_tickless));
|
||||
ztest_run_test_suite(test_tick_less);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user