diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt new file mode 100644 index 0000000000..942adbcbf8 --- /dev/null +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -0,0 +1,149 @@ +# 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-os_SOURCE_DIR}/platform/include + ${mbed-os_SOURCE_DIR}/platform/include/platform + ${mbed-os_SOURCE_DIR}/platform/randlib/include/mbed-client-randlib/ + ${mbed-os_SOURCE_DIR}/platform/randlib/include/ + ${mbed-os_SOURCE_DIR}/platform/mbed-trace/include +) + +target_include_directories(mbed-headers-base + INTERFACE + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h/platform + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h/platform/cxxsupport + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h/drivers + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h/rtos/include + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h/rtos + ${mbed-os_SOURCE_DIR}/UNITTESTS/target_h/sys +) + +target_include_directories(mbed-headers-storage + INTERFACE + ${mbed-os_SOURCE_DIR}/storage/filesystem/fat/include + ${mbed-os_SOURCE_DIR}/storage/filesystem/fat/ChaN + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/include + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs/bd + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/littlefs + ${mbed-os_SOURCE_DIR}/storage/blockdevice/include + ${mbed-os_SOURCE_DIR}/storage/filesystem/include + ${mbed-os_SOURCE_DIR}/storage/kvstore/include + ${mbed-os_SOURCE_DIR}/storage/kvstore/kv_config + ${mbed-os_SOURCE_DIR}/storage/kvstore/kv_config/include + ${mbed-os_SOURCE_DIR}/storage/kvstore/tdbstore/include + ${mbed-os_SOURCE_DIR}/storage/kvstore/filesystemstore/include + ${mbed-os_SOURCE_DIR}/storage/kvstore/kvstore_global_api/include + ${mbed-os_SOURCE_DIR}/storage/blockdevice/include/blockdevice +) + +target_include_directories(mbed-headers-connectivity + INTERFACE + ${mbed-os_SOURCE_DIR}/connectivity/libraries/nanostack-libservice + ${mbed-os_SOURCE_DIR}/connectivity/libraries/nanostack-libservice/mbed-client-libservice + ${mbed-os_SOURCE_DIR}/connectivity/netsocket/include + ${mbed-os_SOURCE_DIR}/connectivity/cellular/include/cellular/framework/API + ${mbed-os_SOURCE_DIR}/connectivity/cellular/include/cellular/framework/AT + ${mbed-os_SOURCE_DIR}/connectivity/cellular/include/cellular/framework/device + ${mbed-os_SOURCE_DIR}/connectivity/cellular/include/cellular/framework + ${mbed-os_SOURCE_DIR}/connectivity/cellular/include/cellular/framework/common + ${mbed-os_SOURCE_DIR}/connectivity + ${mbed-os_SOURCE_DIR}/connectivity/lorawan/include/lorawan + ${mbed-os_SOURCE_DIR}/connectivity/lorawan/lorastack + ${mbed-os_SOURCE_DIR}/connectivity/lorawan/lorastack/mac + ${mbed-os_SOURCE_DIR}/connectivity/lorawan/lorastack/phy + ${mbed-os_SOURCE_DIR}/connectivity/lorawan + ${mbed-os_SOURCE_DIR}/connectivity/lorawan/system + ${mbed-os_SOURCE_DIR}/connectivity/mbedtls + ${mbed-os_SOURCE_DIR}/connectivity/mbedtls/include + ${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/include + ${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/include/ble +) + +target_include_directories(mbed-headers-drivers + INTERFACE + ${mbed-os_SOURCE_DIR}/drivers + ${mbed-os_SOURCE_DIR}/drivers/include + ${mbed-os_SOURCE_DIR}/drivers/include/drivers +) + +target_include_directories(mbed-headers-events + INTERFACE + ${mbed-os_SOURCE_DIR}/events/tests/UNITTESTS/target_h + ${mbed-os_SOURCE_DIR}/events/tests/UNITTESTS/target_h/equeue + ${mbed-os_SOURCE_DIR}/events/include + ${mbed-os_SOURCE_DIR}/events/include/events + ${mbed-os_SOURCE_DIR}/events/include/events/internal +) + +target_include_directories(mbed-headers-hal + INTERFACE + ${mbed-os_SOURCE_DIR}/hal + ${mbed-os_SOURCE_DIR}/hal/include +) + +target_include_directories(mbed-headers-rtos + INTERFACE + ${mbed-os_SOURCE_DIR}/rtos/include + ${mbed-os_SOURCE_DIR}/rtos/include/rtos +) + +target_include_directories(mbed-headers + INTERFACE + ${mbed-os_SOURCE_DIR}/features + ${mbed-os_SOURCE_DIR}/features/frameworks +) + +target_include_directories(mbed-stubs-headers + INTERFACE + . + ${mbed-os_SOURCE_DIR}/connectivity/nanostack/coap-service/test/coap-service/unittest/stub +) + +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 0000000000..faba2e38e2 --- /dev/null +++ b/UNITTESTS/stubs/connectivity/CMakeLists.txt @@ -0,0 +1,63 @@ +# 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 + ${mbed-os_SOURCE_DIR}/connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_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 0000000000..139fa28451 --- /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 0000000000..c0127aab56 --- /dev/null +++ b/UNITTESTS/stubs/events/CMakeLists.txt @@ -0,0 +1,19 @@ +# 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 + ${mbed-os_SOURCE_DIR}/events/tests/UNITTESTS/stubs/EqueuePosix_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 0000000000..5f011143fa --- /dev/null +++ b/UNITTESTS/stubs/hal/CMakeLists.txt @@ -0,0 +1,25 @@ +# 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 + gcov +) 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 0000000000..a1d1bd1bf8 --- /dev/null +++ b/UNITTESTS/stubs/platform/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 + FileHandle_stub.cpp + nvic_wrapper_stub.c + randLIB_stub.c + randLIB_stub.cpp +) + +target_link_libraries(mbed-stubs-platform + PRIVATE + mbed-headers + mbed-stubs-headers + gcov +) diff --git a/UNITTESTS/stubs/FileHandle_stub.cpp b/UNITTESTS/stubs/platform/FileHandle_stub.cpp similarity index 100% rename from UNITTESTS/stubs/FileHandle_stub.cpp rename to UNITTESTS/stubs/platform/FileHandle_stub.cpp 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 0000000000..fc9a759b8d --- /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 aa45009fa5..889065cbcb 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 de5aed92bd..916be3ee95 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 0000000000..721f0f1d92 --- /dev/null +++ b/UNITTESTS/stubs/storage/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 + 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/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 99% rename from UNITTESTS/stubs/MBRBlockDevice_stub.cpp rename to UNITTESTS/stubs/storage/MBRBlockDevice_stub.cpp index 449236be6e..64fe7d181b 100644 --- a/UNITTESTS/stubs/MBRBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/storage/MBRBlockDevice_stub.cpp @@ -18,6 +18,7 @@ #include "MBRBlockDevice.h" #include "mbed_critical.h" #include +#include "mbed_toolchain.h" // On disk structures, all entries are little endian 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 a40ab9e73b..570a52a0d9 100644 --- a/UNITTESTS/target_h/cmsis_os.h +++ b/UNITTESTS/target_h/cmsis_os.h @@ -27,4 +27,5 @@ typedef struct { } osEvent; +typedef int32_t osStatus; #endif