mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9527 from bridadan/remove_yotta_references
Remove yotta references within testing frameworkspull/9572/head
commit
7c578cf2c6
|
@ -55,6 +55,7 @@ For example, the `{{timeout;120}}}` string is a key-value message where the key
|
||||||
## Test example
|
## Test example
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
|
#include "mbed.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
|
@ -83,7 +84,7 @@ status_t greentea_setup(const size_t number_of_cases) {
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_start(int, char*[]) {
|
void main(int, char*[]) {
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -22,11 +22,7 @@
|
||||||
#define GREENTEA_CLIENT_TEST_ENV_H_
|
#define GREENTEA_CLIENT_TEST_ENV_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#ifdef YOTTA_GREENTEA_CLIENT_VERSION_STRING
|
|
||||||
#define MBED_GREENTEA_CLIENT_VERSION_STRING YOTTA_GREENTEA_CLIENT_VERSION_STRING
|
|
||||||
#else
|
|
||||||
#define MBED_GREENTEA_CLIENT_VERSION_STRING "1.3.0"
|
#define MBED_GREENTEA_CLIENT_VERSION_STRING "1.3.0"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -41,7 +37,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auxilary macros to keep mbed-drivers compatibility with utest before greentea-client
|
* Ensure compatibility with utest
|
||||||
*/
|
*/
|
||||||
#define TEST_ENV_TESTCASE_COUNT GREENTEA_TEST_ENV_TESTCASE_COUNT
|
#define TEST_ENV_TESTCASE_COUNT GREENTEA_TEST_ENV_TESTCASE_COUNT
|
||||||
#define TEST_ENV_TESTCASE_START GREENTEA_TEST_ENV_TESTCASE_START
|
#define TEST_ENV_TESTCASE_START GREENTEA_TEST_ENV_TESTCASE_START
|
||||||
|
|
|
@ -158,8 +158,8 @@ extern bool coverage_report;
|
||||||
*
|
*
|
||||||
* Generates preamble of message sent to notify host about code coverage data dump.
|
* Generates preamble of message sent to notify host about code coverage data dump.
|
||||||
*
|
*
|
||||||
* This function is used by mbedOS software
|
* This function is used by Mbed OS
|
||||||
* (see: mbed-drivers/source/retarget.cpp file) to generate code coverage
|
* (see: mbed-os/platform/mbed_retarget.cpp) to generate code coverage
|
||||||
* messages to host. When code coverage feature is turned on slave will
|
* messages to host. When code coverage feature is turned on slave will
|
||||||
* print-out code coverage data in form of key-value protocol.
|
* print-out code coverage data in form of key-value protocol.
|
||||||
* Message with code coverage data will contain message name, path to code
|
* Message with code coverage data will contain message name, path to code
|
||||||
|
@ -176,8 +176,8 @@ void greentea_notify_coverage_start(const char *path) {
|
||||||
/**
|
/**
|
||||||
* \brief Sufix for code coverage message to master (closing statement)
|
* \brief Sufix for code coverage message to master (closing statement)
|
||||||
*
|
*
|
||||||
* This function is used by mbedOS software
|
* This function is used by Mbed OS
|
||||||
* (see: mbed-drivers/source/retarget.cpp file) to generate code coverage
|
* (see: mbed-os/platform/mbed_retarget.cpp) to generate code coverage
|
||||||
* messages to host. When code coverage feature is turned on slave will
|
* messages to host. When code coverage feature is turned on slave will
|
||||||
* print-out code coverage data in form of key-value protocol.
|
* print-out code coverage data in form of key-value protocol.
|
||||||
* Message with code coverage data will contain message name, path to code
|
* Message with code coverage data will contain message name, path to code
|
||||||
|
|
|
@ -25,10 +25,11 @@ The order of handler execution is:
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
The following example showcases a lot of functionality and proper integration with the [Greentea testing automation framework](https://github.com/ARMmbed/greentea), while making use of the [unity test macros](https://github.com/ARMmbed/mbed-os/tree/master/features/frameworks/unity):
|
The following example showcases a lot of functionality and proper integration with the [Greentea test tool](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-greentea), while making use of the [unity test macros](https://github.com/ARMmbed/mbed-os/tree/master/features/frameworks/unity):
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
#include "mbed-drivers/test_env.h"
|
#include "mbed.h"
|
||||||
|
#include "greentea-client/test_env.h"
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ status_t test_repeats_setup(const Case *const source, const size_t index_of_case
|
||||||
printf("Setting up for '%s'\n", source->get_description());
|
printf("Setting up for '%s'\n", source->get_description());
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
control_t test_repeats(const size_t call_count) {
|
control_t test_repeats(const size_t call_count) {
|
||||||
printf("Called for the %u. time\n", call_count);
|
printf("Called for the %u. time\n", call_count);
|
||||||
TEST_ASSERT_NOT_EQUAL(3, call_count);
|
TEST_ASSERT_NOT_EQUAL(3, call_count);
|
||||||
|
@ -58,10 +60,12 @@ void test_callback_validate() {
|
||||||
// Validate the callback
|
// Validate the callback
|
||||||
Harness::validate_callback();
|
Harness::validate_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
control_t test_asynchronous() {
|
control_t test_asynchronous() {
|
||||||
TEST_ASSERT_TRUE_MESSAGE(true, "(true == false) o_O");
|
TEST_ASSERT_TRUE_MESSAGE(true, "(true == false) o_O");
|
||||||
// Set up a callback in the future. This may also be an interrupt!
|
// Set up a callback in the future. This may also be an interrupt!
|
||||||
minar::Scheduler::postCallback(test_callback_validate).delay(minar::milliseconds(100));
|
EventQueue *queue = mbed_event_queue();
|
||||||
|
queue->call_in(100, test_callback_validate);
|
||||||
// Set a 200ms timeout starting from now
|
// Set a 200ms timeout starting from now
|
||||||
return CaseTimeout(200);
|
return CaseTimeout(200);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +76,8 @@ control_t test_asynchronous_timeout(const size_t call_count) {
|
||||||
// but automatically repeat only this handler on timeout.
|
// but automatically repeat only this handler on timeout.
|
||||||
if (call_count >= 5) {
|
if (call_count >= 5) {
|
||||||
// but after the 5th call, the callback finally gets validated
|
// but after the 5th call, the callback finally gets validated
|
||||||
minar::Scheduler::postCallback(test_callback_validate).delay(minar::milliseconds(100));
|
EventQueue *queue = mbed_event_queue();
|
||||||
|
queue->call_in(100, test_callback_validate);
|
||||||
}
|
}
|
||||||
return CaseRepeatHandlerOnTimeout(200);
|
return CaseRepeatHandlerOnTimeout(200);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +100,7 @@ Case cases[] = {
|
||||||
// Declare your test specification with a custom setup handler
|
// Declare your test specification with a custom setup handler
|
||||||
Specification specification(greentea_setup, cases);
|
Specification specification(greentea_setup, cases);
|
||||||
|
|
||||||
void app_start(int, char**)
|
int main()
|
||||||
{ // Run the test specification
|
{ // Run the test specification
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +160,7 @@ Please see the `utest/types.h` file for a detailed description.
|
||||||
1. `status_t case_teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)`: called after execution of each test case, and if testing is aborted.
|
1. `status_t case_teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)`: called after execution of each test case, and if testing is aborted.
|
||||||
1. `status_t case_failure_handler_t(const Case *const source, const failure_t reason)`: called whenever a failure occurs during the execution of a test case.
|
1. `status_t case_failure_handler_t(const Case *const source, const failure_t reason)`: called whenever a failure occurs during the execution of a test case.
|
||||||
|
|
||||||
All handlers are defaulted for integration with the [Greentea testing automation framework](https://github.com/ARMmbed/greentea).
|
All handlers are defaulted for integration with the [Greentea testing tool](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-greentea).
|
||||||
|
|
||||||
### Test Case Handlers
|
### Test Case Handlers
|
||||||
|
|
||||||
|
@ -416,4 +421,4 @@ void main() // or whatever your custom entry point is
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// define this to get rid of the minar dependency.
|
|
||||||
#define YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER 1
|
|
||||||
|
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// define this to get rid of the minar dependency.
|
|
||||||
#define YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER 1
|
|
||||||
|
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
|
@ -18,50 +18,9 @@
|
||||||
|
|
||||||
#include "utest/utest_shim.h"
|
#include "utest/utest_shim.h"
|
||||||
#include "utest/utest_stack_trace.h"
|
#include "utest/utest_stack_trace.h"
|
||||||
|
|
||||||
#if UTEST_SHIM_SCHEDULER_USE_MINAR
|
|
||||||
#include "minar/minar.h"
|
|
||||||
|
|
||||||
static int32_t utest_minar_init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void *utest_minar_post(const utest_v1_harness_callback_t callback, const uint32_t delay_ms)
|
|
||||||
{
|
|
||||||
void *handle = minar::Scheduler::postCallback(callback).delay(minar::milliseconds(delay_ms)).getHandle();
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
static int32_t utest_minar_cancel(void *handle)
|
|
||||||
{
|
|
||||||
int32_t ret = minar::Scheduler::cancelCallback(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
static int32_t utest_minar_run()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
extern "C" {
|
|
||||||
static const utest_v1_scheduler_t utest_v1_scheduler =
|
|
||||||
{
|
|
||||||
utest_minar_init,
|
|
||||||
utest_minar_post,
|
|
||||||
utest_minar_cancel,
|
|
||||||
utest_minar_run
|
|
||||||
};
|
|
||||||
utest_v1_scheduler_t utest_v1_get_scheduler()
|
|
||||||
{
|
|
||||||
return utest_v1_scheduler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif UTEST_SHIM_SCHEDULER_USE_US_TICKER
|
|
||||||
#ifdef YOTTA_MBED_HAL_VERSION_STRING
|
|
||||||
# include "mbed-hal/us_ticker_api.h"
|
|
||||||
#else
|
|
||||||
#include "platform/SingletonPtr.h"
|
#include "platform/SingletonPtr.h"
|
||||||
#include "Timeout.h"
|
#include "Timeout.h"
|
||||||
using mbed::Timeout;
|
using mbed::Timeout;
|
||||||
#endif
|
|
||||||
|
|
||||||
// only one callback is active at any given time
|
// only one callback is active at any given time
|
||||||
static volatile utest_v1_harness_callback_t minimal_callback;
|
static volatile utest_v1_harness_callback_t minimal_callback;
|
||||||
|
@ -79,7 +38,7 @@ static void ticker_handler()
|
||||||
static int32_t utest_us_ticker_init()
|
static int32_t utest_us_ticker_init()
|
||||||
{
|
{
|
||||||
UTEST_LOG_FUNCTION();
|
UTEST_LOG_FUNCTION();
|
||||||
// initialize the Timeout object to makes sure it is not initialized in
|
// initialize the Timeout object to makes sure it is not initialized in
|
||||||
// interrupt context.
|
// interrupt context.
|
||||||
utest_timeout_object.get();
|
utest_timeout_object.get();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -88,13 +47,13 @@ static void *utest_us_ticker_post(const utest_v1_harness_callback_t callback, ti
|
||||||
{
|
{
|
||||||
UTEST_LOG_FUNCTION();
|
UTEST_LOG_FUNCTION();
|
||||||
timestamp_t delay_us = delay_ms *1000;
|
timestamp_t delay_us = delay_ms *1000;
|
||||||
|
|
||||||
if (delay_ms) {
|
if (delay_ms) {
|
||||||
ticker_callback = callback;
|
ticker_callback = callback;
|
||||||
// fire the interrupt in 1000us * delay_ms
|
// fire the interrupt in 1000us * delay_ms
|
||||||
utest_timeout_object->attach_us(ticker_handler, delay_us);
|
utest_timeout_object->attach_us(ticker_handler, delay_us);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
minimal_callback = callback;
|
minimal_callback = callback;
|
||||||
}
|
}
|
||||||
|
@ -142,10 +101,3 @@ utest_v1_scheduler_t utest_v1_get_scheduler()
|
||||||
return utest_v1_scheduler;
|
return utest_v1_scheduler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef YOTTA_CORE_UTIL_VERSION_STRING
|
|
||||||
// their functionality is implemented using the CriticalSectionLock class
|
|
||||||
void utest_v1_enter_critical_section(void) {}
|
|
||||||
void utest_v1_leave_critical_section(void) {}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -41,11 +41,6 @@ namespace v1 {
|
||||||
* The harness executes the test specification in an asynchronous fashion, therefore
|
* The harness executes the test specification in an asynchronous fashion, therefore
|
||||||
* `run()` returns immediately.
|
* `run()` returns immediately.
|
||||||
*
|
*
|
||||||
* By default, this harness uses the MINAR scheduler for asynchronous callbacks.
|
|
||||||
* If you wamt to provide your own custom scheduler, set `config.utest.use_custom_scheduler` to `true`
|
|
||||||
* inside your yotta config and set a custom scheduler implementation using the `set_scheduler()` function.
|
|
||||||
* You must set the scheduler before running a specification.
|
|
||||||
*
|
|
||||||
* @note In case of an test abort, the harness will busy-wait and never finish.
|
* @note In case of an test abort, the harness will busy-wait and never finish.
|
||||||
*/
|
*/
|
||||||
class Harness
|
class Harness
|
||||||
|
|
|
@ -27,50 +27,22 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "utest/utest_scheduler.h"
|
#include "utest/utest_scheduler.h"
|
||||||
|
|
||||||
#ifdef YOTTA_CFG
|
#ifndef __deprecated_message
|
||||||
# include "compiler-polyfill/attributes.h"
|
# if defined(__CC_ARM)
|
||||||
#else
|
# define __deprecated_message(msg) __attribute__((deprecated))
|
||||||
# ifndef __deprecated_message
|
# elif defined (__ICCARM__)
|
||||||
# if defined(__CC_ARM)
|
# define __deprecated_message(msg)
|
||||||
# define __deprecated_message(msg) __attribute__((deprecated))
|
|
||||||
# elif defined (__ICCARM__)
|
|
||||||
# define __deprecated_message(msg)
|
|
||||||
# else
|
|
||||||
# define __deprecated_message(msg) __attribute__((deprecated(msg)))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef YOTTA_CORE_UTIL_VERSION_STRING
|
|
||||||
# include "core-util/CriticalSectionLock.h"
|
|
||||||
# define UTEST_ENTER_CRITICAL_SECTION mbed::util::CriticalSectionLock lock
|
|
||||||
# define UTEST_LEAVE_CRITICAL_SECTION
|
|
||||||
#else
|
|
||||||
# ifndef UTEST_ENTER_CRITICAL_SECTION
|
|
||||||
# define UTEST_ENTER_CRITICAL_SECTION utest_v1_enter_critical_section()
|
|
||||||
# endif
|
|
||||||
# ifndef UTEST_LEAVE_CRITICAL_SECTION
|
|
||||||
# define UTEST_LEAVE_CRITICAL_SECTION utest_v1_leave_critical_section()
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER
|
|
||||||
# ifdef YOTTA_MINAR_VERSION_STRING
|
|
||||||
# define UTEST_MINAR_AVAILABLE 1
|
|
||||||
# else
|
# else
|
||||||
# define UTEST_MINAR_AVAILABLE 0
|
# define __deprecated_message(msg) __attribute__((deprecated(msg)))
|
||||||
# endif
|
# endif
|
||||||
# ifndef UTEST_SHIM_SCHEDULER_USE_MINAR
|
#endif
|
||||||
# define UTEST_SHIM_SCHEDULER_USE_MINAR UTEST_MINAR_AVAILABLE
|
|
||||||
# endif
|
#ifndef UTEST_ENTER_CRITICAL_SECTION
|
||||||
# ifndef UTEST_SHIM_SCHEDULER_USE_US_TICKER
|
# define UTEST_ENTER_CRITICAL_SECTION utest_v1_enter_critical_section()
|
||||||
# ifdef __MBED__
|
#endif
|
||||||
# define UTEST_SHIM_SCHEDULER_USE_US_TICKER 1
|
#ifndef UTEST_LEAVE_CRITICAL_SECTION
|
||||||
# else
|
# define UTEST_LEAVE_CRITICAL_SECTION utest_v1_leave_critical_section()
|
||||||
# define UTEST_SHIM_SCHEDULER_USE_US_TICKER 0
|
#endif
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif // YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Reference in New Issue