From 5e7f992575c4a31f4b31b640525c3098d5b4333d Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Mon, 15 Feb 2021 03:18:12 -0800 Subject: [PATCH 01/13] CMake : Refactor Mbed OS UNITTESTS - Created a CMake stubs library. - Created CMake fake watchdog and PWM out the library. - Added CMakeLists in Watchdog and PWM unittest to build with the respective watchdog and PWM fake library. --- UNITTESTS/fakes/drivers/CMakeLists.txt | 11 + UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt | 19 ++ .../fakes/drivers/watchdog/CMakeLists.txt | 20 ++ UNITTESTS/stubs/CMakeLists.txt | 203 ++++++++++++++++++ drivers/tests/CMakeLists.txt | 22 ++ drivers/tests/UNITTESTS/CMakeLists.txt | 11 + drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt | 27 +++ .../tests/UNITTESTS/Watchdog/CMakeLists.txt | 28 +++ tools/cmake/mbed_unittest.cmake | 79 +++++++ 9 files changed, 420 insertions(+) create mode 100644 UNITTESTS/fakes/drivers/CMakeLists.txt create mode 100644 UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt create mode 100644 UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt create mode 100644 UNITTESTS/stubs/CMakeLists.txt create mode 100644 drivers/tests/CMakeLists.txt create mode 100644 drivers/tests/UNITTESTS/CMakeLists.txt create mode 100644 drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt create mode 100644 drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt create mode 100644 tools/cmake/mbed_unittest.cmake diff --git a/UNITTESTS/fakes/drivers/CMakeLists.txt b/UNITTESTS/fakes/drivers/CMakeLists.txt new file mode 100644 index 00000000000..7ebc77c7523 --- /dev/null +++ b/UNITTESTS/fakes/drivers/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +include(${MBED_PATH}/tools/cmake/mbed_unittest.cmake) + +list(APPEND MBED_ADD_UNITTEST_SUBDIRS + PwmOut + watchdog +) + +mbed_add_all_subdirectories("${MBED_ADD_UNITTEST_SUBDIRS}") diff --git a/UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt b/UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt new file mode 100644 index 00000000000..f45ed5c36c0 --- /dev/null +++ b/UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-fakes-drivers-pwmout) + +target_compile_definitions(mbed-fakes-drivers-pwmout + PRIVATE + DEVICE_PWMOUT +) + +target_sources(mbed-fakes-drivers-pwmout + PRIVATE + ${MBED_PATH}/drivers/source/PwmOut.cpp +) + +target_link_libraries(mbed-fakes-drivers-pwmout + PRIVATE + mbed-headers +) diff --git a/UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt b/UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt new file mode 100644 index 00000000000..5fd5a7c6e62 --- /dev/null +++ b/UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-fakes-drivers-watchdog) + +target_compile_definitions(mbed-fakes-drivers-watchdog + PRIVATE + DEVICE_WATCHDOG + MBED_WDOG_ASSERT=1 +) + +target_sources(mbed-fakes-drivers-watchdog + PRIVATE + ${MBED_PATH}/drivers/source/Watchdog.cpp +) + +target_link_libraries(mbed-fakes-drivers-watchdog + PRIVATE + mbed-headers +) diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt new file mode 100644 index 00000000000..29ed34fc203 --- /dev/null +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -0,0 +1,203 @@ +# Copyright (c) 2020 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-os-stubs-headers INTERFACE) +add_library(mbed-os-headers INTERFACE) +add_library(mbed-os-headers-base INTERFACE) +add_library(mbed-os-headers-platform INTERFACE) +add_library(mbed-os-headers-connectivity INTERFACE) +add_library(mbed-os-headers-storage INTERFACE) +add_library(mbed-os-headers-drivers INTERFACE) +add_library(mbed-os-headers-hal INTERFACE) +add_library(mbed-os-headers-events INTERFACE) +add_library(mbed-os-headers-rtos INTERFACE) +add_library(mbed-os-stubs) + +target_link_libraries(mbed-os-headers + INTERFACE + mbed-os-headers-base + mbed-os-headers-platform + mbed-os-headers-connectivity + mbed-os-headers-storage + mbed-os-headers-drivers + mbed-os-headers-hal + mbed-os-headers-events + mbed-os-headers-rtos +) + +target_include_directories(mbed-os-headers-platform + INTERFACE + ${MBED_PATH}/platform/include + ${MBED_PATH}/platform/include/platform + ${MBED_PATH}/platform/include/platform/internal + ${MBED_PATH}/platform/mbed-trace/include +) + +target_include_directories(mbed-os-headers-base + INTERFACE + ${MBED_PATH}/UNITTESTS/target_h + ${MBED_PATH}/UNITTESTS/target_h/platform + ${MBED_PATH}/UNITTESTS/target_h/platform/cxxsupport + ${MBED_PATH}/UNITTESTS/target_h/drivers + ${MBED_PATH}/UNITTESTS/target_h/rtos/include +) + +target_include_directories(mbed-os-headers-storage + INTERFACE + ${MBED_PATH}/storage/filesystem/fat/include + ${MBED_PATH}/storage/filesystem/fat/ChaN + ${MBED_PATH}/storage/filesystem/littlefs/include + ${MBED_PATH}/storage/filesystem/littlefsv2/littlefs + ${MBED_PATH}/storage/filesystem/littlefsv2/littlefs/bd + ${MBED_PATH}/storage/filesystem/littlefs/littlefs + ${MBED_PATH}/storage/blockdevice/include + ${MBED_PATH}/storage/filesystem/include + ${MBED_PATH}/storage/kvstore/include + ${MBED_PATH}/storage/kvstore/kv_config + ${MBED_PATH}/storage/kvstore/kv_config/include + ${MBED_PATH}/storage/kvstore/tdbstore/include + ${MBED_PATH}/storage/kvstore/filesystemstore/include + ${MBED_PATH}/storage/kvstore/kvstore_global_api/include +) + +target_include_directories(mbed-os-headers-connectivity + INTERFACE + ${MBED_PATH}/connectivity/libraries/nanostack-libservice + ${MBED_PATH}/connectivity/libraries/nanostack-libservice/mbed-client-libservice + ${MBED_PATH}/connectivity/netsocket/include + ${MBED_PATH}/connectivity/cellular/include/cellular/framework/API + ${MBED_PATH}/connectivity/cellular/include/cellular/framework/AT + ${MBED_PATH}/connectivity/cellular/include/cellular/framework/device + ${MBED_PATH}/connectivity/cellular/include/cellular/framework + ${MBED_PATH}/connectivity/cellular/include/cellular/framework/common + ${MBED_PATH}/connectivity + ${MBED_PATH}/connectivity/lorawan/include/lorawan + ${MBED_PATH}/connectivity/lorawan/lorastack + ${MBED_PATH}/connectivity/lorawan/lorastack/mac + ${MBED_PATH}/connectivity/lorawan/lorastack/phy + ${MBED_PATH}/connectivity/lorawan + ${MBED_PATH}/connectivity/mbedtls + ${MBED_PATH}/connectivity/mbedtls/include + ${MBED_PATH}/connectivity/FEATURE_BLE/include + ${MBED_PATH}/connectivity/FEATURE_BLE/include/ble +) + +target_include_directories(mbed-os-headers-drivers + INTERFACE + ${MBED_PATH}/drivers + ${MBED_PATH}/drivers/include + ${MBED_PATH}/drivers/include/drivers +) + +target_include_directories(mbed-os-headers-events + INTERFACE + ${MBED_PATH}/events/tests/UNITTESTS/target_h + ${MBED_PATH}/events/tests/UNITTESTS/target_h/equeue + ${MBED_PATH}/events/include + ${MBED_PATH}/events/include/events/internal +) + +target_include_directories(mbed-os-headers-hal + INTERFACE + ${MBED_PATH}/hal + ${MBED_PATH}/hal/include +) + +target_include_directories(mbed-os-headers-rtos + INTERFACE + ${MBED_PATH}/rtos/include +) + +target_include_directories(mbed-os-headers + INTERFACE + ${MBED_PATH}/features + ${MBED_PATH}/features/frameworks +) + +target_include_directories(mbed-os-stubs-headers + INTERFACE + ${MBED_PATH}/UNITTESTS/stubs +) + +target_sources(mbed-os-stubs + PUBLIC + #${MBED_PATH}/UNITTESTS/stubs/aes_stub.c + #${MBED_PATH}/UNITTESTS/stubs/AT_CellularContext_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/AT_CellularDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/AT_CellularInformation_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/AT_CellularSMS_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/AT_CellularStack_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/ATHandler_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/BufferedSerial_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/CellularContext_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/CellularDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/CellularInterface_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/CellularStateMachine_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/CellularUtil_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/cipher_stub.c + #${MBED_PATH}/UNITTESTS/stubs/cmac_stub.c + #${MBED_PATH}/UNITTESTS/stubs/ConditionVariable_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/EmulatedSD.cpp + #${MBED_PATH}/UNITTESTS/stubs/equeue_stub.c + #${MBED_PATH}/UNITTESTS/stubs/EventFlags_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/EventQueue_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/FileHandle_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/HeapBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/ip4tos_stub.c + #${MBED_PATH}/UNITTESTS/stubs/Kernel_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/kv_config_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaMacCommand_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaMac_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaPHY_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaWANStack_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/LoRaWANTimer_stub.cpp + ${MBED_PATH}/UNITTESTS/stubs/mbed_assert_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/mbed_atomic_stub.c + ${MBED_PATH}/UNITTESTS/stubs/mbed_critical_stub.c + #${MBED_PATH}/UNITTESTS/stubs/mbed_error.c + #${MBED_PATH}/UNITTESTS/stubs/mbed_poll_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/mbed_retarget_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/mbed_rtos_rtx_stub.c + #${MBED_PATH}/UNITTESTS/stubs/mbed_shared_queues_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/mbed_wait_api_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/MBRBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/MeshInterface_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/Mutex_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/NetworkInterfaceDefaults_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/NetworkInterface_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/NetworkStack_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/nsapi_dns_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/nvic_wrapper_stub.c + #${MBED_PATH}/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp + ${MBED_PATH}/UNITTESTS/stubs/pwmout_api_stub.c + #${MBED_PATH}/UNITTESTS/stubs/randLIB_stub.c + #${MBED_PATH}/UNITTESTS/stubs/randLIB_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/rtx_mutex_stub.c + #${MBED_PATH}/UNITTESTS/stubs/Semaphore_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/SerialBase_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/SocketAddress_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/SocketStats_Stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/stoip4_stub.c + #${MBED_PATH}/UNITTESTS/stubs/ThisThread_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/Thread_stub.cpp + #${MBED_PATH}/UNITTESTS/stubs/us_ticker_stub.cpp + ${MBED_PATH}/UNITTESTS/stubs/watchdog_api_stub.c +) + +target_link_libraries(mbed-os-stubs + PRIVATE + mbed-os-stubs-headers + mbed-os-headers +) diff --git a/drivers/tests/CMakeLists.txt b/drivers/tests/CMakeLists.txt new file mode 100644 index 00000000000..c8e9e99ad57 --- /dev/null +++ b/drivers/tests/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +cmake_minimum_required(VERSION 3.19.0) + +set(PROJECT_NAME mbed-drivers-unittests) + +project(${PROJECT_NAME}) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../ CACHE INTERNAL "") + +include(${MBED_PATH}/tools/cmake/mbed_unittest.cmake) + +mbed_unittest_setup() + +## add mbed-os cmakelists +add_subdirectory(${MBED_PATH}/UNITTESTS/stubs ${CMAKE_CURRENT_BINARY_DIR}/stubs_build) +add_subdirectory(${MBED_PATH}/UNITTESTS/stubs/platform ${CMAKE_CURRENT_BINARY_DIR}/stubs_platform_build) +add_subdirectory(${MBED_PATH}/UNITTESTS/stubs/hal ${CMAKE_CURRENT_BINARY_DIR}/stubs_hal_build) +add_subdirectory(${MBED_PATH}/UNITTESTS/fakes/drivers ${CMAKE_CURRENT_BINARY_DIR}/fakes_build) + +## all directories here will be added +add_subdirectory(UNITTESTS) diff --git a/drivers/tests/UNITTESTS/CMakeLists.txt b/drivers/tests/UNITTESTS/CMakeLists.txt new file mode 100644 index 00000000000..3164ec922b7 --- /dev/null +++ b/drivers/tests/UNITTESTS/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +include(${MBED_PATH}/tools/cmake/mbed_unittest.cmake) + +list(APPEND MBED_ADD_UNITTEST_SUBDIRS + PwmOut + Watchdog +) + +mbed_add_all_subdirectories("${MBED_ADD_UNITTEST_SUBDIRS}") diff --git a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt new file mode 100644 index 00000000000..c0cae09d7f6 --- /dev/null +++ b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME pwmout-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_PWMOUT +) + +target_sources(${TEST_NAME} + PRIVATE + test_pwmout.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-fakes-drivers-pwmout + mbed-stubs-hal + mbed-stubs-platform + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) diff --git a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt new file mode 100644 index 00000000000..59fdcbeac5b --- /dev/null +++ b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME watchdog-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_WATCHDOG + MBED_WDOG_ASSERT=1 +) + +target_sources(${TEST_NAME} + PRIVATE + test_watchdog.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-fakes-drivers-watchdog + mbed-stubs-platform + mbed-stubs-hal + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) diff --git a/tools/cmake/mbed_unittest.cmake b/tools/cmake/mbed_unittest.cmake new file mode 100644 index 00000000000..ac668a1a72c --- /dev/null +++ b/tools/cmake/mbed_unittest.cmake @@ -0,0 +1,79 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +macro( mbed_unittest_setup ) + set(LIB_NAME MbedOS) + + # Setup c++ standard + set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + + if (MINGW) + # enable PRIx formatting globally + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_FORMAT_MACROS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS") + endif (MINGW) + + #################### + # GTEST + #################### + include(FetchContent) + # Download and unpack googletest + if(NOT GTEST_FOUND) + FetchContent_Declare(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.10.0 + ) + FetchContent_MakeAvailable(googletest) + endif() + + # Prevent overriding the parent project's compiler/linker + # settings on Windows + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + + + #################### + # TESTING + #################### + + include(CTest) + + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + "${CMAKE_BINARY_DIR}/Testing" + ) + + #################### + # CODE COVERAGE SETUP + #################### + + if (COVERAGE) + + if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message(WARNING "Non-debug build may result misleading code coverage results.") + endif() + + # Append coverage compiler flags + set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") + + endif(COVERAGE) + + if (VALGRIND) + find_program(MEMORYCHECK_COMMAND valgrind) + endif(VALGRIND) + + #################### + # UNIT TESTS + #################### + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNITTEST") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNITTEST") +endmacro() + +macro( mbed_add_all_subdirectories subdirectories_list ) + foreach(dir ${subdirectories_list}) + if(IS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/${dir}) + add_subdirectory(${dir}) + endif() + endforeach() +endmacro() From 1f27632f97e4c9b42c138d56ee61d92aada489be Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Mon, 15 Feb 2021 05:17:27 -0800 Subject: [PATCH 02/13] Refactor Unittest Stub library --- UNITTESTS/stubs/CMakeLists.txt | 144 ++++-------------- UNITTESTS/stubs/hal/CMakeLists.txt | 15 ++ UNITTESTS/stubs/{ => hal}/pwmout_api_stub.c | 0 UNITTESTS/stubs/{ => hal}/watchdog_api_stub.c | 0 UNITTESTS/stubs/platform/CMakeLists.txt | 25 +++ .../stubs/{ => platform}/mbed_assert_stub.cpp | 0 .../stubs/{ => platform}/mbed_atomic_stub.c | 0 .../stubs/{ => platform}/mbed_critical_stub.c | 0 UNITTESTS/stubs/{ => platform}/mbed_error.c | 0 .../stubs/{ => platform}/mbed_poll_stub.cpp | 0 .../stubs/{ => platform}/mbed_poll_stub.h | 0 .../{ => platform}/mbed_retarget_stub.cpp | 0 .../{ => platform}/mbed_wait_api_stub.cpp | 0 13 files changed, 71 insertions(+), 113 deletions(-) create mode 100644 UNITTESTS/stubs/hal/CMakeLists.txt rename UNITTESTS/stubs/{ => hal}/pwmout_api_stub.c (100%) rename UNITTESTS/stubs/{ => hal}/watchdog_api_stub.c (100%) create mode 100644 UNITTESTS/stubs/platform/CMakeLists.txt rename UNITTESTS/stubs/{ => platform}/mbed_assert_stub.cpp (100%) rename UNITTESTS/stubs/{ => platform}/mbed_atomic_stub.c (100%) rename UNITTESTS/stubs/{ => platform}/mbed_critical_stub.c (100%) rename UNITTESTS/stubs/{ => platform}/mbed_error.c (100%) rename UNITTESTS/stubs/{ => platform}/mbed_poll_stub.cpp (100%) rename UNITTESTS/stubs/{ => platform}/mbed_poll_stub.h (100%) rename UNITTESTS/stubs/{ => platform}/mbed_retarget_stub.cpp (100%) rename UNITTESTS/stubs/{ => platform}/mbed_wait_api_stub.cpp (100%) diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index 29ed34fc203..e69e8e759d2 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -1,31 +1,31 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-os-stubs-headers INTERFACE) -add_library(mbed-os-headers INTERFACE) -add_library(mbed-os-headers-base INTERFACE) -add_library(mbed-os-headers-platform INTERFACE) -add_library(mbed-os-headers-connectivity INTERFACE) -add_library(mbed-os-headers-storage INTERFACE) -add_library(mbed-os-headers-drivers INTERFACE) -add_library(mbed-os-headers-hal INTERFACE) -add_library(mbed-os-headers-events INTERFACE) -add_library(mbed-os-headers-rtos INTERFACE) -add_library(mbed-os-stubs) +add_library(mbed-stubs-headers INTERFACE) +add_library(mbed-headers INTERFACE) +add_library(mbed-headers-base INTERFACE) +add_library(mbed-headers-platform INTERFACE) +add_library(mbed-headers-connectivity INTERFACE) +add_library(mbed-headers-storage INTERFACE) +add_library(mbed-headers-drivers INTERFACE) +add_library(mbed-headers-hal INTERFACE) +add_library(mbed-headers-events INTERFACE) +add_library(mbed-headers-rtos INTERFACE) -target_link_libraries(mbed-os-headers + +target_link_libraries(mbed-headers INTERFACE - mbed-os-headers-base - mbed-os-headers-platform - mbed-os-headers-connectivity - mbed-os-headers-storage - mbed-os-headers-drivers - mbed-os-headers-hal - mbed-os-headers-events - mbed-os-headers-rtos + mbed-headers-base + mbed-headers-platform + mbed-headers-connectivity + mbed-headers-storage + mbed-headers-drivers + mbed-headers-hal + mbed-headers-events + mbed-headers-rtos ) -target_include_directories(mbed-os-headers-platform +target_include_directories(mbed-headers-platform INTERFACE ${MBED_PATH}/platform/include ${MBED_PATH}/platform/include/platform @@ -33,7 +33,7 @@ target_include_directories(mbed-os-headers-platform ${MBED_PATH}/platform/mbed-trace/include ) -target_include_directories(mbed-os-headers-base +target_include_directories(mbed-headers-base INTERFACE ${MBED_PATH}/UNITTESTS/target_h ${MBED_PATH}/UNITTESTS/target_h/platform @@ -42,7 +42,7 @@ target_include_directories(mbed-os-headers-base ${MBED_PATH}/UNITTESTS/target_h/rtos/include ) -target_include_directories(mbed-os-headers-storage +target_include_directories(mbed-headers-storage INTERFACE ${MBED_PATH}/storage/filesystem/fat/include ${MBED_PATH}/storage/filesystem/fat/ChaN @@ -60,7 +60,7 @@ target_include_directories(mbed-os-headers-storage ${MBED_PATH}/storage/kvstore/kvstore_global_api/include ) -target_include_directories(mbed-os-headers-connectivity +target_include_directories(mbed-headers-connectivity INTERFACE ${MBED_PATH}/connectivity/libraries/nanostack-libservice ${MBED_PATH}/connectivity/libraries/nanostack-libservice/mbed-client-libservice @@ -82,14 +82,14 @@ target_include_directories(mbed-os-headers-connectivity ${MBED_PATH}/connectivity/FEATURE_BLE/include/ble ) -target_include_directories(mbed-os-headers-drivers +target_include_directories(mbed-headers-drivers INTERFACE ${MBED_PATH}/drivers ${MBED_PATH}/drivers/include ${MBED_PATH}/drivers/include/drivers ) -target_include_directories(mbed-os-headers-events +target_include_directories(mbed-headers-events INTERFACE ${MBED_PATH}/events/tests/UNITTESTS/target_h ${MBED_PATH}/events/tests/UNITTESTS/target_h/equeue @@ -97,107 +97,25 @@ target_include_directories(mbed-os-headers-events ${MBED_PATH}/events/include/events/internal ) -target_include_directories(mbed-os-headers-hal +target_include_directories(mbed-headers-hal INTERFACE ${MBED_PATH}/hal ${MBED_PATH}/hal/include ) -target_include_directories(mbed-os-headers-rtos +target_include_directories(mbed-headers-rtos INTERFACE ${MBED_PATH}/rtos/include ) -target_include_directories(mbed-os-headers +target_include_directories(mbed-headers INTERFACE ${MBED_PATH}/features ${MBED_PATH}/features/frameworks ) -target_include_directories(mbed-os-stubs-headers +target_include_directories(mbed-stubs-headers INTERFACE ${MBED_PATH}/UNITTESTS/stubs ) -target_sources(mbed-os-stubs - PUBLIC - #${MBED_PATH}/UNITTESTS/stubs/aes_stub.c - #${MBED_PATH}/UNITTESTS/stubs/AT_CellularContext_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/AT_CellularDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/AT_CellularInformation_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/AT_CellularSMS_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/AT_CellularStack_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/ATHandler_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/BufferedSerial_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/CellularContext_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/CellularDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/CellularInterface_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/CellularStateMachine_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/CellularUtil_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/cipher_stub.c - #${MBED_PATH}/UNITTESTS/stubs/cmac_stub.c - #${MBED_PATH}/UNITTESTS/stubs/ConditionVariable_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/EmulatedSD.cpp - #${MBED_PATH}/UNITTESTS/stubs/equeue_stub.c - #${MBED_PATH}/UNITTESTS/stubs/EventFlags_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/EventQueue_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/FileHandle_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/HeapBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/ip4tos_stub.c - #${MBED_PATH}/UNITTESTS/stubs/Kernel_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/kv_config_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaMacCommand_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaMac_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaPHY_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaWANStack_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/LoRaWANTimer_stub.cpp - ${MBED_PATH}/UNITTESTS/stubs/mbed_assert_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/mbed_atomic_stub.c - ${MBED_PATH}/UNITTESTS/stubs/mbed_critical_stub.c - #${MBED_PATH}/UNITTESTS/stubs/mbed_error.c - #${MBED_PATH}/UNITTESTS/stubs/mbed_poll_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/mbed_retarget_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/mbed_rtos_rtx_stub.c - #${MBED_PATH}/UNITTESTS/stubs/mbed_shared_queues_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/mbed_wait_api_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/MBRBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/MeshInterface_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/Mutex_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/NetworkInterfaceDefaults_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/NetworkInterface_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/NetworkStack_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/nsapi_dns_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/nvic_wrapper_stub.c - #${MBED_PATH}/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp - ${MBED_PATH}/UNITTESTS/stubs/pwmout_api_stub.c - #${MBED_PATH}/UNITTESTS/stubs/randLIB_stub.c - #${MBED_PATH}/UNITTESTS/stubs/randLIB_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/rtx_mutex_stub.c - #${MBED_PATH}/UNITTESTS/stubs/Semaphore_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/SerialBase_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/SocketAddress_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/SocketStats_Stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/stoip4_stub.c - #${MBED_PATH}/UNITTESTS/stubs/ThisThread_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/Thread_stub.cpp - #${MBED_PATH}/UNITTESTS/stubs/us_ticker_stub.cpp - ${MBED_PATH}/UNITTESTS/stubs/watchdog_api_stub.c -) - -target_link_libraries(mbed-os-stubs - PRIVATE - mbed-os-stubs-headers - mbed-os-headers -) diff --git a/UNITTESTS/stubs/hal/CMakeLists.txt b/UNITTESTS/stubs/hal/CMakeLists.txt new file mode 100644 index 00000000000..4f97cb0df9c --- /dev/null +++ b/UNITTESTS/stubs/hal/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-hal) + +target_sources(mbed-stubs-hal + PUBLIC + pwmout_api_stub.c + watchdog_api_stub.c +) + +target_link_libraries(mbed-stubs-hal + PRIVATE + mbed-headers +) diff --git a/UNITTESTS/stubs/pwmout_api_stub.c b/UNITTESTS/stubs/hal/pwmout_api_stub.c similarity index 100% rename from UNITTESTS/stubs/pwmout_api_stub.c rename to UNITTESTS/stubs/hal/pwmout_api_stub.c diff --git a/UNITTESTS/stubs/watchdog_api_stub.c b/UNITTESTS/stubs/hal/watchdog_api_stub.c similarity index 100% rename from UNITTESTS/stubs/watchdog_api_stub.c rename to UNITTESTS/stubs/hal/watchdog_api_stub.c diff --git a/UNITTESTS/stubs/platform/CMakeLists.txt b/UNITTESTS/stubs/platform/CMakeLists.txt new file mode 100644 index 00000000000..bc77e445255 --- /dev/null +++ b/UNITTESTS/stubs/platform/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-platform) + +target_include_directories(mbed-stubs-platform + PRIVATE + . +) + +target_sources(mbed-stubs-platform + PRIVATE + mbed_critical_stub.c + mbed_atomic_stub.c + mbed_error.c + mbed_poll_stub.cpp + mbed_assert_stub.cpp + mbed_wait_api_stub.cpp + mbed_retarget_stub.cpp +) + +target_link_libraries(mbed-stubs-platform + PRIVATE + mbed-headers +) diff --git a/UNITTESTS/stubs/mbed_assert_stub.cpp b/UNITTESTS/stubs/platform/mbed_assert_stub.cpp similarity index 100% rename from UNITTESTS/stubs/mbed_assert_stub.cpp rename to UNITTESTS/stubs/platform/mbed_assert_stub.cpp diff --git a/UNITTESTS/stubs/mbed_atomic_stub.c b/UNITTESTS/stubs/platform/mbed_atomic_stub.c similarity index 100% rename from UNITTESTS/stubs/mbed_atomic_stub.c rename to UNITTESTS/stubs/platform/mbed_atomic_stub.c diff --git a/UNITTESTS/stubs/mbed_critical_stub.c b/UNITTESTS/stubs/platform/mbed_critical_stub.c similarity index 100% rename from UNITTESTS/stubs/mbed_critical_stub.c rename to UNITTESTS/stubs/platform/mbed_critical_stub.c diff --git a/UNITTESTS/stubs/mbed_error.c b/UNITTESTS/stubs/platform/mbed_error.c similarity index 100% rename from UNITTESTS/stubs/mbed_error.c rename to UNITTESTS/stubs/platform/mbed_error.c diff --git a/UNITTESTS/stubs/mbed_poll_stub.cpp b/UNITTESTS/stubs/platform/mbed_poll_stub.cpp similarity index 100% rename from UNITTESTS/stubs/mbed_poll_stub.cpp rename to UNITTESTS/stubs/platform/mbed_poll_stub.cpp diff --git a/UNITTESTS/stubs/mbed_poll_stub.h b/UNITTESTS/stubs/platform/mbed_poll_stub.h similarity index 100% rename from UNITTESTS/stubs/mbed_poll_stub.h rename to UNITTESTS/stubs/platform/mbed_poll_stub.h diff --git a/UNITTESTS/stubs/mbed_retarget_stub.cpp b/UNITTESTS/stubs/platform/mbed_retarget_stub.cpp similarity index 100% rename from UNITTESTS/stubs/mbed_retarget_stub.cpp rename to UNITTESTS/stubs/platform/mbed_retarget_stub.cpp diff --git a/UNITTESTS/stubs/mbed_wait_api_stub.cpp b/UNITTESTS/stubs/platform/mbed_wait_api_stub.cpp similarity index 100% rename from UNITTESTS/stubs/mbed_wait_api_stub.cpp rename to UNITTESTS/stubs/platform/mbed_wait_api_stub.cpp From bcd37bcbc1d374ad74153739062021d039fe1780 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Thu, 18 Feb 2021 14:47:27 +0000 Subject: [PATCH 03/13] unit tests built at the top level --- .gitignore | 2 + CMakeLists.txt | 13 + UNITTESTS/CMakeLists.txt | 229 +++--------------- UNITTESTS/fakes/CMakeLists.txt | 4 + UNITTESTS/fakes/drivers/CMakeLists.txt | 10 +- UNITTESTS/stubs/CMakeLists.txt | 2 + drivers/tests/CMakeLists.txt | 22 -- drivers/tests/UNITTESTS/CMakeLists.txt | 10 +- drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt | 2 + .../tests/UNITTESTS/Watchdog/CMakeLists.txt | 2 + tools/cmake/mbed_unittest.cmake | 79 ------ 11 files changed, 65 insertions(+), 310 deletions(-) create mode 100644 UNITTESTS/fakes/CMakeLists.txt delete mode 100644 drivers/tests/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 3da68113d33..849fe880cc5 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,5 @@ features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_IGNORE/ CMakeCache.txt cmake_install.cmake CMakeFiles/ +cmake_build +Testing/ diff --git a/CMakeLists.txt b/CMakeLists.txt index f1967c3f654..ff6220c085f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,17 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) +option(UNITTESTS "Run unit tests only." OFF) + +if(UNITTESTS) + +enable_testing() + +add_subdirectory(UNITTESTS) +add_subdirectory(drivers/tests/UNITTESTS) + +else() + include(${MBED_CONFIG_PATH}/mbed_config.cmake) include(tools/cmake/set_linker_script.cmake) @@ -257,3 +268,5 @@ if ("${CMAKE_GENERATOR}" MATCHES "Ninja") set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "") endif() endif() + +endif() \ No newline at end of file diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 6aba4ba07ff..7b4a4dd7793 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -1,66 +1,37 @@ -cmake_minimum_required(VERSION 3.0.2) +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 -set(PROJECT_NAME unittests) -set(LIB_NAME MbedOS) +project(unittests) -project(${PROJECT_NAME}) +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.. CACHE INTERNAL "") # Setup c++ standard -macro(use_cxx14) - if (CMAKE_VERSION VERSION_LESS 3.1) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14") - endif() - else() - set(CMAKE_CXX_STANDARD 14) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - endif() -endmacro() - -use_cxx14() - +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) if (MINGW) - # enable PRIx formatting globally - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_FORMAT_MACROS") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS") + # enable PRIx formatting globally + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_FORMAT_MACROS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS") endif (MINGW) #################### # GTEST #################### - -# Download and unpack googletest at configure time -configure_file(googletest-CMakeLists.txt.in googletest-download/CMakeLists.txt) -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) -if (result) - message(FATAL_ERROR "CMake failed for google test: ${result}") -endif() -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) -if (result) - message(FATAL_ERROR "Build failed for google test: ${result}") +include(FetchContent) +# Download and unpack googletest +if(NOT GTEST_FOUND) + FetchContent_Declare(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.10.0 + ) + FetchContent_MakeAvailable(googletest) endif() # Prevent overriding the parent project's compiler/linker # settings on Windows set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -# Add googletest directly to our build. This defines -# the gtest and gtest_main targets. -add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src - ${CMAKE_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL) - -# The gtest/gtest_main/gmock/gmock_main targets carry header search path -# dependencies automatically when using CMake 2.8.11 or -# later. -target_include_directories(gmock_main SYSTEM BEFORE INTERFACE - "$" - "$") #################### # TESTING @@ -69,8 +40,8 @@ target_include_directories(gmock_main SYSTEM BEFORE INTERFACE include(CTest) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - "${CMAKE_BINARY_DIR}/Testing" -) + "${CMAKE_BINARY_DIR}/Testing" + ) #################### # CODE COVERAGE SETUP @@ -78,19 +49,19 @@ set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES if (COVERAGE) - if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - message(WARNING "Non-debug build may result misleading code coverage results.") - endif() + if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message(WARNING "Non-debug build may result misleading code coverage results.") + endif() - # Append coverage compiler flags - set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") + # Append coverage compiler flags + set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") endif(COVERAGE) if (VALGRIND) - find_program(MEMORYCHECK_COMMAND valgrind) + find_program(MEMORYCHECK_COMMAND valgrind) endif(VALGRIND) #################### @@ -100,141 +71,13 @@ endif(VALGRIND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNITTEST") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNITTEST") -# Set include dirs. -set(unittest-includes-base - "${PROJECT_SOURCE_DIR}/target_h" - "${PROJECT_SOURCE_DIR}/../events/tests/UNITTESTS/target_h" - "${PROJECT_SOURCE_DIR}/../events/tests/UNITTESTS/target_h/equeue" - "${PROJECT_SOURCE_DIR}/target_h/platform" - "${PROJECT_SOURCE_DIR}/target_h/platform/cxxsupport" - "${PROJECT_SOURCE_DIR}/target_h/drivers" - "${PROJECT_SOURCE_DIR}/target_h/rtos/include" - "${PROJECT_SOURCE_DIR}/stubs" - "${PROJECT_SOURCE_DIR}/.." - "${PROJECT_SOURCE_DIR}/../features" - "${PROJECT_SOURCE_DIR}/../platform/include" - "${PROJECT_SOURCE_DIR}/../platform/include/platform" - "${PROJECT_SOURCE_DIR}/../platform/mbed-trace/include" - "${PROJECT_SOURCE_DIR}/../storage/filesystem/littlefs/include" - "${PROJECT_SOURCE_DIR}/../storage/filesystem/fat/include" - "${PROJECT_SOURCE_DIR}/../storage/blockdevice/include" - "${PROJECT_SOURCE_DIR}/../storage/filesystem/include" - "${PROJECT_SOURCE_DIR}/../storage/kvstore/include" - "${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config" - "${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config/include" - "${PROJECT_SOURCE_DIR}/../storage/kvstore/tdbstore/include" - "${PROJECT_SOURCE_DIR}/../storage/kvstore/filesystemstore/include" - "${PROJECT_SOURCE_DIR}/../storage/kvstore/kvstore_global_api/include" - "${PROJECT_SOURCE_DIR}/../drivers" - "${PROJECT_SOURCE_DIR}/../drivers/include" - "${PROJECT_SOURCE_DIR}/../drivers/include/drivers" - "${PROJECT_SOURCE_DIR}/../drivers/include/drivers/internal" - "${PROJECT_SOURCE_DIR}/../hal" - "${PROJECT_SOURCE_DIR}/../hal/include" - "${PROJECT_SOURCE_DIR}/../events/include" - "${PROJECT_SOURCE_DIR}/../events/include/events/internal" - "${PROJECT_SOURCE_DIR}/../events/source" - "${PROJECT_SOURCE_DIR}/../rtos/include" - "${PROJECT_SOURCE_DIR}/../features/frameworks" - "${PROJECT_SOURCE_DIR}/../connectivity/libraries/nanostack-libservice" - "${PROJECT_SOURCE_DIR}/../connectivity/libraries/nanostack-libservice/mbed-client-libservice" - "${PROJECT_SOURCE_DIR}/../connectivity/netsocket/include" - "${PROJECT_SOURCE_DIR}/../features/filesystem/fat" - "${PROJECT_SOURCE_DIR}/../features/filesystem/fat/ChaN" - "${PROJECT_SOURCE_DIR}/../features/filesystem/bd" - "${PROJECT_SOURCE_DIR}/../features/filesystem/" - "${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs" - "${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs/littlefs" - "${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/API" - "${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/AT" - "${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/device" - "${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework" - "${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/common" - "${PROJECT_SOURCE_DIR}/../connectivity" - "${PROJECT_SOURCE_DIR}/../connectivity/lorawan/include/lorawan" - "${PROJECT_SOURCE_DIR}/../connectivity/lorawan/lorastack" - "${PROJECT_SOURCE_DIR}/../connectivity/lorawan/lorastack/mac" - "${PROJECT_SOURCE_DIR}/../connectivity/lorawan/lorastack/phy" - "${PROJECT_SOURCE_DIR}/../connectivity/lorawan" - "${PROJECT_SOURCE_DIR}/../connectivity/mbedtls" - "${PROJECT_SOURCE_DIR}/../connectivity/mbedtls/include" -) - -# Create a list for test suites. -set(TEST_SUITES) - -# Get all matched tests. -file(GLOB_RECURSE unittest-file-list - "../unittest.cmake" # matches any ../**/unittest.cmake -) - -if ("${unittest-file-list}" STREQUAL "") - message(FATAL_ERROR "No tests found. Exiting...") -endif() - -# Create unit test targets -foreach(testfile ${unittest-file-list}) - #################### - # DEFINE TARGETS - #################### - - # Init file lists. - set(unittest-includes ${unittest-includes-base}) - set(unittest-sources) - set(unittest-test-sources) - set(unittest-test-flags) - - # Get source files - include("${testfile}") - - get_filename_component(TEST_SUITE_DIR ${testfile} DIRECTORY) - - file(RELATIVE_PATH - TEST_SUITE_NAME # output - "${PROJECT_SOURCE_DIR}/.." # root - ${TEST_SUITE_DIR} #abs dirpath - ) - - string(REGEX REPLACE "/|\\\\" "-" TEST_SUITE_NAME ${TEST_SUITE_NAME}) - - set(TEST_SUITES ${TEST_SUITES} ${TEST_SUITE_NAME}) - - set(LIBS_TO_BE_LINKED gmock_main) - - # Build directories list - set(BUILD_DIRECTORIES) - - if (unittest-sources) - # Create the testable static library. - add_library("${TEST_SUITE_NAME}.${LIB_NAME}" STATIC ${unittest-sources}) - target_include_directories("${TEST_SUITE_NAME}.${LIB_NAME}" PRIVATE - ${unittest-includes}) - target_compile_options("${TEST_SUITE_NAME}.${LIB_NAME}" PRIVATE - ${unittest-test-flags}) - set(LIBS_TO_BE_LINKED ${LIBS_TO_BE_LINKED} "${TEST_SUITE_NAME}.${LIB_NAME}") - - # Append lib build directory to list - list(APPEND BUILD_DIRECTORIES "./CMakeFiles/${TEST_SUITE_NAME}.${LIB_NAME}.dir") - endif(unittest-sources) - - if (unittest-test-sources) - # Create the executable. - add_executable(${TEST_SUITE_NAME} ${unittest-test-sources}) - - target_include_directories(${TEST_SUITE_NAME} PRIVATE - ${unittest-includes}) - target_compile_options(${TEST_SUITE_NAME} PRIVATE - ${unittest-test-flags}) - - # Link the executable with the libraries. - target_link_libraries(${TEST_SUITE_NAME} ${LIBS_TO_BE_LINKED}) - - add_test(NAME "${TEST_SUITE_NAME}" COMMAND ${TEST_SUITE_NAME}) - - # Append test build directory to list - list(APPEND BUILD_DIRECTORIES "./CMakeFiles/${TEST_SUITE_NAME}.dir") - else() - message(WARNING "No test source files found for ${TEST_SUITE_NAME}.\n") - endif(unittest-test-sources) -endforeach(testfile) +macro( mbed_add_all_subdirectories subdirectories_list ) + foreach(dir ${subdirectories_list}) + if(IS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/${dir}) + add_subdirectory(${dir}) + endif() + endforeach() +endmacro() +add_subdirectory(stubs) +add_subdirectory(fakes) \ No newline at end of file diff --git a/UNITTESTS/fakes/CMakeLists.txt b/UNITTESTS/fakes/CMakeLists.txt new file mode 100644 index 00000000000..4831381ffd0 --- /dev/null +++ b/UNITTESTS/fakes/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(drivers) \ No newline at end of file diff --git a/UNITTESTS/fakes/drivers/CMakeLists.txt b/UNITTESTS/fakes/drivers/CMakeLists.txt index 7ebc77c7523..b653f4b042a 100644 --- a/UNITTESTS/fakes/drivers/CMakeLists.txt +++ b/UNITTESTS/fakes/drivers/CMakeLists.txt @@ -1,11 +1,5 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -include(${MBED_PATH}/tools/cmake/mbed_unittest.cmake) - -list(APPEND MBED_ADD_UNITTEST_SUBDIRS - PwmOut - watchdog -) - -mbed_add_all_subdirectories("${MBED_ADD_UNITTEST_SUBDIRS}") +add_subdirectory(PwmOut) +add_subdirectory(watchdog) \ No newline at end of file diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index e69e8e759d2..8f70ed92962 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -119,3 +119,5 @@ target_include_directories(mbed-stubs-headers ${MBED_PATH}/UNITTESTS/stubs ) +add_subdirectory(hal) +add_subdirectory(platform) \ No newline at end of file diff --git a/drivers/tests/CMakeLists.txt b/drivers/tests/CMakeLists.txt deleted file mode 100644 index c8e9e99ad57..00000000000 --- a/drivers/tests/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0) - -set(PROJECT_NAME mbed-drivers-unittests) - -project(${PROJECT_NAME}) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../ CACHE INTERNAL "") - -include(${MBED_PATH}/tools/cmake/mbed_unittest.cmake) - -mbed_unittest_setup() - -## add mbed-os cmakelists -add_subdirectory(${MBED_PATH}/UNITTESTS/stubs ${CMAKE_CURRENT_BINARY_DIR}/stubs_build) -add_subdirectory(${MBED_PATH}/UNITTESTS/stubs/platform ${CMAKE_CURRENT_BINARY_DIR}/stubs_platform_build) -add_subdirectory(${MBED_PATH}/UNITTESTS/stubs/hal ${CMAKE_CURRENT_BINARY_DIR}/stubs_hal_build) -add_subdirectory(${MBED_PATH}/UNITTESTS/fakes/drivers ${CMAKE_CURRENT_BINARY_DIR}/fakes_build) - -## all directories here will be added -add_subdirectory(UNITTESTS) diff --git a/drivers/tests/UNITTESTS/CMakeLists.txt b/drivers/tests/UNITTESTS/CMakeLists.txt index 3164ec922b7..ce1549bf229 100644 --- a/drivers/tests/UNITTESTS/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/CMakeLists.txt @@ -1,11 +1,5 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -include(${MBED_PATH}/tools/cmake/mbed_unittest.cmake) - -list(APPEND MBED_ADD_UNITTEST_SUBDIRS - PwmOut - Watchdog -) - -mbed_add_all_subdirectories("${MBED_ADD_UNITTEST_SUBDIRS}") +add_subdirectory(PwmOut) +add_subdirectory(Watchdog) \ No newline at end of file diff --git a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt index c0cae09d7f6..0fe77756f22 100644 --- a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt @@ -25,3 +25,5 @@ target_link_libraries(${TEST_NAME} ) add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") \ No newline at end of file diff --git a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt index 59fdcbeac5b..4037e46b7ad 100644 --- a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt @@ -26,3 +26,5 @@ target_link_libraries(${TEST_NAME} ) add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") \ No newline at end of file diff --git a/tools/cmake/mbed_unittest.cmake b/tools/cmake/mbed_unittest.cmake index ac668a1a72c..e69de29bb2d 100644 --- a/tools/cmake/mbed_unittest.cmake +++ b/tools/cmake/mbed_unittest.cmake @@ -1,79 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -macro( mbed_unittest_setup ) - set(LIB_NAME MbedOS) - - # Setup c++ standard - set(CMAKE_CXX_STANDARD 14) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - - if (MINGW) - # enable PRIx formatting globally - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_FORMAT_MACROS") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS") - endif (MINGW) - - #################### - # GTEST - #################### - include(FetchContent) - # Download and unpack googletest - if(NOT GTEST_FOUND) - FetchContent_Declare(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.10.0 - ) - FetchContent_MakeAvailable(googletest) - endif() - - # Prevent overriding the parent project's compiler/linker - # settings on Windows - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - - - #################### - # TESTING - #################### - - include(CTest) - - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - "${CMAKE_BINARY_DIR}/Testing" - ) - - #################### - # CODE COVERAGE SETUP - #################### - - if (COVERAGE) - - if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - message(WARNING "Non-debug build may result misleading code coverage results.") - endif() - - # Append coverage compiler flags - set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") - - endif(COVERAGE) - - if (VALGRIND) - find_program(MEMORYCHECK_COMMAND valgrind) - endif(VALGRIND) - - #################### - # UNIT TESTS - #################### - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNITTEST") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNITTEST") -endmacro() - -macro( mbed_add_all_subdirectories subdirectories_list ) - foreach(dir ${subdirectories_list}) - if(IS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/${dir}) - add_subdirectory(${dir}) - endif() - endforeach() -endmacro() From f5376d08a642faf64e149c5a62482a1ca80bb6fe Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Thu, 18 Feb 2021 14:59:12 +0000 Subject: [PATCH 04/13] run new unit tests --- UNITTESTS/mbed_unittest.py | 161 ++----------------------------------- 1 file changed, 6 insertions(+), 155 deletions(-) diff --git a/UNITTESTS/mbed_unittest.py b/UNITTESTS/mbed_unittest.py index 41039b0354f..e924aec7824 100755 --- a/UNITTESTS/mbed_unittest.py +++ b/UNITTESTS/mbed_unittest.py @@ -1,163 +1,14 @@ #!/usr/bin/env python """ -Copyright (c) 2018, Arm Limited -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. - - -UNIT TEST BUILD & RUN +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 """ -from __future__ import print_function import os -import logging -import re - -from unit_test.options import get_options_parser, \ - pretty_print_test_options -from unit_test.settings import DEFAULT_CMAKE_GENERATORS -from unit_test.test import UnitTestTool -from unit_test.new import UnitTestGeneratorTool -from unit_test.coverage import CoverageAPI - -def _mbed_unittest_test(options, cwd, pwd): - if options is None: - return - - if options.coverage: - options.debug_build = True - - if options.cmake_generator is None: - options.cmake_generator = DEFAULT_CMAKE_GENERATORS.get( - options.make_program, - "Unix Makefiles") - - # Do not clean directory if only run. - if options.clean and options.run_only and not options.compile_only: - options.clean = False - - # Build and run by default - if (not options.compile_only and - not options.run_only and - not options.clean): - options.compile_only = True - options.run_only = True - - # Set build path - if not os.path.isabs(options.build): - options.build = os.path.normpath( - os.path.join(cwd, options.build)) - - pretty_print_test_options(options) - - # Create test tool - tool = UnitTestTool(make_program=options.make_program) - - # Prepare build directory - tool.prepare_build_directory(path_to_src=pwd, - build_path=options.build, - clean=options.clean) - - if options.compile_only: - # Create makefiles - src_path = os.path.relpath(pwd, options.build) - tool.create_makefiles(path_to_src=src_path, - generator=options.cmake_generator, - coverage_output_type=options.coverage, - debug=options.debug_build, - valgrind=options.valgrind) - - # Build tests - tool.build_tests() - - if options.run_only: - tool.run_tests(filter_regex=options.test_regex, - valgrind=options.valgrind) - - # If code coverage generation: - if options.coverage: - cov_api = CoverageAPI( - mbed_os_root=os.path.normpath(os.path.join(pwd, "..")), - build_dir=options.build) - - # Generate reports - outputs = [options.coverage] - if options.coverage == "both": - outputs = ["html", "xml"] - - excludes = [pwd, options.build] - - if not options.include_headers: - excludes.append(re.compile(".*\\.h")) - - cov_api.generate_reports(outputs=outputs, - excludes=excludes, - build_path=options.build) - -def _mbed_unittest_new(options, pwd): - if options is None: - return - - generator = UnitTestGeneratorTool() - - mbed_os_root = os.path.normpath( - os.path.join(pwd, "..") - ) - - for filepath in options.new_files: - generator.create( - mbed_os_root=mbed_os_root, - filepath=filepath) - -def mbed_unittest(options=None): - """ - Create, build and run unit tests - """ - - if options is None: - return - - cwd = os.getcwd() - - # Change current working directory to script location - unittest_dir = os.path.dirname(os.path.realpath(__file__)) - os.chdir(unittest_dir) - - if options.new_files: - _mbed_unittest_new(options, unittest_dir) - else: - _mbed_unittest_test(options, cwd, unittest_dir) - -def mbed_unittest_main(): - """ - Create, build and run unit tests - main - """ - - # Get parser and parse command line arguments - parser = get_options_parser() - options = parser.parse_args() - - # Setup logger - if options.log_level: - logging.basicConfig(level=getattr(logging, options.log_level), - format="%(message)s") - else: - logging.basicConfig(level=logging.INFO, - format="%(message)s") - - mbed_unittest(options) if __name__ == "__main__": - mbed_unittest_main() + os.system("cmake -DUNITTESTS=ON -S . -B cmake_build -GNinja") + os.system("cmake --build cmake_build") + os.chdir("cmake_build") + os.system("ctest -V") From 7d5b45af4307d8810322918269acb56673230873 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Fri, 19 Feb 2021 08:25:59 +0000 Subject: [PATCH 05/13] sort stubs into libraries --- UNITTESTS/stubs/CMakeLists.txt | 30 ++++++-- .../{ => connectivity}/ATHandler_stub.cpp | 0 .../AT_CellularContext_stub.cpp | 0 .../AT_CellularDevice_stub.cpp | 0 .../AT_CellularInformation_stub.cpp | 0 .../AT_CellularNetwork_stub.cpp | 0 .../AT_CellularSMS_stub.cpp | 0 .../AT_CellularStack_stub.cpp | 0 .../AT_ControlPlane_netif_stub.cpp | 0 UNITTESTS/stubs/connectivity/CMakeLists.txt | 72 +++++++++++++++++++ .../CellularContext_stub.cpp | 0 .../CellularDevice_stub.cpp | 0 .../CellularInterface_stub.cpp | 0 .../CellularStateMachine_stub.cpp | 0 .../{ => connectivity}/CellularUtil_stub.cpp | 0 .../LoRaMacChannelPlan_stub.cpp | 0 .../LoRaMacCommand_stub.cpp | 0 .../{ => connectivity}/LoRaMacCrypto_stub.cpp | 0 .../stubs/{ => connectivity}/LoRaMac_stub.cpp | 0 .../{ => connectivity}/LoRaPHYEU868_stub.cpp | 0 .../stubs/{ => connectivity}/LoRaPHY_stub.cpp | 0 .../{ => connectivity}/LoRaWANStack_stub.cpp | 0 .../{ => connectivity}/LoRaWANTimer_stub.cpp | 0 .../{ => connectivity}/MeshInterface_stub.cpp | 0 .../NetworkInterfaceDefaults_stub.cpp | 0 .../NetworkInterface_stub.cpp | 0 .../{ => connectivity}/NetworkStack_stub.cpp | 0 .../{ => connectivity}/SocketAddress_stub.cpp | 0 .../{ => connectivity}/SocketStats_Stub.cpp | 0 UNITTESTS/stubs/{ => connectivity}/aes_stub.c | 0 .../stubs/{ => connectivity}/cipher_stub.c | 0 .../stubs/{ => connectivity}/cmac_stub.c | 0 .../stubs/{ => connectivity}/ip4tos_stub.c | 0 .../{ => connectivity}/nsapi_dns_stub.cpp | 0 .../stubs/{ => connectivity}/stoip4_stub.c | 0 .../{ => drivers}/BufferedSerial_stub.cpp | 0 UNITTESTS/stubs/drivers/CMakeLists.txt | 23 ++++++ .../stubs/{ => drivers}/SerialBase_stub.cpp | 0 UNITTESTS/stubs/events/CMakeLists.txt | 18 +++++ .../stubs/{ => events}/EventFlags_stub.cpp | 0 .../stubs/{ => events}/EventQueue_stub.cpp | 0 UNITTESTS/stubs/{ => events}/equeue_stub.c | 0 .../{ => events}/mbed_shared_queues_stub.cpp | 0 UNITTESTS/stubs/hal/CMakeLists.txt | 11 ++- UNITTESTS/stubs/{ => hal}/us_ticker_stub.cpp | 0 .../stubs/{platform => }/mbed_poll_stub.h | 0 UNITTESTS/stubs/platform/CMakeLists.txt | 9 ++- .../stubs/{ => platform}/nvic_wrapper_stub.c | 0 UNITTESTS/stubs/{ => platform}/randLIB_stub.c | 0 .../stubs/{ => platform}/randLIB_stub.cpp | 0 UNITTESTS/stubs/rtos/CMakeLists.txt | 22 ++++++ .../{ => rtos}/ConditionVariable_stub.cpp | 0 UNITTESTS/stubs/{ => rtos}/Kernel_stub.cpp | 0 UNITTESTS/stubs/{ => rtos}/Mutex_stub.cpp | 0 UNITTESTS/stubs/{ => rtos}/Semaphore_stub.cpp | 0 .../stubs/{ => rtos}/ThisThread_stub.cpp | 0 UNITTESTS/stubs/{ => rtos}/Thread_stub.cpp | 0 .../stubs/{ => rtos}/mbed_rtos_rtx_stub.c | 2 +- UNITTESTS/stubs/{ => rtos}/rtx_mutex_stub.c | 2 +- .../BufferedBlockDevice_stub.cpp | 0 UNITTESTS/stubs/storage/CMakeLists.txt | 27 +++++++ .../ChainingBlockDevice_stub.cpp | 0 UNITTESTS/stubs/{ => storage}/EmulatedSD.cpp | 0 .../ExhaustibleBlockDevice_stub.cpp | 0 .../stubs/{ => storage}/FileHandle_stub.cpp | 0 .../FlashSimBlockDevice_stub.cpp | 0 .../{ => storage}/HeapBlockDevice_stub.cpp | 0 .../{ => storage}/MBRBlockDevice_stub.cpp | 0 .../ObservingBlockDevice_stub.cpp | 0 .../ProfilingBlockDevice_stub.cpp | 0 .../ReadOnlyBlockDevice_stub.cpp | 0 .../{ => storage}/SlicingBlockDevice_stub.cpp | 0 .../stubs/{ => storage}/kv_config_stub.cpp | 0 73 files changed, 204 insertions(+), 12 deletions(-) rename UNITTESTS/stubs/{ => connectivity}/ATHandler_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_CellularContext_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_CellularDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_CellularInformation_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_CellularNetwork_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_CellularSMS_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_CellularStack_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/AT_ControlPlane_netif_stub.cpp (100%) create mode 100644 UNITTESTS/stubs/connectivity/CMakeLists.txt rename UNITTESTS/stubs/{ => connectivity}/CellularContext_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/CellularDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/CellularInterface_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/CellularStateMachine_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/CellularUtil_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaMacChannelPlan_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaMacCommand_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaMacCrypto_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaMac_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaPHYEU868_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaPHY_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaWANStack_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/LoRaWANTimer_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/MeshInterface_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/NetworkInterfaceDefaults_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/NetworkInterface_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/NetworkStack_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/SocketAddress_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/SocketStats_Stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/aes_stub.c (100%) rename UNITTESTS/stubs/{ => connectivity}/cipher_stub.c (100%) rename UNITTESTS/stubs/{ => connectivity}/cmac_stub.c (100%) rename UNITTESTS/stubs/{ => connectivity}/ip4tos_stub.c (100%) rename UNITTESTS/stubs/{ => connectivity}/nsapi_dns_stub.cpp (100%) rename UNITTESTS/stubs/{ => connectivity}/stoip4_stub.c (100%) rename UNITTESTS/stubs/{ => drivers}/BufferedSerial_stub.cpp (100%) create mode 100644 UNITTESTS/stubs/drivers/CMakeLists.txt rename UNITTESTS/stubs/{ => drivers}/SerialBase_stub.cpp (100%) create mode 100644 UNITTESTS/stubs/events/CMakeLists.txt rename UNITTESTS/stubs/{ => events}/EventFlags_stub.cpp (100%) rename UNITTESTS/stubs/{ => events}/EventQueue_stub.cpp (100%) rename UNITTESTS/stubs/{ => events}/equeue_stub.c (100%) rename UNITTESTS/stubs/{ => events}/mbed_shared_queues_stub.cpp (100%) rename UNITTESTS/stubs/{ => hal}/us_ticker_stub.cpp (100%) rename UNITTESTS/stubs/{platform => }/mbed_poll_stub.h (100%) rename UNITTESTS/stubs/{ => platform}/nvic_wrapper_stub.c (100%) rename UNITTESTS/stubs/{ => platform}/randLIB_stub.c (100%) rename UNITTESTS/stubs/{ => platform}/randLIB_stub.cpp (100%) create mode 100644 UNITTESTS/stubs/rtos/CMakeLists.txt rename UNITTESTS/stubs/{ => rtos}/ConditionVariable_stub.cpp (100%) rename UNITTESTS/stubs/{ => rtos}/Kernel_stub.cpp (100%) rename UNITTESTS/stubs/{ => rtos}/Mutex_stub.cpp (100%) rename UNITTESTS/stubs/{ => rtos}/Semaphore_stub.cpp (100%) rename UNITTESTS/stubs/{ => rtos}/ThisThread_stub.cpp (100%) rename UNITTESTS/stubs/{ => rtos}/Thread_stub.cpp (100%) rename UNITTESTS/stubs/{ => rtos}/mbed_rtos_rtx_stub.c (96%) rename UNITTESTS/stubs/{ => rtos}/rtx_mutex_stub.c (96%) rename UNITTESTS/stubs/{ => storage}/BufferedBlockDevice_stub.cpp (100%) create mode 100644 UNITTESTS/stubs/storage/CMakeLists.txt rename UNITTESTS/stubs/{ => storage}/ChainingBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/EmulatedSD.cpp (100%) rename UNITTESTS/stubs/{ => storage}/ExhaustibleBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/FileHandle_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/FlashSimBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/HeapBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/MBRBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/ObservingBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/ProfilingBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/ReadOnlyBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/SlicingBlockDevice_stub.cpp (100%) rename UNITTESTS/stubs/{ => storage}/kv_config_stub.cpp (100%) diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index 8f70ed92962..d03fe648a27 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -12,7 +12,6 @@ add_library(mbed-headers-hal INTERFACE) add_library(mbed-headers-events INTERFACE) add_library(mbed-headers-rtos INTERFACE) - target_link_libraries(mbed-headers INTERFACE mbed-headers-base @@ -29,7 +28,8 @@ target_include_directories(mbed-headers-platform INTERFACE ${MBED_PATH}/platform/include ${MBED_PATH}/platform/include/platform - ${MBED_PATH}/platform/include/platform/internal + ${MBED_PATH}/platform/randlib/include/mbed-client-randlib/ + ${MBED_PATH}/platform/randlib/include/ ${MBED_PATH}/platform/mbed-trace/include ) @@ -40,6 +40,8 @@ target_include_directories(mbed-headers-base ${MBED_PATH}/UNITTESTS/target_h/platform/cxxsupport ${MBED_PATH}/UNITTESTS/target_h/drivers ${MBED_PATH}/UNITTESTS/target_h/rtos/include + ${MBED_PATH}/UNITTESTS/target_h/rtos + ${MBED_PATH}/UNITTESTS/target_h/sys ) target_include_directories(mbed-headers-storage @@ -58,6 +60,7 @@ target_include_directories(mbed-headers-storage ${MBED_PATH}/storage/kvstore/tdbstore/include ${MBED_PATH}/storage/kvstore/filesystemstore/include ${MBED_PATH}/storage/kvstore/kvstore_global_api/include + ${MBED_PATH}/storage/blockdevice/include/blockdevice ) target_include_directories(mbed-headers-connectivity @@ -106,6 +109,7 @@ target_include_directories(mbed-headers-hal target_include_directories(mbed-headers-rtos INTERFACE ${MBED_PATH}/rtos/include + ${MBED_PATH}/rtos/include/rtos ) target_include_directories(mbed-headers @@ -116,8 +120,26 @@ target_include_directories(mbed-headers target_include_directories(mbed-stubs-headers INTERFACE - ${MBED_PATH}/UNITTESTS/stubs + . ) +add_subdirectory(connectivity) +add_subdirectory(drivers) +add_subdirectory(events) add_subdirectory(hal) -add_subdirectory(platform) \ No newline at end of file +add_subdirectory(platform) +add_subdirectory(rtos) +add_subdirectory(storage) + +add_library(mbed-stubs INTERFACE) + +target_link_libraries(mbed-stubs + INTERFACE + mbed-stubs-connectivity + mbed-stubs-drivers + mbed-stubs-events + mbed-stubs-hal + mbed-stubs-platform + mbed-stubs-rtos + mbed-stubs-storage +) \ No newline at end of file diff --git a/UNITTESTS/stubs/ATHandler_stub.cpp b/UNITTESTS/stubs/connectivity/ATHandler_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ATHandler_stub.cpp rename to UNITTESTS/stubs/connectivity/ATHandler_stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularContext_stub.cpp b/UNITTESTS/stubs/connectivity/AT_CellularContext_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_CellularContext_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_CellularContext_stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularDevice_stub.cpp b/UNITTESTS/stubs/connectivity/AT_CellularDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_CellularDevice_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_CellularDevice_stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularInformation_stub.cpp b/UNITTESTS/stubs/connectivity/AT_CellularInformation_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_CellularInformation_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_CellularInformation_stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp b/UNITTESTS/stubs/connectivity/AT_CellularNetwork_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_CellularNetwork_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_CellularNetwork_stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularSMS_stub.cpp b/UNITTESTS/stubs/connectivity/AT_CellularSMS_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_CellularSMS_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_CellularSMS_stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularStack_stub.cpp b/UNITTESTS/stubs/connectivity/AT_CellularStack_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_CellularStack_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_CellularStack_stub.cpp diff --git a/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp b/UNITTESTS/stubs/connectivity/AT_ControlPlane_netif_stub.cpp similarity index 100% rename from UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp rename to UNITTESTS/stubs/connectivity/AT_ControlPlane_netif_stub.cpp diff --git a/UNITTESTS/stubs/connectivity/CMakeLists.txt b/UNITTESTS/stubs/connectivity/CMakeLists.txt new file mode 100644 index 00000000000..27b0274d594 --- /dev/null +++ b/UNITTESTS/stubs/connectivity/CMakeLists.txt @@ -0,0 +1,72 @@ +# 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_CELLULAR_USE_SMS=1 + MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL + 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 +) + +target_sources(mbed-stubs-connectivity + PRIVATE + ATHandler_stub.cpp + AT_CellularDevice_stub.cpp + AT_CellularStack_stub.cpp + AT_CellularNetwork_stub.cpp + AT_ControlPlane_netif_stub.cpp + CellularDevice_stub.cpp + CellularStateMachine_stub.cpp + NetworkInterface_stub.cpp + NetworkInterfaceDefaults_stub.cpp + NetworkStack_stub.cpp + CellularContext_stub.cpp + CellularUtil_stub.cpp + SocketAddress_stub.cpp + aes_stub.c + cipher_stub.c + #AT_CellularContext_stub.cpp + #AT_CellularDevice_stub.cpp + #AT_CellularInformation_stub.cpp + #AT_CellularNetwork_stub.cpp + #AT_CellularSMS_stub.cpp + #AT_CellularStack_stub.cpp + #AT_ControlPlane_netif_stub.cpp + #ATHandler_stub.cpp + #CellularContext_stub.cpp + #CellularDevice_stub.cpp + #CellularInterface_stub.cpp + #CellularStateMachine_stub.cpp + #CellularUtil_stub.cpp + #cmac_stub.c + #ip4tos_stub.c + #LoRaMacChannelPlan_stub.cpp + #LoRaMacCommand_stub.cpp + #LoRaMacCrypto_stub.cpp + #LoRaMac_stub.cpp + #LoRaPHYEU868_stub.cpp + #LoRaPHY_stub.cpp + #LoRaWANStack_stub.cpp + #LoRaWANTimer_stub.cpp + #MeshInterface_stub.cpp + #NetworkInterfaceDefaults_stub.cpp + #NetworkInterface_stub.cpp + #NetworkStack_stub.cpp + #nsapi_dns_stub.cpp + #SocketAddress_stub.cpp + #SocketStats_Stub.cpp + #stoip4_stub.c +) + +target_link_libraries(mbed-stubs-connectivity + PRIVATE + mbed-headers + mbed-stubs-headers +) diff --git a/UNITTESTS/stubs/CellularContext_stub.cpp b/UNITTESTS/stubs/connectivity/CellularContext_stub.cpp similarity index 100% rename from UNITTESTS/stubs/CellularContext_stub.cpp rename to UNITTESTS/stubs/connectivity/CellularContext_stub.cpp diff --git a/UNITTESTS/stubs/CellularDevice_stub.cpp b/UNITTESTS/stubs/connectivity/CellularDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/CellularDevice_stub.cpp rename to UNITTESTS/stubs/connectivity/CellularDevice_stub.cpp diff --git a/UNITTESTS/stubs/CellularInterface_stub.cpp b/UNITTESTS/stubs/connectivity/CellularInterface_stub.cpp similarity index 100% rename from UNITTESTS/stubs/CellularInterface_stub.cpp rename to UNITTESTS/stubs/connectivity/CellularInterface_stub.cpp diff --git a/UNITTESTS/stubs/CellularStateMachine_stub.cpp b/UNITTESTS/stubs/connectivity/CellularStateMachine_stub.cpp similarity index 100% rename from UNITTESTS/stubs/CellularStateMachine_stub.cpp rename to UNITTESTS/stubs/connectivity/CellularStateMachine_stub.cpp diff --git a/UNITTESTS/stubs/CellularUtil_stub.cpp b/UNITTESTS/stubs/connectivity/CellularUtil_stub.cpp similarity index 100% rename from UNITTESTS/stubs/CellularUtil_stub.cpp rename to UNITTESTS/stubs/connectivity/CellularUtil_stub.cpp diff --git a/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaMacChannelPlan_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaMacChannelPlan_stub.cpp diff --git a/UNITTESTS/stubs/LoRaMacCommand_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaMacCommand_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaMacCommand_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaMacCommand_stub.cpp diff --git a/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaMacCrypto_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaMacCrypto_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaMacCrypto_stub.cpp diff --git a/UNITTESTS/stubs/LoRaMac_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaMac_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaMac_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaMac_stub.cpp diff --git a/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaPHYEU868_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaPHYEU868_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaPHYEU868_stub.cpp diff --git a/UNITTESTS/stubs/LoRaPHY_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaPHY_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaPHY_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaPHY_stub.cpp diff --git a/UNITTESTS/stubs/LoRaWANStack_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaWANStack_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaWANStack_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaWANStack_stub.cpp diff --git a/UNITTESTS/stubs/LoRaWANTimer_stub.cpp b/UNITTESTS/stubs/connectivity/LoRaWANTimer_stub.cpp similarity index 100% rename from UNITTESTS/stubs/LoRaWANTimer_stub.cpp rename to UNITTESTS/stubs/connectivity/LoRaWANTimer_stub.cpp diff --git a/UNITTESTS/stubs/MeshInterface_stub.cpp b/UNITTESTS/stubs/connectivity/MeshInterface_stub.cpp similarity index 100% rename from UNITTESTS/stubs/MeshInterface_stub.cpp rename to UNITTESTS/stubs/connectivity/MeshInterface_stub.cpp diff --git a/UNITTESTS/stubs/NetworkInterfaceDefaults_stub.cpp b/UNITTESTS/stubs/connectivity/NetworkInterfaceDefaults_stub.cpp similarity index 100% rename from UNITTESTS/stubs/NetworkInterfaceDefaults_stub.cpp rename to UNITTESTS/stubs/connectivity/NetworkInterfaceDefaults_stub.cpp diff --git a/UNITTESTS/stubs/NetworkInterface_stub.cpp b/UNITTESTS/stubs/connectivity/NetworkInterface_stub.cpp similarity index 100% rename from UNITTESTS/stubs/NetworkInterface_stub.cpp rename to UNITTESTS/stubs/connectivity/NetworkInterface_stub.cpp diff --git a/UNITTESTS/stubs/NetworkStack_stub.cpp b/UNITTESTS/stubs/connectivity/NetworkStack_stub.cpp similarity index 100% rename from UNITTESTS/stubs/NetworkStack_stub.cpp rename to UNITTESTS/stubs/connectivity/NetworkStack_stub.cpp diff --git a/UNITTESTS/stubs/SocketAddress_stub.cpp b/UNITTESTS/stubs/connectivity/SocketAddress_stub.cpp similarity index 100% rename from UNITTESTS/stubs/SocketAddress_stub.cpp rename to UNITTESTS/stubs/connectivity/SocketAddress_stub.cpp diff --git a/UNITTESTS/stubs/SocketStats_Stub.cpp b/UNITTESTS/stubs/connectivity/SocketStats_Stub.cpp similarity index 100% rename from UNITTESTS/stubs/SocketStats_Stub.cpp rename to UNITTESTS/stubs/connectivity/SocketStats_Stub.cpp diff --git a/UNITTESTS/stubs/aes_stub.c b/UNITTESTS/stubs/connectivity/aes_stub.c similarity index 100% rename from UNITTESTS/stubs/aes_stub.c rename to UNITTESTS/stubs/connectivity/aes_stub.c diff --git a/UNITTESTS/stubs/cipher_stub.c b/UNITTESTS/stubs/connectivity/cipher_stub.c similarity index 100% rename from UNITTESTS/stubs/cipher_stub.c rename to UNITTESTS/stubs/connectivity/cipher_stub.c diff --git a/UNITTESTS/stubs/cmac_stub.c b/UNITTESTS/stubs/connectivity/cmac_stub.c similarity index 100% rename from UNITTESTS/stubs/cmac_stub.c rename to UNITTESTS/stubs/connectivity/cmac_stub.c diff --git a/UNITTESTS/stubs/ip4tos_stub.c b/UNITTESTS/stubs/connectivity/ip4tos_stub.c similarity index 100% rename from UNITTESTS/stubs/ip4tos_stub.c rename to UNITTESTS/stubs/connectivity/ip4tos_stub.c diff --git a/UNITTESTS/stubs/nsapi_dns_stub.cpp b/UNITTESTS/stubs/connectivity/nsapi_dns_stub.cpp similarity index 100% rename from UNITTESTS/stubs/nsapi_dns_stub.cpp rename to UNITTESTS/stubs/connectivity/nsapi_dns_stub.cpp diff --git a/UNITTESTS/stubs/stoip4_stub.c b/UNITTESTS/stubs/connectivity/stoip4_stub.c similarity index 100% rename from UNITTESTS/stubs/stoip4_stub.c rename to UNITTESTS/stubs/connectivity/stoip4_stub.c diff --git a/UNITTESTS/stubs/BufferedSerial_stub.cpp b/UNITTESTS/stubs/drivers/BufferedSerial_stub.cpp similarity index 100% rename from UNITTESTS/stubs/BufferedSerial_stub.cpp rename to UNITTESTS/stubs/drivers/BufferedSerial_stub.cpp diff --git a/UNITTESTS/stubs/drivers/CMakeLists.txt b/UNITTESTS/stubs/drivers/CMakeLists.txt new file mode 100644 index 00000000000..139fa28451d --- /dev/null +++ b/UNITTESTS/stubs/drivers/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-drivers) + +target_sources(mbed-stubs-drivers + PRIVATE + BufferedSerial_stub.cpp + SerialBase_stub.cpp +) + +target_compile_definitions(mbed-stubs-drivers + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 +) + +target_link_libraries(mbed-stubs-drivers + PRIVATE + mbed-headers + mbed-stubs-headers +) diff --git a/UNITTESTS/stubs/SerialBase_stub.cpp b/UNITTESTS/stubs/drivers/SerialBase_stub.cpp similarity index 100% rename from UNITTESTS/stubs/SerialBase_stub.cpp rename to UNITTESTS/stubs/drivers/SerialBase_stub.cpp diff --git a/UNITTESTS/stubs/events/CMakeLists.txt b/UNITTESTS/stubs/events/CMakeLists.txt new file mode 100644 index 00000000000..161563c8d44 --- /dev/null +++ b/UNITTESTS/stubs/events/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-events) + +target_sources(mbed-stubs-events + PRIVATE + equeue_stub.c + EventFlags_stub.cpp + EventQueue_stub.cpp + mbed_shared_queues_stub.cpp +) + +target_link_libraries(mbed-stubs-events + PRIVATE + mbed-headers + mbed-stubs-headers +) diff --git a/UNITTESTS/stubs/EventFlags_stub.cpp b/UNITTESTS/stubs/events/EventFlags_stub.cpp similarity index 100% rename from UNITTESTS/stubs/EventFlags_stub.cpp rename to UNITTESTS/stubs/events/EventFlags_stub.cpp diff --git a/UNITTESTS/stubs/EventQueue_stub.cpp b/UNITTESTS/stubs/events/EventQueue_stub.cpp similarity index 100% rename from UNITTESTS/stubs/EventQueue_stub.cpp rename to UNITTESTS/stubs/events/EventQueue_stub.cpp diff --git a/UNITTESTS/stubs/equeue_stub.c b/UNITTESTS/stubs/events/equeue_stub.c similarity index 100% rename from UNITTESTS/stubs/equeue_stub.c rename to UNITTESTS/stubs/events/equeue_stub.c diff --git a/UNITTESTS/stubs/mbed_shared_queues_stub.cpp b/UNITTESTS/stubs/events/mbed_shared_queues_stub.cpp similarity index 100% rename from UNITTESTS/stubs/mbed_shared_queues_stub.cpp rename to UNITTESTS/stubs/events/mbed_shared_queues_stub.cpp diff --git a/UNITTESTS/stubs/hal/CMakeLists.txt b/UNITTESTS/stubs/hal/CMakeLists.txt index 4f97cb0df9c..50d93669208 100644 --- a/UNITTESTS/stubs/hal/CMakeLists.txt +++ b/UNITTESTS/stubs/hal/CMakeLists.txt @@ -3,13 +3,22 @@ add_library(mbed-stubs-hal) +target_compile_definitions(mbed-stubs-hal + PRIVATE + DEVICE_PWMOUT + DEVICE_WATCHDOG + MBED_WDOG_ASSERT=1 +) + target_sources(mbed-stubs-hal - PUBLIC + PRIVATE pwmout_api_stub.c + us_ticker_stub.cpp watchdog_api_stub.c ) target_link_libraries(mbed-stubs-hal PRIVATE mbed-headers + mbed-stubs-headers ) diff --git a/UNITTESTS/stubs/us_ticker_stub.cpp b/UNITTESTS/stubs/hal/us_ticker_stub.cpp similarity index 100% rename from UNITTESTS/stubs/us_ticker_stub.cpp rename to UNITTESTS/stubs/hal/us_ticker_stub.cpp diff --git a/UNITTESTS/stubs/platform/mbed_poll_stub.h b/UNITTESTS/stubs/mbed_poll_stub.h similarity index 100% rename from UNITTESTS/stubs/platform/mbed_poll_stub.h rename to UNITTESTS/stubs/mbed_poll_stub.h diff --git a/UNITTESTS/stubs/platform/CMakeLists.txt b/UNITTESTS/stubs/platform/CMakeLists.txt index bc77e445255..e03919fe060 100644 --- a/UNITTESTS/stubs/platform/CMakeLists.txt +++ b/UNITTESTS/stubs/platform/CMakeLists.txt @@ -3,11 +3,6 @@ add_library(mbed-stubs-platform) -target_include_directories(mbed-stubs-platform - PRIVATE - . -) - target_sources(mbed-stubs-platform PRIVATE mbed_critical_stub.c @@ -17,9 +12,13 @@ target_sources(mbed-stubs-platform mbed_assert_stub.cpp mbed_wait_api_stub.cpp mbed_retarget_stub.cpp + nvic_wrapper_stub.c + randLIB_stub.c + randLIB_stub.cpp ) target_link_libraries(mbed-stubs-platform PRIVATE mbed-headers + mbed-stubs-headers ) diff --git a/UNITTESTS/stubs/nvic_wrapper_stub.c b/UNITTESTS/stubs/platform/nvic_wrapper_stub.c similarity index 100% rename from UNITTESTS/stubs/nvic_wrapper_stub.c rename to UNITTESTS/stubs/platform/nvic_wrapper_stub.c diff --git a/UNITTESTS/stubs/randLIB_stub.c b/UNITTESTS/stubs/platform/randLIB_stub.c similarity index 100% rename from UNITTESTS/stubs/randLIB_stub.c rename to UNITTESTS/stubs/platform/randLIB_stub.c diff --git a/UNITTESTS/stubs/randLIB_stub.cpp b/UNITTESTS/stubs/platform/randLIB_stub.cpp similarity index 100% rename from UNITTESTS/stubs/randLIB_stub.cpp rename to UNITTESTS/stubs/platform/randLIB_stub.cpp diff --git a/UNITTESTS/stubs/rtos/CMakeLists.txt b/UNITTESTS/stubs/rtos/CMakeLists.txt new file mode 100644 index 00000000000..fc9a759b8d6 --- /dev/null +++ b/UNITTESTS/stubs/rtos/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-rtos) + +target_sources(mbed-stubs-rtos + PRIVATE + ConditionVariable_stub.cpp + Kernel_stub.cpp + mbed_rtos_rtx_stub.c + Mutex_stub.cpp + rtx_mutex_stub.c + Semaphore_stub.cpp + ThisThread_stub.cpp + Thread_stub.cpp +) + +target_link_libraries(mbed-stubs-rtos + PRIVATE + mbed-headers + mbed-stubs-headers +) diff --git a/UNITTESTS/stubs/ConditionVariable_stub.cpp b/UNITTESTS/stubs/rtos/ConditionVariable_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ConditionVariable_stub.cpp rename to UNITTESTS/stubs/rtos/ConditionVariable_stub.cpp diff --git a/UNITTESTS/stubs/Kernel_stub.cpp b/UNITTESTS/stubs/rtos/Kernel_stub.cpp similarity index 100% rename from UNITTESTS/stubs/Kernel_stub.cpp rename to UNITTESTS/stubs/rtos/Kernel_stub.cpp diff --git a/UNITTESTS/stubs/Mutex_stub.cpp b/UNITTESTS/stubs/rtos/Mutex_stub.cpp similarity index 100% rename from UNITTESTS/stubs/Mutex_stub.cpp rename to UNITTESTS/stubs/rtos/Mutex_stub.cpp diff --git a/UNITTESTS/stubs/Semaphore_stub.cpp b/UNITTESTS/stubs/rtos/Semaphore_stub.cpp similarity index 100% rename from UNITTESTS/stubs/Semaphore_stub.cpp rename to UNITTESTS/stubs/rtos/Semaphore_stub.cpp diff --git a/UNITTESTS/stubs/ThisThread_stub.cpp b/UNITTESTS/stubs/rtos/ThisThread_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ThisThread_stub.cpp rename to UNITTESTS/stubs/rtos/ThisThread_stub.cpp diff --git a/UNITTESTS/stubs/Thread_stub.cpp b/UNITTESTS/stubs/rtos/Thread_stub.cpp similarity index 100% rename from UNITTESTS/stubs/Thread_stub.cpp rename to UNITTESTS/stubs/rtos/Thread_stub.cpp diff --git a/UNITTESTS/stubs/mbed_rtos_rtx_stub.c b/UNITTESTS/stubs/rtos/mbed_rtos_rtx_stub.c similarity index 96% rename from UNITTESTS/stubs/mbed_rtos_rtx_stub.c rename to UNITTESTS/stubs/rtos/mbed_rtos_rtx_stub.c index aa45009fa51..889065cbcbd 100644 --- a/UNITTESTS/stubs/mbed_rtos_rtx_stub.c +++ b/UNITTESTS/stubs/rtos/mbed_rtos_rtx_stub.c @@ -15,6 +15,6 @@ * limitations under the License. */ -#include "cmsis_os2.h" +#include "mbed_rtos_types.h" osMutexId_t singleton_mutex_id; diff --git a/UNITTESTS/stubs/rtx_mutex_stub.c b/UNITTESTS/stubs/rtos/rtx_mutex_stub.c similarity index 96% rename from UNITTESTS/stubs/rtx_mutex_stub.c rename to UNITTESTS/stubs/rtos/rtx_mutex_stub.c index de5aed92bd1..916be3ee955 100644 --- a/UNITTESTS/stubs/rtx_mutex_stub.c +++ b/UNITTESTS/stubs/rtos/rtx_mutex_stub.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "cmsis_os2.h" +#include "mbed_rtos_types.h" osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) { diff --git a/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/BufferedBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/BufferedBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/BufferedBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/storage/CMakeLists.txt b/UNITTESTS/stubs/storage/CMakeLists.txt new file mode 100644 index 00000000000..8f10c63378a --- /dev/null +++ b/UNITTESTS/stubs/storage/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-storage) + +target_sources(mbed-stubs-storage + PRIVATE + BufferedBlockDevice_stub.cpp + ChainingBlockDevice_stub.cpp + EmulatedSD.cpp + ExhaustibleBlockDevice_stub.cpp + FileHandle_stub.cpp + FlashSimBlockDevice_stub.cpp + HeapBlockDevice_stub.cpp + #MBRBlockDevice_stub.cpp + ObservingBlockDevice_stub.cpp + ProfilingBlockDevice_stub.cpp + ReadOnlyBlockDevice_stub.cpp + SlicingBlockDevice_stub.cpp + kv_config_stub.cpp +) + +target_link_libraries(mbed-stubs-storage + PRIVATE + mbed-headers + mbed-stubs-headers +) diff --git a/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/ChainingBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ChainingBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/ChainingBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/EmulatedSD.cpp b/UNITTESTS/stubs/storage/EmulatedSD.cpp similarity index 100% rename from UNITTESTS/stubs/EmulatedSD.cpp rename to UNITTESTS/stubs/storage/EmulatedSD.cpp diff --git a/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/ExhaustibleBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/ExhaustibleBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/FileHandle_stub.cpp b/UNITTESTS/stubs/storage/FileHandle_stub.cpp similarity index 100% rename from UNITTESTS/stubs/FileHandle_stub.cpp rename to UNITTESTS/stubs/storage/FileHandle_stub.cpp diff --git a/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/FlashSimBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/FlashSimBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/HeapBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/HeapBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/HeapBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/HeapBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/MBRBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/MBRBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/MBRBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/MBRBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/ObservingBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ObservingBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/ObservingBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/ProfilingBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/ProfilingBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/ReadOnlyBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/ReadOnlyBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp b/UNITTESTS/stubs/storage/SlicingBlockDevice_stub.cpp similarity index 100% rename from UNITTESTS/stubs/SlicingBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/SlicingBlockDevice_stub.cpp diff --git a/UNITTESTS/stubs/kv_config_stub.cpp b/UNITTESTS/stubs/storage/kv_config_stub.cpp similarity index 100% rename from UNITTESTS/stubs/kv_config_stub.cpp rename to UNITTESTS/stubs/storage/kv_config_stub.cpp From 7a8e3dcdfdae298b6320bd4f54135932e6e5fb20 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Fri, 19 Feb 2021 08:27:46 +0000 Subject: [PATCH 06/13] these are not fakes these are normal mbedos objects --- UNITTESTS/fakes/CMakeLists.txt | 1 - UNITTESTS/fakes/drivers/CMakeLists.txt | 5 ----- UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt | 19 ------------------ .../fakes/drivers/watchdog/CMakeLists.txt | 20 ------------------- drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt | 2 +- .../tests/UNITTESTS/Watchdog/CMakeLists.txt | 2 +- 6 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 UNITTESTS/fakes/drivers/CMakeLists.txt delete mode 100644 UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt delete mode 100644 UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt diff --git a/UNITTESTS/fakes/CMakeLists.txt b/UNITTESTS/fakes/CMakeLists.txt index 4831381ffd0..01834be5919 100644 --- a/UNITTESTS/fakes/CMakeLists.txt +++ b/UNITTESTS/fakes/CMakeLists.txt @@ -1,4 +1,3 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_subdirectory(drivers) \ No newline at end of file diff --git a/UNITTESTS/fakes/drivers/CMakeLists.txt b/UNITTESTS/fakes/drivers/CMakeLists.txt deleted file mode 100644 index b653f4b042a..00000000000 --- a/UNITTESTS/fakes/drivers/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -add_subdirectory(PwmOut) -add_subdirectory(watchdog) \ No newline at end of file diff --git a/UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt b/UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt deleted file mode 100644 index f45ed5c36c0..00000000000 --- a/UNITTESTS/fakes/drivers/PwmOut/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -add_library(mbed-fakes-drivers-pwmout) - -target_compile_definitions(mbed-fakes-drivers-pwmout - PRIVATE - DEVICE_PWMOUT -) - -target_sources(mbed-fakes-drivers-pwmout - PRIVATE - ${MBED_PATH}/drivers/source/PwmOut.cpp -) - -target_link_libraries(mbed-fakes-drivers-pwmout - PRIVATE - mbed-headers -) diff --git a/UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt b/UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt deleted file mode 100644 index 5fd5a7c6e62..00000000000 --- a/UNITTESTS/fakes/drivers/watchdog/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2021 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -add_library(mbed-fakes-drivers-watchdog) - -target_compile_definitions(mbed-fakes-drivers-watchdog - PRIVATE - DEVICE_WATCHDOG - MBED_WDOG_ASSERT=1 -) - -target_sources(mbed-fakes-drivers-watchdog - PRIVATE - ${MBED_PATH}/drivers/source/Watchdog.cpp -) - -target_link_libraries(mbed-fakes-drivers-watchdog - PRIVATE - mbed-headers -) diff --git a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt index 0fe77756f22..106c035bf40 100644 --- a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt @@ -12,13 +12,13 @@ target_compile_definitions(${TEST_NAME} target_sources(${TEST_NAME} PRIVATE + ${MBED_PATH}/drivers/source/PwmOut.cpp test_pwmout.cpp ) target_link_libraries(${TEST_NAME} PRIVATE mbed-headers - mbed-fakes-drivers-pwmout mbed-stubs-hal mbed-stubs-platform gmock_main diff --git a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt index 4037e46b7ad..0a79be0d67f 100644 --- a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt @@ -13,13 +13,13 @@ target_compile_definitions(${TEST_NAME} target_sources(${TEST_NAME} PRIVATE + ${MBED_PATH}/drivers/source/Watchdog.cpp test_watchdog.cpp ) target_link_libraries(${TEST_NAME} PRIVATE mbed-headers - mbed-fakes-drivers-watchdog mbed-stubs-platform mbed-stubs-hal gmock_main From cca373afaba56836b2eb7a7563d43af23a2d96a9 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Fri, 19 Feb 2021 08:37:51 +0000 Subject: [PATCH 07/13] don't include bare cmsis due to conflicts --- UNITTESTS/target_h/cmsis_os.h | 2 +- UNITTESTS/target_h/rtos/Semaphore.h | 2 +- .../target_h/rtos/include/rtos/internal/mbed_rtos_storage.h | 2 +- .../device/cellularstatemachine/cellularstatemachinetest.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/UNITTESTS/target_h/cmsis_os.h b/UNITTESTS/target_h/cmsis_os.h index a40ab9e73b3..6d3e2e5cd5e 100644 --- a/UNITTESTS/target_h/cmsis_os.h +++ b/UNITTESTS/target_h/cmsis_os.h @@ -18,7 +18,7 @@ #ifndef CMSIS_OS_H_ #define CMSIS_OS_H_ -#include "cmsis_os2.h" +#include "mbed_rtos_types.h" #define osPriority osPriority_t diff --git a/UNITTESTS/target_h/rtos/Semaphore.h b/UNITTESTS/target_h/rtos/Semaphore.h index ecbdee511da..aecea8f6a35 100644 --- a/UNITTESTS/target_h/rtos/Semaphore.h +++ b/UNITTESTS/target_h/rtos/Semaphore.h @@ -18,7 +18,7 @@ #define SEMAPHORE_H #include -#include "cmsis_os2.h" +#include "internal/mbed_rtos1_types.h" #include "rtos/Kernel.h" namespace rtos { diff --git a/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h b/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h index e1b12761386..c160374e657 100644 --- a/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h +++ b/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h @@ -22,7 +22,7 @@ extern "C" { #endif -#include "cmsis_os2.h" +#include "mbed_rtos_types.h" #include "rtx_os.h" #include "rtx_lib.h" #include "mbed_rtx_conf.h" diff --git a/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/cellularstatemachinetest.cpp b/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/cellularstatemachinetest.cpp index 8f4ad47e623..96c9b89d0c3 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/cellularstatemachinetest.cpp +++ b/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/cellularstatemachinetest.cpp @@ -23,7 +23,7 @@ #include "AT_CellularNetwork_stub.h" #include "myCellularDevice.h" #include "Thread_stub.h" -#include "cmsis_os2.h" +#include "mbed_rtos_types.h" #include "equeue_stub.h" using namespace mbed; From 7686450c03b8f129dbfbf1ab8e1cc2d2c33a7754 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Fri, 19 Feb 2021 08:38:29 +0000 Subject: [PATCH 08/13] add first cellular unittest --- CMakeLists.txt | 1 + .../cellular/tests/UNITTESTS/CMakeLists.txt | 4 +++ .../UNITTESTS/framework/AT/CMakeLists.txt | 9 +++++ .../AT/at_cellularcontext/CMakeLists.txt | 33 +++++++++++++++++++ .../tests/UNITTESTS/framework/CMakeLists.txt | 6 ++++ 5 files changed, 53 insertions(+) create mode 100644 connectivity/cellular/tests/UNITTESTS/CMakeLists.txt create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ff6220c085f..ec70343f6b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ enable_testing() add_subdirectory(UNITTESTS) add_subdirectory(drivers/tests/UNITTESTS) +add_subdirectory(connectivity/cellular/tests/UNITTESTS) else() diff --git a/connectivity/cellular/tests/UNITTESTS/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/CMakeLists.txt new file mode 100644 index 00000000000..7fa72fe29ee --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(framework) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt new file mode 100644 index 00000000000..547a4d9125e --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(at_cellularcontext) +#add_subdirectory(at_cellulardevice) +#add_subdirectory(at_cellularinformation) +#add_subdirectory(at_cellularnetwork) +#add_subdirectory(at_cellularsms) +#add_subdirectory(at_cellularstack) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt new file mode 100644 index 00000000000..b3e7c509f01 --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME at_cellularcontexttest-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_CELLULAR_USE_SMS=1 + MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 +) + +target_sources(${TEST_NAME} + PRIVATE + ${MBED_PATH}/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp + at_cellularcontexttest.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs + mbed-stubs-headers + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file diff --git a/connectivity/cellular/tests/UNITTESTS/framework/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/CMakeLists.txt new file mode 100644 index 00000000000..5fd2b426e48 --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(AT) +#add_subdirectory(common) +#add_subdirectory(device) From 8e2824adfc29510c2123d99f0075e61ccfe8935c Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Fri, 19 Feb 2021 17:05:16 +0000 Subject: [PATCH 09/13] add all connectivity stubs --- UNITTESTS/stubs/connectivity/CMakeLists.txt | 65 +++++++++------------ 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/UNITTESTS/stubs/connectivity/CMakeLists.txt b/UNITTESTS/stubs/connectivity/CMakeLists.txt index 27b0274d594..dc3473ae6d3 100644 --- a/UNITTESTS/stubs/connectivity/CMakeLists.txt +++ b/UNITTESTS/stubs/connectivity/CMakeLists.txt @@ -13,56 +13,45 @@ target_compile_definitions(mbed-stubs-connectivity MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION=true MBED_CONF_LORA_AUTOMATIC_UPLINK_MESSAGE=true MBED_CONF_LORA_TX_MAX_SIZE=255 + MDMTXD=NC + MDMRXD=NC ) target_sources(mbed-stubs-connectivity PRIVATE - ATHandler_stub.cpp + aes_stub.c + AT_CellularContext_stub.cpp AT_CellularDevice_stub.cpp - AT_CellularStack_stub.cpp + AT_CellularInformation_stub.cpp AT_CellularNetwork_stub.cpp + AT_CellularSMS_stub.cpp + AT_CellularStack_stub.cpp AT_ControlPlane_netif_stub.cpp + ATHandler_stub.cpp + CellularContext_stub.cpp CellularDevice_stub.cpp + CellularInterface_stub.cpp CellularStateMachine_stub.cpp - NetworkInterface_stub.cpp + CellularUtil_stub.cpp + cipher_stub.c + cmac_stub.c + ip4tos_stub.c + LoRaMacChannelPlan_stub.cpp + LoRaMacCommand_stub.cpp + LoRaMacCrypto_stub.cpp + LoRaMac_stub.cpp + LoRaPHYEU868_stub.cpp + LoRaPHY_stub.cpp + LoRaWANStack_stub.cpp + LoRaWANTimer_stub.cpp + MeshInterface_stub.cpp NetworkInterfaceDefaults_stub.cpp + NetworkInterface_stub.cpp NetworkStack_stub.cpp - CellularContext_stub.cpp - CellularUtil_stub.cpp + nsapi_dns_stub.cpp SocketAddress_stub.cpp - aes_stub.c - cipher_stub.c - #AT_CellularContext_stub.cpp - #AT_CellularDevice_stub.cpp - #AT_CellularInformation_stub.cpp - #AT_CellularNetwork_stub.cpp - #AT_CellularSMS_stub.cpp - #AT_CellularStack_stub.cpp - #AT_ControlPlane_netif_stub.cpp - #ATHandler_stub.cpp - #CellularContext_stub.cpp - #CellularDevice_stub.cpp - #CellularInterface_stub.cpp - #CellularStateMachine_stub.cpp - #CellularUtil_stub.cpp - #cmac_stub.c - #ip4tos_stub.c - #LoRaMacChannelPlan_stub.cpp - #LoRaMacCommand_stub.cpp - #LoRaMacCrypto_stub.cpp - #LoRaMac_stub.cpp - #LoRaPHYEU868_stub.cpp - #LoRaPHY_stub.cpp - #LoRaWANStack_stub.cpp - #LoRaWANTimer_stub.cpp - #MeshInterface_stub.cpp - #NetworkInterfaceDefaults_stub.cpp - #NetworkInterface_stub.cpp - #NetworkStack_stub.cpp - #nsapi_dns_stub.cpp - #SocketAddress_stub.cpp - #SocketStats_Stub.cpp - #stoip4_stub.c + SocketStats_Stub.cpp + stoip4_stub.c ) target_link_libraries(mbed-stubs-connectivity From ccb2841a466dbcaa244de542c9d365ba822f1d62 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Fri, 19 Feb 2021 17:05:34 +0000 Subject: [PATCH 10/13] add connectivity framework unittests --- .../UNITTESTS/framework/AT/CMakeLists.txt | 10 +-- .../AT/at_cellularcontext/CMakeLists.txt | 2 +- .../AT/at_cellularcontext/unittest.cmake | 54 ---------------- .../AT/at_cellulardevice/CMakeLists.txt | 39 ++++++++++++ .../AT/at_cellulardevice/unittest.cmake | 61 ------------------- .../AT/at_cellularinformation/CMakeLists.txt | 31 ++++++++++ .../AT/at_cellularinformation/unittest.cmake | 43 ------------- .../AT/at_cellularnetwork/CMakeLists.txt | 32 ++++++++++ .../AT/at_cellularnetwork/unittest.cmake | 45 -------------- .../AT/at_cellularsms/CMakeLists.txt | 32 ++++++++++ .../AT/at_cellularsms/unittest.cmake | 47 -------------- .../AT/at_cellularstack/CMakeLists.txt | 37 +++++++++++ .../AT/at_cellularstack/unittest.cmake | 52 ---------------- drivers/tests/UNITTESTS/PwmOut/unittest.cmake | 29 --------- .../tests/UNITTESTS/Watchdog/unittest.cmake | 29 --------- 15 files changed, 177 insertions(+), 366 deletions(-) delete mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/unittest.cmake create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt delete mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/unittest.cmake create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt delete mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/unittest.cmake create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt delete mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/unittest.cmake create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt delete mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/unittest.cmake create mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt delete mode 100644 connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/unittest.cmake delete mode 100644 drivers/tests/UNITTESTS/PwmOut/unittest.cmake delete mode 100644 drivers/tests/UNITTESTS/Watchdog/unittest.cmake diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt index 547a4d9125e..fcc649fa527 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/CMakeLists.txt @@ -2,8 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 add_subdirectory(at_cellularcontext) -#add_subdirectory(at_cellulardevice) -#add_subdirectory(at_cellularinformation) -#add_subdirectory(at_cellularnetwork) -#add_subdirectory(at_cellularsms) -#add_subdirectory(at_cellularstack) +add_subdirectory(at_cellulardevice) +add_subdirectory(at_cellularinformation) +add_subdirectory(at_cellularnetwork) +add_subdirectory(at_cellularsms) +add_subdirectory(at_cellularstack) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt index b3e7c509f01..df155632bf3 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -set(TEST_NAME at_cellularcontexttest-unittest) +set(TEST_NAME at_cellularcontext-unittest) add_executable(${TEST_NAME}) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/unittest.cmake b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/unittest.cmake deleted file mode 100644 index 4c90919afe1..00000000000 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/unittest.cmake +++ /dev/null @@ -1,54 +0,0 @@ - -#################### -# UNIT TESTS -#################### - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - ../connectivity/cellular/tests/UNITTESTS/framework/common/util - ../connectivity/cellular/include/cellular/framework/common - ../connectivity/cellular/include/cellular/framework/AT - ../connectivity/cellular/include/cellular/framework/device -) - -# Source files -set(unittest-sources - ../connectivity/cellular/source/framework/AT/AT_CellularContext.cpp -) - -# Test files -set(unittest-test-sources - ${CMAKE_CURRENT_LIST_DIR}/at_cellularcontexttest.cpp - stubs/ATHandler_stub.cpp - stubs/AT_CellularDevice_stub.cpp - stubs/AT_CellularStack_stub.cpp - stubs/AT_CellularNetwork_stub.cpp - stubs/AT_ControlPlane_netif_stub.cpp - stubs/CellularDevice_stub.cpp - stubs/CellularStateMachine_stub.cpp - stubs/equeue_stub.c - stubs/EventQueue_stub.cpp - stubs/FileHandle_stub.cpp - stubs/mbed_assert_stub.cpp - stubs/NetworkInterface_stub.cpp - stubs/NetworkInterfaceDefaults_stub.cpp - stubs/NetworkStack_stub.cpp - stubs/randLIB_stub.cpp - stubs/Semaphore_stub.cpp - stubs/us_ticker_stub.cpp - stubs/BufferedSerial_stub.cpp - stubs/SerialBase_stub.cpp - stubs/CellularContext_stub.cpp - stubs/CellularUtil_stub.cpp - stubs/SocketAddress_stub.cpp - stubs/ConditionVariable_stub.cpp - stubs/Mutex_stub.cpp -) - -set(unittest-test-flags - -DDEVICE_SERIAL=1 - -DDEVICE_INTERRUPTIN=1 - -DMBED_CONF_CELLULAR_USE_SMS=1 - -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL - -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt new file mode 100644 index 00000000000..b7eaf80e936 --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt @@ -0,0 +1,39 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME at_cellulardevice-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL + MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME=NULL + MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD=NULL + MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN=NULL + MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN=NULL + MDMTXD=NC + MDMRXD=NC + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 + MBED_CONF_CELLULAR_USE_SMS=1 +) + +target_sources(${TEST_NAME} + PRIVATE + ${MBED_PATH}/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp + at_cellulardevicetest.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs + mbed-stubs-headers + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/unittest.cmake b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/unittest.cmake deleted file mode 100644 index 20bc3168805..00000000000 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/unittest.cmake +++ /dev/null @@ -1,61 +0,0 @@ - -#################### -# UNIT TESTS -#################### - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - ../connectivity/cellular/tests/UNITTESTS/framework/common/util - ../connectivity/cellular/include/cellular/framework/common - ../connectivity/cellular/include/cellular/framework/AT - ../connectivity/cellular/include/cellular/framework/device - ../platform/randlib/include/mbed-client-randlib - ../drivers - ../hal -) - -# Source files -set(unittest-sources - stubs/randLIB_stub.c - ../connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp -) - -# Test files -set(unittest-test-sources - ${CMAKE_CURRENT_LIST_DIR}/at_cellulardevicetest.cpp - stubs/AT_CellularNetwork_stub.cpp - stubs/ATHandler_stub.cpp - stubs/AT_CellularSMS_stub.cpp - stubs/AT_CellularInformation_stub.cpp - stubs/CellularUtil_stub.cpp - stubs/NetworkInterface_stub.cpp - stubs/NetworkInterfaceDefaults_stub.cpp - stubs/EventQueue_stub.cpp - stubs/FileHandle_stub.cpp - stubs/mbed_assert_stub.cpp - stubs/CellularDevice_stub.cpp - stubs/NetworkStack_stub.cpp - stubs/AT_CellularContext_stub.cpp - stubs/Semaphore_stub.cpp - stubs/BufferedSerial_stub.cpp - stubs/SerialBase_stub.cpp - stubs/CellularStateMachine_stub.cpp - stubs/CellularContext_stub.cpp - stubs/ThisThread_stub.cpp - stubs/ConditionVariable_stub.cpp - stubs/Mutex_stub.cpp -) - -set(unittest-test-flags - -DDEVICE_SERIAL=1 - -DDEVICE_INTERRUPTIN=1 - -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL - -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME=NULL - -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD=NULL - -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN=NULL - -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN=NULL - -DMDMTXD=NC - -DMDMRXD=NC - -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 - -DMBED_CONF_CELLULAR_USE_SMS=1 -) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt new file mode 100644 index 00000000000..e42f1b73006 --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME at_cellularinformation-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 +) + +target_sources(${TEST_NAME} + PRIVATE + ${MBED_PATH}/connectivity/cellular/source/framework/AT/AT_CellularInformation.cpp + at_cellularinformationtest.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs + mbed-stubs-headers + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/unittest.cmake b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/unittest.cmake deleted file mode 100644 index fad602356cf..00000000000 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/unittest.cmake +++ /dev/null @@ -1,43 +0,0 @@ - -#################### -# UNIT TESTS -#################### - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - ../connectivity/cellular/tests/UNITTESTS/framework/common/util - ../connectivity/cellular/include/cellular/framework/common - ../connectivity/cellular/include/cellular/framework/AT - ../platform/randlib/include/mbed-client-randlib -) - -# Source files -set(unittest-sources - stubs/randLIB_stub.c - ../connectivity/cellular/source/framework/AT/AT_CellularInformation.cpp -) - -# Test files -set(unittest-test-sources - ${CMAKE_CURRENT_LIST_DIR}/at_cellularinformationtest.cpp - stubs/ATHandler_stub.cpp - stubs/EventQueue_stub.cpp - stubs/FileHandle_stub.cpp - stubs/mbed_assert_stub.cpp - stubs/ConditionVariable_stub.cpp - stubs/CellularDevice_stub.cpp - stubs/AT_CellularDevice_stub.cpp - stubs/CellularContext_stub.cpp - stubs/AT_CellularContext_stub.cpp - stubs/AT_CellularNetwork_stub.cpp - stubs/NetworkInterface_stub.cpp - stubs/NetworkInterfaceDefaults_stub.cpp - stubs/Mutex_stub.cpp - stubs/Semaphore_stub.cpp -) - -set(unittest-test-flags - -DDEVICE_SERIAL=1 - -DDEVICE_INTERRUPTIN=1 - -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt new file mode 100644 index 00000000000..6b1667189d0 --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME at_cellularnetwork-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 +) + +target_sources(${TEST_NAME} + PRIVATE + ${MBED_PATH}/connectivity/cellular/source/framework/AT/AT_CellularNetwork.cpp + ${MBED_PATH}/connectivity/cellular/source/framework/common/CellularUtil.cpp + at_cellularnetworktest.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs + mbed-stubs-headers + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/unittest.cmake b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/unittest.cmake deleted file mode 100644 index 07c7b9c4387..00000000000 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/unittest.cmake +++ /dev/null @@ -1,45 +0,0 @@ - -#################### -# UNIT TESTS -#################### - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - ../connectivity/cellular/tests/UNITTESTS/framework/common/util - ../connectivity/cellular/include/cellular/framework/common - ../connectivity/cellular/include/cellular/framework/AT - ../platform/randlib/include/mbed-client-randlib -) - -# Source files -set(unittest-sources - ../connectivity/cellular/source/framework/AT/AT_CellularNetwork.cpp - ../connectivity/cellular/source/framework/common/CellularUtil.cpp -) - -# Test files -set(unittest-test-sources - ${CMAKE_CURRENT_LIST_DIR}/at_cellularnetworktest.cpp - stubs/ATHandler_stub.cpp - stubs/EventQueue_stub.cpp - stubs/FileHandle_stub.cpp - stubs/us_ticker_stub.cpp - stubs/CellularDevice_stub.cpp - stubs/AT_CellularDevice_stub.cpp - stubs/CellularContext_stub.cpp - stubs/AT_CellularContext_stub.cpp - stubs/NetworkInterface_stub.cpp - stubs/NetworkInterfaceDefaults_stub.cpp - stubs/mbed_assert_stub.cpp - stubs/SocketAddress_stub.cpp - stubs/randLIB_stub.cpp - stubs/ConditionVariable_stub.cpp - stubs/Mutex_stub.cpp - stubs/Semaphore_stub.cpp -) - -set(unittest-test-flags - -DDEVICE_SERIAL=1 - -DDEVICE_INTERRUPTIN=1 - -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt new file mode 100644 index 00000000000..29ae195a4d7 --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME at_cellularsms-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 + MBED_CONF_CELLULAR_USE_SMS=1 +) + +target_sources(${TEST_NAME} + PRIVATE + ${MBED_PATH}/connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp + at_cellularsmstest.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs + mbed-stubs-headers + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/unittest.cmake b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/unittest.cmake deleted file mode 100644 index dc344876f98..00000000000 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/unittest.cmake +++ /dev/null @@ -1,47 +0,0 @@ - -#################### -# UNIT TESTS -#################### - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - ../connectivity/cellular/tests/UNITTESTS/framework/common/util - ../connectivity/cellular/include/cellular/framework/common - ../connectivity/cellular/include/cellular/framework/AT - ../platform/randlib/include/mbed-client-randlib -) - -# Source files -set(unittest-sources - ../connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp -) - -# Test files -set(unittest-test-sources - ${CMAKE_CURRENT_LIST_DIR}/at_cellularsmstest.cpp - stubs/ATHandler_stub.cpp - stubs/EventQueue_stub.cpp - stubs/FileHandle_stub.cpp - stubs/CellularUtil_stub.cpp - stubs/us_ticker_stub.cpp - stubs/mbed_assert_stub.cpp - stubs/ThisThread_stub.cpp - stubs/mbed_wait_api_stub.cpp - stubs/ConditionVariable_stub.cpp - stubs/CellularDevice_stub.cpp - stubs/AT_CellularDevice_stub.cpp - stubs/CellularContext_stub.cpp - stubs/AT_CellularContext_stub.cpp - stubs/AT_CellularNetwork_stub.cpp - stubs/NetworkInterface_stub.cpp - stubs/NetworkInterfaceDefaults_stub.cpp - stubs/Mutex_stub.cpp - stubs/Semaphore_stub.cpp -) - -set(unittest-test-flags - -DMBED_CONF_CELLULAR_USE_SMS=1 - -DDEVICE_SERIAL=1 - -DDEVICE_INTERRUPTIN=1 - -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt new file mode 100644 index 00000000000..b4391837bbb --- /dev/null +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt @@ -0,0 +1,37 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set(TEST_NAME at_cellularstack-unittest) + +add_executable(${TEST_NAME}) + +target_compile_definitions(${TEST_NAME} + PRIVATE + DEVICE_SERIAL=1 + DEVICE_INTERRUPTIN=1 + MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 +) + +target_sources(${TEST_NAME} + PRIVATE + ${MBED_PATH}/connectivity/cellular/source/framework/AT/AT_CellularStack.cpp + ${MBED_PATH}/connectivity/libraries/nanostack-libservice/source/libip4string/ip4tos.c + ${MBED_PATH}/connectivity/libraries/nanostack-libservice/source/libip6string/ip6tos.c + ${MBED_PATH}/connectivity/libraries/nanostack-libservice/source/libip4string/stoip4.c + ${MBED_PATH}/connectivity/libraries/nanostack-libservice/source/libip6string/stoip6.c + ${MBED_PATH}/connectivity/libraries/nanostack-libservice/source/libBits/common_functions.c + ${MBED_PATH}/connectivity/netsocket/source/SocketAddress.cpp + at_cellularstacktest.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs + mbed-stubs-headers + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/unittest.cmake b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/unittest.cmake deleted file mode 100644 index 97fe9a230b7..00000000000 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/unittest.cmake +++ /dev/null @@ -1,52 +0,0 @@ - -#################### -# UNIT TESTS -#################### - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - ../connectivity/cellular/tests/UNITTESTS/framework/common/util - ../connectivity/cellular/include/cellular/framework/common - ../connectivity/cellular/include/cellular/framework/AT - ../platform/randlib/include/mbed-client-randlib -) - -# Source files -set(unittest-sources - ../connectivity/cellular/source/framework/AT/AT_CellularStack.cpp - ../connectivity/libraries/nanostack-libservice/source/libip4string/ip4tos.c - ../connectivity/libraries/nanostack-libservice/source/libip6string/ip6tos.c - ../connectivity/libraries/nanostack-libservice/source/libip4string/stoip4.c - ../connectivity/libraries/nanostack-libservice/source/libip6string/stoip6.c - ../connectivity/libraries/nanostack-libservice/source/libBits/common_functions.c - ../connectivity/netsocket/source/SocketAddress.cpp -) - -# Test files -set(unittest-test-sources - ${CMAKE_CURRENT_LIST_DIR}/at_cellularstacktest.cpp - stubs/ATHandler_stub.cpp - stubs/EventQueue_stub.cpp - stubs/FileHandle_stub.cpp - stubs/CellularUtil_stub.cpp - stubs/CellularContext_stub.cpp - stubs/AT_CellularContext_stub.cpp - stubs/AT_CellularNetwork_stub.cpp - stubs/NetworkInterfaceDefaults_stub.cpp - stubs/NetworkInterface_stub.cpp - stubs/CellularDevice_stub.cpp - stubs/AT_CellularDevice_stub.cpp - stubs/us_ticker_stub.cpp - stubs/NetworkStack_stub.cpp - stubs/mbed_assert_stub.cpp - stubs/ThisThread_stub.cpp - stubs/ConditionVariable_stub.cpp - stubs/Mutex_stub.cpp - stubs/Semaphore_stub.cpp -) - -set(unittest-test-flags - -DDEVICE_SERIAL=1 - -DDEVICE_INTERRUPTIN=1 - -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -) diff --git a/drivers/tests/UNITTESTS/PwmOut/unittest.cmake b/drivers/tests/UNITTESTS/PwmOut/unittest.cmake deleted file mode 100644 index 20ed5238752..00000000000 --- a/drivers/tests/UNITTESTS/PwmOut/unittest.cmake +++ /dev/null @@ -1,29 +0,0 @@ - -#################### -# UNIT TESTS -#################### -set(TEST_SUITE_NAME "PwmOut") - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - . - ../hal -) - -# Source files -set(unittest-sources - ../drivers/source/PwmOut.cpp -) - -# Test files -set(unittest-test-sources - ../drivers/tests/UNITTESTS/PwmOut/test_pwmout.cpp - stubs/mbed_critical_stub.c - stubs/mbed_assert_stub.cpp - stubs/pwmout_api_stub.c -) - -set(unittest-test-flags - -DDEVICE_PWMOUT -) - diff --git a/drivers/tests/UNITTESTS/Watchdog/unittest.cmake b/drivers/tests/UNITTESTS/Watchdog/unittest.cmake deleted file mode 100644 index 92254cee56e..00000000000 --- a/drivers/tests/UNITTESTS/Watchdog/unittest.cmake +++ /dev/null @@ -1,29 +0,0 @@ - -#################### -# UNIT TESTS -#################### -set(TEST_SUITE_NAME "Watchdog") - -# Add test specific include paths -set(unittest-includes ${unittest-includes} - . - ../hal -) - -# Source files -set(unittest-sources - ../drivers/source/Watchdog.cpp -) - -# Test files -set(unittest-test-sources - ../drivers/tests/UNITTESTS/Watchdog/test_watchdog.cpp - stubs/mbed_critical_stub.c - stubs/mbed_assert_stub.cpp - stubs/watchdog_api_stub.c -) - -set(unittest-test-flags - -DDEVICE_WATCHDOG - -DMBED_WDOG_ASSERT=1 -) From 5a27f3bc1dcec553baf09c24ee230529704d3aa2 Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Mon, 22 Feb 2021 02:49:03 -0800 Subject: [PATCH 11/13] - Add missing new line - Remove redundant file --- CMakeLists.txt | 2 +- UNITTESTS/CMakeLists.txt | 3 ++- UNITTESTS/stubs/CMakeLists.txt | 2 +- .../UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt | 2 +- .../UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt | 2 +- .../framework/AT/at_cellularinformation/CMakeLists.txt | 2 +- .../UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt | 2 +- .../tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt | 2 +- .../UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt | 2 +- drivers/tests/UNITTESTS/CMakeLists.txt | 2 +- drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt | 2 +- drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt | 2 +- tools/cmake/mbed_unittest.cmake | 0 13 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 tools/cmake/mbed_unittest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ec70343f6b1..0a2a92250e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,4 +270,4 @@ if ("${CMAKE_GENERATOR}" MATCHES "Ninja") endif() endif() -endif() \ No newline at end of file +endif() diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 7b4a4dd7793..78491c14e09 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -80,4 +80,5 @@ macro( mbed_add_all_subdirectories subdirectories_list ) endmacro() add_subdirectory(stubs) -add_subdirectory(fakes) \ No newline at end of file +add_subdirectory(fakes) + diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index d03fe648a27..2c196e66c32 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -142,4 +142,4 @@ target_link_libraries(mbed-stubs mbed-stubs-platform mbed-stubs-rtos mbed-stubs-storage -) \ No newline at end of file +) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt index df155632bf3..d24165b8558 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt @@ -30,4 +30,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt index b7eaf80e936..7b7d924aa1e 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt @@ -36,4 +36,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt index e42f1b73006..1c0a9e28d28 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/CMakeLists.txt @@ -28,4 +28,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt index 6b1667189d0..9ce24d83523 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/CMakeLists.txt @@ -29,4 +29,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt index 29ae195a4d7..9b1e5d23cbb 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/CMakeLists.txt @@ -29,4 +29,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt index b4391837bbb..db48013ce76 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt @@ -34,4 +34,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular") diff --git a/drivers/tests/UNITTESTS/CMakeLists.txt b/drivers/tests/UNITTESTS/CMakeLists.txt index ce1549bf229..b04c7f0be60 100644 --- a/drivers/tests/UNITTESTS/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/CMakeLists.txt @@ -2,4 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 add_subdirectory(PwmOut) -add_subdirectory(Watchdog) \ No newline at end of file +add_subdirectory(Watchdog) diff --git a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt index 106c035bf40..184767de77c 100644 --- a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt @@ -26,4 +26,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") diff --git a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt index 0a79be0d67f..26903b586c9 100644 --- a/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt +++ b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt @@ -27,4 +27,4 @@ target_link_libraries(${TEST_NAME} add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) -set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") \ No newline at end of file +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") diff --git a/tools/cmake/mbed_unittest.cmake b/tools/cmake/mbed_unittest.cmake deleted file mode 100644 index e69de29bb2d..00000000000 From 0a915fa10efbf55aea21cbd5ce4052982ace7e4b Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Mon, 22 Feb 2021 03:23:19 -0800 Subject: [PATCH 12/13] - Fix CMake project missing warning - Fix connectivity build issue of miss to link aginst gtest --- CMakeLists.txt | 2 ++ UNITTESTS/CMakeLists.txt | 2 -- UNITTESTS/stubs/connectivity/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a2a92250e0..6ea3c417ac5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ option(UNITTESTS "Run unit tests only." OFF) if(UNITTESTS) +project(unittests) + enable_testing() add_subdirectory(UNITTESTS) diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 78491c14e09..2dc413c0e84 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -1,8 +1,6 @@ # Copyright (c) 2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -project(unittests) - set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.. CACHE INTERNAL "") # Setup c++ standard diff --git a/UNITTESTS/stubs/connectivity/CMakeLists.txt b/UNITTESTS/stubs/connectivity/CMakeLists.txt index dc3473ae6d3..e3cdfc7415e 100644 --- a/UNITTESTS/stubs/connectivity/CMakeLists.txt +++ b/UNITTESTS/stubs/connectivity/CMakeLists.txt @@ -58,4 +58,5 @@ target_link_libraries(mbed-stubs-connectivity PRIVATE mbed-headers mbed-stubs-headers + gtest ) From 29eed7c4aa359e570cbb962bda97f7423539bc57 Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Mon, 22 Feb 2021 08:02:34 -0800 Subject: [PATCH 13/13] Incorporated review comments --- CMakeLists.txt | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ea3c417ac5..7eff09c5dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,18 +5,15 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) -option(UNITTESTS "Run unit tests only." OFF) - -if(UNITTESTS) - -project(unittests) - -enable_testing() - -add_subdirectory(UNITTESTS) -add_subdirectory(drivers/tests/UNITTESTS) -add_subdirectory(connectivity/cellular/tests/UNITTESTS) - +option(MBED_BUILD_UNITTESTS "Run unit tests only." OFF) + +if(MBED_BUILD_UNITTESTS) + project(mbed-unittests) + enable_testing() + + add_subdirectory(UNITTESTS) + add_subdirectory(${MBED_PATH}/drivers/tests/UNITTESTS) + add_subdirectory(${MBED_PATH}/connectivity/cellular/tests/UNITTESTS) else() include(${MBED_CONFIG_PATH}/mbed_config.cmake)