One limitation of C++ is that implicit casts do not occur when
matching template overloads, as a consequence the callback's
argument type requires a strict match.
Unfortunately, the prevents the previously common pattern of using
void pointers as function arguments, causing unnecessary problems
for users porting code.
Thing *t;
void doit(void *p) { blablabla }
Callback<void()> cb(t, doit);
To avoid this, explicit overloads on void pointers were added. This
avoids a template expansion, and allows the implicit cast to occur
as the user would expect.
As the templated tests grew, the resulting binary exceeded a
flash size of 64K. This caused the test to incorrectly fail on
small devices.
Moved and split into the following:
TESTS/mbed_functional/callback
TESTS/mbed_functional/callback_small
TESTS/mbed_functional/callback_big
TESTS/mbed_functional/functionpointer
- Marked `call` and `operator()` functions as const
- Moved to static_cast for internal function pointer to avoid losing
compiler checked const-safety
- Added test for `operator=` with non-callback types
- Moved from zero-cast to value-initializer when callback is null
- Added `operator==` and `operator!=`
- Removed special handling of null callback
- Replicated doxygen to all overloads
- Added correct nops where uninitialized callbacks are called
- Added assertion for null callback
- Removed copy-constructor from callback constructor
Additionally, the following changes were don to avoid combinatorial
explosion in function overloads as a result of adding cv-qualifiers:
- Added convenience function for inferred type
- Deprecated callback overloads qhere cv-qualifiers are not scalable
Supported overloads:
callback(void (*f)(A...));
callback(const Callback<R(A...)> &);
callback(T *t, void (*f)(T*, A...));
callback(const T *t, void (*f)(const T*, A...));
callback(volatile T *t, void (*f)(volatile T*, A...));
callback(const volatile T *t, void (*f)(const volatile T*, A...));
callback(T *t, void (T::*f)(A...));
callback(const T *t, void (T::*f)(A...) const);
callback(volatile T *t, void (T::*f)(A...) volatile);
callback(const volatile T *t, void (T::*f)(A...) const volatile);
Keep track of the current size allocated, maximum size allocated,
number of allocations, failed allocations and total size allocated for
both GCC and ARM. Report the maximum size allocated at the end of
testing.
Also, add a test to verify heap metrics are working as expected.
From the discussion on issue #2068:
Functions marked deprecated in the mbed library should notate when
the deprecation was started to allow efficient removal once a set
amount of time has expired.
Added the following macro:
MBED_DEPRECATED_SINCE("version", "message string")
Example usage:
MBED_DEPRECATED_SINCE("v5.1", "don't foo any more, bar instead")
void foo(int arg);
Adopted in existing deprecations:
- FunctionPointer
- RtosTimer
- Thread
threaded.
For mbed micro, if the MBED_RTOS_SINGLE_THREAD is defined then the
compilation of the test will fail with the info
[NOT_SUPPORTED] test not supported
This patch bring this behavior to mbed-os RTOS tests.
This commit adds the following test frameworks:
- `greentea-client` (https://github.com/ARMmbed/greentea-client)
- This framework provides a key-value api for communicating with the
greentea test tool (https://github.com/ARMmbed/greentea)
- `unity` (https://github.com/ARMmbed/unity)
- This framework provides test assert macros that can be used when
writing test cases
- `utest` (https://github.com/ARMmbed/utest)
- This framework allows you to execute a series of test cases with
reporting that works with the greentea test tool
(https://github.com/ARMmbed/greentea)
The following changes were made when bringing these frameworks into the
tree:
- References to `mbed_drivers/mbed.h` within utest's tests were migrated
to `mbed.h`
- The yotta file `module.json` was removed from `greentea-client` and
`unity`
- `coverage.json` was also removed from `greentea-client`
- `.gitignore` and `.gitattributes` were removed from `greentea-client`
- Apache 2.0 license files were removed from `greentea-client`
This also brings in a number of tests that have been newly written or ported from various sources:
- `TESTS/integration` - Very basic tests, used to check if testing frameworks are working correctly
- `TESTS/mbed_drivers` (Thanks @PrzemekWirkus!) - TESTS ported from mbed OS 3.0 (https://github.com/ARMmbed/mbed-drivers)
- `TESTS/mbedmicro-mbed` (Thanks @PrzemekWirkus!) - Tests that weren't covered by `TESTS/mbed_drivers` that currently live in `libraries/tests/mbed`
- `TESTS/mbedmicro-rtos-mbed` (Thanks @PrzemekWirkus!) - Ported tests that currently live in `libraries/tests/rtos/mbed`
- `TESTS/storage_abstraction` (Thanks @rgrover!) - Tests for the storage_abstraction hal