Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
This module provides test stress when using Ztest. More...
Data Structures | |
struct | ztress_context_data |
Macros | |
#define | ZTRESS_TIMER(handler, user_data, exec_cnt, init_timeout) (ZTRESS_ID_K_TIMER, handler, user_data, exec_cnt, 0, init_timeout) |
Descriptor of a k_timer handler execution context. | |
#define | ZTRESS_THREAD(handler, user_data, exec_cnt, preempt_cnt, init_timeout) (ZTRESS_ID_THREAD, handler, user_data, exec_cnt, preempt_cnt, init_timeout) |
Descriptor of a thread execution context. | |
#define | ZTRESS_CONTEXT_INITIALIZER(_handler, _user_data, _exec_cnt, _preempt_cnt, _t) |
Initialize context structure. | |
#define | ZTRESS_EXECUTE(...) |
Setup and run stress test. | |
Typedefs | |
typedef bool(* | ztress_handler) (void *user_data, uint32_t cnt, bool last, int prio) |
User handler called in one of the configured contexts. | |
Functions | |
int | ztress_execute (struct ztress_context_data *timer_data, struct ztress_context_data *thread_data, size_t cnt) |
Execute contexts. | |
void | ztress_abort (void) |
Abort ongoing stress test. | |
void | ztress_set_timeout (k_timeout_t t) |
Set test timeout. | |
void | ztress_report (void) |
Print last test report. | |
int | ztress_exec_count (uint32_t id) |
Get number of executions of a given context in the last test. | |
int | ztress_preempt_count (uint32_t id) |
Get number of preemptions of a given context in the last test. | |
uint32_t | ztress_optimized_ticks (uint32_t id) |
Get optimized timeout base of a given context in the last test. | |
This module provides test stress when using Ztest.
#define ZTRESS_CONTEXT_INITIALIZER | ( | _handler, | |
_user_data, | |||
_exec_cnt, | |||
_preempt_cnt, | |||
_t | |||
) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Initialize context structure.
For argument types see ztress_context_data. For more details see ZTRESS_THREAD.
_handler | Handler. |
_user_data | User data passed to the handler. |
_exec_cnt | Execution count limit. |
_preempt_cnt | Preemption count limit. |
_t | Initial timeout. |
#define ZTRESS_EXECUTE | ( | ... | ) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Setup and run stress test.
It initialises all contexts and calls ztress_execute.
... | List of contexts. Contexts are configured using ZTRESS_TIMER and ZTRESS_THREAD macros. ZTRESS_TIMER must be the first argument if used. Each thread context has an assigned priority. The priority is assigned in a descending order (first listed thread context has the highest priority). The maximum number of supported thread contexts, including the timer context, is configurable in Kconfig (ZTRESS_MAX_THREADS). |
#define ZTRESS_THREAD | ( | handler, | |
user_data, | |||
exec_cnt, | |||
preempt_cnt, | |||
init_timeout | |||
) | (ZTRESS_ID_THREAD, handler, user_data, exec_cnt, preempt_cnt, init_timeout) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Descriptor of a thread execution context.
The handler is executed in the thread context. The priority of the thread is determined based on the order in which contexts are listed in ZTRESS_EXECUTE.
handler | User handler of type ztress_handler. |
user_data | User data passed to the handler . |
exec_cnt | Number of handler executions to complete the test. If 0 then this is not included in completion criteria. |
preempt_cnt | Number of preemptions of that context to complete the test. If 0 then this is not included in completion criteria. |
init_timeout | Initial backoff time base (given in k_timeout_t). It is adjusted during the test to optimize CPU load. The actual timeout used for sleeping is randomized. |
#define ZTRESS_TIMER | ( | handler, | |
user_data, | |||
exec_cnt, | |||
init_timeout | |||
) | (ZTRESS_ID_K_TIMER, handler, user_data, exec_cnt, 0, init_timeout) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Descriptor of a k_timer handler execution context.
The handler is executed in the k_timer handler context which typically means interrupt context. This context will preempt any other used in the set.
handler | User handler of type ztress_handler. |
user_data | User data passed to the handler . |
exec_cnt | Number of handler executions to complete the test. If 0 then this is not included in completion criteria. |
init_timeout | Initial backoff time base (given in k_timeout_t). It is adjusted during the test to optimize CPU load. The actual timeout used for the timer is randomized. |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
User handler called in one of the configured contexts.
user_data | User data provided in the context descriptor. |
cnt | Current execution counter. Counted from 0. |
last | Flag set to true indicates that it is the last execution because completion criteria are met, test timed out or was aborted. |
prio | Context priority counting from 0 which indicates the highest priority. |
true | continue test. |
false | stop executing the current context. |
void ztress_abort | ( | void | ) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Abort ongoing stress test.
int ztress_exec_count | ( | uint32_t | id | ) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Get number of executions of a given context in the last test.
id | Context id. 0 means the highest priority. |
int ztress_execute | ( | struct ztress_context_data * | timer_data, |
struct ztress_context_data * | thread_data, | ||
size_t | cnt | ||
) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Execute contexts.
The test runs until all completion requirements are met or until the test times out (use ztress_set_timeout to configure timeout) or until the test is aborted (ztress_abort).
on test completion a report is printed (ztress_report is called internally).
timer_data | Timer context. NULL if timer context is not used. |
thread_data | List of thread contexts descriptors in priority descending order. |
cnt | Number of thread contexts. |
-EINVAL | If configuration is invalid. |
0 | if test is successfully performed. |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Get optimized timeout base of a given context in the last test.
Optimized value can be used to update initial value. It will improve the test since optimal CPU load will be reach immediately.
id | Context id. 0 means the highest priority. |
int ztress_preempt_count | ( | uint32_t | id | ) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Get number of preemptions of a given context in the last test.
id | Context id. 0 means the highest priority. |
void ztress_report | ( | void | ) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Print last test report.
Report contains number of executions and preemptions for each context, initial and adjusted timeouts and CPU load during the test.
void ztress_set_timeout | ( | k_timeout_t | t | ) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztress.h>
Set test timeout.
Test is terminated after timeout disregarding completion criteria. Setting is persistent between executions.
t | Timeout. |