diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index 69195ef..50cfb30 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -9,7 +9,6 @@ add_library(mbed-headers-storage 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 @@ -101,12 +100,6 @@ ${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 @@ -123,7 +116,6 @@ add_subdirectory(events) add_subdirectory(hal) add_subdirectory(platform) -add_subdirectory(rtos) add_subdirectory(storage) add_library(mbed-stubs INTERFACE) diff --git a/UNITTESTS/stubs/ConditionVariable_stub.h b/UNITTESTS/stubs/ConditionVariable_stub.h deleted file mode 100644 index ddb7197..0000000 --- a/UNITTESTS/stubs/ConditionVariable_stub.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019, Arm Limited and affiliates. - * 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. - */ -#ifndef MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_H_ -#define MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_H_ - -#include "rtos/ConditionVariable.h" - -namespace ConditionVariable_stub { -extern bool time_out; -} - - -#endif /* MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_H_ */ diff --git a/UNITTESTS/stubs/Semaphore_stub.h b/UNITTESTS/stubs/Semaphore_stub.h deleted file mode 100644 index c63d365..0000000 --- a/UNITTESTS/stubs/Semaphore_stub.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited and affiliates. - * 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. - */ -#ifndef MBED_OS_UNITTESTS_STUBS_SEMAPHORE_STUB_H_ -#define MBED_OS_UNITTESTS_STUBS_SEMAPHORE_STUB_H_ - -namespace Semaphore_stub { -extern int wait_return_value; -extern bool acquire_return_value; -} - - - -#endif /* MBED_OS_UNITTESTS_STUBS_SEMAPHORE_STUB_H_ */ diff --git a/UNITTESTS/stubs/Thread_stub.h b/UNITTESTS/stubs/Thread_stub.h deleted file mode 100644 index 60156eb..0000000 --- a/UNITTESTS/stubs/Thread_stub.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited and affiliates. - * 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. - */ -#ifndef THREAD_STUB_H_ -#define THREAD_STUB_H_ - -#include "rtos/Thread.h" - -namespace Thread_stub { -extern osStatus osStatus_value; -} - -#endif /* THREAD_STUB_H_ */ diff --git a/UNITTESTS/stubs/connectivity/CMakeLists.txt b/UNITTESTS/stubs/connectivity/CMakeLists.txt index 4f207f2..d3873c3 100644 --- a/UNITTESTS/stubs/connectivity/CMakeLists.txt +++ b/UNITTESTS/stubs/connectivity/CMakeLists.txt @@ -58,7 +58,9 @@ target_link_libraries(mbed-stubs-connectivity PRIVATE + mbed-stubs-rtos-headers mbed-headers mbed-stubs-headers + mbed-stubs-rtos gtest ) diff --git a/UNITTESTS/stubs/rtos/CMakeLists.txt b/UNITTESTS/stubs/rtos/CMakeLists.txt deleted file mode 100644 index fc9a759..0000000 --- a/UNITTESTS/stubs/rtos/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# 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/rtos/ConditionVariable_stub.cpp b/UNITTESTS/stubs/rtos/ConditionVariable_stub.cpp deleted file mode 100644 index ee734ab..0000000 --- a/UNITTESTS/stubs/rtos/ConditionVariable_stub.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2019, Arm Limited and affiliates. - * 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. - */ -#ifndef MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_CPP_ -#define MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_CPP_ - -#include "ConditionVariable_stub.h" -#include "mbed_error.h" -#include "mbed_assert.h" - -bool ConditionVariable_stub::time_out = false; -#ifdef MBED_CONF_RTOS_PRESENT -using namespace rtos; - -ConditionVariable::ConditionVariable(Mutex &mutex): _mutex(mutex), _wait_list(0) -{ - // No initialization to do -} - -ConditionVariable::~ConditionVariable() -{ -} - -void ConditionVariable::notify_one() -{ - -} - -void ConditionVariable::wait() -{ -} - -bool ConditionVariable::wait_for(uint32_t millisec) -{ - return ConditionVariable_stub::time_out; -} - -void ConditionVariable::notify_all() -{ -} -#endif -#endif /* MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_CPP_ */ diff --git a/UNITTESTS/stubs/rtos/Kernel_stub.cpp b/UNITTESTS/stubs/rtos/Kernel_stub.cpp deleted file mode 100644 index d72a016..0000000 --- a/UNITTESTS/stubs/rtos/Kernel_stub.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * 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. - */ - -#include "rtos/Kernel.h" - -namespace rtos { - -uint64_t Kernel::get_ms_count() -{ - return impl::get_tick_count(); - -} -uint64_t Kernel::impl::get_tick_count() -{ - return 20; -} -} diff --git a/UNITTESTS/stubs/rtos/Mutex_stub.cpp b/UNITTESTS/stubs/rtos/Mutex_stub.cpp deleted file mode 100644 index d90ae20..0000000 --- a/UNITTESTS/stubs/rtos/Mutex_stub.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017, Arm Limited and affiliates. - * 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. - */ - -#include "rtos/Mutex.h" - -rtos::Mutex::Mutex() -{ - return; -} - -rtos::Mutex::~Mutex() -{ - return; -} - -osStatus rtos::Mutex::lock() -{ - return osOK; -} - -osStatus rtos::Mutex::unlock() -{ - return osOK; -} diff --git a/UNITTESTS/stubs/rtos/Semaphore_stub.cpp b/UNITTESTS/stubs/rtos/Semaphore_stub.cpp deleted file mode 100644 index fd2b2f2..0000000 --- a/UNITTESTS/stubs/rtos/Semaphore_stub.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * 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. - */ - -#include "rtos/Semaphore.h" -#include "Semaphore_stub.h" - -int Semaphore_stub::wait_return_value = 0; -bool Semaphore_stub::acquire_return_value; - -namespace rtos { - -Semaphore::Semaphore(int32_t count) -{ - -} - -Semaphore::Semaphore(int32_t count, uint16_t max_count) -{ - -} - -void Semaphore::constructor(int32_t count, uint16_t max_count) -{ - -} - -void Semaphore::acquire() -{ - -} - -bool Semaphore::try_acquire() -{ - return Semaphore_stub::acquire_return_value; -} - -bool Semaphore::try_acquire_for(uint32_t millisec) -{ - return Semaphore_stub::acquire_return_value; -} - -bool Semaphore::try_acquire_for(Kernel::Clock::duration_u32 rel_time) -{ - return Semaphore_stub::acquire_return_value; -} - -bool Semaphore::try_acquire_until(uint64_t millisec) -{ - return Semaphore_stub::acquire_return_value; -} - -bool Semaphore::try_acquire_until(Kernel::Clock::time_point abs_time) -{ - return Semaphore_stub::acquire_return_value; -} - -osStatus Semaphore::release(void) -{ - return 0; -} - -Semaphore::~Semaphore() -{ - -} - -} diff --git a/UNITTESTS/stubs/rtos/ThisThread_stub.cpp b/UNITTESTS/stubs/rtos/ThisThread_stub.cpp deleted file mode 100644 index 6c1dae9..0000000 --- a/UNITTESTS/stubs/rtos/ThisThread_stub.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * 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. - */ - -#include "rtos/ThisThread.h" - -namespace rtos { - -void ThisThread::sleep_until(uint64_t millisec) -{ -} - -void ThisThread::sleep_until(Kernel::Clock::time_point abs_time) -{ -} - -void ThisThread::sleep_for(uint32_t millisec) -{ -} - -void ThisThread::sleep_for(Kernel::Clock::duration_u32 rel_time) -{ -} - -} diff --git a/UNITTESTS/stubs/rtos/Thread_stub.cpp b/UNITTESTS/stubs/rtos/Thread_stub.cpp deleted file mode 100644 index c757df3..0000000 --- a/UNITTESTS/stubs/rtos/Thread_stub.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * 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. - */ - -#include "Thread_stub.h" - -using namespace rtos; - -osStatus Thread_stub::osStatus_value = osOK; - -osStatus Thread::terminate() -{ - return 0; -} - -osStatus Thread::start(mbed::Callback task) -{ - return Thread_stub::osStatus_value; -} - -void Thread::constructor(osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name) -{ -} - -Thread::~Thread() -{ -} diff --git a/UNITTESTS/stubs/rtos/mbed_rtos_rtx_stub.c b/UNITTESTS/stubs/rtos/mbed_rtos_rtx_stub.c deleted file mode 100644 index 889065c..0000000 --- a/UNITTESTS/stubs/rtos/mbed_rtos_rtx_stub.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, Arm Limited and affiliates. - * 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. - */ - -#include "mbed_rtos_types.h" - -osMutexId_t singleton_mutex_id; diff --git a/UNITTESTS/stubs/rtos/rtx_mutex_stub.c b/UNITTESTS/stubs/rtos/rtx_mutex_stub.c deleted file mode 100644 index 916be3e..0000000 --- a/UNITTESTS/stubs/rtos/rtx_mutex_stub.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2019, Arm Limited and affiliates. - * 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. - */ - -#include "mbed_rtos_types.h" - -osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) -{ - return osOK; -} - -osStatus_t osMutexRelease(osMutexId_t mutex_id) -{ - return osOK; -} diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt index 0daa233..ffc33cb 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt @@ -26,6 +26,7 @@ mbed-headers mbed-stubs mbed-stubs-headers + mbed-stubs-rtos-headers gmock_main ) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt index e065e68..1440432 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellulardevice/CMakeLists.txt @@ -32,6 +32,7 @@ mbed-headers mbed-stubs mbed-stubs-headers + mbed-stubs-rtos gmock_main ) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt index 79c69ea..ec71a7e 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/CMakeLists.txt @@ -30,6 +30,7 @@ mbed-headers mbed-stubs mbed-stubs-headers + mbed-stubs-rtos-headers gmock_main ) diff --git a/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/CMakeLists.txt index 00d3b3b..4412d70 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/CMakeLists.txt @@ -31,6 +31,7 @@ mbed-headers mbed-stubs mbed-stubs-headers + mbed-stubs-rtos-headers gmock_main ) diff --git a/rtos/CMakeLists.txt b/rtos/CMakeLists.txt index 9e2194d..ab9d308 100644 --- a/rtos/CMakeLists.txt +++ b/rtos/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + add_subdirectory(tests/UNITTESTS) +endif() + target_include_directories(mbed-core INTERFACE . diff --git a/rtos/tests/.mbedignore b/rtos/tests/.mbedignore new file mode 100644 index 0000000..e28badb --- /dev/null +++ b/rtos/tests/.mbedignore @@ -0,0 +1 @@ +UNITTESTS/* diff --git a/rtos/tests/UNITTESTS/CMakeLists.txt b/rtos/tests/UNITTESTS/CMakeLists.txt new file mode 100644 index 0000000..b632a73 --- /dev/null +++ b/rtos/tests/UNITTESTS/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(doubles) diff --git a/rtos/tests/UNITTESTS/doubles/CMakeLists.txt b/rtos/tests/UNITTESTS/doubles/CMakeLists.txt new file mode 100644 index 0000000..4216a6a --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-headers-rtos INTERFACE) + +target_include_directories(mbed-headers-rtos + INTERFACE + ${mbed-os_SOURCE_DIR}/rtos/include + ${mbed-os_SOURCE_DIR}/rtos/include/rtos +) + +add_library(mbed-stubs-rtos-headers INTERFACE) + +target_include_directories(mbed-stubs-rtos-headers + INTERFACE + . +) + +add_library(mbed-stubs-rtos) + +add_definitions(-DUNITTEST) + +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-base + mbed-headers-rtos + mbed-headers-platform + mbed-headers-drivers + mbed-headers-hal +) diff --git a/rtos/tests/UNITTESTS/doubles/ConditionVariable_stub.cpp b/rtos/tests/UNITTESTS/doubles/ConditionVariable_stub.cpp new file mode 100644 index 0000000..ee734ab --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/ConditionVariable_stub.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019, Arm Limited and affiliates. + * 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. + */ +#ifndef MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_CPP_ +#define MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_CPP_ + +#include "ConditionVariable_stub.h" +#include "mbed_error.h" +#include "mbed_assert.h" + +bool ConditionVariable_stub::time_out = false; +#ifdef MBED_CONF_RTOS_PRESENT +using namespace rtos; + +ConditionVariable::ConditionVariable(Mutex &mutex): _mutex(mutex), _wait_list(0) +{ + // No initialization to do +} + +ConditionVariable::~ConditionVariable() +{ +} + +void ConditionVariable::notify_one() +{ + +} + +void ConditionVariable::wait() +{ +} + +bool ConditionVariable::wait_for(uint32_t millisec) +{ + return ConditionVariable_stub::time_out; +} + +void ConditionVariable::notify_all() +{ +} +#endif +#endif /* MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_CPP_ */ diff --git a/rtos/tests/UNITTESTS/doubles/ConditionVariable_stub.h b/rtos/tests/UNITTESTS/doubles/ConditionVariable_stub.h new file mode 100644 index 0000000..ddb7197 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/ConditionVariable_stub.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019, Arm Limited and affiliates. + * 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. + */ +#ifndef MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_H_ +#define MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_H_ + +#include "rtos/ConditionVariable.h" + +namespace ConditionVariable_stub { +extern bool time_out; +} + + +#endif /* MBED_OS_UNITTESTS_STUBS_CONDITIONVARIABLE_STUB_H_ */ diff --git a/rtos/tests/UNITTESTS/doubles/Kernel_stub.cpp b/rtos/tests/UNITTESTS/doubles/Kernel_stub.cpp new file mode 100644 index 0000000..d72a016 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/Kernel_stub.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * 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. + */ + +#include "rtos/Kernel.h" + +namespace rtos { + +uint64_t Kernel::get_ms_count() +{ + return impl::get_tick_count(); + +} +uint64_t Kernel::impl::get_tick_count() +{ + return 20; +} +} diff --git a/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp b/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp new file mode 100644 index 0000000..d90ae20 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/Mutex_stub.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, Arm Limited and affiliates. + * 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. + */ + +#include "rtos/Mutex.h" + +rtos::Mutex::Mutex() +{ + return; +} + +rtos::Mutex::~Mutex() +{ + return; +} + +osStatus rtos::Mutex::lock() +{ + return osOK; +} + +osStatus rtos::Mutex::unlock() +{ + return osOK; +} diff --git a/rtos/tests/UNITTESTS/doubles/Semaphore_stub.cpp b/rtos/tests/UNITTESTS/doubles/Semaphore_stub.cpp new file mode 100644 index 0000000..fd2b2f2 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/Semaphore_stub.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * 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. + */ + +#include "rtos/Semaphore.h" +#include "Semaphore_stub.h" + +int Semaphore_stub::wait_return_value = 0; +bool Semaphore_stub::acquire_return_value; + +namespace rtos { + +Semaphore::Semaphore(int32_t count) +{ + +} + +Semaphore::Semaphore(int32_t count, uint16_t max_count) +{ + +} + +void Semaphore::constructor(int32_t count, uint16_t max_count) +{ + +} + +void Semaphore::acquire() +{ + +} + +bool Semaphore::try_acquire() +{ + return Semaphore_stub::acquire_return_value; +} + +bool Semaphore::try_acquire_for(uint32_t millisec) +{ + return Semaphore_stub::acquire_return_value; +} + +bool Semaphore::try_acquire_for(Kernel::Clock::duration_u32 rel_time) +{ + return Semaphore_stub::acquire_return_value; +} + +bool Semaphore::try_acquire_until(uint64_t millisec) +{ + return Semaphore_stub::acquire_return_value; +} + +bool Semaphore::try_acquire_until(Kernel::Clock::time_point abs_time) +{ + return Semaphore_stub::acquire_return_value; +} + +osStatus Semaphore::release(void) +{ + return 0; +} + +Semaphore::~Semaphore() +{ + +} + +} diff --git a/rtos/tests/UNITTESTS/doubles/Semaphore_stub.h b/rtos/tests/UNITTESTS/doubles/Semaphore_stub.h new file mode 100644 index 0000000..c63d365 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/Semaphore_stub.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018, Arm Limited and affiliates. + * 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. + */ +#ifndef MBED_OS_UNITTESTS_STUBS_SEMAPHORE_STUB_H_ +#define MBED_OS_UNITTESTS_STUBS_SEMAPHORE_STUB_H_ + +namespace Semaphore_stub { +extern int wait_return_value; +extern bool acquire_return_value; +} + + + +#endif /* MBED_OS_UNITTESTS_STUBS_SEMAPHORE_STUB_H_ */ diff --git a/rtos/tests/UNITTESTS/doubles/ThisThread_stub.cpp b/rtos/tests/UNITTESTS/doubles/ThisThread_stub.cpp new file mode 100644 index 0000000..6c1dae9 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/ThisThread_stub.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * 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. + */ + +#include "rtos/ThisThread.h" + +namespace rtos { + +void ThisThread::sleep_until(uint64_t millisec) +{ +} + +void ThisThread::sleep_until(Kernel::Clock::time_point abs_time) +{ +} + +void ThisThread::sleep_for(uint32_t millisec) +{ +} + +void ThisThread::sleep_for(Kernel::Clock::duration_u32 rel_time) +{ +} + +} diff --git a/rtos/tests/UNITTESTS/doubles/Thread_stub.cpp b/rtos/tests/UNITTESTS/doubles/Thread_stub.cpp new file mode 100644 index 0000000..c757df3 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/Thread_stub.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * 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. + */ + +#include "Thread_stub.h" + +using namespace rtos; + +osStatus Thread_stub::osStatus_value = osOK; + +osStatus Thread::terminate() +{ + return 0; +} + +osStatus Thread::start(mbed::Callback task) +{ + return Thread_stub::osStatus_value; +} + +void Thread::constructor(osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name) +{ +} + +Thread::~Thread() +{ +} diff --git a/rtos/tests/UNITTESTS/doubles/Thread_stub.h b/rtos/tests/UNITTESTS/doubles/Thread_stub.h new file mode 100644 index 0000000..60156eb --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/Thread_stub.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018, Arm Limited and affiliates. + * 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. + */ +#ifndef THREAD_STUB_H_ +#define THREAD_STUB_H_ + +#include "rtos/Thread.h" + +namespace Thread_stub { +extern osStatus osStatus_value; +} + +#endif /* THREAD_STUB_H_ */ diff --git a/rtos/tests/UNITTESTS/doubles/mbed_rtos_rtx_stub.c b/rtos/tests/UNITTESTS/doubles/mbed_rtos_rtx_stub.c new file mode 100644 index 0000000..889065c --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/mbed_rtos_rtx_stub.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019, Arm Limited and affiliates. + * 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. + */ + +#include "mbed_rtos_types.h" + +osMutexId_t singleton_mutex_id; diff --git a/rtos/tests/UNITTESTS/doubles/rtx_mutex_stub.c b/rtos/tests/UNITTESTS/doubles/rtx_mutex_stub.c new file mode 100644 index 0000000..916be3e --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtx_mutex_stub.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019, Arm Limited and affiliates. + * 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. + */ + +#include "mbed_rtos_types.h" + +osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) +{ + return osOK; +} + +osStatus_t osMutexRelease(osMutexId_t mutex_id) +{ + return osOK; +}