The mbed_greentea_add_test macro required a greentea test to set an
MBED_PATH variable to the path of the mbed-os root directory, which it
attempts to add as a 'subdirectory' of the test project. We can instead
use CMake's built in CMAKE_CURRENT_LIST_DIR variable to deduce the path
to mbed-os relative to the current list file directory, removing the
need for greentea tests to set MBED_PATH.
The header `mbed.h` pulls in headers from a number of Mbed OS
components that are not necessarily used. It was intended for user
applications only, and libraries and unit tests should explicitly
include library headers it uses to limit dependencies.
This change avoids having to link unnecessary libraries in storage
unit tests' CMake definitions.
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 the hal stub library depended on `mbed-headers`, which
is a collection of all available headers in mbed-os. To make it easier
to separate the library, only depend on the headers we're using.
Move the header-only mbed-headers-hal library the unit test stubs
depend on into the hal component directory. This makes the events
stubs more self-contained and improves the composition of the library.
Previously the connectivity cellular stub library depended on
`mbed-headers`, which is a collection of all available headers
in mbed-os. To make it easier to separate the library, only depend
on the headers we're using.
- Previously all cellular header made as a part of the
mbed-headers-connectivity library. To make it easier to separate all
the cellular headers into the separate mbed-headers-cellular library
and keep them as part of cellular stub CMake. This makes the cellular
stubs more self-contained and improves the composition of the library.
- Update all unit test that depends on cellular headers with mbed-headers-cellular library
Move the connectivity cellular into the connectivity/cellular component
directory. So we can avoid duplicating the mbed-os source tree in a
central UNITTESTS folder.
As we depend on the cryptography library, and the pip version that comes
with Ubuntu Focal isn't new enough to avoid the following error about a
rust compiler and pre-built wheels, ensure Travis uses an up-to-date
pip.
error: can't find Rust compiler
If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.
To update pip, run:
pip install --upgrade pip
subprocess.PIPE is used to enable the parent process to communicate with
the subprocess via pipes, which mean all stdout and stderr messages are
captured and returned as part of Popen.communicate's result tuple.
In our case, we want to display the error messages on the console, so we
don't need to capture the output from stdout.
Example of a typical error message before this change:
```
Traceback (most recent call last):
File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 197, in <module>
sign_and_merge_tfm_bin(args.tfm_target, args.target_path, args.non_secure_bin, args.secure_bin)
File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 81, in sign_and_merge_tfm_bin
" secure binary, Error code: " + str(retcode))
Exception: Unable to sign musca_b1 secure binary, Error code: 1
```
Example of the error message after this change:
```
Traceback (most recent call last):
File "/mbed-os/tools/psa/tfm/bin_utils/wrapper.py", line 13, in <module>
import click
ModuleNotFoundError: No module named 'click'
Traceback (most recent call last):
File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 194, in <module>
sign_and_merge_tfm_bin(args.tfm_target, args.target_path, args.non_secure_bin, args.secure_bin)
File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 80, in sign_and_merge_tfm_bin
raise Exception("Unable to sign " + target_name +
Exception: Unable to sign musca_b1 secure binary, Error code: 1
```
This is a significant improvement as now you can see what the reason for
the failure was.