Commit Graph

33 Commits (master)

Author SHA1 Message Date
Hari Limaye c6312a3c70 Unit tests: Add boilerplate code for AnalogIn.cpp
In pursuit of increasing unit test coverage of Mbed OS, we add the
boilerplate code for unit testing of AnalogIn.cpp and an empty test
source file. This serves two purposes - it allows us to report on
currently untested sources in code coverage data, and it makes it a
little easier for developers to write unit tests for these sources.

The 'empty' test file contains a main function that simply returns. This
is required to allow CMake's add_executable() to be used to pull in the
source file for the SUT, which ensures that this source file is built
and therefore instrumented to generate coverage data. The alternative
that was explored was to instead use Google Test's TEST() macro and
prefix the test name with 'DISABLED_' to skip it, but that resulted in
the test being reported as skipped, which was deemed undesireable for
these 'empty' tests.
2021-08-16 10:13:11 +01:00
Lingkai Dong d7ef8f857f CMake: greentea: Add skip reason to ticker test 2021-08-11 11:43:17 +01:00
Robert Walton 40154ee2b1 CMake: greentea: Port mbed-drivers-ticker to CTest
Call add_test in mbed_greentea_add_test and specify mbedhtrun as the
command to run.

An MBED_HTRUN_ARGUMENTS variable has been added, which is a semicolon
separated list of arguments to forward to htrun. The user is required to
pass in any arguments mbedhtrun needs to communicate with the device
under test at CMake configuration time.

We automate passing some of the htrun arguments in CMake using data
provided by mbed_config.cmake or gathered from the CMake environment.
The following arguments are passed to htrun from CMake:

* -f/--image-path
* -e/--enum-host-tests
* -m/--micro
* -R/--reset-timeout

--baud-rate is also passed if the MBED_CONF_PLATFORM_STDIO_BAUD_RATE
config parameter is defined.

Temporary checks have been added to mbed_greentea_add_test to keep the
old flow working until we port all of the greentea tests to CTest. These
checks should be removed after we make all greentea tests runnable by
CTest.
2021-08-10 16:54:03 +01:00
Lingkai Dong dca2aa79a0 Unit tests: Remove redundant CMake target mbed-headers-base
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.
2021-08-02 17:42:43 +01:00
Lingkai Dong e75a45d041 Unit tests: Move drivers target_h stubs 2021-08-02 17:42:43 +01:00
Martin Kojtal 3318720ada
Merge pull request #14941 from hazzlim/update-tests-to-use-chrono
Update references to time values to use chrono
2021-07-30 12:02:10 +01:00
harmut01 86c2d70a5b Greentea: Remove deprecated APIs and use chrono
References to time should do so using std::chrono. We reworked tests in
connectivity and drivers to use std::chrono and new APIs in order to
remove deprecation warnings resulting from deprecated API calls.
This required addition of  a macro for test assertions using std::chrono
values.

As host test "timing_drift_auto" expects time values represented as an
integral number of microseconds, we explicitly provide this in place
using "microseconds{TICKER_TIME}.count()" in the relevant ticker tests.
We recognise this is ugly, but thought it best to descriptively convert
from std::chrono to the host test's required representation.

Co-authored-by: Hari Limaye <hari.limaye@arm.com>
2021-07-29 14:06:27 +01:00
Robert Walton a09d08917b CMake: unittests: Show all tests in CTest report
Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that didn't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.
2021-07-27 21:09:39 +01:00
Robert Walton 1e48a61d89 CMake: unittests: Remove trailing whitespace 2021-07-27 21:09:38 +01:00
Hari Limaye bfe24ce64d Greentea: Remove unused variable from ticker test
Ticker test contains definition of variable total_ticks, which is unused
in the file since removal of function wait_and_print() in commit
aaa15bcf58
2021-07-21 12:21:58 +01:00
jeromecoutant d9204d06eb generic_tests update for targets without LED1 2021-07-06 17:13:45 +02:00
Jaeden Amero 472c688a83
Merge pull request #14828 from hazzlim/add-cmake-supports-psa-tests
CMake: Add CMake to mbed-psa greentea tests
2021-06-29 15:17:01 +01:00
Hari Limaye f95052cf6f CMake: Require TEST_SOURCES in greentea CMake file
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.
2021-06-29 13:33:42 +01:00
Martin Kojtal 9244625508
Merge pull request #14786 from ARMmbed/move_drivers_stub
Move mbed-stubs-drivers to the drivers directory
2021-06-24 15:43:37 +02:00
Rajkumar Kanagaraj e64d1c7605 CMake: unit-tests: Make drivers stub only depend on headers it uses
Previously the drivers 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.
2021-06-22 04:32:17 -07:00
Rajkumar Kanagaraj 05cd885931 CMake: unit-tests: Move mbed-headers-drivers to the drivers directory
Move the header-only mbed-headers-drivers library the unit test stubs
depend on into the drivers component directory. This makes the drivers
stubs more self-contained and improves the composition of the library.
2021-06-22 04:28:06 -07:00
Rajkumar Kanagaraj ae5bc5a39e CMake: Move drivers stubs to the mbed-os/drivers directory
Move the drivers stub library into the drivers component directory.
so we can avoid duplicating the mbed-os source tree in a central
UNITTESTS folder.
2021-06-22 04:28:06 -07:00
Rajkumar Kanagaraj 9a4bdb8ef4 CMake: unit-tests: Make drivers UNITTESTS only depend on headers it uses
Previously the drivers unit tests 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.
2021-06-22 04:17:56 -07:00
Rajkumar Kanagaraj 10beeab6c2 CMake: unit-tests: Pwmout & Watchdog: Remove trailing whitespace 2021-06-22 04:05:07 -07:00
Rajkumar Kanagaraj 50fc85dc44 CMake: Remove all unittest.cmake script from test suite
- Remove redundant cmake script as already added the CMake configuration file
- Remove redundant empty_baseline as it is no longer needed with the help of CMake configuration file
2021-05-26 07:09:14 -07:00
Rajkumar Kanagaraj 2bafdf82e7 CMake: Refactor drivers unittest cmake 2021-05-11 02:29:56 -07:00
George Psimenos cd5330e5a9 Replace USBTX/RX everywhere else 2021-03-24 10:11:30 +00:00
Rajkumar Kanagaraj 6824b14e48 CMake: rename greentea test macro 2021-02-02 07:43:40 -08:00
Rajkumar Kanagaraj 20fb74f829 Add CMake support 2021-01-05 09:10:05 -08:00
Lingkai Dong 562b31ccd3 Move SFDP unit tests 2020-12-07 12:05:07 +00:00
Lingkai Dong fb0f9687e4 Initial unit test for SFDP
As a starting point, only sfdp_iterate_next_largest_erase_type(),
which the pull request is intended to fix, is tested. More test
cases shall be added in the future.
2020-11-26 09:55:47 +00:00
Evelyne Donnaes 30e9050f10 Moved USB greentea tests 2020-11-12 14:57:01 +00:00
jeromecoutant f9832cb3be USB_DEVICE MSD test skipped when RAM is limited 2020-08-27 11:13:21 +02:00
jeromecoutant ccece2fdee Move USB host tests 2020-08-27 11:13:16 +02:00
Lingkai Dong 2f92378642 Move TESTS/usb_device -> drivers/tests/TESTS/usb_device 2020-08-14 17:57:13 +01:00
George Psimenos bb5c2cf32a Duplicate host tests for drivers 2020-07-31 10:04:36 +01:00
George Psimenos 0a759aaa38 Move drivers greentea tests 2020-07-31 10:04:36 +01:00
George Psimenos 973c1dc2ff Move drivers unit tests 2020-07-31 10:04:36 +01:00