Commit Graph

81 Commits (master)

Author SHA1 Message Date
Lukas Karel 46e8545b55 reduce spam on info log of cellular sockets 2024-07-11 15:22:48 +02:00
David Alonso de la Torre 9e7e22dd2c Fix AT_CellularSMS::list_messages breaking in text mode when CRLF is contained in SMS payload text
When parsing SMS, it can happen that we receive CRLF in the SMS payload (happened to me when receiving provider texts).
As an example, we can receive:

"""
Hello <CR><LF>
World!
"""

With previous implementation, second consume_to_stop_tag was stopping in <CR><LF> and rest of the code was failing for obvious reasons.
With this commit we consume the full payload as bytes.
2024-05-11 10:42:46 +02:00
David Alonso de la Torre d676084600 Increase AT timeout to 10s in AT_CellularSMS::get_sms
When SMS list is big and baudrate is not fast enough, with default timeout we can suffer from timeout error while getting a sms because method is parsing the full list and this takes long.
2024-04-05 16:46:05 +02:00
David Alonso de la Torre 5c49f161fb Increase AT timeout to 10s in AT_CellularSMS::send_sms
For some devices sending can be slow (as an example see SIM800, it can be up to 60s), command is being run properly but default timeout is returning an invalid error.
See https://www.elecrow.com/wiki/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf
2024-04-05 16:45:59 +02:00
Martin Kojtal b3a5d6a473
Merge pull request #15454 from world-direct/feature/cellularevents
make cellular event queue size configurable
2023-09-14 11:23:48 +02:00
Lukas Karel ab46d51253 make cellular event queue size configurable
update unit tests
2023-09-13 15:11:07 +02:00
Saeed Kazemi 19fddbf01a
Fix missing GLOBAL_UP callback on successful connect
Fix an issue where CellularContext::do_connect_with_retry() does not call NSAPI_STATUS_GLOBAL_UP callback and validate_ip_address() on successful connect after failed try in blocking mode.
2022-07-25 09:25:36 +02:00
Saeed Kazemi 63dc2fd550
Fix missing GLOBAL_UP callback on successful connect
Fix an issue where CellularContext::do_connect_with_retry() does not call NSAPI_STATUS_GLOBAL_UP callback on successful connect after failed try in blocking mode.
2022-07-22 17:01:39 +02:00
tobi15 73f2dd6379 modify method signatures to pass astyle tests 2022-05-10 14:27:54 +02:00
tobi15 d720db5bc8 modify AT_CellularDevice_stub to pass test with the new feature 2022-04-21 17:29:10 +02:00
merge 337b811ba1 add the possibility to customize the delimiter of the ATHandler in ATCellularDevice class 2022-04-20 14:21:31 +02:00
Bora Özgen 7523588035 NetworkStack: Remove stub implementations of socket_x_control
As a default implementation is already provided by
NetworkStack, stub implementations in the child classes
are not required. Furthermore, they return unsupported for
all cases instead of redirecting to the non-control API,
which is plainly wrong.
2021-10-21 10:33:13 +02:00
mateusz.kalinowski ec3f4379d9 Code improvements for the unresolved comments
This patch contains improvements mentioned in the unresolved PR
comments:
- function names were changed from socket_sendmsg/socket_recvmsg to
  socket_sendto_control/socket_recvfrom_control.
- default implementation of this functions was provided in the
  NetworkStack class.
- MsgHeaderIterator accesses elements on the aligned addresses.
2021-09-03 12:49:00 +01:00
Tymoteusz Bloch bdfd98e764 New feature: send/recv message implementation added to network stack 2021-09-01 09:13:57 +01:00
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
Lingkai Dong 44cd64a3e4 Unit tests: Fix style in cellular myCellularContext.h stub 2021-08-02 13:47:57 +01:00
Lingkai Dong 57dd6812c3 Unit tests: Move cellular target_h stubs
We move test-specific files from the top-level UNITTESTS directory
into individual components' UNITTESTS/doubles subdirectories.
2021-08-02 13:47:57 +01:00
Robert Walton 2e75d184b6 unittests: Remove ATHandler test interdependencies
Some tests in athandlertest.cpp relied on the state of stubs set in
previous tests. This caused test failures if the tests cases were ran in
isolation. Remove the interdependencies between tests by setting stub
values in the tests that rely on them.
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
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
Martin Kojtal 2181d7cc77
Merge pull request #14924 from ARMmbed/refactor_cellular_unittest
Refactor cellular unittest CMake
2021-07-20 10:09:57 +02:00
Rajkumar Kanagaraj f32a3cbeb7 CMake: Limit cellular device cmake to use mocks/sources what it depends
Update cellular device unit tests CMake depends on a mock, which is
required for the test instead of depending on the group of mbed-stubs,
mbed-headers, mbed_stub_headers, libraries.
Limit the cellular context unit test CMake target_sources to keep only
required sources
2021-07-15 06:27:28 -07:00
Rajkumar Kanagaraj 27bfa906c6 CMake: Limit cellular common unit tests to use mocks what it depends
Update cellular common unit tests CMake depends on a mock, which is
required for the test instead of depending on the group of
mbed-headers libraries.
2021-07-15 06:25:50 -07:00
Rajkumar Kanagaraj 6cf1211b3a CMake: Limit at cellular unittest to use mock what it depends
Update AT cellular unit tests CMake depends on a mock, which is required
for the test instead of depending on the group of mbed-stubs,
mbed-headers, mbed_stub_headers, libraries.
2021-07-15 06:17:07 -07:00
Paul Szczepanek a8982ca06e AT command fix - hex string shouldn't be quoted on bc95 2021-07-14 21:43:53 +01:00
Rajkumar Kanagaraj 22b2e9f800 CMake: Add mbed-headers-nanostack-libservice 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.
2021-07-13 05:49:53 -07:00
Rajkumar Kanagaraj bb3cd37a5e CMake: Remove mbed-stubs-rtos-headers 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
2021-07-08 07:14:56 -07:00
Martin Kojtal feb48fca2b
Merge pull request #14873 from ARMmbed/move_connectivity_netsocket_stubs
Move connectivity netsocket stubs
2021-07-07 17:45:47 +02:00
Jaeden Amero 8287c5221b
Merge pull request #14773 from rwalton-arm/move_platform_stub
Move mbed-stubs-platform to the platform directory
2021-07-07 16:33:35 +01:00
Jaeden Amero dc6dd17bb0
Merge pull request #14884 from LDong-Arm/rm_UNITTEST_macro
Remove the `UNITTEST` macro from production code
2021-07-07 15:20:31 +01:00
Martin Kojtal fea4e928d0
Merge pull request #14835 from ARMmbed/move_stubs_cellular_headers
Move stubs cellular headers
2021-07-07 11:29:37 +02:00
Rajkumar Kanagaraj ef0e3f99e4 CMake: Move netsocket stub headers to the netsocket doubles dir
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.
2021-07-07 01:33:36 -07:00
Rajkumar Kanagaraj 68b46f6199 CMake: Add mbed-headers-netsocket headers library
- 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.
2021-07-07 01:33:36 -07:00
Rajkumar Kanagaraj cb343f9ba9 CMake: Update netsocket, cellular unittest to use mbed-stubs-netsocket
Update netsocket and cellular unit tests to link with a mbed-stubs-netsocket
library that it depends on instead of link with mbed-stubs
which is a group of stubs libraries.
2021-07-07 01:33:36 -07:00
Lingkai Dong 3a24305916 rtos: Remove UNITTEST macro from rtos
Production code should not contain any test-specific checks. Rather
than checking `UNITTEST`, unit tests can directly set
`MBED_CONF_RTOS_PRESENT=1` to make RTOS available for testing.

Note: The cellular ATHandler test also has `MBED_CONF_RTOS_PRESENT=1`
added because `ATHandler.cpp` contains a check of this variable.
2021-07-06 16:50:49 +01:00
Robert Walton 021baa68e7 CMake: unit-tests: Split platform headers out of mbed-stubs-headers
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.
2021-07-06 13:50:46 +01:00
Lingkai Dong 7c74d31c57 Unit tests: Create mbed-headers-filesystem
Create a CMake target mbed-headers-filesystem to separate FileSystem
headers from the generic mbed-headers-storage. Update tests to use it.
2021-07-02 16:25:43 +01:00
Rajkumar Kanagaraj a60869da85 CMake: Move cellular stub headers to the cellular/tests/UNITTESTS/double dir
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
2021-07-02 06:30:32 -07:00
Rajkumar Kanagaraj d8add9e1a1 CMake: unit-tests: Make cellular stub only depend on headers it uses
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.
2021-06-30 06:01:42 -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
Rajkumar Kanagaraj fa0ab53692 CMake: Move connectivity/cellular stubs to the mbed-os/connectivity/cellular dir
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.
2021-06-30 06:01:42 -07:00
Martin Kojtal 8902a0c866
Merge pull request #14819 from ARMmbed/move_rtos_stubs
Move rtos stubs to the rtos directory
2021-06-30 11:49:41 +02:00
Martin Kojtal 16acae3bd0
Merge pull request #14716 from boraozgen/at-handler-buffer-size-config
Cellular: Add AT handler buffer size to configuration
2021-06-29 11:29:48 +02:00
Rajkumar Kanagaraj 8efb322e15 CMake: unit-tests: Update connectivity stubs and their unittests
mbed-stubs-connectivity now depends on the mbed-stubs-rtos and
mbed-stubs-rtos-headers because it requires some headers and sources
which were moved to mbed-stubs-rtos and mbed-stubs-rtos-headers.
2021-06-28 06:31:37 -07:00
Bora Özgen 8705a6a510 Cellular: Add AT handler buffer size to configuration 2021-06-15 15:03:57 +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 8ce03867c2 test: at: Remove dead code
Remove two expressions from at_cellularcontexttest that do nothing. This
fixes the following two warnings.

    connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp:61:67: warning: expression result unused [-Wunused-value]            ATHandler_stub::int_valid_count_table[kRead_int_table_size];                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~^
    connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp:64:66: warning: expression result unused [-Wunused-value]            ATHandler_stub::read_string_table[kRead_string_table_size];
2021-05-27 09:38:18 +01: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