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..7eff09c5dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,17 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) +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) 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() diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 6aba4ba07ff..2dc413c0e84 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -1,66 +1,35 @@ -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(${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 +38,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 +47,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 +69,14 @@ 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}) +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() - # 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) +add_subdirectory(stubs) +add_subdirectory(fakes) diff --git a/UNITTESTS/fakes/CMakeLists.txt b/UNITTESTS/fakes/CMakeLists.txt new file mode 100644 index 00000000000..01834be5919 --- /dev/null +++ b/UNITTESTS/fakes/CMakeLists.txt @@ -0,0 +1,3 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + 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") diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt new file mode 100644 index 00000000000..2c196e66c32 --- /dev/null +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -0,0 +1,145 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +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-headers + INTERFACE + 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-headers-platform + INTERFACE + ${MBED_PATH}/platform/include + ${MBED_PATH}/platform/include/platform + ${MBED_PATH}/platform/randlib/include/mbed-client-randlib/ + ${MBED_PATH}/platform/randlib/include/ + ${MBED_PATH}/platform/mbed-trace/include +) + +target_include_directories(mbed-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 + ${MBED_PATH}/UNITTESTS/target_h/rtos + ${MBED_PATH}/UNITTESTS/target_h/sys +) + +target_include_directories(mbed-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 + ${MBED_PATH}/storage/blockdevice/include/blockdevice +) + +target_include_directories(mbed-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-headers-drivers + INTERFACE + ${MBED_PATH}/drivers + ${MBED_PATH}/drivers/include + ${MBED_PATH}/drivers/include/drivers +) + +target_include_directories(mbed-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-headers-hal + INTERFACE + ${MBED_PATH}/hal + ${MBED_PATH}/hal/include +) + +target_include_directories(mbed-headers-rtos + INTERFACE + ${MBED_PATH}/rtos/include + ${MBED_PATH}/rtos/include/rtos +) + +target_include_directories(mbed-headers + INTERFACE + ${MBED_PATH}/features + ${MBED_PATH}/features/frameworks +) + +target_include_directories(mbed-stubs-headers + INTERFACE + . +) + +add_subdirectory(connectivity) +add_subdirectory(drivers) +add_subdirectory(events) +add_subdirectory(hal) +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 +) 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..e3cdfc7415e --- /dev/null +++ b/UNITTESTS/stubs/connectivity/CMakeLists.txt @@ -0,0 +1,62 @@ +# 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 + MDMTXD=NC + MDMRXD=NC +) + +target_sources(mbed-stubs-connectivity + PRIVATE + aes_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 + 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 + 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 + gtest +) 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 new file mode 100644 index 00000000000..50d93669208 --- /dev/null +++ b/UNITTESTS/stubs/hal/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +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 + 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/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/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/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..e03919fe060 --- /dev/null +++ b/UNITTESTS/stubs/platform/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-stubs-platform) + +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 + 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/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_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 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 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/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..fcc649fa527 --- /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..d24165b8558 --- /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_cellularcontext-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") 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..7b7d924aa1e --- /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") 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..1c0a9e28d28 --- /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") 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..9ce24d83523 --- /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") 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..9b1e5d23cbb --- /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") 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..db48013ce76 --- /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") 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/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) 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; diff --git a/drivers/tests/UNITTESTS/CMakeLists.txt b/drivers/tests/UNITTESTS/CMakeLists.txt new file mode 100644 index 00000000000..b04c7f0be60 --- /dev/null +++ b/drivers/tests/UNITTESTS/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(PwmOut) +add_subdirectory(Watchdog) diff --git a/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt new file mode 100644 index 00000000000..184767de77c --- /dev/null +++ b/drivers/tests/UNITTESTS/PwmOut/CMakeLists.txt @@ -0,0 +1,29 @@ +# 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 + ${MBED_PATH}/drivers/source/PwmOut.cpp + test_pwmout.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs-hal + mbed-stubs-platform + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") 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/CMakeLists.txt b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt new file mode 100644 index 00000000000..26903b586c9 --- /dev/null +++ b/drivers/tests/UNITTESTS/Watchdog/CMakeLists.txt @@ -0,0 +1,30 @@ +# 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 + ${MBED_PATH}/drivers/source/Watchdog.cpp + test_watchdog.cpp +) + +target_link_libraries(${TEST_NAME} + PRIVATE + mbed-headers + mbed-stubs-platform + mbed-stubs-hal + gmock_main +) + +add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME}) + +set_tests_properties(${TEST_NAME} PROPERTIES LABELS "drivers") 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 -)