Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Tests for the Timer kernel object. More...
Tests for the Timer kernel object.
#include <tests/kernel/timer/timer_monotonic/src/main.c>
Test monotonic timer.
Validates monotonic timer's clock calibration.
It reads the System clock’s h/w timer frequency value continuously using k_cycle_get_32() to verify its working and correctiveness. It also checks system tick frequency by checking the delta error between generated and system clock provided HW cycles per sec values.
#include <tests/kernel/timer/timer_api/src/main.c>
Test duration and period of Timer.
Validates initial duration and period of timer.
It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() with specific initial duration and period. Stops the timer using k_timer_stop() and checks for proper completion of duration and period.
TESTPOINT: init timer via k_timer_init
TESTPOINT: check expire and stop times
#include <tests/kernel/timer/timer_api/src/main.c>
Test Timer without any timer expiry callback function.
Validates timer without any expiry_fn(set to NULL). expiry_fn() is a function that is invoked each time the timer expires.
It initializes the timer with k_timer_init(), then starts the timer using k_timer_start(). Stops the timer using k_timer_stop() and checks for expire_cnt to zero, as expiry_fn was not defined at all.
TESTPOINT: expire function NULL
TESTPOINT: expire handler is not invoked
TESTPOINT: stop handler is invoked
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_expires_ticks() API.
Create a thread and set k_timer_expires_ticks() input to NULL
#include <tests/kernel/timer/timer_api/src/main.c>
Test statically defined Timer init.
Validate statically defined timer init using K_TIMER_DEFINE
It creates prototype of K_TIMER_DEFINE to statically define timer init and starts the timer with k_timer_start() with specific initial duration and period. Stops the timer using k_timer_stop() and checks for proper completion of duration and period.
TESTPOINT: init timer via k_timer_init
TESTPOINT: check expire and stop times
TESTPOINT: init timer via k_timer_init
TESTPOINT: check expire and stop times
#include <tests/kernel/timer/timer_api/src/main.c>
Test Timer with zero period value.
Validates initial timer duration, keeping timer period to zero. Basically, acting as one-shot timer. It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() with specific initial duration and period as zero. Stops the timer using k_timer_stop() and checks for proper completion.
TESTPOINT: set period 0
TESTPOINT: ensure it is one-shot timer
#include <tests/kernel/timer/timer_api/src/main.c>
Test Timer with K_FOREVER period value.
Validates initial timer duration, keeping timer period to K_FOREVER. Basically, acting as one-shot timer. It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() with specific initial duration and period as zero. Stops the timer using k_timer_stop() and checks for proper completion.
TESTPOINT: set period 0
TESTPOINT: ensure it is one-shot timer
#include <tests/kernel/timer/timer_api/src/main.c>
Test to check timer periodicity.
Timer test to check for the predictability with which the timer expires depending on the period configured.
It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() with specific period. It resets the timer’s status to zero with k_timer_status_sync and identifies the delta between each timer expiry to check for the timer expiration period correctness. Finally, stops the timer using k_timer_stop().
TESTPOINT: set duration 0
TESTPOINT: expired times returned by status sync
TESTPOINT: check if timer fired within 1ms of the expected period (firing time).
Please note, that expected firing time is not the one requested, as the kernel uses the ticks to manage time. The actual perioid will be equal to [tick time] multiplied by k_ms_to_ticks_ceil32(PERIOD).
In the case of inexact conversion the delta will occasionally be one less than the expected number.
#include <tests/kernel/timer/timer_api/src/main.c>
Test accuracy of k_timer_remaining_get()
Validate countdown of time to expiration
Starts a timer, busy-waits for half the DURATION, then checks the remaining time to expiration and stops the timer. The remaining time should reflect the passage of at least the busy-wait interval.
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_remaining_ticks() API.
Create a thread and set k_timer_remaining_ticks() input to NULL
#include <tests/kernel/timer/timer_api/src/main.c>
Test restart the timer.
Validates initial duration and period of timer. Start the timer with specific duration and period. Then starts the timer again, and check the status of timer.
TESTPOINT: restart the timer
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_start() API.
Create a thread and set k_timer_start() input to NULL and set a duration and period.
#include <tests/kernel/timer/timer_api/src/main.c>
Test Timer status and time remaining before next expiry.
Timer test to validate timer status and next trigger expiry time
It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() and checks for timer current status with k_timer_status_get() and remaining time before next expiry using k_timer_remaining_get(). Stops the timer using k_timer_stop().
TESTPOINT: status get upon timer starts
TESTPOINT: remaining get upon timer starts
#include <tests/kernel/timer/timer_api/src/main.c>
Test Timer status randomly after certain duration.
Validate timer status function using k_timer_status_get().
It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() with specific initial duration and period. Checks for timer status randomly after certain duration. Stops the timer using k_timer_stop().
TESTPOINT: status get at any time
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_status_get() API.
Create a thread and set k_timer_status_get() input to NULL
#include <tests/kernel/timer/timer_api/src/main.c>
Test Timer thread synchronization.
Validate thread synchronization by blocking the calling thread until the timer expires.
It initializes the timer with k_timer_init(), then starts the timer using k_timer_start() and checks timer status with k_timer_status_sync() for thread synchronization with expiry count. Stops the timer using k_timer_stop.
TESTPOINT: check timer not expire
TESTPOINT: expired times returned by status sync
TESTPOINT: check timer not expire
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_status_sync() API.
Create a thread and set k_timer_status_sync() input to NULL
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_stop() API.
Create a thread and set k_timer_stop() input to NULL
#include <tests/kernel/timer/timer_api/src/main.c>
Test user-specific data associated with timer.
Validate user-specific data associated with timer
It creates prototype of K_TIMER_DEFINE and starts the timer using k_timer_start() with specific initial duration, alongwith associated user data using k_timer_user_data_set and k_timer_user_data_get(). Stops the timer using k_timer_stop() and checks for correct data retrieval after timer completion.
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_user_data_get() API.
Create a thread and set k_timer_user_data_get() input to NULL
#include <tests/kernel/timer/timer_error_case/src/main.c>
Test k_timer_user_data_set() API.
Create a thread and set k_timer_user_data_set() input to NULL