Zephyr API Documentation
3.0.0
A Scalable Open Source RTOS
|
|
3.0.0 |
Data Structures | |
struct | ztest_test_rule |
Macros | |
#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 | |
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 |
This module eases the testing process by providing helpful macros and other testing structures.
#define ZTEST | ( | suite, | |
fn | |||
) | Z_ZTEST(suite, fn, 0) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Create and register a new unit test.
Calling this macro will create a new unit test and attach it to the declared suite
. The suite
does not need to be defined in the same compilational unit.
suite | The name of the test suite to attach this test |
fn | The test function to call. |
#define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition) |
#define ZTEST_DMEM K_APP_DMEM(ztest_mem_partition) |
#define ZTEST_F | ( | suite, | |
fn | |||
) | Z_ZTEST_F(suite, fn, 0) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Define a test function.
This macro behaves exactly the same as ZTEST(), but the function takes an argument for the fixture of type struct suite##_fixture*
named this
.
suite | The name of the test suite to attach this test |
fn | The test function to call. |
#define ZTEST_RULE | ( | name, | |
before_each_fn, | |||
after_each_fn | |||
) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Define a test rule that will run before/after each unit test.
Functions defined here will run before/after each unit test for every test suite. Along with the callback, the test functions are provided a pointer to the test being run, and the data. This provides a mechanism for tests to perform custom operations depending on the specific test or the data (for example logging may use the test's name).
name | The name for the test rule (must be unique within the compilational unit) |
before_each_fn | The callback function to call before each test (may be NULL) |
after_each_fn | The callback function to call after each test (may be NULL) |
#define ztest_run_test_suite | ( | suite | ) | z_ztest_run_test_suite(STRINGIFY(suite)) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Run the specified test suite.
suite | Test suite to run. |
#define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition) |
#define ZTEST_USER | ( | suite, | |
fn | |||
) | Z_ZTEST(suite, fn, COND_CODE_1(CONFIG_USERSPACE, (K_USER), (0))) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Define a test function that should run as a user thread.
This macro behaves exactly the same as ZTEST, but calls the test function in user space if CONFIG_USERSPACE
was enabled.
suite | The name of the test suite to attach this test |
fn | The test function to call. |
#define ZTEST_USER_F | ( | suite, | |
fn | |||
) | Z_ZTEST_F(suite, fn, COND_CODE_1(CONFIG_USERSPACE, (K_USER), (0))) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Define a test function that should run as a user thread.
If CONFIG_USERSPACE is not enabled, this is functionally identical to ZTEST_F(). The test function takes a single fixture argument of type struct suite##_fixture*
named this
.
suite | The name of the test suite to attach this test |
fn | The test function to call. |
typedef void(* ztest_rule_cb) (const struct ztest_unit_test *test, void *data) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Test rule callback function signature.
The function signature that can be used to register a test rule's before/after callback. This provides access to the test and the fixture data (if provided).
test | Pointer to the unit test in context |
data | Pointer to the test's fixture data (may be NULL) |
|
inlinestatic |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Do nothing, successfully.
Unit test / setup function / teardown function that does nothing, successfully. Can be used as a parameter to ztest_unit_test_setup_teardown().
void ztest_simple_1cpu_after | ( | void * | data | ) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
A 'after' function to use in test suites that just need to stop 1cpu.
Ignores data, and calls z_test_1cpu_stop()
data | The test suite's data |
void ztest_simple_1cpu_before | ( | void * | data | ) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
A 'before' function to use in test suites that just need to start 1cpu.
Ignores data, and calls z_test_1cpu_start()
data | The test suite's data |
void ztest_test_fail | ( | void | ) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Fail the currently running test.
This is the function called from failed assertions and the like. You probably don't need to call it yourself.
void ztest_test_pass | ( | void | ) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Pass the currently running test.
Normally a test passes just by returning without an assertion failure. However, if the success case for your test involves a fatal fault, you can call this function from k_sys_fatal_error_handler to indicate that the test passed before aborting the thread.
void ztest_test_skip | ( | void | ) |
#include <subsys/testsuite/ztest/include/ztest_test_new.h>
Skip the current test.
|
extern |