From f58c5631c0b5533672afd405cdab65d377ef0626 Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Sun, 19 Jul 2020 10:02:32 -0700 Subject: [PATCH] Fix UNITTESTS issue --- UNITTESTS/CMakeLists.txt | 10 ++++------ UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp | 2 +- UNITTESTS/stubs/Kernel_stub.cpp | 2 +- UNITTESTS/stubs/Semaphore_stub.cpp | 2 +- UNITTESTS/stubs/Thread_stub.h | 2 +- UNITTESTS/target_h/rtos/Mutex.h | 4 ++-- UNITTESTS/target_h/rtos/Semaphore.h | 6 ++++++ UNITTESTS/target_h/rtos/Thread.h | 17 +++++++++++++---- .../rtos/internal}/mbed_rtos1_types.h | 0 .../rtos/internal}/mbed_rtos_storage.h | 0 features/cellular/framework/API/ATHandler.h | 2 +- .../cellular/framework/API/CellularDevice.h | 2 +- .../framework/AT/AT_CellularContext.cpp | 2 +- .../cellular/framework/AT/AT_CellularContext.h | 2 +- .../cellular/framework/AT/AT_CellularSMS.cpp | 2 +- .../cellular/framework/AT/AT_CellularStack.cpp | 2 +- .../framework/AT/AT_ControlPlane_netif.cpp | 2 +- .../cellular/framework/device/ATHandler.cpp | 2 +- .../framework/device/CellularContext.cpp | 2 +- features/netsocket/TLSSocketWrapper.cpp | 2 +- features/netsocket/nsapi_dns.cpp | 2 +- 21 files changed, 40 insertions(+), 27 deletions(-) rename UNITTESTS/target_h/rtos/{ => include/rtos/internal}/mbed_rtos1_types.h (100%) rename UNITTESTS/target_h/rtos/{ => include/rtos/internal}/mbed_rtos_storage.h (100%) diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index b6b1d6b6af..3db4960d59 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -108,6 +108,7 @@ set(unittest-includes-base "${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" @@ -118,10 +119,7 @@ set(unittest-includes-base "${PROJECT_SOURCE_DIR}/../events" "${PROJECT_SOURCE_DIR}/../events/source" "${PROJECT_SOURCE_DIR}/../events/internal" - "${PROJECT_SOURCE_DIR}/../rtos" - "${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX" - "${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX/rtx5/Include" - "${PROJECT_SOURCE_DIR}/../cmsis" + "${PROJECT_SOURCE_DIR}/../rtos/include" "${PROJECT_SOURCE_DIR}/../features/frameworks" "${PROJECT_SOURCE_DIR}/../features/frameworks/mbed-trace" "${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice" @@ -152,7 +150,7 @@ set(TEST_SUITES) # Get all matched tests. file(GLOB_RECURSE unittest-file-list - "unittest.cmake" + "../unittest.cmake" # matches any ../**/unittest.cmake ) if ("${unittest-file-list}" STREQUAL "") @@ -178,7 +176,7 @@ foreach(testfile ${unittest-file-list}) file(RELATIVE_PATH TEST_SUITE_NAME # output - ${PROJECT_SOURCE_DIR} # root + "${PROJECT_SOURCE_DIR}/.." # root ${TEST_SUITE_DIR} #abs dirpath ) diff --git a/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp b/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp index 8f89a3a6c6..9dad6b0d7e 100644 --- a/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp +++ b/UNITTESTS/stubs/AT_ControlPlane_netif_stub.cpp @@ -16,7 +16,7 @@ */ #include "CellularUtil.h" -#include "ThisThread.h" +#include "rtos/ThisThread.h" #include "AT_ControlPlane_netif.h" #include "CellularLog.h" diff --git a/UNITTESTS/stubs/Kernel_stub.cpp b/UNITTESTS/stubs/Kernel_stub.cpp index a2697ad161..d72a016cdd 100644 --- a/UNITTESTS/stubs/Kernel_stub.cpp +++ b/UNITTESTS/stubs/Kernel_stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "Kernel.h" +#include "rtos/Kernel.h" namespace rtos { diff --git a/UNITTESTS/stubs/Semaphore_stub.cpp b/UNITTESTS/stubs/Semaphore_stub.cpp index a1dddb6c9d..fd2b2f25ef 100644 --- a/UNITTESTS/stubs/Semaphore_stub.cpp +++ b/UNITTESTS/stubs/Semaphore_stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "Semaphore.h" +#include "rtos/Semaphore.h" #include "Semaphore_stub.h" int Semaphore_stub::wait_return_value = 0; diff --git a/UNITTESTS/stubs/Thread_stub.h b/UNITTESTS/stubs/Thread_stub.h index be13fb841e..60156ebac7 100644 --- a/UNITTESTS/stubs/Thread_stub.h +++ b/UNITTESTS/stubs/Thread_stub.h @@ -17,7 +17,7 @@ #ifndef THREAD_STUB_H_ #define THREAD_STUB_H_ -#include "Thread.h" +#include "rtos/Thread.h" namespace Thread_stub { extern osStatus osStatus_value; diff --git a/UNITTESTS/target_h/rtos/Mutex.h b/UNITTESTS/target_h/rtos/Mutex.h index f98a692c43..a92abd8c3d 100644 --- a/UNITTESTS/target_h/rtos/Mutex.h +++ b/UNITTESTS/target_h/rtos/Mutex.h @@ -18,8 +18,8 @@ #define __MUTEX_H__ #include -#include "mbed_rtos_types.h" -#include "mbed_rtos1_types.h" +#include "rtos/mbed_rtos_types.h" +#include "rtos/internal/mbed_rtos1_types.h" namespace rtos { diff --git a/UNITTESTS/target_h/rtos/Semaphore.h b/UNITTESTS/target_h/rtos/Semaphore.h index ded7fe6394..ecbdee511d 100644 --- a/UNITTESTS/target_h/rtos/Semaphore.h +++ b/UNITTESTS/target_h/rtos/Semaphore.h @@ -19,6 +19,7 @@ #include #include "cmsis_os2.h" +#include "rtos/Kernel.h" namespace rtos { class Semaphore { @@ -28,8 +29,13 @@ public: void acquire(); bool try_acquire(); bool try_acquire_for(uint32_t millisec); + bool try_acquire_for(Kernel::Clock::duration_u32 rel_time); bool try_acquire_until(uint64_t millisec); + bool try_acquire_until(Kernel::Clock::time_point abs_time); osStatus release(void); + ~Semaphore(); +private: + void constructor(int32_t count, uint16_t max_count); }; } diff --git a/UNITTESTS/target_h/rtos/Thread.h b/UNITTESTS/target_h/rtos/Thread.h index 49a7805781..1fa8e47f15 100644 --- a/UNITTESTS/target_h/rtos/Thread.h +++ b/UNITTESTS/target_h/rtos/Thread.h @@ -25,6 +25,9 @@ #include #include "cmsis_os.h" +#include "platform/Callback.h" + +#define OS_STACK_SIZE 0 namespace rtos { @@ -43,12 +46,10 @@ public: { } - osStatus start(mbed::Callback task) { - return 0; - } + osStatus start(mbed::Callback task); osStatus join() {return 0;}; - osStatus terminate(){return 0;}; + osStatus terminate(); osStatus set_priority(osPriority priority){return 0;}; osPriority get_priority() const{return osPriorityNormal;}; uint32_t flags_set(uint32_t flags){return 0;}; @@ -97,6 +98,14 @@ public: osThreadId_t get_id() const { return 0; }; + virtual ~Thread(); +private: + // Required to share definitions without + // delegated constructors + void constructor(osPriority priority = osPriorityNormal, + uint32_t stack_size = OS_STACK_SIZE, + unsigned char *stack_mem = nullptr, + const char *name = nullptr); }; } #endif diff --git a/UNITTESTS/target_h/rtos/mbed_rtos1_types.h b/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos1_types.h similarity index 100% rename from UNITTESTS/target_h/rtos/mbed_rtos1_types.h rename to UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos1_types.h diff --git a/UNITTESTS/target_h/rtos/mbed_rtos_storage.h b/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h similarity index 100% rename from UNITTESTS/target_h/rtos/mbed_rtos_storage.h rename to UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h diff --git a/features/cellular/framework/API/ATHandler.h b/features/cellular/framework/API/ATHandler.h index b454c4047c..f0d9828412 100644 --- a/features/cellular/framework/API/ATHandler.h +++ b/features/cellular/framework/API/ATHandler.h @@ -40,7 +40,7 @@ #define AT_HANDLER_MUTEX #if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT -#include "ConditionVariable.h" +#include "rtos/ConditionVariable.h" #endif namespace mbed { diff --git a/features/cellular/framework/API/CellularDevice.h b/features/cellular/framework/API/CellularDevice.h index e25c2a7143..236f2d329a 100644 --- a/features/cellular/framework/API/CellularDevice.h +++ b/features/cellular/framework/API/CellularDevice.h @@ -24,7 +24,7 @@ #include "PinNames.h" #ifdef MBED_CONF_RTOS_PRESENT -#include "Thread.h" +#include "rtos/Thread.h" #endif // MBED_CONF_RTOS_PRESENT /** @file CellularDevice.h diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index c72a73e582..b851cc4b38 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -25,7 +25,7 @@ #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) #include "drivers/BufferedSerial.h" #endif // #if DEVICE_SERIAL -#include "ThisThread.h" +#include "rtos/ThisThread.h" #define NETWORK_TIMEOUT 30min #define DEVICE_TIMEOUT 5min diff --git a/features/cellular/framework/AT/AT_CellularContext.h b/features/cellular/framework/AT/AT_CellularContext.h index 162a3479b9..b1d8985a9c 100644 --- a/features/cellular/framework/AT/AT_CellularContext.h +++ b/features/cellular/framework/AT/AT_CellularContext.h @@ -19,7 +19,7 @@ #include "CellularContext.h" #include "ATHandler.h" -#include "Semaphore.h" +#include "rtos/Semaphore.h" #include "AT_CellularDevice.h" const int MAX_APN_LENGTH = 63 + 1; diff --git a/features/cellular/framework/AT/AT_CellularSMS.cpp b/features/cellular/framework/AT/AT_CellularSMS.cpp index 82c1819a32..79ebc90873 100644 --- a/features/cellular/framework/AT/AT_CellularSMS.cpp +++ b/features/cellular/framework/AT/AT_CellularSMS.cpp @@ -20,7 +20,7 @@ #include #include #include -#include "ThisThread.h" +#include "rtos/ThisThread.h" #include "AT_CellularSMS.h" #include "CellularUtil.h" #include "CellularLog.h" diff --git a/features/cellular/framework/AT/AT_CellularStack.cpp b/features/cellular/framework/AT/AT_CellularStack.cpp index f8a30db817..961d101c9b 100644 --- a/features/cellular/framework/AT/AT_CellularStack.cpp +++ b/features/cellular/framework/AT/AT_CellularStack.cpp @@ -18,7 +18,7 @@ #include "AT_CellularStack.h" #include "CellularUtil.h" #include "CellularLog.h" -#include "ThisThread.h" +#include "rtos/ThisThread.h" #include "AT_CellularDevice.h" using namespace mbed_cellular_util; diff --git a/features/cellular/framework/AT/AT_ControlPlane_netif.cpp b/features/cellular/framework/AT/AT_ControlPlane_netif.cpp index f865b8f99d..b4689745f9 100644 --- a/features/cellular/framework/AT/AT_ControlPlane_netif.cpp +++ b/features/cellular/framework/AT/AT_ControlPlane_netif.cpp @@ -16,7 +16,7 @@ */ #include "CellularUtil.h" -#include "ThisThread.h" +#include "rtos/ThisThread.h" #include "AT_ControlPlane_netif.h" #include "CellularLog.h" diff --git a/features/cellular/framework/device/ATHandler.cpp b/features/cellular/framework/device/ATHandler.cpp index e7e971f080..c504b1f038 100644 --- a/features/cellular/framework/device/ATHandler.cpp +++ b/features/cellular/framework/device/ATHandler.cpp @@ -24,7 +24,7 @@ #include "FileHandle.h" #include "mbed_debug.h" #include "rtos/ThisThread.h" -#include "Kernel.h" +#include "rtos/Kernel.h" #include "CellularUtil.h" #include "SingletonPtr.h" #include "ScopedLock.h" diff --git a/features/cellular/framework/device/CellularContext.cpp b/features/cellular/framework/device/CellularContext.cpp index 2bccb2d4d4..6773a24dce 100644 --- a/features/cellular/framework/device/CellularContext.cpp +++ b/features/cellular/framework/device/CellularContext.cpp @@ -16,7 +16,7 @@ */ #include "CellularContext.h" #include "CellularLog.h" -#include "ThisThread.h" +#include "rtos/ThisThread.h" using namespace std::chrono_literals; diff --git a/features/netsocket/TLSSocketWrapper.cpp b/features/netsocket/TLSSocketWrapper.cpp index 4cd7714837..90134da870 100644 --- a/features/netsocket/TLSSocketWrapper.cpp +++ b/features/netsocket/TLSSocketWrapper.cpp @@ -25,7 +25,7 @@ #include "mbedtls/debug.h" #include "mbedtls/platform.h" #include "mbed_error.h" -#include "Kernel.h" +#include "rtos/Kernel.h" // This class requires Mbed TLS SSL/TLS client code #if defined(MBEDTLS_SSL_CLI_C) diff --git a/features/netsocket/nsapi_dns.cpp b/features/netsocket/nsapi_dns.cpp index 16947bb387..a2aac6995c 100644 --- a/features/netsocket/nsapi_dns.cpp +++ b/features/netsocket/nsapi_dns.cpp @@ -27,7 +27,7 @@ #include "mbed_shared_queues.h" #include "events/EventQueue.h" #include "OnboardNetworkStack.h" -#include "Kernel.h" +#include "rtos/Kernel.h" #include "PlatformMutex.h" #include "SingletonPtr.h"