Commit Graph

54 Commits (fix_lp1114_flash_overflow_issue)

Author SHA1 Message Date
Robert Walton 7842320ab7 CMake: Add option to enable greentea tests
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.
2021-08-10 16:35:11 +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
Robert Walton 98e25f193e unittests: Test_LoRaWANStack.acquire_rx_metadata: Fix SEGFAULT
We failed to set `LoRaMac_stub::mlme_ind_ptr` to a valid pointer. When
we tried to dereference it in `LoRaWANStack::process_reception` we hit a
SEGFAULT.
2021-07-27 21:09:39 +01:00
Robert Walton 421adc9888 unittests: Fix Test_LoRaWANStack.acquire_tx_metadata
This test was relying on the state of `LoRaMac_stub::bool_true_counter`
to be set to 1 from a previous test. When the test was ran in isolation
the `LoRaWANStack::rx_timeout_interrupt_handler` callback would fail
because we weren't returning true from the stub implementation of
`LoRaMac::nwk_joined`. Due to this
`LoRaWANStack::post_process_tx_no_reception` was never called. This
caused the LoRaWANStack object to think the "tx_metadata" was "stale"
(i.e the data hadn't changed since any previous read). So, when we
attempted to call `LoRaWANStack::acquire_tx_metadata` it returned
`LORAWAN_STATUS_METADATA_NOT_AVAILABLE` as it thought we had no new
metadata to report, causing the test assertion to fail.
2021-07-27 21:09:39 +01:00
Robert Walton 9f3069f1e1 unittests: Test_LoRaMac.post_process_mcps_req: Fix segfault
We had commented out a line where we reset LoRaPHY_stub::uint16_value to
0. This was causing an invalid array access in
LoRaMac::handle_data_frame, when trying to extract the
_mps_indication.channel from list of channel_params_t returned by
lora_phy->get_phy_channels.
2021-07-27 21:09:39 +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
Jaeden Amero 0a944f0ac4 test: lorawanstack: Use valid message type
We previously made up an invalid message type, which was roughly
`MCPS_MULTICAST | 0x40`. This causes an MBED_ASSERT failure in the
handle_rx function, as it uses an assert to validate the message type
passed to it (in convert_to_msg_flag()). Use the valid message type
MCPS_MULTICAST instead in the handle_rx unit test.
2021-07-27 10:28:12 +01:00
Robert Walton 07aefbc6bc unittests: Test_LoRaWANTimer.start: Fix test failure
We weren't initialising the mocks correctly, so an MBED_ASSERT failed in
`LoRaWANTimer::start` because the "timer_id" was not set.
2021-07-27 10:28:12 +01:00
Jaeden Amero b17ffaa68a cmake: Remove trailing whitespace
Remove trailing whitespace from lorawantimer's CMakeLists.txt.
2021-07-22 15:41:06 +01:00
Rajkumar Kanagaraj 86737bdb89 Remove mbed-headers-connectivity
Moved all the headers out of mbed-headers-connectivity, and these changes remove
that headers lib reference from lorawan and cellular unit tests
2021-07-21 01:56:29 -07:00
Hari Limaye db2042755c Unit tests: Make lorawan test header dependencies explicit
To quote @LDong-Arm - "The CMake target `mbed-headers` brings in all
headers, and we are gradually moving away from it and explicitly use
only headers needed by each unit test."
2021-07-14 15:27:30 +01:00
Rajkumar Kanagaraj ef7699d824 CMake: Update netsocket, lorawan unittest to use mbed-stubs-mbedtls
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.
2021-07-12 07:18:41 -07:00
Rajkumar Kanagaraj 66019cb80e CMake: Move mbedtls stubs to the mbedtls dir
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.
2021-07-12 07:18:41 -07:00
Rajkumar Kanagaraj 46d4247b58 CMake: Move lorawan stub headers to the lorawan/tests/UNITTESTS/double dir
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
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 728e183205 CMake: unit-tests: Make lorawan stub only depend on headers it uses
Previously the connectivity lorawan 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-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 8d7d173bb0 CMake: Update lorawan unittest to use mbed-headers-lorawan lib
Update lorawan unit test to link only with a mbed-headers-lorawan
library that it depends on instead of link with mbed-headers
which is a group of headers libraries.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 8c580489f6 CMake: unit-tests: Add mbed-headers-lorawan headers library
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.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj fee7906b0c CMake: Update lorawan unittest to use mbed-stubs-lorawan
Update lorawan unit test to link only with a mbed-stubs-lorawan
library that it depends on instead of link with mbed-stubs
which is a group of stubs libraries.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj 8f238f13b1 CMake: Move lorawan stubs to the lorawan dir
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.
2021-07-02 05:06:09 -07:00
Rajkumar Kanagaraj ee67310922 CMake: unit-tests: Add mbed-headers-cellular headers library
- 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
2021-06-30 06:01:42 -07: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 2dcd6c026d
Merge pull request #14767 from ghseb/early-test-skip
connectivity tests: early skip fix
2021-06-14 12:06:59 +02:00
Sebastian Stockhammer 3bee4917bb Early test skip
Adding mbed-os subdirectories that are not required for a specific project to .mbedignore is a good way to reduce compilation time. Sometimes it happens that tests depend on ignored files, which causes the test-build to fail even though the corresponding feature/component
is not configured. The reason is that the conditional that skips the test is placed after the includes.
2021-06-14 10:46:14 +02:00
Robert Walton a0befae2d4 CMake: Only build unit tests if Mbed OS is the current project
Typically when adding a unit test directory to a CMake project a check
will be used to ensure the subdirectory is added only if the following
are true:

* The BUILD_TESTING option is set to ON.
* The current CMake project is the top-level project.

The reason being, if a downstream project includes our project they
generally don't want to build our unit tests.

In mbed-os, we do correctly specify the above condition before adding
the central UNITTEST subdirectory, which fetches googletest and adds the
"stub" libraries the unit tests depend on. However, we only check if
CMAKE_CROSSCOMPILING is OFF (or undefined) before actually adding the
unit tests. This mismatched logic would lead to unexpected build
failures in various scenarios. One likely case could be: a downstream
project including mbed-os happens to set CMAKE_CROSSCOMPILING to
OFF/undefined for any reason (possibly to build its own unit tests).
mbed-os would go ahead and attempt to build its tests without fetching
googletest or adding the required stub targets.

To fix the issue replace the check for CMAKE_CROSSCOMPILING in the unit
tests with the same BUILD_TESTING idiom we use for adding the central
UNITTESTS subdirectory.
2021-06-10 23:34:14 +01:00
Martin Kojtal bc7fc2b2e7
Merge pull request #14708 from Patater/fix-test-function-return
test: Fix function does not return a value warnings
2021-05-31 12:20:00 +02:00
Jaeden Amero 7f7571657e test: Fix function does not return a value warnings
Many test stub functions are meant to return a value, but weren't. Clang
would generate a warning for each instance where we weren't returning
anything in a function that was meant to return a value.

    warning: non-void function does not return a value [-Wreturn-type]

For a specific example, my_radio::time_on_air() is supposed to return a
uint32_t, but wasn't returning anything. We'll return a zero instead of
relying on undefined behavior.

Without this, clang 11.0.1 was generating a virtual function
implementation with a `ud2` instruction to abort at run-time, causing
some execution of some unit tests to abort.

    Running main() from gmock_main.cc
    [==========] Running 10 tests from 1 test suite.
    [----------] Global test environment set-up.
    [----------] 10 tests from Test_LoRaPHYUS915
    [ RUN      ] Test_LoRaPHYUS915.constructor
    [       OK ] Test_LoRaPHYUS915.constructor (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.restore_default_channels
    [       OK ] Test_LoRaPHYUS915.restore_default_channels (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.rx_config
    [       OK ] Test_LoRaPHYUS915.rx_config (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.tx_config
    Process 35669 stopped
    * thread #1, name = 'lorawan-loraphy-', stop reason = signal SIGILL: privileged instruction
        frame #0: 0x0000000000276f73 lorawan-loraphy-us915-unittest`my_radio::time_on_air(this=0x0000000800c2b048, modem=MODEM_LORA, pkt_len='\0') at Test_LoRaPHYUS915.cpp:90:5
       87       };
       88
       89       virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len)
    -> 90       {
       91       };
       92
       93       virtual bool perform_carrier_sense(radio_modems_t modem,
    (lldb) disassemble --pc
    lorawan-loraphy-us915-unittest`my_radio::time_on_air:
    ->  0x276f73 <+67>: ud2
        0x276f75:       int3
        0x276f76:       int3
        0x276f77:       int3
    (lldb)
2021-05-27 09:38:18 +01: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 bf4ec4a290 CMake: Refactor lorawan unittest cmake
- Add CMakeLists.txt file to all lorawan test suite
2021-05-11 02:29:56 -07:00
Rajkumar Kanagaraj ba04c1cf76 CMake: Add add_subdirectory of unittests
- add every libraries unittest directory into respective CMake
  which allows to include unittest source into build based on
  MBED_BUILD_UNITTESTS flag
2021-05-11 02:29:56 -07:00
jeromecoutant b63ca7c800 STM32WL: update "lora.max-sys-rx-error" 2021-03-29 09:25:25 +02:00
Martin Kojtal 9e0495a770
LoRaWANTimer: add new line at the end of the file 2021-03-12 08:24:16 +00:00
Vincent Coubard 9781418e31 Lora: Clear callback ID when timer callback is executed. 2021-03-11 21:00:43 +00:00
Vincent Coubard 4885739c4e Lora: Add clear method to LoRaWANTimer.
This function must be called by the callback registered in init.
It clears the timer_id to prevent abusive use of the stop methods on expired timer.
2021-03-11 20:59:45 +00:00
jeromecoutant 7baae39ece STM32WL LORA : enable connectivity test 2021-02-09 11:56:50 +01:00
Ludovic Champsaur 08050839d5 STM32WL LORA : lorawan update 2021-02-09 11:56:41 +01:00
Martin Kojtal 733975220d
Merge pull request #14228 from ARMmbed/rename_greentea_test_macro
CMake: rename greentea test macro
2021-02-03 14:17:20 +00:00
Rajkumar Kanagaraj 6824b14e48 CMake: rename greentea test macro 2021-02-02 07:43:40 -08:00
jeromecoutant dd602689d2 LoraRadio test update for baremetal support 2021-01-26 14:47:56 +01:00
Hugues Kamba 9985392c09 CMake: Add support for LoRaWAN Greentea test
The LoRaWAN Greentea test can now be built with CMake.
2021-01-14 17:35:16 +00:00
Hugues Kamba 5616537c3a CMake: Add MbedTLS dependency to LoRaWAN library
This way applications that need LoRaWAN do need to also add MbedTLS
2021-01-14 17:32:00 +00:00
jeromecoutant c3664d2339 LORA: update test 2021-01-12 11:42:06 +01:00
jeromecoutant 80aa710a48 LORA-DRIVER: add pins in json configuration 2021-01-12 11:42:04 +01:00
Hugues Kamba 794e32df74 CMake: Use relative paths to list source files and directories
The absolute path is still required for listing linker
files as they are referenced from a function in the top
level CMake input source file.
2020-11-09 12:32:30 +00:00
Hugues Kamba bf84a5b329 CMake: Rename CMake targets
* mbed-os renamed mbed-core
* mbed-os-<COMPONENT> renamed mbed-<COMPONENT>
2020-11-06 17:25:22 +00:00
Hugues Kamba fa98689639 CMake: Componentize Mbed OS into multiple CMake targets (#13732)
Aside from the core mbed-os CMake target, a number of targets have been created so they can optionally be included by application executables that require them using `target_link_libraries()`.

Co-authored-by: Martin Kojtal <martin.kojtal@arm.com>
Co-authored-by: Rajkumar Kanagaraj <rajkumar.kanagaraj@arm.com>
2020-11-06 17:25:21 +00:00
Hugues Kamba 67a20580cf CMake: Fix build failure due to lora, cryptocell, and nfc dirs move 2020-11-06 17:25:19 +00:00
Rajkumar Kanagaraj 07511d39b1 Fix UNITTESTS build failure 2020-08-14 12:32:50 +01:00
Ashok Rao 9977da64af Incorporating review comments 2020-08-12 11:18:39 +01:00
Ashok Rao 0c584dfd58 Following 2 changes as part of this commit:
1. Moving lora drivers from \components\lora to \connectivity\drivers\lora
    2. Incorporating review comments.
2020-08-12 11:18:39 +01:00