diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index ce1e5ec..3f381ba 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -48,13 +48,10 @@ . ) -add_subdirectory(connectivity) - add_library(mbed-stubs INTERFACE) target_link_libraries(mbed-stubs INTERFACE - mbed-stubs-connectivity mbed-stubs-drivers mbed-stubs-events mbed-stubs-hal diff --git a/UNITTESTS/stubs/connectivity/CMakeLists.txt b/UNITTESTS/stubs/connectivity/CMakeLists.txt deleted file mode 100644 index df8dbd5..0000000 --- a/UNITTESTS/stubs/connectivity/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -add_library(mbed-stubs-connectivity) - -target_compile_definitions(mbed-stubs-connectivity - PRIVATE - DEVICE_SERIAL=1 - DEVICE_INTERRUPTIN=1 - MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 - MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION=true - MBED_CONF_LORA_AUTOMATIC_UPLINK_MESSAGE=true - MBED_CONF_LORA_TX_MAX_SIZE=255 - MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32 - MDMTXD=NC - MDMRXD=NC -) - -target_sources(mbed-stubs-connectivity - PRIVATE - ip4tos_stub.c - stoip4_stub.c -) - -target_link_libraries(mbed-stubs-connectivity - PRIVATE - mbed-headers - mbed-stubs-headers - mbed-stubs-rtos - mbed-stubs-platform - gtest -) diff --git a/UNITTESTS/stubs/connectivity/ip4tos_stub.c b/UNITTESTS/stubs/connectivity/ip4tos_stub.c deleted file mode 100644 index c45c138..0000000 --- a/UNITTESTS/stubs/connectivity/ip4tos_stub.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "common_functions.h" -#include "ip4string.h" - -static void ipv4_itoa(char *string, uint8_t byte); - -uint_fast8_t ip4tos(const void *ip4addr, char *p) -{ - return 0; -} - -static void ipv4_itoa(char *string, uint8_t byte) -{ -} diff --git a/UNITTESTS/stubs/connectivity/stoip4_stub.c b/UNITTESTS/stubs/connectivity/stoip4_stub.c deleted file mode 100644 index 9cb8036..0000000 --- a/UNITTESTS/stubs/connectivity/stoip4_stub.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "common_functions.h" -#include "ip4string.h" - -/** - * Convert numeric IPv4 address string to a binary. - * \param ip4addr IPv4 address in string format. - * \param len Length of IPv4 string, maximum of 16.. - * \param dest buffer for address. MUST be 4 bytes. - * \return boolean set to true if conversion succeded, false if it didn't - */ -bool stoip4(const char *ip4addr, size_t len, void *dest) -{ - return true; -} diff --git a/connectivity/CMakeLists.txt b/connectivity/CMakeLists.txt index 68a16b1..9d75d3b 100644 --- a/connectivity/CMakeLists.txt +++ b/connectivity/CMakeLists.txt @@ -42,4 +42,5 @@ add_subdirectory(lorawan) add_subdirectory(netsocket) add_subdirectory(mbedtls) + add_subdirectory(libraries) endif() diff --git a/connectivity/libraries/CMakeLists.txt b/connectivity/libraries/CMakeLists.txt index 18ce713..7d856fa 100644 --- a/connectivity/libraries/CMakeLists.txt +++ b/connectivity/libraries/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + add_subdirectory(tests/UNITTESTS) +endif() + add_subdirectory(mbed-coap) add_subdirectory(nanostack-libservice) add_subdirectory(ppp) diff --git a/connectivity/libraries/tests/UNITTESTS/.mbedignore b/connectivity/libraries/tests/UNITTESTS/.mbedignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/connectivity/libraries/tests/UNITTESTS/.mbedignore @@ -0,0 +1 @@ +* diff --git a/connectivity/libraries/tests/UNITTESTS/CMakeLists.txt b/connectivity/libraries/tests/UNITTESTS/CMakeLists.txt new file mode 100644 index 0000000..b632a73 --- /dev/null +++ b/connectivity/libraries/tests/UNITTESTS/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(doubles) diff --git a/connectivity/libraries/tests/UNITTESTS/doubles/CMakeLists.txt b/connectivity/libraries/tests/UNITTESTS/doubles/CMakeLists.txt new file mode 100644 index 0000000..f2b9b91 --- /dev/null +++ b/connectivity/libraries/tests/UNITTESTS/doubles/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-nanostack-libservice) + +target_sources(mbed-stubs-nanostack-libservice + PRIVATE + ip4tos_stub.c + stoip4_stub.c +) + +target_link_libraries(mbed-stubs-nanostack-libservice + PRIVATE + mbed-stubs-rtos-headers + mbed-headers + mbed-stubs-headers + mbed-stubs-rtos + mbed-stubs-platform + gtest +) diff --git a/connectivity/libraries/tests/UNITTESTS/doubles/ip4tos_stub.c b/connectivity/libraries/tests/UNITTESTS/doubles/ip4tos_stub.c new file mode 100644 index 0000000..c45c138 --- /dev/null +++ b/connectivity/libraries/tests/UNITTESTS/doubles/ip4tos_stub.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "common_functions.h" +#include "ip4string.h" + +static void ipv4_itoa(char *string, uint8_t byte); + +uint_fast8_t ip4tos(const void *ip4addr, char *p) +{ + return 0; +} + +static void ipv4_itoa(char *string, uint8_t byte) +{ +} diff --git a/connectivity/libraries/tests/UNITTESTS/doubles/stoip4_stub.c b/connectivity/libraries/tests/UNITTESTS/doubles/stoip4_stub.c new file mode 100644 index 0000000..9cb8036 --- /dev/null +++ b/connectivity/libraries/tests/UNITTESTS/doubles/stoip4_stub.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "common_functions.h" +#include "ip4string.h" + +/** + * Convert numeric IPv4 address string to a binary. + * \param ip4addr IPv4 address in string format. + * \param len Length of IPv4 string, maximum of 16.. + * \param dest buffer for address. MUST be 4 bytes. + * \return boolean set to true if conversion succeded, false if it didn't + */ +bool stoip4(const char *ip4addr, size_t len, void *dest) +{ + return true; +}