Merge pull request #14884 from LDong-Arm/rm_UNITTEST_macro

Remove the `UNITTEST` macro from production code
pull/14870/head
Jaeden Amero 2021-07-07 15:20:31 +01:00 committed by GitHub
commit dc6dd17bb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 40 deletions

View File

@ -20,26 +20,6 @@
/* <mstd_type_traits>
*
* - includes toolchain's <type_traits>
* - For ARM C 5, standard C++11/14 features:
* - std::integral_constant, std::true_type, std::false_type
* - primary type categories (std::is_void, std::is_integral etc)
* - composite type categories (std::is_reference etc)
* - type properties (std::is_const, std::is_constructible etc), except std::is_final
* - type property queries (std::alignment_of, std::rank, std::extent)
* - type relations (std::is_same, std::is_base_of, std::is_convertible)
* - const-volatile modifications (std::remove_cv, std::add_const etc)
* - reference modifications (std::remove_reference, std::add_lvalue_reference etc)
* - sign modifications (std::make_signed, std::make_unsigned)
* - array modifications (std::remove_extent, std::remove_all_extents)
* - pointer modifications (std::remove_pointer, std::add_pointer)
* - other modifications:
* - std::aligned_storage
* - std::decay
* - std::enable_if
* - std::conditional
* - std::common_type
* - std::underlying_type
* - std::result_of
* - For all toolchains, C++17/20 backports:
* - mstd::type_identity
* - mstd::bool_constant
@ -47,6 +27,7 @@
* - mstd::is_invocable, mbed::is_invocable_r, etc
* - mstd::invoke_result
* - logical operator traits (mstd::conjunction, mstd::disjunction, mstd::negation)
* - mstd::is_constant_evaluated
*/
#include <mstd_cstddef>
@ -55,7 +36,6 @@
// The template stuff in here is too confusing for astyle
// *INDENT-OFF*
namespace mstd {
/* C++20 type identity */
@ -92,6 +72,10 @@ template <typename F, typename... Args>
struct invoke_result;
#endif
} // namespace mstd
namespace mstd {
using std::is_same;
using std::conditional;
using std::conditional_t;
@ -462,8 +446,30 @@ struct is_nothrow_invocable_r : impl::is_invocable_r<R, invoke_result<F, Args...
#endif // __cpp_lib_is_invocable
/* C++20 is_constant_evaluated */
constexpr bool is_constant_evaluated() noexcept
{
#ifdef __clang__
#if __has_builtin(__builtin_is_constant_evaluated)
#define MSTD_HAS_IS_CONSTANT_EVALUATED 1
return __builtin_is_constant_evaluated();
#else
return false;
#endif
#elif __GNUC__ >= 9
#define MSTD_HAS_IS_CONSTANT_EVALUATED 1
return __builtin_is_constant_evaluated();
#else
return false;
#endif
}
#if MSTD_HAS_IS_CONSTANT_EVALUATED
#define MSTD_CONSTEXPR_IF_HAS_IS_CONSTANT_EVALUATED constexpr
#else
#define MSTD_CONSTEXPR_IF_HAS_IS_CONSTANT_EVALUATED
#endif
} // namespace mstd
#endif /* MSTD_TYPE_TRAITS_ */

View File

@ -41,9 +41,7 @@ extern "C" {
*/
// mbed_assert_internal UT stub only prints an assert trace and returns, so therefore
// MBED_NORETURN must not be defined for UTs.
#ifndef UNITTEST
MBED_NORETURN
#endif
void mbed_assert_internal(const char *expr, const char *file, int line);
#ifdef __cplusplus

View File

@ -13,6 +13,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
MBED_CONF_RTOS_PRESENT=1
)
target_sources(${TEST_NAME}

View File

@ -29,12 +29,7 @@
#include "platform/SingletonPtr.h"
#include "platform/PlatformMutex.h"
#ifdef UNITTEST
#include <type_traits>
#define MSTD_CONSTEXPR_IF_HAS_IS_CONSTANT_EVALUATED
#else
#include <mstd_type_traits>
#endif
namespace mbed {
/** \addtogroup drivers-public-api */

View File

@ -33,7 +33,7 @@
#include "rtos/Semaphore.h"
#include "rtos/Mutex.h"
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
namespace rtos {
/** \addtogroup rtos-public-api */

View File

@ -17,7 +17,7 @@
#ifndef MBED_RTOS_RTX1_TYPES_H
#define MBED_RTOS_RTX1_TYPES_H
#if MBED_CONF_RTOS_PRESENT || defined(UNITTEST)
#if MBED_CONF_RTOS_PRESENT
#include "cmsis_os.h"

View File

@ -17,7 +17,7 @@
#ifndef MBED_RTOS_STORAGE_H
#define MBED_RTOS_STORAGE_H
#if MBED_CONF_RTOS_PRESENT || defined(UNITTEST)
#if MBED_CONF_RTOS_PRESENT
#include "mbed_rtx_storage.h"

View File

@ -17,7 +17,7 @@
#ifndef RTOS_TYPES_H_
#define RTOS_TYPES_H_
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY)
#include "cmsis_os2.h"
#else

View File

@ -18,7 +18,10 @@ target_include_directories(mbed-stubs-rtos-headers
add_library(mbed-stubs-rtos)
add_definitions(-DUNITTEST)
target_compile_definitions(mbed-stubs-rtos
PRIVATE
MBED_CONF_RTOS_PRESENT=1
)
target_sources(mbed-stubs-rtos
PRIVATE

View File

@ -7,7 +7,6 @@ add_executable(${TEST_NAME})
target_compile_definitions(${TEST_NAME}
PRIVATE
UNITTEST
MBED_LFS_READ_SIZE=64
MBED_LFS_PROG_SIZE=64
MBED_LFS_BLOCK_SIZE=512

View File

@ -5,11 +5,6 @@ set(TEST_NAME tdbstore-unittest)
add_executable(${TEST_NAME})
target_compile_definitions(${TEST_NAME}
PRIVATE
UNITTEST
)
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp