Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
Tests for the Timer kernel object. More...
Functions | |
ZTEST_USER (timer_api, test_timer_duration_period) | |
Test duration and period of Timer. | |
ZTEST_USER (timer_api, test_timer_restart) | |
Test restart the timer. | |
ZTEST_USER (timer_api, test_timer_period_0) | |
Test Timer with zero period value. | |
ZTEST_USER (timer_api, test_timer_period_k_forever) | |
Test Timer with K_FOREVER period value. | |
ZTEST_USER (timer_api, test_timer_expirefn_null) | |
Test Timer without any timer expiry callback function. | |
ZTEST_USER (timer_api, test_timer_periodicity) | |
Test to check timer periodicity. | |
ZTEST_USER (timer_api, test_timer_status_get) | |
Test Timer status and time remaining before next expiry. | |
ZTEST_USER (timer_api, test_timer_status_get_anytime) | |
Test Timer status randomly after certain duration. | |
ZTEST_USER (timer_api, test_timer_status_sync) | |
Test Timer thread synchronization. | |
ZTEST_USER (timer_api, test_timer_k_define) | |
Test statically defined Timer init. | |
ZTEST_USER (timer_api, test_timer_user_data) | |
Test user-specific data associated with timer. | |
ZTEST_USER (timer_api, test_timer_remaining) | |
Test accuracy of k_timer_remaining_get() | |
ZTEST_USER (timer_api_error, test_timer_start_null) | |
Test k_timer_start() API. | |
ZTEST_USER (timer_api_error, test_timer_stop_null) | |
Test k_timer_stop() API. | |
ZTEST_USER (timer_api_error, test_timer_status_get_null) | |
Test k_timer_status_get() API. | |
ZTEST_USER (timer_api_error, test_timer_status_sync_null) | |
Test k_timer_status_sync() API. | |
ZTEST_USER (timer_api_error, test_timer_remaining_ticks_null) | |
Test k_timer_remaining_ticks() API. | |
ZTEST_USER (timer_api_error, test_timer_expires_ticks_null) | |
Test k_timer_expires_ticks() API. | |
ZTEST_USER (timer_api_error, test_timer_user_data_get_null) | |
Test k_timer_user_data_get() API. | |
ZTEST_USER (timer_api_error, test_timer_user_data_set_null) | |
Test k_timer_user_data_set() API. | |
ZTEST (timer_fn, test_timer) | |
Test monotonic timer. | |
Tests for the Timer kernel object.
ZTEST | ( | timer_fn | , |
test_timer | |||
) |
#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 correctness. It also checks system tick frequency by checking the delta error between generated and system clock provided HW cycles per sec values.
ZTEST_USER | ( | timer_api | , |
test_timer_duration_period | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_expirefn_null | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_k_define | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_period_0 | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_period_k_forever | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_periodicity | |||
) |
#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 period 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.
ZTEST_USER | ( | timer_api | , |
test_timer_remaining | |||
) |
#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.
ZTEST_USER | ( | timer_api | , |
test_timer_restart | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_status_get | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_status_get_anytime | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_status_sync | |||
) |
#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
ZTEST_USER | ( | timer_api | , |
test_timer_user_data | |||
) |
#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, along with 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.
ZTEST_USER | ( | timer_api_error | , |
test_timer_expires_ticks_null | |||
) |
#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
ZTEST_USER | ( | timer_api_error | , |
test_timer_remaining_ticks_null | |||
) |
#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
ZTEST_USER | ( | timer_api_error | , |
test_timer_start_null | |||
) |
#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.
ZTEST_USER | ( | timer_api_error | , |
test_timer_status_get_null | |||
) |
#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
ZTEST_USER | ( | timer_api_error | , |
test_timer_status_sync_null | |||
) |
#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
ZTEST_USER | ( | timer_api_error | , |
test_timer_stop_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
ZTEST_USER | ( | timer_api_error | , |
test_timer_user_data_get_null | |||
) |
#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
ZTEST_USER | ( | timer_api_error | , |
test_timer_user_data_set_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