Individual libraries' `target_h` stub headers have now all been moved
from `mbed-headers-base` to `mbed-headers-<library>`.
Note: Even though headers previously in `target_h` are technically
stubs/fakes too, they are used by not only unit tests but also regular
libraries when compiled for unit tests, because no target-specific HAL
implementation exists in this case. In order for regular library
sources to pick up `target_h` headers, those headers must
* have the same names as regular headers
* appear first in include paths
This is why those headers are part of `mbed-headers-<library>` and not
`mbed-stubs-<library>`. Before this refactoring, `mbed-headers-base`
was the first in unit tests' include paths.
Stubs previously in UNITTESTS/target_h/ have the same names as
regular Mbed OS headers, intending to override the latter directly.
We move hal target_h stubs into hal/tests/UNITTESTS/doubles/.
Note: In Mbed OS, the standard include format requires each header to
be prefixed with its module name, for example "hal/gpio_api.h". This
requires headers to be organized in a module directory. But unit tests
stubs for hal correspond to what a real Mbed target would have
implemented (in a non-test scenario), and targets do not currently put
headers in hal/, so we similary put stub headers directly in
hal/tests/UNITTESTS/doubles/ instead of add a hal/ subdirectory there.
The stub header randLIB.h overrides the header of the same name in
platform/randlib/ which is an external repository vendored into
the mbed-os codebase. As the repository is synchronized regularly,
it is better not to put overrides there, so we put the randLIB.h
stub into the regular platform doubles directory.
The header `mbed.h` is a convenient wrapper that pre-includes some
platform headers, for use by user applications. Libraries and tests
internal to Mbed OS should not use it, and they should explicitly
include headers they need. So a stub is not needed.
Stubs previously in UNITTESTS/target_h/ have the same names as
regular Mbed OS headers, intending to override the latter directly.
We move platform target_h stubs into
platform/tests/UNITTESTS/doubles/platform/.
Note: nvic_wrapper.h is normally implemented and used by Mbed targets
as needed. But as unit tests do not have a real target, we treat it
as a stub for the platform.
Previously ble headers are part of mbed-headers-connectivity, this PR
moves ble headers into new mbed-headers-ble to make ble stubs to be
more self-contained and improves the composition of the library.
Previously all nanostack libservice headers part of
mbed-headers-connectivity. This PR moves all the nanostack
libservice headers into newly added mbed-headers-nanostack-libraries.
This makes the nanostack libservice stubs more self-contained and
improves the composition of the library.
Move the connectivity nanostack-libservice stubs into the connectivity/libraries
directory where the nanostack libservice component present as nanostack
libservice source copied from the external repo. So we can avoid duplicating
the mbed-os source tree in a central UNITTESTS folder.
Previously all the mbedtls stubs headers under mbed-stubs-headers,
so this PR move all mbedtls stubs headers under
mbedtls/tests/UNITTESTS/double directory and update CMake to include
stubs headers into mbed-stubs-mbedtls library to make mbedtls stubs
to be self-contained.
Update netsocket and lorawan unit tests to link with a mbed-stubs-mbedtls
library that it depends on instead of link with mbed-stubs
which is a group of stubs libraries.
Move the connectivity mbedtls stubs into the connectivity/mbedtls
component directory. So we can avoid duplicating the mbed-os source
tree in a central UNITTESTS folder.
Move the header-only mbed-headers-events library the unit test stubs
depend on into the events component directory. This makes the events
stubs more self-contained and improves the composition of the library.
- Previous changes moved all rtos stubs headers into mbed-stubs-rtos-headers
lib, but the decision to keep all stubs headers under the respective
component stubs library so moved all stubs rtos headers under
mbed-stubs-rtos and updated it depend component CMake
- Remove unnecessary add_definition call for UNITTEST as any of the stubs library
added from UNITTEST/CMakeLists.txt is not required this macro
Previously all the netsocket stubs headers under mbed-stubs-headers,
so this PR move all netsocket stubs headers under
netsocket/tests/UNITTESTS/double directory and update CMake to include
stubs headers into mbed-stubs-netsocket library to make netsocket stubs
to be self-contained.
- Previously, all netsocket headers made as a part of the
mbed-headers-connectivity library. To make it easier to separate all
the netsocket headers into the separate mbed-headers-netsocket library
and keep them, as part of netsocket stubs CMake. This makes the
netsocket stubs more self-contained and improves the composition of the library.
- Update cellular, netsocket unit tests to link only with a mbed-headers-netsocket
library that it depends on instead of link with mbed-headers
which is a group of headers libraries.
Move the connectivity netsocket stubs into the connectivity/netsocket
component directory. So we can avoid duplicating the mbed-os source
tree in a central UNITTESTS folder.
The stub version of <mstd_type_traits> is mostly identical to the
production file of the same name, except the former lags behind
and doesn't contain the recent "is_constant_evaluated" feature.
It's safe to update the stub file, because "is_constant_evaluated"
only checks generic GCC and Clang versions that also apply to
compilers on PCs.
This enables MbedCRC.h to include <mstd_type_traits> without
distinguishing between Mbed applications and unit tests.
We have a central collection of "stub headers", which makes reasoning
about dependencies rather difficult, as it forces every stub library to
depend on all available stub headers. The standard approach would be for
each stub library to expose its public headers, and its dependents to
explicitly specify a dependency on the stub library containing the
headers it needs. This is a more modular design than creating a
header-only monolith library. Move the platform stub headers from this
central library into the mbed-stubs-platform library to increase
modularity.
mbed-stubs-connectivity now depends on the mbed-stubs-platform because
it requires some headers which were moved to mbed-stubs-platform.
Move the header-only mbed-headers-platform library the unit test stubs
depend on into the platform component directory. This makes the platform
stubs more self contained and improves composition of the library.
Move the platform stub library into the platform component directory.
This change is so we can avoid duplicating the mbed-os source tree in a
central UNITTESTS folder.
Previously all the stubs headers under mbed-stubs-headers,
so this PR move all cellular stubs headers under
cellular/tests/UNITTESTS/double directory and update CMake
to include headers into mbed-stubs-cellular library to make
cellular stubs to be self-contained
Move storage stubs from UNITTESTS/stubs into components inside the
top-level storage directory. Specifically,
* storage/blockdevice/tests/UNITTESTS/doubles/ for BlockDevice stubs.
* storage/kvstore/filesystemstore/tests/UNITTESTS/ for a stub used by
the FileSystemStore test. The stub has been renamed from
kv_config_stub.cpp to filesystemstore_kv_config_stub.cpp, to make it
evident why it doesn't go into storage/kvstore/kv_config/.
Previously all the lorawan stubs headers under mbed-stubs-headers,
so this PR move all lorawan stubs headers under
cellular/tests/UNITTESTS/double directory and update CMake to include
stubs headers into mbed-stubs-lorawan library to make lorawan stubs to be self-contained
Previously, all lorawan headers made as a part of the
mbed-headers-connectivity library. To make it easier to separate all
the lorawan headers into the separate mbed-headers-lorawan library
and keep them, as part of lorawan stubs CMake. This makes the lorawan
stubs more self-contained and improves the composition of the library.
Move the connectivity lorawan stubs into the connectivity/lorawan
component directory. So we can avoid duplicating the mbed-os source
tree in a central UNITTESTS folder.