Currently there are no stub implementations of the analogin_api.c
functions. As the AnalogIn class makes use of these functions, these
stub definitions are required in order to build AnalogIn.cpp and
generate .gcno files to be used to generate code coverage metrics.
Add an option to enable the greentea tests independently from the unit
tests.
We can't just use the typical BUILD_TESTING option to enable greentea
tests. BUILD_TESTING enables unit tests and fetches googletest, which
are compiled for the host. Greentea tests are cross compiled and require
a toolchain file. For this reason we add a new option just to enable
greentea tests, preventing build failures triggered by the unit tests
and googletest.
The test script pinvalidate.py requires the following which are
missing in the unit test stub PinName.h:
* A comment "MBED TARGET LIST"
* `CONSOLE_TX` and `CONSOLE_RX` in the `PinName` enum
This commit adds them.
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.
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.
Assumption that greentea test file is always named main.cpp is
incorrect. Updated mbed_greentea_add_test() macro to make TEST_SOURCES
parameter compulsory, which is used to specify greentea test
file(s). This allows tests to use C, or have a different name.
Therefore also updated all pre-existing greentea test CMake files to
explicity add main.cpp to TEST_SOURCES.
CMakeLists.txt file in /hal/tests/TESTS/mbed_hal_fpga_ci_test_shield
directory was non-functional as it used the greentea_add_test macro,
which expects a main.cpp in current directory, but no main.cpp exists
there. I checked with @rajkan01 who confirmed that this CMake file is
serving no purpose and is there erroneously. All tests in subdirectories
of this directory have their own CMakeLists.txt that successfully build
them.
In the Standard Pin Names porting guide, pinvalidate.py is run
without prefixing the "python" command. But to make it possible,
a shebang needs to exist.
This commit adds provisions to enable using interface::CAN on targets that don't have DEVICE_CAN set to 1 (ie: they don't normally have a CAN peripheral).
Runtime code that analysed clock frequency to determine numerator and
denominator for conversion to standard 1MHz failed to handle the case
of either being 1 correctly.
Although it would spot other values that could be performed as shifts,
it failed to spot that 1 is "shift by 0", so would end up doing runtime
multiply and/or divide by 1. The runtime divide by 1 could be slow on a
Cortex-M0 device, increasing interrupt latency.
UART character loss on STM32F0 devices has been traced to this incorrect
code.
Correct the `exact_log2` routine so that `exact_log2(1)` returns 0 to
fix this.
Original code had a single special no-multiply-or-divide case for
hardware clock frequency being exactly 1MHz, as USTICKER is on STM32F0 -
this code lacks that but has a more general special case that covers all
shift-convertible frequencies like 500kHz or 8MHz, which should be
similar speed as shifts are cheap.