diff --git a/iceoryx_binding_c/test/moduletests/test_c2cpp_enum_translation.cpp b/iceoryx_binding_c/test/moduletests/test_c2cpp_enum_translation.cpp index cfff983ae18..8ab6e3a197b 100644 --- a/iceoryx_binding_c/test/moduletests/test_c2cpp_enum_translation.cpp +++ b/iceoryx_binding_c/test/moduletests/test_c2cpp_enum_translation.cpp @@ -58,8 +58,8 @@ TEST(c2cpp_enum_translation_test, SubscriberState) // the clang sanitizer detects this successfully and this leads to termination, and with this the test fails #if !defined(__clang__) iox::Error errorValue = iox::Error::kNO_ERROR; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error e, const std::function, const iox::ErrorLevel) { errorValue = e; }); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error e, const iox::ErrorLevel) { errorValue = e; }); EXPECT_EQ(c2cpp::queueFullPolicy(static_cast(-1)), iox::popo::QueueFullPolicy::DISCARD_OLDEST_DATA); EXPECT_THAT(errorValue, Eq(iox::Error::kBINDING_C__UNDEFINED_STATE_IN_IOX_QUEUE_FULL_POLICY)); @@ -95,8 +95,8 @@ TEST(c2cpp_enum_translation_test, SubscriberEvent) // the clang sanitizer detects this successfully and this leads to termination, and with this the test fails #if !defined(__clang__) iox::Error errorValue = iox::Error::kNO_ERROR; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error e, const std::function, const iox::ErrorLevel) { errorValue = e; }); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error e, const iox::ErrorLevel) { errorValue = e; }); EXPECT_EQ(c2cpp::subscriberTooSlowPolicy(static_cast(-1)), iox::popo::SubscriberTooSlowPolicy::DISCARD_OLDEST_DATA); EXPECT_THAT(errorValue, Eq(iox::Error::kBINDING_C__UNDEFINED_STATE_IN_IOX_SUBSCRIBER_TOO_SLOW_POLICY)); diff --git a/iceoryx_hoofs/CMakeLists.txt b/iceoryx_hoofs/CMakeLists.txt index 8db3f06d73b..d4f95201457 100644 --- a/iceoryx_hoofs/CMakeLists.txt +++ b/iceoryx_hoofs/CMakeLists.txt @@ -72,6 +72,7 @@ if(GTest_FOUND) # only GTest_FOUND, just in case someone want's to use iceoryx_h testing/mocks/time_mock.cpp testing/timing_test.cpp testing/compile_test.cpp + testing/test.cpp ) add_library(iceoryx_hoofs_testing::iceoryx_hoofs_testing ALIAS iceoryx_hoofs_testing) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp index e3c90bd01ff..4f10ac1fe81 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp @@ -20,6 +20,7 @@ /// @todo #590 rename this file to error_handler.hpp #include "iceoryx_hoofs/cxx/generic_raii.hpp" +#include "iceoryx_hoofs/cxx/type_traits.hpp" #include "iceoryx_hoofs/log/logger.hpp" #include "iceoryx_hoofs/log/logging.hpp" #include "iceoryx_hoofs/log/logmanager.hpp" @@ -29,8 +30,13 @@ #include #include #include + + namespace iox { +// Forward declaration +void outputToGTestFail(const char* error); + // clang-format off #define ICEORYX_ERRORS(error) \ error(NO_ERROR)\ @@ -173,12 +179,6 @@ enum class Error : uint32_t ICEORYX_ERRORS(CREATE_ICEORYX_ERROR_ENUM) }; -/// @brief Convenience stream operator to easily use the Error enum with std::ostream -/// @param[in] stream sink to write the message to -/// @param[in] value to convert to a string literal -/// @return the reference to `stream` which was provided as input parameter -std::ostream& operator<<(std::ostream& stream, Error value) noexcept; - /// @brief the available error levels /// FATAL /// - Log message with FATAL @@ -205,37 +205,6 @@ enum class ErrorLevel : uint32_t MODERATE }; -template -using HandlerFunction = std::function, const ErrorLevel)>; - -/// @brief This handler is needed for unit testing, special debugging cases and -/// other corner cases where we'd like to explicitly suppress the -/// error handling. -/// @tparam[in] Error type of the enum which is used to report the error -template -class ErrorHandler -{ - template - friend void - errorHandler(const ErrorType error, const std::function& errorCallBack, const ErrorLevel level) noexcept; - - public: - static cxx::GenericRAII setTemporaryErrorHandler(const HandlerFunction& newHandler) noexcept; - - protected: - static void reactOnErrorLevel(const ErrorLevel level, const char* errorText) noexcept; - - private: - static void defaultHandler(const Error error, - const std::function& errorCallBack, - const ErrorLevel level = ErrorLevel::FATAL) noexcept; - - static iox::HandlerFunction handler; - /// Needed, if you want to exchange the handler. Remember the old one and call it if it is not your error. The error - /// mock needs to be the last one exchanging the handler in tests. - static std::mutex handler_mutex; -}; - /// @brief Howto use the error handler correctly /// 1.) Use the macro ICEORYX_ERRORS(error)\ to create the enum for your component and /// add new errors like: @@ -245,9 +214,6 @@ class ErrorHandler /// And a long name is alright! /// /// 2.) Specialize the following methods for your NewEnumErrorType: -/// - defaultHandler(const NewEnumErrorType error, const std::function& errorCallBack, const -/// ErrorLevel level) -/// - std::ostream& operator<<(std::ostream& stream, NewEnumErrorType value) /// - const char* toString(const NewEnumErrorType error) /// /// 3.) Call errorHandler(Error::kMODULE_NAME__MY_FUNKY_ERROR); @@ -271,7 +237,7 @@ class ErrorHandler /// /// @code /// bool called = false; -/// auto temporaryErrorHandler = ErrorHandler::setTemporaryErrorHandler( +/// auto temporaryErrorHandler = ErrorHandler::setTemporaryErrorHandler( /// [&](const Error e, std::function, const ErrorLevel) { /// called = true; /// }); @@ -280,78 +246,94 @@ class ErrorHandler /// ASSERT_TRUE(called); /// @endcode /// @tparam[in] Error type of the enum which is used to report the error -/// @todo use enable_if with is_enum +/// @todo #590 use enable_if with is_enum template -inline void errorHandler(const Error error, - const std::function& errorCallBack = std::function(), - const ErrorLevel level = ErrorLevel::FATAL) noexcept -{ - ErrorHandler::handler(error, errorCallBack, level); -} +void errorHandler(const Error error, + const std::function& errorCallBack = std::function(), + const ErrorLevel level = ErrorLevel::FATAL) noexcept; + +template +using TypedHandlerFunction = std::function; + +using HandlerFunction = std::function; -/// @todo #590 specialise for posh and c binding error handling -template <> -inline void ErrorHandler::defaultHandler(const Error error, - const std::function& errorCallBack, - const ErrorLevel level) noexcept +/// @brief This handler is needed for unit testing, special debugging cases and +/// other corner cases where we'd like to explicitly suppress the +/// error handling. +class ErrorHandler { - if (errorCallBack) - { - errorCallBack(); - } - else - { - std::stringstream ss; - ss << "iceoryx_posh error! " << error; + template + friend void + errorHandler(const Error error, const std::function& errorCallBack, const ErrorLevel level) noexcept; - reactOnErrorLevel(level, ss.str().c_str()); - } -} + public: + template + static cxx::GenericRAII setTemporaryErrorHandler(const TypedHandlerFunction& newHandler) noexcept; -/// @todo #590 move the below to .inl + protected: + static void reactOnErrorLevel(const ErrorLevel level, const char* errorText) noexcept; -template -std::mutex ErrorHandler::handler_mutex; + private: + static void + defaultHandler(const uint32_t error, const char* errorName, const ErrorLevel level = ErrorLevel::FATAL) noexcept; + + static iox::HandlerFunction handler; + /// Needed, if you want to exchange the handler. Remember the old one and call it if it is not your error. The error + /// mock needs to be the last one exchanging the handler in tests. + static std::mutex handler_mutex; +}; + +const char* toString(const Error error) noexcept; -// NOLINTNEXTLINE(cert-err58-cpp) ErrorHander only used in tests template -HandlerFunction ErrorHandler::handler = {ErrorHandler::defaultHandler}; +cxx::optional> typedHandler; + +/// @todo #590 move the implementations below to .inl template -inline void ErrorHandler::reactOnErrorLevel(const ErrorLevel level, const char* errorText) noexcept +inline void errorHandler(const Error error, + const std::function& errorCallBack IOX_MAYBE_UNUSED, + const ErrorLevel level) noexcept { - static auto& logger = createLogger("", "", log::LogManager::GetLogManager().DefaultLogLevel()); - switch (level) + ErrorHandler::handler(static_cast::type>(error), toString(error), level); +} + +template +inline void +errorHandlerForTest(const uint32_t error, const char* errorName IOX_MAYBE_UNUSED, const ErrorLevel level) noexcept +{ + uint32_t errorEnumType = error >> 16; + uint32_t expectedErrorEnumType = + static_cast::type>(ErrorEnumType::kNO_ERROR) >> 16; + + if (errorEnumType == expectedErrorEnumType) { - case ErrorLevel::FATAL: - logger.LogError() << errorText; - assert(false); - std::terminate(); - break; - case ErrorLevel::SEVERE: - logger.LogWarn() << errorText; - assert(false); - break; - case ErrorLevel::MODERATE: - logger.LogWarn() << errorText; - break; + // We undo the type erasure + auto typedError = static_cast(error); + typedHandler.and_then( + [&](TypedHandlerFunction storedHandler) { storedHandler(typedError, level); }); + } + else + { + outputToGTestFail(errorName); } } template -inline cxx::GenericRAII ErrorHandler::setTemporaryErrorHandler(const HandlerFunction& newHandler) noexcept +inline cxx::GenericRAII ErrorHandler::setTemporaryErrorHandler(const TypedHandlerFunction& newHandler) noexcept { return cxx::GenericRAII( [&newHandler] { std::lock_guard lock(handler_mutex); - handler = newHandler; + typedHandler.emplace(newHandler); + handler = errorHandlerForTest; }, [] { std::lock_guard lock(handler_mutex); + typedHandler.reset(); handler = defaultHandler; }); } - } // namespace iox #endif // IOX_HOOFS_ERROR_HANDLING_ERROR_HANDLING_HPP diff --git a/iceoryx_hoofs/source/error_handling/error_handling.cpp b/iceoryx_hoofs/source/error_handling/error_handling.cpp index 8a1e253c716..3dc279f9cb1 100644 --- a/iceoryx_hoofs/source/error_handling/error_handling.cpp +++ b/iceoryx_hoofs/source/error_handling/error_handling.cpp @@ -22,14 +22,44 @@ namespace iox { const char* ERROR_NAMES[] = {ICEORYX_ERRORS(CREATE_ICEORYX_ERROR_STRING)}; +std::mutex ErrorHandler::handler_mutex; + +// NOLINTNEXTLINE(cert-err58-cpp) ErrorHander only used in tests +iox::HandlerFunction ErrorHandler::handler = {ErrorHandler::defaultHandler}; + const char* toString(const Error error) noexcept { - return ERROR_NAMES[static_cast(error)]; + return ERROR_NAMES[static_cast::type>(error)]; } -std::ostream& operator<<(std::ostream& stream, Error value) noexcept +void ErrorHandler::defaultHandler(const uint32_t error IOX_MAYBE_UNUSED, + const char* errorName, + const ErrorLevel level) noexcept { - stream << toString(value); - return stream; + std::stringstream ss; + ss << "ICEORYX error! " << errorName; + + reactOnErrorLevel(level, ss.str().c_str()); } + +void ErrorHandler::reactOnErrorLevel(const ErrorLevel level, const char* errorText) noexcept +{ + static auto& logger = createLogger("", "", log::LogManager::GetLogManager().DefaultLogLevel()); + switch (level) + { + case ErrorLevel::FATAL: + logger.LogError() << errorText; + assert(false); + std::terminate(); + break; + case ErrorLevel::SEVERE: + logger.LogWarn() << errorText; + assert(false); + break; + case ErrorLevel::MODERATE: + logger.LogWarn() << errorText; + break; + } +} + } // namespace iox diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp index 76e9ae0cd9a..8fb7d976de6 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp @@ -36,8 +36,8 @@ void ExpectDoesNotCallTerminateWhenObjectIsValid(const ExpectCall& callExpect) bool wasErrorHandlerCalled = false; SutType sut = FactoryType::createValidObject(); { - auto handle = iox::ErrorHandler::setTemporaryErrorHandler( - [&](auto, auto, auto) { wasErrorHandlerCalled = true; }); + auto handle = iox::ErrorHandler::setTemporaryErrorHandler( + [&](auto, auto) { wasErrorHandlerCalled = true; }); callExpect(sut); } @@ -75,8 +75,8 @@ void ExpectDoesCallTerminateWhenObjectIsInvalid(const ExpectCall& callExpect) bool wasErrorHandlerCalled = true; SutType sut = FactoryType::createInvalidObject(); { - auto handle = iox::ErrorHandler::setTemporaryErrorHandler( - [&](auto, auto, auto) { wasErrorHandlerCalled = true; }); + auto handle = iox::ErrorHandler::setTemporaryErrorHandler( + [&](auto, auto) { wasErrorHandlerCalled = true; }); callExpect(sut); } diff --git a/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp b/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp index d809ac3cc96..412c18d63da 100644 --- a/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp +++ b/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp @@ -416,8 +416,8 @@ TEST_F(Mepoo_IntegrationTest, WrongSampleSize) constexpr uint32_t SAMPLE_SIZE = 2048U; constexpr uint32_t REPETITION = 1U; iox::cxx::optional receivedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&receivedError](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&receivedError](const iox::Error error, const iox::ErrorLevel) { receivedError.emplace(error); }); @@ -436,8 +436,8 @@ TEST_F(Mepoo_IntegrationTest, SampleOverflow) constexpr uint32_t SAMPLE_SIZE_1 = 200U; constexpr uint32_t REPETITION = 1U; iox::cxx::optional receivedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&receivedError](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&receivedError](const iox::Error error, const iox::ErrorLevel) { receivedError.emplace(error); }); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp b/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp index a832f9744c2..78d3ddf17d2 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp @@ -92,8 +92,8 @@ TEST_F(MemoryManager_test, AddingMempoolNotInTheIncreasingOrderReturnsError) mempoolconf.addMemPool({CHUNK_SIZE_256, CHUNK_COUNT}); mempoolconf.addMemPool({CHUNK_SIZE_64, CHUNK_COUNT}); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::FATAL); }); @@ -112,8 +112,8 @@ TEST_F(MemoryManager_test, WrongCallOfConfigureMemoryManagerReturnsError) mempoolconf.addMemPool({CHUNK_SIZE_64, CHUNK_COUNT}); sut->configureMemoryManager(mempoolconf, *allocator, *allocator); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::FATAL); }); @@ -158,8 +158,8 @@ TEST_F(MemoryManager_test, GetChunkMethodWithNoMemPoolInMemConfigReturnsError) { ::testing::Test::RecordProperty("TEST_ID", "dff31ea2-8ae0-4786-8c97-633af59c287d"); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); @@ -189,8 +189,8 @@ TEST_F(MemoryManager_test, GetChunkMethodWithChunkSizeGreaterThanAvailableChunkS sut->configureMemoryManager(mempoolconf, *allocator, *allocator); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); @@ -222,8 +222,8 @@ TEST_F(MemoryManager_test, GetChunkMethodWhenNoFreeChunksInMemPoolConfigReturnsE auto chunkStore = getChunksFromSut(CHUNK_COUNT, chunkSettings); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::MODERATE); }); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp index d501241f9c5..fcd5d08b5c0 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp @@ -72,8 +72,8 @@ TEST_F(MemPool_test, MempoolCtorWhenChunkSizeIsNotAMultipleOfAlignmentReturnErro constexpr uint32_t NOT_ALLIGNED_CHUNKED_SIZE{33U}; iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::FATAL)); }); @@ -176,8 +176,8 @@ TEST_F(MemPool_test, FreeChunkMethodWhenSameChunkIsTriedToFreeTwiceReturnsError) chunks.push_back(reinterpret_cast(sut.getChunk())); sut.freeChunk(chunks[INDEX]); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::FATAL)); }); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_segment_management.cpp b/iceoryx_posh/test/moduletests/test_mepoo_segment_management.cpp index 4b9ae24a6dc..2175da94d6b 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_segment_management.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_segment_management.cpp @@ -162,8 +162,8 @@ TEST_F(SegmentManager_test, ADD_TEST_WITH_ADDITIONAL_USER(addingMoreThanOneWrite SegmentManager<> sut{segmentConfig, &allocator}; iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::FATAL)); }); diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp index 61aa609adaf..7cb0b6eaa9c 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp @@ -168,8 +168,8 @@ TYPED_TEST(ChunkDistributor_test, QueueOverflow) typename TestFixture::ChunkDistributor_t sut(sutData.get()); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp index 534c4a18a08..03e045d0c52 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp @@ -193,8 +193,8 @@ TYPED_TEST(ChunkQueue_test, PopChunkWithIncompatibleChunkHeaderCallsErrorHandler this->m_pusher.push(chunk); iox::Error receivedError{iox::Error::kNO_ERROR}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { receivedError = error; EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp index 9c3feb7a0d8..013b6eeb7fa 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp @@ -200,8 +200,8 @@ TEST_F(ChunkReceiver_test, releaseInvalidChunk) } auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp index 770be036a65..e2d7a7f643c 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp @@ -242,8 +242,8 @@ TEST_F(ChunkSender_test, freeInvalidChunk) EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U)); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); @@ -414,8 +414,8 @@ TEST_F(ChunkSender_test, sendTillRunningOutOfChunks) } auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); @@ -434,8 +434,8 @@ TEST_F(ChunkSender_test, sendInvalidChunk) EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U)); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); @@ -495,8 +495,8 @@ TEST_F(ChunkSender_test, sendToQueueWithInvalidChunkTriggersTheErrorHandler) EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U)); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error error, const iox::ErrorLevel errorLevel) { errorHandlerCalled = true; EXPECT_THAT(error, Eq(iox::Error::kPOPO__CHUNK_SENDER_INVALID_CHUNK_TO_SEND_FROM_USER)); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::SEVERE)); @@ -535,8 +535,8 @@ TEST_F(ChunkSender_test, pushInvalidChunkToHistory) EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U)); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); diff --git a/iceoryx_posh/test/moduletests/test_popo_client_port.cpp b/iceoryx_posh/test/moduletests/test_popo_client_port.cpp index c3cb4cf5d17..975a2e24d10 100644 --- a/iceoryx_posh/test/moduletests/test_popo_client_port.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_client_port.cpp @@ -252,8 +252,8 @@ TEST_F(ClientPort_test, FreeRequestWithNullptrCallsErrorHandler) auto& sut = clientPortWithConnectOnCreate; iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); @@ -286,8 +286,8 @@ TEST_F(ClientPort_test, SendRequestWithNullptrOnConnectedClientPortTerminates) auto& sut = clientPortWithConnectOnCreate; iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); @@ -410,8 +410,8 @@ TEST_F(ClientPort_test, ReleaseResponseWithNullptrIsTerminating) auto& sut = clientPortWithConnectOnCreate; iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); @@ -896,8 +896,8 @@ TEST_F(ClientPort_test, InvalidStateTransitionsCallErrorHandler) } iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); diff --git a/iceoryx_posh/test/moduletests/test_popo_notification_info.cpp b/iceoryx_posh/test/moduletests/test_popo_notification_info.cpp index 8bc663c1e9f..49cc474421a 100644 --- a/iceoryx_posh/test/moduletests/test_popo_notification_info.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_notification_info.cpp @@ -94,8 +94,8 @@ TEST_F(NotificationInfo_test, getOriginReturnsNullptrWithWrongType) ::testing::Test::RecordProperty("TEST_ID", "badb467b-bf64-4e43-af30-77c163e90c99"); auto errorHandlerCalled{false}; iox::Error errorHandlerType; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); @@ -111,8 +111,8 @@ TEST_F(NotificationInfo_test, constGetOriginReturnsNullptrWithWrongType) ::testing::Test::RecordProperty("TEST_ID", "4fdb2bed-9928-4181-b195-e411d1b16572"); auto errorHandlerCalled{false}; iox::Error errorHandlerType; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); diff --git a/iceoryx_posh/test/moduletests/test_popo_sample.cpp b/iceoryx_posh/test/moduletests/test_popo_sample.cpp index 669d62270b5..804e5ca7189 100644 --- a/iceoryx_posh/test/moduletests/test_popo_sample.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_sample.cpp @@ -102,8 +102,8 @@ TEST_F(SampleTest, PublishingEmptySampleCallsErrorHandler) sut.publish(); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::MODERATE)); }); diff --git a/iceoryx_posh/test/moduletests/test_popo_subscriber_port.cpp b/iceoryx_posh/test/moduletests/test_popo_subscriber_port.cpp index f34c9a7c671..e04dc43cb3a 100644 --- a/iceoryx_posh/test/moduletests/test_popo_subscriber_port.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_subscriber_port.cpp @@ -315,8 +315,8 @@ TEST_F(SubscriberPortSingleProducer_test, InvalidMessageResultsInError) { ::testing::Test::RecordProperty("TEST_ID", "23aaa4fd-5567-4831-b539-802c5de238ab"); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); iox::capro::CaproMessage caproMessage(iox::capro::CaproMessageType::SUB, @@ -332,8 +332,8 @@ TEST_F(SubscriberPortSingleProducer_test, AckWhenNotWaitingForResultsInError) { ::testing::Test::RecordProperty("TEST_ID", "541719e5-fdfa-4ef8-86f6-a9baf4919fe8"); auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); iox::capro::CaproMessage caproMessage(iox::capro::CaproMessageType::ACK, @@ -350,9 +350,9 @@ TEST_F(SubscriberPortSingleProducer_test, NackWhenNotWaitingForResultsInError) ::testing::Test::RecordProperty("TEST_ID", "063e3a61-209b-4755-abfa-69aed6258ab3"); auto errorHandlerCalled{false}; iox::Error receivedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( [&errorHandlerCalled, - &receivedError](const iox::Error error, const std::function, const iox::ErrorLevel) { + &receivedError](const iox::Error error, const iox::ErrorLevel) { errorHandlerCalled = true; receivedError = error; }); @@ -534,9 +534,9 @@ TEST_F(SubscriberPortMultiProducer_test, InvalidMessageResultsInError) ::testing::Test::RecordProperty("TEST_ID", "419aa91f-991b-4814-b1ee-11637ee14d30"); auto errorHandlerCalled{false}; iox::Error receivedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( [&errorHandlerCalled, - &receivedError](const iox::Error error, const std::function, const iox::ErrorLevel) { + &receivedError](const iox::Error error, const iox::ErrorLevel) { errorHandlerCalled = true; receivedError = error; }); diff --git a/iceoryx_posh/test/moduletests/test_popo_trigger.cpp b/iceoryx_posh/test/moduletests/test_popo_trigger.cpp index f71234d82f7..54a6c31741a 100644 --- a/iceoryx_posh/test/moduletests/test_popo_trigger.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_trigger.cpp @@ -200,8 +200,8 @@ TEST_F(Trigger_test, TriggerWithInvalidHasTriggeredCallbackCallsErrorHandlerAndI bool hasTerminated = false; iox::Error errorType = iox::Error::kNO_ERROR; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel) { hasTerminated = true; errorType = error; }); @@ -232,8 +232,8 @@ TEST_F(Trigger_test, TriggerWithEmptyResetCallCallsErrorHandlerAndIsInvalid) bool hasTerminated = false; iox::Error errorType = iox::Error::kNO_ERROR; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel) { hasTerminated = true; errorType = error; }); @@ -303,8 +303,8 @@ TEST_F(Trigger_test, TriggerWithEmptyResetInvalidatesTriggerWhenBeingResetted) constexpr uint64_t type = 0U; constexpr uint64_t typeHash = 0U; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error, const std::function, const iox::ErrorLevel) {}); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error, const iox::ErrorLevel) {}); Trigger sut(StateBasedTrigger, &m_triggerClass, @@ -699,8 +699,8 @@ TEST_F(Trigger_test, EventBasedTriggerWithEmptyResetCallInvokesErrorHandlerAndIs bool hasTerminated = false; iox::Error errorType = iox::Error::kNO_ERROR; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel) { hasTerminated = true; errorType = error; }); diff --git a/iceoryx_posh/test/moduletests/test_popo_unique_port_id.cpp b/iceoryx_posh/test/moduletests/test_popo_unique_port_id.cpp index a3075e1c8f3..3cde7bd829c 100644 --- a/iceoryx_posh/test/moduletests/test_popo_unique_port_id.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_unique_port_id.cpp @@ -33,7 +33,7 @@ TEST(UniquePortId_test, SettingTheRouDiIdWorks) ::testing::Test::RecordProperty("TEST_ID", "473467bf-1a6f-4cd2-acd8-447a623a5301"); uint16_t someId = 1243U; // we cannot ensure that setUniqueRouDiId wasn't called before, therefore we ignore the error - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler([](auto, auto, auto) {}); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler([](auto, auto) {}); auto uniqueRouDiIdResetScopeGuard = GenericRAII{[] {}, [] { iox::popo::UniquePortId::setUniqueRouDiId(iox::roudi::DEFAULT_UNIQUE_ROUDI_ID); }}; iox::popo::UniquePortId::setUniqueRouDiId(someId); @@ -46,8 +46,8 @@ TEST(UniquePortId_test, SettingTheRouDiIdTwiceFails) uint16_t someId = 1243U; optional detectedError; optional detectedErrorLevel; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); detectedErrorLevel.emplace(errorLevel); }); diff --git a/iceoryx_posh/test/moduletests/test_posh_runtime.cpp b/iceoryx_posh/test/moduletests/test_posh_runtime.cpp index 81a13ae5874..999bec94f39 100644 --- a/iceoryx_posh/test/moduletests/test_posh_runtime.cpp +++ b/iceoryx_posh/test/moduletests/test_posh_runtime.cpp @@ -111,9 +111,8 @@ TEST(PoshRuntime, LeadingSlashAppName) auto errorHandlerCalled{false}; iox::Error receivedError{iox::Error::kNO_ERROR}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled, - &receivedError](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled, &receivedError](const iox::Error error, const iox::ErrorLevel) { errorHandlerCalled = true; receivedError = error; }); @@ -149,8 +148,8 @@ TEST_F(PoshRuntime_test, GetMiddlewareInterfaceWithInvalidNodeNameIsNotSuccessfu { ::testing::Test::RecordProperty("TEST_ID", "d207e121-d7c2-4a23-a202-1af311f6982b"); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::SEVERE)); }); @@ -177,8 +176,8 @@ TEST_F(PoshRuntime_test, GetMiddlewareInterfaceInterfacelistOverflow) { ::testing::Test::RecordProperty("TEST_ID", "0e164d07-dede-46c3-b2a3-ad78a11c0691"); auto interfacelistOverflowDetected{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&interfacelistOverflowDetected](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&interfacelistOverflowDetected](const iox::Error error, const iox::ErrorLevel) { interfacelistOverflowDetected = true; EXPECT_THAT(error, Eq(iox::Error::kPORT_POOL__INTERFACELIST_OVERFLOW)); }); @@ -266,8 +265,8 @@ TEST_F(PoshRuntime_test, getMiddlewarePublisherPublisherlistOverflow) ::testing::Test::RecordProperty("TEST_ID", "f1f1a662-9580-40a1-a116-6ea1cb791516"); auto publisherlistOverflowDetected{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&publisherlistOverflowDetected](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&publisherlistOverflowDetected](const iox::Error error, const iox::ErrorLevel) { if (error == iox::Error::kPORT_POOL__PUBLISHERLIST_OVERFLOW) { publisherlistOverflowDetected = true; @@ -297,8 +296,8 @@ TEST_F(PoshRuntime_test, GetMiddlewarePublisherWithSameServiceDescriptionsAndOne { ::testing::Test::RecordProperty("TEST_ID", "77fb6dfd-a00d-459e-9dd3-90010d7b8af7"); auto publisherDuplicateDetected{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&publisherDuplicateDetected](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&publisherDuplicateDetected](const iox::Error error, const iox::ErrorLevel) { if (error == iox::Error::kPOSH__RUNTIME_PUBLISHER_PORT_NOT_UNIQUE) { publisherDuplicateDetected = true; @@ -449,8 +448,8 @@ TEST_F(PoshRuntime_test, GetMiddlewareSubscriberSubscriberlistOverflow) { ::testing::Test::RecordProperty("TEST_ID", "d1281cbd-6520-424e-aace-fbd3aa5d73e9"); auto subscriberlistOverflowDetected{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&subscriberlistOverflowDetected](const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&subscriberlistOverflowDetected](const iox::Error error, const iox::ErrorLevel) { if (error == iox::Error::kPORT_POOL__SUBSCRIBERLIST_OVERFLOW) { subscriberlistOverflowDetected = true; @@ -558,9 +557,8 @@ TEST_F(PoshRuntime_test, GetMiddlewareConditionVariableListOverflow) { ::testing::Test::RecordProperty("TEST_ID", "6776a648-03c7-4bd0-ab24-72ed7e118e4f"); auto conditionVariableListOverflowDetected{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&conditionVariableListOverflowDetected]( - const iox::Error error, const std::function, const iox::ErrorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&conditionVariableListOverflowDetected](const iox::Error error, const iox::ErrorLevel) { if (error == iox::Error::kPORT_POOL__CONDITION_VARIABLE_LIST_OVERFLOW) { conditionVariableListOverflowDetected = true; @@ -601,8 +599,8 @@ TEST_F(PoshRuntime_test, CreatingNodeWithInvalidNameLeadsToTermination) iox::runtime::NodeProperty nodeProperty(m_invalidNodeName, nodeDeviceIdentifier); iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::SEVERE)); }); diff --git a/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp b/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp index eb63a0acd58..1011ca5257a 100644 --- a/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp +++ b/iceoryx_posh/test/moduletests/test_posh_runtime_single_process.cpp @@ -68,8 +68,8 @@ TEST_F(PoshRuntimeSingleProcess_test, ConstructorPoshRuntimeSingleProcessMultipl const RuntimeName_t m_runtimeName{"App"}; iox::cxx::optional detectedError; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&detectedError](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&detectedError](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::FATAL)); }); diff --git a/iceoryx_posh/test/moduletests/test_roudi_iceoryx_roudi_app.cpp b/iceoryx_posh/test/moduletests/test_roudi_iceoryx_roudi_app.cpp index 6af3b208060..408ad36b493 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_iceoryx_roudi_app.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_iceoryx_roudi_app.cpp @@ -194,8 +194,8 @@ TEST_F(IceoryxRoudiApp_test, ConstructorCalledWithArgUniqueIdTwoTimesReturnError iox::cxx::optional detectedError; iox::cxx::optional detectedErrorLevel; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&](const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&](const iox::Error error, const iox::ErrorLevel errorLevel) { detectedError.emplace(error); detectedErrorLevel.emplace(errorLevel); }); diff --git a/iceoryx_posh/test/moduletests/test_roudi_portmanager.cpp b/iceoryx_posh/test/moduletests/test_roudi_portmanager.cpp index 0edf054204e..931ca8c771a 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_portmanager.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_portmanager.cpp @@ -429,9 +429,9 @@ TEST_F(PortManager_test, AcquiringOneMoreThanMaximumNumberOfPublishersFails) { // test if overflow errors get hit bool errorHandlerCalled = false; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( [&errorHandlerCalled](const iox::Error error IOX_MAYBE_UNUSED, - const std::function, + const iox::ErrorLevel) { errorHandlerCalled = true; }); auto publisherPortDataResult = m_portManager->acquirePublisherPortData( @@ -458,9 +458,9 @@ TEST_F(PortManager_test, AcquiringOneMoreThanMaximumNumberOfSubscribersFails) { // test if overflow errors get hit bool errorHandlerCalled = false; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( [&errorHandlerCalled](const iox::Error error IOX_MAYBE_UNUSED, - const std::function, + const iox::ErrorLevel) { errorHandlerCalled = true; }); auto subscriberPortDataResult = m_portManager->acquireSubscriberPortData(getUniqueSD(), subscriberOptions, runtimeName1, PortConfigInfo()); @@ -480,10 +480,8 @@ TEST_F(PortManager_test, AcquiringOneMoreThanMaximumNumberOfInterfacesFails) // test if overflow errors get hit { auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { - errorHandlerCalled = true; - }); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); auto interfacePort = m_portManager->acquireInterfacePortData(iox::capro::Interfaces::INTERNAL, "itfPenguin"); EXPECT_EQ(interfacePort, nullptr); @@ -719,10 +717,8 @@ TEST_F(PortManager_test, AcquiringOneMoreThanMaximumNumberOfConditionVariablesFa // test if overflow errors get hit { auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { - errorHandlerCalled = true; - }); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); auto conditionVariableResult = m_portManager->acquireConditionVariableData("AnotherToad"); EXPECT_TRUE(conditionVariableResult.has_error()); @@ -793,10 +789,8 @@ TEST_F(PortManager_test, AcquiringOneMoreThanMaximumNumberOfNodesFails) // test if overflow errors get hit auto errorHandlerCalled{false}; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( - [&errorHandlerCalled](const iox::Error, const std::function, const iox::ErrorLevel) { - errorHandlerCalled = true; - }); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + [&errorHandlerCalled](const iox::Error, const iox::ErrorLevel) { errorHandlerCalled = true; }); auto nodeResult = m_portManager->acquireNodeData("AnotherProcess", "AnotherNode"); EXPECT_THAT(nodeResult.has_error(), Eq(true)); diff --git a/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp b/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp index 9fea4babea8..cced591c8eb 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp @@ -83,8 +83,8 @@ TEST_F(PortPool_test, AddNodeDataWhenNodeListIsFullReturnsError) auto errorHandlerCalled{false}; Error errorHandlerType; - auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( - [&](const Error error, const std::function, const ErrorLevel) { + auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( + [&](const Error error, const ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); @@ -201,8 +201,8 @@ TEST_F(PortPool_test, AddPublisherPortWhenPublisherListOverflowsReturnsError) auto errorHandlerCalled{false}; Error errorHandlerType; - auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( - [&](const Error error, const std::function, const ErrorLevel) { + auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( + [&](const Error error, const ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); @@ -331,8 +331,8 @@ TEST_F(PortPool_test, AddSubscriberPortWhenSubscriberListOverflowsReturnsError) auto errorHandlerCalled{false}; Error errorHandlerType; - auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( - [&](const Error error, const std::function, const ErrorLevel) { + auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( + [&](const Error error, const ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); @@ -423,8 +423,8 @@ TEST_F(PortPool_test, AddInterfacePortWhenInterfaceListOverflowsReturnsError) auto errorHandlerCalled{false}; Error errorHandlerType; - auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( - [&](const Error error, const std::function, const ErrorLevel) { + auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( + [&](const Error error, const ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); @@ -507,8 +507,8 @@ TEST_F(PortPool_test, AddConditionVariableDataWhenContainerIsFullReturnsError) auto errorHandlerCalled{false}; Error errorHandlerType; - auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( - [&](const Error error, const std::function, const ErrorLevel) { + auto errorHandlerGuard = ErrorHandler::setTemporaryErrorHandler( + [&](const Error error, const ErrorLevel) { errorHandlerType = error; errorHandlerCalled = true; }); diff --git a/iceoryx_posh/test/moduletests/test_roudi_process.cpp b/iceoryx_posh/test/moduletests/test_roudi_process.cpp index ebb8baad3af..2c1e6b6e25d 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_process.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_process.cpp @@ -96,9 +96,9 @@ TEST_F(Process_test, sendViaIpcChannelFail) iox::runtime::IpcMessage data{""}; iox::cxx::optional sendViaIpcChannelStatusFail; - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler( [&sendViaIpcChannelStatusFail]( - const iox::Error error, const std::function, const iox::ErrorLevel errorLevel) { + const iox::Error error, const iox::ErrorLevel errorLevel) { sendViaIpcChannelStatusFail.emplace(error); EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::MODERATE)); }); diff --git a/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp b/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp index 381d974b333..ec4130ed5d1 100644 --- a/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp +++ b/iceoryx_posh/testing/roudi_environment/roudi_environment.cpp @@ -30,7 +30,7 @@ namespace roudi RouDiEnvironment::RouDiEnvironment(BaseCTor, const uint16_t uniqueRouDiId) { // setUniqueRouDiId is called multiple times but it is okay for the tests - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler([](auto, auto, auto) {}); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler([](auto, auto) {}); iox::popo::UniquePortId::setUniqueRouDiId(uniqueRouDiId); iox::log::LogManager::GetLogManager().SetDefaultLogLevel(iox::log::LogLevel::kWarn, iox::log::LogLevelOutput::kHideLogLevel); @@ -52,7 +52,7 @@ RouDiEnvironment::~RouDiEnvironment() if (m_runtimes.m_doCleanupOnDestruction) { // setUniqueRouDiId is called multiple times but it is okay for the tests - auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler([](auto, auto, auto) {}); + auto errorHandlerGuard = iox::ErrorHandler::setTemporaryErrorHandler([](auto, auto) {}); popo::UniquePortId::setUniqueRouDiId(roudi::DEFAULT_UNIQUE_ROUDI_ID); } CleanupRuntimes();