From d9548419839982b6ef3b480b1658b946acebef12 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Tue, 14 Sep 2021 15:47:14 +0100 Subject: [PATCH 1/6] memap.py: Allow .a extension for Arm Compiler-generated libraries The most common extension for static libraries is .a and CMake generates it with both GCC and Arm toolchains. Mbed CLI 1 generates .ar files with the Arm Compiler, but since Mbed CLI 2 uses memap.py to generate map files too, both extensions should be permitted. This fixes a warning when building greentea tests: Malformed input found when parsing ARMCC map: _deps/greentea-client-build/libclient_userio.a(greentea_test_env.o) Malformed input found when parsing ARMCC map: _deps/greentea-client-build/libclient_userio.a(greentea_test_env.o) Malformed input found when parsing ARMCC map: _deps/greentea-client-build/libclient_userio.a(greentea_test_env.o) ... which repeats over 30 times per test. --- tools/memap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/memap.py b/tools/memap.py index 2a0a90a596..42f3a5ad94 100644 --- a/tools/memap.py +++ b/tools/memap.py @@ -247,7 +247,7 @@ class _GccParser(_Parser): class _ArmccParser(_Parser): RE = re.compile( r'^\s+0x(\w{8})\s+0x(\w{8})\s+(\w+)\s+(\w+)\s+(\d+)\s+[*]?.+\s+(.+)$') - RE_OBJECT = re.compile(r'(.+\.(l|ar))\((.+\.o(bj)?)\)') + RE_OBJECT = re.compile(r'(.+\.(l|a|ar))\((.+\.o(bj)?)\)') OBJECT_EXTENSIONS = (".o", ".obj") def parse_object_name(self, line): From c01d417ed49bf5b8e4d4f81800b4852d4b299c3e Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Mon, 13 Sep 2021 11:13:42 +0100 Subject: [PATCH 2/6] CMake: connectivity: Unify checks for unit and greentea tests Subdirectories should always be included in the CMake "all" target when building any tests, either unit tests or greentea tests. --- connectivity/CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/connectivity/CMakeLists.txt b/connectivity/CMakeLists.txt index dcf9b48c36..1e7d5ecb52 100644 --- a/connectivity/CMakeLists.txt +++ b/connectivity/CMakeLists.txt @@ -24,7 +24,15 @@ add_library(mbed-nfc INTERFACE) add_library(mbed-ppp INTERFACE) add_library(mbed-wifi INTERFACE) -if(${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + # Add these subdirectories for tests + add_subdirectory(cellular) + add_subdirectory(FEATURE_BLE) + add_subdirectory(libraries) + add_subdirectory(lorawan) + add_subdirectory(mbedtls) + add_subdirectory(netsocket) +else() # The directories below contain optional target libraries add_subdirectory(FEATURE_BLE EXCLUDE_FROM_ALL) add_subdirectory(cellular EXCLUDE_FROM_ALL) @@ -36,12 +44,4 @@ if(${CMAKE_CROSSCOMPILING}) add_subdirectory(nanostack EXCLUDE_FROM_ALL) add_subdirectory(netsocket EXCLUDE_FROM_ALL) add_subdirectory(nfc EXCLUDE_FROM_ALL) -else() - # Add these subdirectories for the Unit test - add_subdirectory(cellular) - add_subdirectory(lorawan) - add_subdirectory(netsocket) - add_subdirectory(mbedtls) - add_subdirectory(libraries) - add_subdirectory(FEATURE_BLE) endif() From db8852c5d8f203848317f53f82037be3cf267479 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Thu, 16 Sep 2021 16:37:32 +0100 Subject: [PATCH 3/6] CMake: connectivity: Guard unit test directories When unit tests or unit test stubs get added as CMake targets, they becomes part of the "all" target and get compiled when building the whole project. When building greentea tests we need to disable unit tests and stubs to avoid unnecessary compilation and errors. --- connectivity/FEATURE_BLE/CMakeLists.txt | 4 +++- connectivity/libraries/CMakeLists.txt | 4 +++- connectivity/mbedtls/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/connectivity/FEATURE_BLE/CMakeLists.txt b/connectivity/FEATURE_BLE/CMakeLists.txt index 1e9da9185a..fbd35db9af 100644 --- a/connectivity/FEATURE_BLE/CMakeLists.txt +++ b/connectivity/FEATURE_BLE/CMakeLists.txt @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(NOT BUILD_GREENTEA_TESTS) + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(libraries) diff --git a/connectivity/libraries/CMakeLists.txt b/connectivity/libraries/CMakeLists.txt index 7d856fa25c..21af84b317 100644 --- a/connectivity/libraries/CMakeLists.txt +++ b/connectivity/libraries/CMakeLists.txt @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(NOT BUILD_GREENTEA_TESTS) + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(mbed-coap) diff --git a/connectivity/mbedtls/CMakeLists.txt b/connectivity/mbedtls/CMakeLists.txt index f000967e33..7bacaa6d97 100644 --- a/connectivity/mbedtls/CMakeLists.txt +++ b/connectivity/mbedtls/CMakeLists.txt @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(NOT BUILD_GREENTEA_TESTS) + add_subdirectory(tests/UNITTESTS) + endif() endif() target_include_directories(mbed-mbedtls From ce1f054bd3c966d6b6e09ba6ac3e43c11c03e37f Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Mon, 13 Sep 2021 12:01:36 +0100 Subject: [PATCH 4/6] CMake: connectivity: Add drivers subdirectory for tests Greentea tests run on microcontrollers, so any required drivers need to be available and built. Note: Even though unit tests do not require drivers, for ease of maintenance there's no need to exclude those drivers when building unit tests because a driver only gets enabled when the Mbed target matches. --- connectivity/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/connectivity/CMakeLists.txt b/connectivity/CMakeLists.txt index 1e7d5ecb52..b2b6fa2b35 100644 --- a/connectivity/CMakeLists.txt +++ b/connectivity/CMakeLists.txt @@ -27,6 +27,7 @@ add_library(mbed-wifi INTERFACE) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) # Add these subdirectories for tests add_subdirectory(cellular) + add_subdirectory(drivers) add_subdirectory(FEATURE_BLE) add_subdirectory(libraries) add_subdirectory(lorawan) From cbec61adb5934839afcd3310a56baa9b0c31f6ec Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Mon, 20 Sep 2021 17:02:49 +0100 Subject: [PATCH 5/6] targets: Declare DISCO_L475VG_IOT01A's built-in M24SR NFC --- targets/targets.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/targets.json b/targets/targets.json index e66c4c73d7..934d9286e4 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3761,7 +3761,8 @@ ], "extra_labels_add": [ "CORDIO", - "MX25R6435F" + "MX25R6435F", + "M24SR" ], "supported_form_factors": [ "ARDUINO_UNO" From 58f83597b4cf40149d68b760fc11e94fb393a65e Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Mon, 20 Sep 2021 17:14:06 +0100 Subject: [PATCH 6/6] CMake: greentea: Migrate the NFC EEPROM test to CTest --- connectivity/CMakeLists.txt | 1 + connectivity/nfc/CMakeLists.txt | 6 ++++++ connectivity/nfc/tests/TESTS/CMakeLists.txt | 4 ++++ .../nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt | 17 ++++++++--------- 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 connectivity/nfc/tests/TESTS/CMakeLists.txt diff --git a/connectivity/CMakeLists.txt b/connectivity/CMakeLists.txt index b2b6fa2b35..1a3bfd41c4 100644 --- a/connectivity/CMakeLists.txt +++ b/connectivity/CMakeLists.txt @@ -33,6 +33,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(lorawan) add_subdirectory(mbedtls) add_subdirectory(netsocket) + add_subdirectory(nfc) else() # The directories below contain optional target libraries add_subdirectory(FEATURE_BLE EXCLUDE_FROM_ALL) diff --git a/connectivity/nfc/CMakeLists.txt b/connectivity/nfc/CMakeLists.txt index b8098066ae..a1c48ac045 100644 --- a/connectivity/nfc/CMakeLists.txt +++ b/connectivity/nfc/CMakeLists.txt @@ -3,6 +3,12 @@ add_subdirectory(libraries) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + if(BUILD_GREENTEA_TESTS) + add_subdirectory(tests/TESTS) + endif() +endif() + target_include_directories(mbed-nfc INTERFACE . diff --git a/connectivity/nfc/tests/TESTS/CMakeLists.txt b/connectivity/nfc/tests/TESTS/CMakeLists.txt new file mode 100644 index 0000000000..c146e3a675 --- /dev/null +++ b/connectivity/nfc/tests/TESTS/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(nfc/eeprom) diff --git a/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt b/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt index f57d64918b..0acf6fa0ed 100644 --- a/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt +++ b/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt @@ -1,20 +1,19 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) +include(mbed_greentea) -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-connectivity-nfc-eeprom) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +if(NOT "MBED_CONF_NFCEEPROM=1" IN_LIST MBED_CONFIG_DEFINITIONS) + set(TEST_SKIPPED "NFC EEPROM required") +endif() mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-connectivity-nfc-eeprom TEST_SOURCES main.cpp TEST_REQUIRED_LIBS mbed-nfc + TEST_SKIPPED + ${TEST_SKIPPED} )