Rtos API example
Frameworks
Data Structures | |
class | Case |
Test case wrapper class. More... | |
struct | handlers_t |
A table of handlers. More... | |
struct | utest_v1_scheduler_t |
The scheduler interface consists out of the `post` and `cancel` functions, which you must implement to use `utest`. More... | |
struct | failure_t |
Contains the reason and location of the failure. More... | |
struct | base_control_t |
POD version of the class control_t. More... | |
struct | control_t |
Control class for specifying test case attributes. More... | |
Typedefs | |
typedef void(* | utest_v1_harness_callback_t )(void) |
The utest harness manages its own state and therefore does not require the scheduler to bind any arguments to the scheduled callback. | |
typedef int32_t(* | utest_v1_scheduler_init_callback_t )(void) |
utest calls this function before running the test specification. | |
typedef void *(* | utest_v1_scheduler_post_callback_t )(const utest_v1_harness_callback_t callback, timestamp_t delay_ms) |
utest calls this function when it needs to schedule a callback with a delay in milliseconds. | |
typedef int32_t(* | utest_v1_scheduler_cancel_callback_t )(void *handle) |
utest needs to cancel callbacks with a non-zero delay some time later. | |
typedef int32_t(* | utest_v1_scheduler_run_callback_t )(void) |
utest calls this function at the end of the `Harnessrun()` function, after (!) the first callback has been requested. | |
typedef utest::v1::status_t(* | test_setup_handler_t )(const size_t number_of_cases) |
Test setup handler. | |
typedef void(* | test_teardown_handler_t )(const size_t passed, const size_t failed, const failure_t failure) |
Test teardown handler. | |
typedef void(* | test_failure_handler_t )(const failure_t reason) |
Test failure handler. | |
typedef utest::v1::status_t(* | case_setup_handler_t )(const Case *const source, const size_t index_of_case) |
Test case setup handler. | |
typedef void(* | case_handler_t )(void) |
Primitive test case handler. | |
typedef control_t(* | case_control_handler_t )(void) |
Complex test case handler. | |
typedef control_t(* | case_call_count_handler_t )(const size_t call_count) |
Test case handler (repeatable) | |
typedef utest::v1::status_t(* | case_teardown_handler_t )(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) |
Test case teardown handler. | |
typedef utest::v1::status_t(* | case_failure_handler_t )(const Case *const source, const failure_t reason) |
Test case failure handler. | |
Enumerations | |
enum | status_t { STATUS_CONTINUE = -1, STATUS_IGNORE = -2, STATUS_ABORT = -3 } |
status_t More... | |
enum | failure_reason_t { REASON_NONE = 0, REASON_UNKNOWN = (1 << 0), REASON_CASES = (1 << 1), REASON_EMPTY_CASE = (1 << 2), REASON_TIMEOUT = (1 << 3), REASON_ASSERTION = (1 << 4), REASON_TEST_SETUP = (1 << 5), REASON_TEST_TEARDOWN = (1 << 6), REASON_CASE_SETUP = (1 << 7), REASON_CASE_HANDLER = (1 << 8), REASON_CASE_TEARDOWN = (1 << 9), REASON_CASE_INDEX = (1 << 10), REASON_SCHEDULER = (1 << 11), REASON_IGNORE = 0x8000 } |
failure_reason_t More... | |
enum | location_t { LOCATION_NONE = 0, LOCATION_TEST_SETUP, LOCATION_TEST_TEARDOWN, LOCATION_CASE_SETUP, LOCATION_CASE_HANDLER, LOCATION_CASE_TEARDOWN, LOCATION_UNKNOWN } |
location_t More... | |
enum | { TIMEOUT_NONE = uint32_t(-1), TIMEOUT_UNDECLR = uint32_t(-2), TIMEOUT_FOREVER = uint32_t(-3) } |
Functions | |
void | greentea_metrics_setup (void) |
Setup platform specific metrics. | |
void | greentea_metrics_report (void) |
Report and cleanup platform specifc metrics. | |
void | GREENTEA_SETUP_UUID (const int timeout, const char *host_test_name, char *buffer, size_t size) |
Greentea-client related API for communication with host side. | |
void | GREENTEA_TESTSUITE_RESULT (const int) |
Notify host (__exit message) side that test suite execution was complete. | |
void | GREENTEA_TESTCASE_START (const char *test_case_name) |
Test Case support. | |
void | GREENTEA_TESTCASE_FINISH (const char *test_case_name, const size_t passes, const size_t failed) |
Notify host side that test case finished. | |
void | greentea_send_kv (const char *, const int) |
Test suite result related notification API. | |
void | greentea_send_kv (const char *, const int, const int) |
Encapsulate and send key-value-value message from DUT to host. | |
void | greentea_send_kv (const char *, const char *, const int) |
Encapsulate and send key-value-value message from DUT to host. | |
void | greentea_send_kv (const char *, const char *, const int, const int) |
Encapsulate and send key-value-value-value message from DUT to host. | |
void | greentea_notify_coverage_start (const char *path) |
Code Coverage API. | |
void | greentea_notify_coverage_end () |
Sufix for code coverage message to master (closing statement) | |
void | GREENTEA_SETUP (const int timeout, const char *host_test) |
Greentea-client C API. | |
void | greentea_send_kv (const char *key, const char *val) |
Encapsulate and send key-value message from DUT to host. | |
int | greentea_parse_kv (char *key, char *val, const int key_len, const int val_len) |
parse input string for key-value pairs: {{key;value}} This function should replace scanf() used to check for incoming messages from master. | |
int | greentea_getc () |
Read character from stream of data. | |
void | utest_unity_assert_failure (void) |
this function is called from the unity module when an assertion failed. | |
void | utest_unity_ignore_failure (void) |
this function is called from the unity module when an assertion failed, but is ignored. | |
const char * | get_description () const |
bool | is_empty () const |
utest::v1::status_t | verbose_test_setup_handler (const size_t number_of_cases) |
Prints the number of tests to run and continues. | |
void | verbose_test_teardown_handler (const size_t passed, const size_t failed, const failure_t failure) |
Prints the number of tests that passed and failed with a reason if provided. | |
void | verbose_test_failure_handler (const failure_t failure) |
Prints the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` and then dies. | |
utest::v1::status_t | verbose_case_setup_handler (const Case *const source, const size_t index_of_case) |
Prints the index and description of the case being run and continues. | |
utest::v1::status_t | verbose_case_teardown_handler (const Case *const source, const size_t passed, const size_t failed, const failure_t failure) |
Prints the number of tests that passed and failed with a reason if provided within this case and continues. | |
utest::v1::status_t | verbose_case_failure_handler (const Case *const source, const failure_t reason) |
Prints the reason of the failure and continues, unless the teardown handler failed, for which it aborts. | |
utest::v1::status_t | greentea_test_setup_handler (const size_t number_of_cases) |
Requests the start test case from greentea and continues. | |
void | greentea_test_teardown_handler (const size_t passed, const size_t failed, const failure_t failure) |
Reports the test results to greentea. | |
void | greentea_test_failure_handler (const failure_t failure) |
Reports the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` to greentea and then dies. | |
utest::v1::status_t | greentea_case_setup_handler (const Case *const source, const size_t index_of_case) |
Registers the test case setup with greentea. | |
utest::v1::status_t | greentea_case_teardown_handler (const Case *const source, const size_t passed, const size_t failed, const failure_t failure) |
Registers the test case teardown with greentea. | |
utest::v1::status_t | greentea_case_failure_abort_handler (const Case *const source, const failure_t reason) |
Reports the failure to greentea and then aborts. | |
utest::v1::status_t | greentea_case_failure_continue_handler (const Case *const source, const failure_t reason) |
Reports the failure to greentea and then continues. | |
void | greentea_testcase_notification_handler (const char *testcase) |
Notify greentea of testcase name. | |
static bool | is_busy () |
static bool | set_scheduler (utest_v1_scheduler_t scheduler) |
Sets the scheduler to be used. | |
static void | validate_callback (const control_t control=control_t()) |
Call this function in the asynchronous callback that you have been waiting for. | |
static void | raise_failure (const failure_reason_t reason) |
Raising a failure causes the failure to be counted and the failure handler to be called. | |
void | utest_v1_enter_critical_section (void) |
must be implemented by the port | |
utest_v1_scheduler_t | utest_v1_get_scheduler (void) |
This is the default scheduler implementation used by the harness. | |
failure_t (const failure_t &obj) | |
Copy constructor. | |
failure_t | ignored () const |
const char * | stringify (failure_reason_t reason) |
Stringifies a failure reason for understandable error messages. | |
const char * | stringify (failure_t failure) |
Stringifies a failure for understandable error messages. | |
const char * | stringify (location_t location) |
Stringifies a location. | |
const char * | stringify (utest::v1::status_t status) |
Stringifies a status. | |
control_t | operator+ (const base_control_t &lhs, const base_control_t &rhs) |
control_t | operator+ (const base_control_t &lhs, const control_t &rhs) |
control_t | operator+ (const control_t &lhs, const base_control_t &rhs) |
control_t | CaseTimeout (uint32_t ms) |
Alias class for asynchronous timeout control in milliseconds. | |
control_t | CaseRepeatAllOnTimeout (uint32_t ms) |
Alias class for asynchronous timeout control in milliseconds and repeats the test case handler with calling teardown and setup handlers. | |
control_t | CaseRepeatHandlerOnTimeout (uint32_t ms) |
Alias class for asynchronous timeout control in milliseconds and repeats only the test case handler without calling teardown and setup handlers. | |
Variables | |
const char * | GREENTEA_TEST_ENV_END |
Generic test suite transport protocol keys. | |
const char * | GREENTEA_TEST_ENV_SUCCESS |
Test suite success code strings. | |
const char * | GREENTEA_TEST_ENV_TESTCASE_NAME |
Test case transport protocol start/finish keys. | |
const char * | GREENTEA_TEST_ENV_LCOV_START |
Code Coverage (LCOV) transport protocol keys. | |
const case_handler_t | handler |
Primitive test case handler This is called only if the case setup succeeded. | |
const case_control_handler_t | control_handler |
const case_call_count_handler_t | repeat_count_handler |
const case_setup_handler_t | setup_handler |
Handler called before the execution of the case handler. | |
const case_teardown_handler_t | teardown_handler |
Handler called after the execution of the case handler. | |
const case_failure_handler_t | failure_handler |
Handler called whenever a faillure occur; at any stage of the case execution (including setup and teardown). | |
const handlers_t | verbose_continue_handlers |
The verbose default handlers that always continue on failure. | |
const handlers_t | greentea_abort_handlers |
The greentea default handlers that always abort on the first encountered failure. | |
const handlers_t | greentea_continue_handlers |
The greentea default handlers that always continue on failure. | |
const handlers_t | selftest_handlers |
The selftest default handlers that always abort on _any_ assertion failure, otherwise continue. | |
const handlers_t & | default_handlers = greentea_abort_handlers |
The greentea aborting handlers are the default. | |
const base_control_t | CaseNext = { REPEAT_NONE, TIMEOUT_NONE } |
does not repeat this test case and immediately moves on to the next one without timeout | |
const base_control_t | CaseNoRepeat = { REPEAT_NONE, TIMEOUT_UNDECLR } |
does not repeat this test case, moves on to the next one | |
const base_control_t | CaseRepeatAll = { REPEAT_ALL, TIMEOUT_UNDECLR } |
repeats the test case handler with calling teardown and setup handlers | |
const base_control_t | CaseRepeatHandler = { REPEAT_HANDLER, TIMEOUT_UNDECLR } |
repeats only the test case handler without calling teardown and setup handlers | |
const base_control_t | CaseNoTimeout = { REPEAT_UNDECLR, TIMEOUT_NONE } |
No timeout, immediately moves on to the next case, but allows repeats. | |
const base_control_t | CaseAwait = { REPEAT_UNDECLR, TIMEOUT_FOREVER } |
Awaits until the callback is validated and never times out. Use with caution! |
Typedef Documentation
typedef control_t(* case_call_count_handler_t)(const size_t call_count) |
Test case handler (repeatable)
This handler is called only if the case setup succeeded and then may be repeated or awaiting a asynchronous callback, depending on the return modifiers.
- Parameters:
-
call_count starting at `1`, contains the number of times this handler has been called
- Returns:
- A combination of control modifiers.
Definition at line 356 of file utest_types.h.
typedef control_t(* case_control_handler_t)(void) |
Complex test case handler.
This handler is called only if the case setup succeeded and then may be repeated or awaiting a asynchronous callback, depending on the return modifiers.
- Returns:
- A combination of control modifiers.
Definition at line 344 of file utest_types.h.
typedef utest::v1::status_t(* case_failure_handler_t)(const Case *const source, const failure_t reason) |
Test case failure handler.
This handler is called whenever a failure occurred during the setup, execution or teardown.
- Parameters:
-
source the test case in which the failure occurred reason the reason why this handler was called
- Returns:
- You can return `STATUS_ABORT` to indicate that this failure is non-recoverable, which will call the case teardown handler with reason. If a failure occurs during teardown, the teardown will not be called again. You may return `STATUS_IGNORE` which will cause the harness to ignore and not count the failure.
Definition at line 386 of file utest_types.h.
typedef void(* case_handler_t)(void) |
Primitive test case handler.
This handler is called only if the case setup succeeded and is followed by the test case teardown handler.
- Note:
- This handler is executed only once.
Definition at line 334 of file utest_types.h.
typedef utest::v1::status_t(* case_setup_handler_t)(const Case *const source, const size_t index_of_case) |
Test case setup handler.
This handler is called before execution of each test case and allows you to modify your environment before each test case.
- Parameters:
-
source the test case to be setup index_of_case the current index of the test case within the specification
- Returns:
- You can return `STATUS_ABORT` to indicate that your setup failed, which will call the case failure handler with `REASON_SETUP` and then the case teardown handler with `REASON_SETUP`. This gives the teardown handler a chance to clean up a failed setup.
Definition at line 326 of file utest_types.h.
typedef utest::v1::status_t(* case_teardown_handler_t)(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) |
Test case teardown handler.
This handler is called after execution of each test case or all repeated test cases and allows you to reset your environment after each test case.
- Parameters:
-
source the test case to be torn down passed the number of cases without failures (can be >1 for repeated test cases) failed the number failures (can be larger than the number of (repeated) test cases) failure the reason why this handler was called
- Returns:
- You can return `STATUS_ABORT` to indicate that your teardown failed, which will call the case failure handler with `REASON_TEARDOWN`.
Definition at line 372 of file utest_types.h.
typedef void(* test_failure_handler_t)(const failure_t reason) |
Test failure handler.
This handler is called anytime a failure occurs during the execution of a test speficication. The handler only allows logging of failures and cannot influence test execution.
- Parameters:
-
failure the reason why this handler was called
Definition at line 311 of file utest_types.h.
typedef utest::v1::status_t(* test_setup_handler_t)(const size_t number_of_cases) |
Test setup handler.
This handler is called before execution of any test case and allows you to initialize your common test environment.
- Parameters:
-
number_of_cases the total number of test cases in the test specification
- Returns:
- You can return `STATUS_ABORT` if you initialization failed and the test teardown handler will then be called with the `REASON_SETUP`.
Definition at line 287 of file utest_types.h.
typedef void(* test_teardown_handler_t)(const size_t passed, const size_t failed, const failure_t failure) |
Test teardown handler.
This handler is called after execution of all test case or if test execution is aborted. You can use this handler to de-initialize your test environment and output test statistics. The failure argument contains the immediate reason why this handler is called. If the test completed normally without failures, this will contain `REASON_NONE`.
After execution of this handler, the test harness will stop execution.
- Parameters:
-
passed the number of cases without failures failed the number of cases with at least one failure failure the reason why this handler was called
Definition at line 302 of file utest_types.h.
typedef void(* utest_v1_harness_callback_t)(void) |
The utest harness manages its own state and therefore does not require the scheduler to bind any arguments to the scheduled callback.
Definition at line 38 of file utest_scheduler.h.
typedef int32_t(* utest_v1_scheduler_cancel_callback_t)(void *handle) |
utest needs to cancel callbacks with a non-zero delay some time later.
Even though `utest` only schedules one callback at any given time, it can cancel a callback more than once. You should therefore make use of the handle to make sure you do not cancel the wrong callback.
- Note:
- If your scheduler cannot provide asynchronous callbacks, do nothing in this function and return non-zero.
- Parameters:
-
handle the handle returned from the `post` call to identify which callback to be cancelled.
- Return values:
-
`0` if success non-zero if failure
Definition at line 80 of file utest_scheduler.h.
typedef int32_t(* utest_v1_scheduler_init_callback_t)(void) |
utest calls this function before running the test specification.
Use this function to initialize your scheduler before the first callback is requested.
- Return values:
-
`0` if success non-zero if failure
Definition at line 47 of file utest_scheduler.h.
typedef void*(* utest_v1_scheduler_post_callback_t)(const utest_v1_harness_callback_t callback, timestamp_t delay_ms) |
utest calls this function when it needs to schedule a callback with a delay in milliseconds.
`delay_ms` will only be non-zero if an asynchronous test case exists in the test specification.
- Note:
- If your scheduler cannot provide asynchronous callbacks (which probably require a hardware timer), then this scheduler may return `NULL` as a handle and `utest` will fail the asynchronous request and move on. Note that test cases which do not require asynchronous callback support will still work fine then.
- Warning:
- You MUST NOT execute the callback inside this function, even for a delay of 0ms. Buffer the callback and call it in your main loop.
- You MUST NOT execute the callback in an interrupt context! Buffer the callback and call it in your main loop.
- Note:
- utest only schedules one callback at any given time. This should make the implementation of this scheduler a lot simpler for you.
- Parameters:
-
callback the pointer to the callback function delay_ms the delay in milliseconds after which the callback should be executed
- Returns:
- A handle to identify the scheduled callback, or `NULL` for failure.
Definition at line 67 of file utest_scheduler.h.
typedef int32_t(* utest_v1_scheduler_run_callback_t)(void) |
utest calls this function at the end of the `Harnessrun()` function, after (!) the first callback has been requested.
This function is meant to implement an optional event loop, which may very well be blocking (if your scheduler works with that). This assumes that `Harnessrun()` will be called on the main stack (ie. not in an interrupt!).
- Return values:
-
`0` if success non-zero if failure
Definition at line 90 of file utest_scheduler.h.
Enumeration Type Documentation
anonymous enum |
- Enumerator:
TIMEOUT_NONE Do not use a timeout.
TIMEOUT_UNDECLR Timeout not explicitly specified, defaults to NONE.
TIMEOUT_FOREVER Never time out.
Definition at line 114 of file utest_types.h.
enum failure_reason_t |
failure_reason_t
- Enumerator:
REASON_NONE No failure occurred.
REASON_UNKNOWN An unknown failure occurred.
REASON_CASES A failure occurred in at least one test case.
REASON_EMPTY_CASE The test case contains only empty handlers.
REASON_TIMEOUT An expected asynchronous call timed out.
REASON_ASSERTION An assertion failed.
REASON_TEST_SETUP Test setup failed.
REASON_TEST_TEARDOWN Test teardown failed.
REASON_CASE_SETUP Case setup failed.
REASON_CASE_HANDLER Case handler failed.
REASON_CASE_TEARDOWN Case teardown failed.
REASON_CASE_INDEX Case index out-of-range.
REASON_SCHEDULER Asynchronous callback scheduling failed.
REASON_IGNORE The failure may be ignored.
Definition at line 59 of file utest_types.h.
enum location_t |
location_t
- Enumerator:
Definition at line 81 of file utest_types.h.
enum status_t |
status_t
- Enumerator:
STATUS_CONTINUE continues testing
STATUS_IGNORE ignores failure and continues testing
STATUS_ABORT stops testing
Definition at line 52 of file utest_types.h.
Function Documentation
control_t utest::v1::CaseRepeatAllOnTimeout | ( | uint32_t | ms ) |
Alias class for asynchronous timeout control in milliseconds and repeats the test case handler with calling teardown and setup handlers.
Definition at line 269 of file utest_types.h.
control_t utest::v1::CaseRepeatHandlerOnTimeout | ( | uint32_t | ms ) |
Alias class for asynchronous timeout control in milliseconds and repeats only the test case handler without calling teardown and setup handlers.
Definition at line 272 of file utest_types.h.
control_t utest::v1::CaseTimeout | ( | uint32_t | ms ) |
Alias class for asynchronous timeout control in milliseconds.
Definition at line 265 of file utest_types.h.
failure_t | ( | const failure_t & | obj ) | [inherited] |
Copy constructor.
Definition at line 99 of file utest_types.h.
const char * get_description | ( | ) | const [inherited] |
- Returns:
- the textual description of the test case
Definition at line 188 of file utest_case.cpp.
utest::v1::status_t greentea_case_failure_abort_handler | ( | const Case *const | source, |
const failure_t | reason | ||
) |
Reports the failure to greentea and then aborts.
Definition at line 136 of file utest_greentea_handlers.cpp.
utest::v1::status_t greentea_case_failure_continue_handler | ( | const Case *const | source, |
const failure_t | reason | ||
) |
Reports the failure to greentea and then continues.
Definition at line 143 of file utest_greentea_handlers.cpp.
utest::v1::status_t greentea_case_setup_handler | ( | const Case *const | source, |
const size_t | index_of_case | ||
) |
Registers the test case setup with greentea.
Definition at line 121 of file utest_greentea_handlers.cpp.
utest::v1::status_t greentea_case_teardown_handler | ( | const Case *const | source, |
const size_t | passed, | ||
const size_t | failed, | ||
const failure_t | failure | ||
) |
Registers the test case teardown with greentea.
Definition at line 129 of file utest_greentea_handlers.cpp.
int greentea_getc | ( | ) |
Read character from stream of data.
Closure for default "get character" function. This function is used to read characters from the stream (default is serial port RX). Key-value protocol tokenizer will build stream of tokes used by key-value protocol to detect valid messages.
If EOF is received parser finishes parsing and stops. In situation where we have serial port stream of data parsing goes forever.
- Returns:
- Next character from the stream or EOF if stream has ended.
Definition at line 557 of file greentea_test_env.cpp.
void greentea_metrics_report | ( | void | ) |
Report and cleanup platform specifc metrics.
Definition at line 61 of file greentea_metrics.cpp.
void greentea_metrics_setup | ( | void | ) |
Setup platform specific metrics.
Definition at line 54 of file greentea_metrics.cpp.
void greentea_notify_coverage_end | ( | ) |
Sufix for code coverage message to master (closing statement)
This function is used by mbedOS software (see: mbed-drivers/source/retarget.cpp file) to generate code coverage messages to host. When code coverage feature is turned on slave will print-out code coverage data in form of key-value protocol. Message with code coverage data will contain message name, path to code coverage output file host will touch and fill with code coverage binary payload. Coverage payload is encoded as stream of ASCII coded bytes ("%02X").
Companion function greentea_notify_coverage_start() defines code coverage message structure
Definition at line 191 of file greentea_test_env.cpp.
void greentea_notify_coverage_start | ( | const char * | path ) |
Code Coverage API.
Code Coverage API.
Generates preamble of message sent to notify host about code coverage data dump.
This function is used by mbedOS software (see: mbed-drivers/source/retarget.cpp file) to generate code coverage messages to host. When code coverage feature is turned on slave will print-out code coverage data in form of key-value protocol. Message with code coverage data will contain message name, path to code coverage output file host will touch and fill with code coverage binary payload. Coverage payload is encoded as stream of ASCII coded bytes ("%02X").
- Parameters:
-
path to file with code coverage payload (set by gcov instrumentation)
Definition at line 173 of file greentea_test_env.cpp.
int greentea_parse_kv | ( | char * | out_key, |
char * | out_value, | ||
const int | out_key_size, | ||
const int | out_value_size | ||
) |
parse input string for key-value pairs: {{key;value}} This function should replace scanf() used to check for incoming messages from master.
All data parsed and rejected is discarded.
- Parameters:
-
out_key Ouput data with key out_value Ouput data with value out_key_size out_key total size out_value_size out_value total data
success != 0 when key-value pair was found success == 0 when end of the stream was found
Definition at line 576 of file greentea_test_env.cpp.
void greentea_send_kv | ( | const char * | key, |
const int | passes, | ||
const int | failures | ||
) |
Encapsulate and send key-value-value message from DUT to host.
This function uses underlying functions to write directly to the serial port, (USBTX). This allows key-value-value to be used from within interrupt context. Both values are integers to avoid integer to string conversion made by the user.
Names of the parameters: this function is used to send number of passes and failures to host. But it can be used to send any key-value-value (string-integer-integer) message to host.
- Parameters:
-
key Message key (message/event name) value Message payload, integer value passes Send additional integer formatted data failures Send additional integer formatted data
Definition at line 409 of file greentea_test_env.cpp.
void greentea_send_kv | ( | const char * | key, |
const char * | val, | ||
const int | result | ||
) |
Encapsulate and send key-value-value message from DUT to host.
This function uses underlying functions to write directly to the serial port, (USBTX). This allows KVs to be used from within interrupt context. Last value is an integer to avoid integer to string conversion made by the user.
- Parameters:
-
key Message key (message/event name) value Message payload, string value result Send additional integer formatted data
Definition at line 343 of file greentea_test_env.cpp.
void greentea_send_kv | ( | const char * | key, |
const char * | val, | ||
const int | passes, | ||
const int | failures | ||
) |
Encapsulate and send key-value-value-value message from DUT to host.
This function uses underlying functions to write directly to the serial port, (USBTX). This allows KVs to be used from within interrupt context. Last 2 values are integers to avoid integer to string conversion made by the user.
Names of the parameters: this function is used to send test case name with number of passes and failures to host. But it can be used to send any key-value-value-value (string-string-integer-integer) set to host.
- Parameters:
-
key Message key (message/event name) value Message payload, string value passes Send additional integer formatted data failures Send additional integer formatted data
Definition at line 376 of file greentea_test_env.cpp.
void greentea_send_kv | ( | const char * | key, |
const int | val | ||
) |
Test suite result related notification API.
Test suite result related notification API.
This function uses underlying functions to write directly to the serial port, (USBTX). This allows KVs to be used from within interrupt context. Last value is an integer to avoid integer to string conversion made by the user.
- Parameters:
-
key Message key (message/event name) value Message payload, integer value
Definition at line 319 of file greentea_test_env.cpp.
void greentea_send_kv | ( | const char * | key, |
const char * | val | ||
) |
Encapsulate and send key-value message from DUT to host.
This function uses underlying functions to write directly to the serial port, (USBTX). This allows KVs to be used from within interrupt context.
- Parameters:
-
key Message key (message/event name) value Message payload, string value
Definition at line 296 of file greentea_test_env.cpp.
void GREENTEA_SETUP | ( | const int | timeout, |
const char * | host_test_name | ||
) |
Greentea-client C API.
Greentea-client C API.
This function will send preamble to master. After host test name is received master will invoke host test script and add host test's callback handlers to main event loop This function is blocking.
Definition at line 97 of file greentea_test_env.cpp.
void GREENTEA_SETUP_UUID | ( | const int | timeout, |
const char * | host_test_name, | ||
char * | buffer, | ||
size_t | size | ||
) |
Greentea-client related API for communication with host side.
Greentea-client related API for communication with host side.
Allows you to preserve sync UUID.
This function will send preamble to master. After host test name is received master will invoke host test script and add host test's callback handlers to main event loop This function is blocking. This function differs from GREENTEA_SETUP because it allows you to preserve the UUID sent during the sync process.
Definition at line 110 of file greentea_test_env.cpp.
void greentea_test_failure_handler | ( | const failure_t | failure ) |
Reports the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` to greentea and then dies.
Definition at line 114 of file utest_greentea_handlers.cpp.
utest::v1::status_t greentea_test_setup_handler | ( | const size_t | number_of_cases ) |
Requests the start test case from greentea and continues.
Example usage: utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { GREENTEA_SETUP(5, "default_auto"); return greentea_test_setup_handler(number_of_cases); }
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
Definition at line 98 of file utest_greentea_handlers.cpp.
void greentea_test_teardown_handler | ( | const size_t | passed, |
const size_t | failed, | ||
const failure_t | failure | ||
) |
Reports the test results to greentea.
Definition at line 105 of file utest_greentea_handlers.cpp.
void GREENTEA_TESTCASE_FINISH | ( | const char * | test_case_name, |
const size_t | passes, | ||
const size_t | failed | ||
) |
Notify host side that test case finished.
test_case_name Test case name
result Test case result (0 -OK, non zero...)
Definition at line 137 of file greentea_test_env.cpp.
void greentea_testcase_notification_handler | ( | const char * | testcase ) |
Notify greentea of testcase name.
Definition at line 84 of file utest_greentea_handlers.cpp.
void GREENTEA_TESTCASE_START | ( | const char * | test_case_name ) |
Test Case support.
Notify host side that test case started
test_case_name Test case name
Definition at line 129 of file greentea_test_env.cpp.
void GREENTEA_TESTSUITE_RESULT | ( | const int | result ) |
Notify host (__exit message) side that test suite execution was complete.
- Returns:
- Test suite result
If __exit is not received by host side we will assume TIMEOUT
Definition at line 118 of file greentea_test_env.cpp.
failure_t ignored | ( | ) | const [inherited] |
- Returns:
- a copy of the failure with the reason ignored.
Definition at line 105 of file utest_types.h.
bool is_busy | ( | ) | [static, inherited] |
- Returns:
- `true` if a test specification is being executed, `false` otherwise
Definition at line 285 of file utest_harness.cpp.
bool is_empty | ( | ) | const [inherited] |
- Returns:
- `true` if setup, test and teardown handlers are set to `ignore_handler`
Definition at line 193 of file utest_case.cpp.
control_t utest::v1::operator+ | ( | const base_control_t & | lhs, |
const base_control_t & | rhs | ||
) |
- See also:
- operator+ in control_t
Definition at line 236 of file utest_types.h.
control_t utest::v1::operator+ | ( | const base_control_t & | lhs, |
const control_t & | rhs | ||
) |
- See also:
- operator+ in control_t
Definition at line 241 of file utest_types.h.
control_t utest::v1::operator+ | ( | const control_t & | lhs, |
const base_control_t & | rhs | ||
) |
- See also:
- operator+ in control_t
Definition at line 246 of file utest_types.h.
void raise_failure | ( | const failure_reason_t | reason ) | [static, inherited] |
Raising a failure causes the failure to be counted and the failure handler to be called.
Further action then depends on its return state.
Definition at line 165 of file utest_harness.cpp.
bool set_scheduler | ( | utest_v1_scheduler_t | scheduler ) | [static, inherited] |
Sets the scheduler to be used.
- Returns:
- `true` if scheduler is properly specified (all functions non-null).
Definition at line 74 of file utest_harness.cpp.
const char * stringify | ( | failure_reason_t | reason ) |
Stringifies a failure reason for understandable error messages.
Definition at line 21 of file utest_types.cpp.
const char * stringify | ( | location_t | location ) |
Stringifies a location.
Definition at line 76 of file utest_types.cpp.
const char * stringify | ( | utest::v1::status_t | status ) |
Stringifies a status.
Definition at line 104 of file utest_types.cpp.
const char * stringify | ( | failure_t | failure ) |
Stringifies a failure for understandable error messages.
Definition at line 71 of file utest_types.cpp.
void utest_unity_assert_failure | ( | void | ) |
this function is called from the unity module when an assertion failed.
Definition at line 24 of file unity_handler.cpp.
void utest_unity_ignore_failure | ( | void | ) |
this function is called from the unity module when an assertion failed, but is ignored.
Definition at line 30 of file unity_handler.cpp.
void utest_v1_enter_critical_section | ( | void | ) |
must be implemented by the port
Definition at line 24 of file mbed-utest-shim.cpp.
utest_v1_scheduler_t utest_v1_get_scheduler | ( | void | ) |
This is the default scheduler implementation used by the harness.
Definition at line 51 of file utest_shim.cpp.
Call this function in the asynchronous callback that you have been waiting for.
You can only validate a callback once, calling this function when no callback is expected has no side effects. After callback validation, the next test case is scheduled.
You may specify additional test case attributes with this callback. So for example, you may delay the decision to repeat an asynchronous test case until the callback needs to be validated.
However, be aware, that only the repeat attributes can be modified and the usual arbitration rules apply. The modified case attributes are only valid until the case handler returns updated attributes.
- Parameters:
-
control the test case attribute to be added to the existing attributes.
Definition at line 267 of file utest_harness.cpp.
utest::v1::status_t verbose_case_failure_handler | ( | const Case *const | source, |
const failure_t | reason | ||
) |
Prints the reason of the failure and continues, unless the teardown handler failed, for which it aborts.
Definition at line 95 of file utest_default_handlers.cpp.
utest::v1::status_t verbose_case_setup_handler | ( | const Case *const | source, |
const size_t | index_of_case | ||
) |
Prints the index and description of the case being run and continues.
Definition at line 76 of file utest_default_handlers.cpp.
utest::v1::status_t verbose_case_teardown_handler | ( | const Case *const | source, |
const size_t | passed, | ||
const size_t | failed, | ||
const failure_t | failure | ||
) |
Prints the number of tests that passed and failed with a reason if provided within this case and continues.
Definition at line 83 of file utest_default_handlers.cpp.
void verbose_test_failure_handler | ( | const failure_t | failure ) |
Prints the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` and then dies.
Definition at line 69 of file utest_default_handlers.cpp.
utest::v1::status_t verbose_test_setup_handler | ( | const size_t | number_of_cases ) |
Prints the number of tests to run and continues.
Definition at line 50 of file utest_default_handlers.cpp.
void verbose_test_teardown_handler | ( | const size_t | passed, |
const size_t | failed, | ||
const failure_t | failure | ||
) |
Prints the number of tests that passed and failed with a reason if provided.
Definition at line 57 of file utest_default_handlers.cpp.
Variable Documentation
const utest::v1::base_control_t CaseAwait = { REPEAT_UNDECLR, TIMEOUT_FOREVER } |
Awaits until the callback is validated and never times out. Use with caution!
Definition at line 129 of file utest_types.cpp.
const utest::v1::base_control_t CaseNext = { REPEAT_NONE, TIMEOUT_NONE } |
does not repeat this test case and immediately moves on to the next one without timeout
Definition at line 119 of file utest_types.cpp.
const utest::v1::base_control_t CaseNoRepeat = { REPEAT_NONE, TIMEOUT_UNDECLR } |
does not repeat this test case, moves on to the next one
Definition at line 121 of file utest_types.cpp.
const utest::v1::base_control_t CaseNoTimeout = { REPEAT_UNDECLR, TIMEOUT_NONE } |
No timeout, immediately moves on to the next case, but allows repeats.
Definition at line 127 of file utest_types.cpp.
const utest::v1::base_control_t CaseRepeatAll = { REPEAT_ALL, TIMEOUT_UNDECLR } |
repeats the test case handler with calling teardown and setup handlers
Definition at line 123 of file utest_types.cpp.
const utest::v1::base_control_t CaseRepeatHandler = { REPEAT_HANDLER, TIMEOUT_UNDECLR } |
repeats only the test case handler without calling teardown and setup handlers
Definition at line 125 of file utest_types.cpp.
const case_control_handler_t control_handler [inherited] |
- See also:
- case_control_handler_t
Definition at line 61 of file utest_case.h.
const handlers_t & default_handlers = greentea_abort_handlers |
The greentea aborting handlers are the default.
Definition at line 37 of file utest_default_handlers.cpp.
const case_failure_handler_t failure_handler [inherited] |
Handler called whenever a faillure occur; at any stage of the case execution (including setup and teardown).
Definition at line 84 of file utest_case.h.
const handlers_t greentea_abort_handlers |
{ default_greentea_test_setup_handler, greentea_test_teardown_handler, test_failure_handler, greentea_case_setup_handler, greentea_case_teardown_handler, greentea_case_failure_abort_handler }
The greentea default handlers that always abort on the first encountered failure.
Definition at line 31 of file utest_greentea_handlers.cpp.
const handlers_t greentea_continue_handlers |
{ default_greentea_test_setup_handler, greentea_test_teardown_handler, test_failure_handler, greentea_case_setup_handler, greentea_case_teardown_handler, greentea_case_failure_continue_handler }
The greentea default handlers that always continue on failure.
Definition at line 40 of file utest_greentea_handlers.cpp.
const char* GREENTEA_TEST_ENV_END |
Generic test suite transport protocol keys.
Definition at line 30 of file greentea_test_env.cpp.
const char* GREENTEA_TEST_ENV_LCOV_START |
Code Coverage (LCOV) transport protocol keys.
Definition at line 52 of file greentea_test_env.cpp.
const char* GREENTEA_TEST_ENV_SUCCESS |
Test suite success code strings.
Definition at line 40 of file greentea_test_env.cpp.
const char* GREENTEA_TEST_ENV_TESTCASE_NAME |
Test case transport protocol start/finish keys.
Definition at line 46 of file greentea_test_env.cpp.
const case_handler_t handler [inherited] |
Primitive test case handler This is called only if the case setup succeeded.
It is followed by the test case teardown handler.
Definition at line 56 of file utest_case.h.
const case_call_count_handler_t repeat_count_handler [inherited] |
- See also:
- case_call_count_handler_t
Definition at line 66 of file utest_case.h.
const handlers_t selftest_handlers |
{ default_greentea_test_setup_handler, greentea_test_teardown_handler, selftest_failure_handler, greentea_case_setup_handler, greentea_case_teardown_handler, greentea_case_failure_continue_handler }
The selftest default handlers that always abort on _any_ assertion failure, otherwise continue.
Definition at line 49 of file utest_greentea_handlers.cpp.
const case_setup_handler_t setup_handler [inherited] |
Handler called before the execution of the case handler.
It sets up the case environment.
Definition at line 72 of file utest_case.h.
const case_teardown_handler_t teardown_handler [inherited] |
Handler called after the execution of the case handler.
It cleans up the case environment.
Definition at line 78 of file utest_case.h.
const handlers_t verbose_continue_handlers |
{ verbose_test_setup_handler, verbose_test_teardown_handler, test_failure_handler, verbose_case_setup_handler, verbose_case_teardown_handler, verbose_case_failure_handler }
The verbose default handlers that always continue on failure.
Definition at line 28 of file utest_default_handlers.cpp.
Generated on Sun Jul 17 2022 08:25:38 by 1.7.2