Zephyr API Documentation
3.0.0
A Scalable Open Source RTOS
|
|
3.0.0 |
Zephyr testing framework _test. More...
Go to the source code of this file.
Data Structures | |
struct | ztest_unit_test |
struct | ztest_suite_stats |
struct | ztest_suite_node |
struct | ztest_test_rule |
Macros | |
#define | ZTEST_SUITE(SUITE_NAME, PREDICATE, setup_fn, before_fn, after_fn, teardown_fn) |
#define | ZTEST(suite, fn) Z_ZTEST(suite, fn, 0) |
Create and register a new unit test. More... | |
#define | ZTEST_USER(suite, fn) Z_ZTEST(suite, fn, COND_CODE_1(CONFIG_USERSPACE, (K_USER), (0))) |
Define a test function that should run as a user thread. More... | |
#define | ZTEST_F(suite, fn) Z_ZTEST_F(suite, fn, 0) |
Define a test function. More... | |
#define | ZTEST_USER_F(suite, fn) Z_ZTEST_F(suite, fn, COND_CODE_1(CONFIG_USERSPACE, (K_USER), (0))) |
Define a test function that should run as a user thread. More... | |
#define | ZTEST_RULE(name, before_each_fn, after_each_fn) |
Define a test rule that will run before/after each unit test. More... | |
#define | ZTEST_DMEM K_APP_DMEM(ztest_mem_partition) |
#define | ZTEST_BMEM K_APP_BMEM(ztest_mem_partition) |
#define | ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition) |
#define | ztest_run_test_suite(suite) z_ztest_run_test_suite(STRINGIFY(suite)) |
Run the specified test suite. More... | |
Typedefs | |
typedef void(* | ztest_rule_cb) (const struct ztest_unit_test *test, void *data) |
Test rule callback function signature. More... | |
Functions | |
int | ztest_run_test_suites (const void *state) |
void | ztest_verify_all_test_suites_ran (void) |
Fails the test if any of the registered tests did not run. More... | |
void | ztest_test_fail (void) |
Fail the currently running test. More... | |
void | ztest_test_pass (void) |
Pass the currently running test. More... | |
void | ztest_test_skip (void) |
Skip the current test. More... | |
static void | unit_test_noop (void) |
Do nothing, successfully. More... | |
void | ztest_simple_1cpu_before (void *data) |
A 'before' function to use in test suites that just need to start 1cpu. More... | |
void | ztest_simple_1cpu_after (void *data) |
A 'after' function to use in test suites that just need to stop 1cpu. More... | |
Variables | |
struct k_mem_partition | ztest_mem_partition |
Zephyr testing framework _test.
#define ZTEST_SUITE | ( | SUITE_NAME, | |
PREDICATE, | |||
setup_fn, | |||
before_fn, | |||
after_fn, | |||
teardown_fn | |||
) |
Create and register a ztest suite. Using this macro creates a new test suite (using ztest_test_suite). It then creates a struct ztest_suite_node in a specific linker section.
Tests can then be run by calling ztest_run_test_suites(const void *state) by passing in the current state. See the documentation for ztest_run_test_suites for more info.
SUITE_NAME | The name of the suite (see ztest_test_suite for more info) |
PREDICATE | A function to test against the state and determine if the test should run. |
setup_fn | The setup function to call before running this test suite |
before_fn | The function to call before each unit test in this suite |
after_fn | The function to call after each unit test in this suite |
teardown_fn | The function to call after running all the tests in this suite |
int ztest_run_test_suites | ( | const void * | state | ) |
Run the registered unit tests which return true from their pragma function.
state | The current state of the machine as it relates to the test executable. |
void ztest_verify_all_test_suites_ran | ( | void | ) |
Fails the test if any of the registered tests did not run.
When registering test suites, a pragma function can be provided to determine WHEN the test should run. It is possible that a test suite could be registered but the pragma always prevents it from running. In cases where a test should make sure that ALL suites ran at least once, this function may be called at the end of test_main(). It will cause the test to fail if any suite was registered but never ran.