diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e8197e7246..b86901df0a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install iceoryx dependencies and clang-tidy uses: ./.github/actions/install-iceoryx-deps-and-clang - run: ./tools/scripts/clang_format.sh check @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-20.04 needs: pre-flight-check steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: egor-tensin/setup-gcc@v1.3 with: # gcc 8.3 is compiler used in QNX 7.1 @@ -71,7 +71,7 @@ jobs: runs-on: windows-latest needs: pre-flight-check steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./tools/ci/build-test-windows.ps1 -toolchain MSVC shell: powershell @@ -81,7 +81,7 @@ jobs: runs-on: windows-latest needs: pre-flight-check steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: egor-tensin/setup-mingw@v2 with: version: 10.3 @@ -99,7 +99,7 @@ jobs: uses: ros-tooling/setup-ros@v0.7 with: required-ros-distributions: humble - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./tools/ci/run-integration-test.sh build-test-ubuntu-with-address-sanitizer-gcc-latest: @@ -112,7 +112,7 @@ jobs: with: version: 13 platform: x64 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run Address Sanitizer run: ./tools/ci/build-test-ubuntu-with-sanitizers.sh gcc asan @@ -123,7 +123,7 @@ jobs: needs: pre-flight-check steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install iceoryx dependencies and clang-tidy uses: ./.github/actions/install-iceoryx-deps-and-clang - name: Run Address Sanitizer @@ -135,7 +135,7 @@ jobs: runs-on: macos-latest needs: pre-flight-check steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run Address Sanitizer run: ./tools/ci/build-test-macos-with-sanitizers.sh asan @@ -146,7 +146,7 @@ jobs: needs: pre-flight-check steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install iceoryx dependencies and clang-tidy uses: ./.github/actions/install-iceoryx-deps-and-clang - name: Run Thread Sanitizer @@ -160,7 +160,7 @@ jobs: needs: pre-flight-check steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install iceoryx dependencies and clang-tidy uses: ./.github/actions/install-iceoryx-deps-and-clang - run: ./tools/ci/build-test-ubuntu-bazel.sh @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest needs: pre-flight-check steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./tools/ci/coverage-and-docs.sh - name: Archive generated doxygen diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index f09ff2b140..ff268ef550 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/lint_pull_request.yml b/.github/workflows/lint_pull_request.yml index 64728ebb4e..6f78538724 100644 --- a/.github/workflows/lint_pull_request.yml +++ b/.github/workflows/lint_pull_request.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -38,7 +38,7 @@ jobs: verify-links-in-markdown-documentation: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Calculate lychee cache key run: echo "LYCHEE_CACHE_KEY=cache-lychee-all-branches-$(date +'%G-%V')" >> "$GITHUB_ENV" # %G = year; %V = week number diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ca345558c1..b5de354795 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -11,7 +11,7 @@ jobs: # prevent stuck jobs consuming macos runners for 6 hours timeout-minutes: 60 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./tools/ci/build-test-macos.sh clang-tidy-full-scan: @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install iceoryx dependencies and clang-tidy uses: ./.github/actions/install-iceoryx-deps-and-clang - name: clang-tidy full scan of all entries in .clang-tidy-diff-scans.txt diff --git a/.github/workflows/release_build_publish.yml b/.github/workflows/release_build_publish.yml index 4510206812..612fde8203 100644 --- a/.github/workflows/release_build_publish.yml +++ b/.github/workflows/release_build_publish.yml @@ -27,7 +27,7 @@ jobs: sudo apt-get install -y plantuml texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-fonts-recommended - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.ReleaseTag }} env: diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/internal/binding_c_error_reporting.hpp b/iceoryx_binding_c/include/iceoryx_binding_c/internal/binding_c_error_reporting.hpp index d2691f7f86..0b88097571 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/internal/binding_c_error_reporting.hpp +++ b/iceoryx_binding_c/include/iceoryx_binding_c/internal/binding_c_error_reporting.hpp @@ -31,6 +31,7 @@ // additional includes #include "iox/error_reporting/types.hpp" +#include "iox/log/logstream.hpp" namespace iox { @@ -62,6 +63,12 @@ enum class CBindingError : iox::er::ErrorCode::type const char* asStringLiteral(const CBindingError error) noexcept; +inline log::LogStream& operator<<(log::LogStream& stream, CBindingError value) noexcept +{ + stream << asStringLiteral(value); + return stream; +} + class CBindingErrorType { public: diff --git a/iceoryx_binding_c/source/c_chunk.cpp b/iceoryx_binding_c/source/c_chunk.cpp index 91a1aa7559..8524394d6c 100644 --- a/iceoryx_binding_c/source/c_chunk.cpp +++ b/iceoryx_binding_c/source/c_chunk.cpp @@ -15,7 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_posh/mepoo/chunk_header.hpp" - +#include "iox/assertions.hpp" extern "C" { #include "iceoryx_binding_c/chunk.h" @@ -25,36 +25,36 @@ using namespace iox::mepoo; void* iox_chunk_header_to_user_payload(iox_chunk_header_t* const chunkHeader) { - IOX_EXPECTS(chunkHeader != nullptr); + IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'"); return reinterpret_cast(chunkHeader)->userPayload(); } const void* iox_chunk_header_to_user_payload_const(const iox_chunk_header_t* const chunkHeader) { - IOX_EXPECTS(chunkHeader != nullptr); + IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'"); return reinterpret_cast(chunkHeader)->userPayload(); } void* iox_chunk_header_to_user_header(iox_chunk_header_t* const chunkHeader) { - IOX_EXPECTS(chunkHeader != nullptr); + IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'"); return reinterpret_cast(chunkHeader)->userHeader(); } const void* iox_chunk_header_to_user_header_const(const iox_chunk_header_t* const chunkHeader) { - IOX_EXPECTS(chunkHeader != nullptr); + IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'"); return reinterpret_cast(chunkHeader)->userHeader(); } iox_chunk_header_t* iox_chunk_header_from_user_payload(void* const userPayload) { - IOX_EXPECTS(userPayload != nullptr); + IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'"); return reinterpret_cast(ChunkHeader::fromUserPayload(userPayload)); } const iox_chunk_header_t* iox_chunk_header_from_user_payload_const(const void* const userPayload) { - IOX_EXPECTS(userPayload != nullptr); + IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'"); return reinterpret_cast(ChunkHeader::fromUserPayload(userPayload)); } diff --git a/iceoryx_binding_c/source/c_client.cpp b/iceoryx_binding_c/source/c_client.cpp index 385b27aa5f..bb6ce39511 100644 --- a/iceoryx_binding_c/source/c_client.cpp +++ b/iceoryx_binding_c/source/c_client.cpp @@ -35,7 +35,7 @@ constexpr uint64_t CLIENT_OPTIONS_INIT_CHECK_CONSTANT = 47113130815; void iox_client_options_init(iox_client_options_t* options) { - IOX_EXPECTS(options != nullptr); + IOX_ENFORCE(options != nullptr, "'options' must not be a 'nullptr'"); ClientOptions clientOptions; options->responseQueueCapacity = clientOptions.responseQueueCapacity; @@ -49,7 +49,7 @@ void iox_client_options_init(iox_client_options_t* options) bool iox_client_options_is_initialized(const iox_client_options_t* const options) { - IOX_EXPECTS(options != nullptr); + IOX_ENFORCE(options != nullptr, "'options' must not be a 'nullptr'"); return options->initCheck == CLIENT_OPTIONS_INIT_CHECK_CONSTANT; } @@ -60,11 +60,12 @@ iox_client_t iox_client_init(iox_client_storage_t* self, const char* const event, const iox_client_options_t* const options) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(service != nullptr); - IOX_EXPECTS(instance != nullptr); - IOX_EXPECTS(event != nullptr); - IOX_EXPECTS(options == nullptr || (options != nullptr && iox_client_options_is_initialized(options))); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(service != nullptr, "'service' must not be a 'nullptr'"); + IOX_ENFORCE(instance != nullptr, "'instance' must not be a 'nullptr'"); + IOX_ENFORCE(event != nullptr, "'event' must not be a 'nullptr'"); + IOX_ENFORCE(options == nullptr || (options != nullptr && iox_client_options_is_initialized(options)), + "'options' must be either a 'nullptr' or the data behind the pointer must be initialized"); ClientOptions clientOptions; if (options != nullptr) @@ -87,7 +88,7 @@ iox_client_t iox_client_init(iox_client_storage_t* self, void iox_client_deinit(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); delete self; } @@ -102,8 +103,8 @@ iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self, const uint64_t payloadSize, const uint32_t payloadAlignment) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); auto result = self->loan(payloadSize, payloadAlignment); if (result.has_error()) @@ -117,15 +118,15 @@ iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self, void iox_client_release_request(iox_client_t const self, void* const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); self->releaseRequest(payload); } iox_ClientSendResult iox_client_send(iox_client_t const self, void* const payload) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); auto result = self->send(payload); if (result.has_error()) @@ -138,26 +139,26 @@ iox_ClientSendResult iox_client_send(iox_client_t const self, void* const payloa void iox_client_connect(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->connect(); } void iox_client_disconnect(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->disconnect(); } iox_ConnectionState iox_client_get_connection_state(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return cpp2c::connectionState(self->getConnectionState()); } iox_ChunkReceiveResult iox_client_take_response(iox_client_t const self, const void** const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); auto result = self->take(); if (result.has_error()) @@ -171,27 +172,27 @@ iox_ChunkReceiveResult iox_client_take_response(iox_client_t const self, const v void iox_client_release_response(iox_client_t const self, const void* const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); self->releaseResponse(payload); } void iox_client_release_queued_responses(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->releaseQueuedResponses(); } bool iox_client_has_responses(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasResponses(); } bool iox_client_has_missed_responses(iox_client_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasMissedResponses(); } diff --git a/iceoryx_binding_c/source/c_listener.cpp b/iceoryx_binding_c/source/c_listener.cpp index 45b4f1ea85..e369a30c9c 100644 --- a/iceoryx_binding_c/source/c_listener.cpp +++ b/iceoryx_binding_c/source/c_listener.cpp @@ -21,6 +21,7 @@ #include "iceoryx_posh/popo/untyped_client.hpp" #include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" +#include "iox/assertions.hpp" #include @@ -34,7 +35,7 @@ extern "C" { iox_listener_t iox_listener_init(iox_listener_storage_t* self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); auto* me = new Listener(); self->do_not_touch_me[0] = reinterpret_cast(me); @@ -43,7 +44,7 @@ iox_listener_t iox_listener_init(iox_listener_storage_t* self) void iox_listener_deinit(iox_listener_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); delete self; } @@ -53,9 +54,9 @@ ENUM iox_ListenerResult iox_listener_attach_subscriber_event(iox_listener_t cons const ENUM iox_SubscriberEvent subscriberEvent, void (*callback)(iox_sub_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); - IOX_EXPECTS(callback != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); auto result = self->attachEvent(*subscriber, @@ -75,10 +76,10 @@ iox_listener_attach_subscriber_event_with_context_data(iox_listener_t const self void (*callback)(iox_sub_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); - IOX_EXPECTS(callback != nullptr); - IOX_EXPECTS(contextData != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); + IOX_ENFORCE(contextData != nullptr, "'contextData' must not be a 'nullptr'"); auto result = self->attachEvent(*subscriber, c2cpp::subscriberEvent(subscriberEvent), @@ -94,9 +95,9 @@ ENUM iox_ListenerResult iox_listener_attach_user_trigger_event(iox_listener_t co iox_user_trigger_t const userTrigger, void (*callback)(iox_user_trigger_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userTrigger != nullptr); - IOX_EXPECTS(callback != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userTrigger != nullptr, "'userTrigger' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); auto result = self->attachEvent(*userTrigger, NotificationCallback{callback, nullptr}); @@ -113,10 +114,10 @@ ENUM iox_ListenerResult iox_listener_attach_user_trigger_event_with_context_data void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userTrigger != nullptr); - IOX_EXPECTS(callback != nullptr); - IOX_EXPECTS(contextData != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userTrigger != nullptr, "'userTrigger' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); + IOX_ENFORCE(contextData != nullptr, "'contextData' must not be a 'nullptr'"); NotificationCallback notificationCallback; notificationCallback.m_callback = callback; @@ -134,30 +135,30 @@ void iox_listener_detach_subscriber_event(iox_listener_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); self->detachEvent(*subscriber, c2cpp::subscriberEvent(subscriberEvent)); } void iox_listener_detach_user_trigger_event(iox_listener_t const self, iox_user_trigger_t const userTrigger) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userTrigger != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userTrigger != nullptr, "'userTrigger' must not be a 'nullptr'"); self->detachEvent(*userTrigger); } uint64_t iox_listener_size(iox_listener_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->size(); } uint64_t iox_listener_capacity(iox_listener_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->capacity(); } @@ -167,9 +168,9 @@ iox_ListenerResult iox_listener_attach_client_event(iox_listener_t const self, const ENUM iox_ClientEvent clientEvent, void (*callback)(iox_client_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); - IOX_EXPECTS(callback != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); auto result = self->attachEvent( *client, @@ -184,10 +185,10 @@ iox_ListenerResult iox_listener_attach_client_event_with_context_data(iox_listen void (*callback)(iox_client_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); - IOX_EXPECTS(callback != nullptr); - IOX_EXPECTS(contextData != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); + IOX_ENFORCE(contextData != nullptr, "'contextData' must not be a 'nullptr'"); auto result = self->attachEvent(*client, @@ -200,8 +201,8 @@ void iox_listener_detach_client_event(iox_listener_t const self, iox_client_t const client, const ENUM iox_ClientEvent clientEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); self->detachEvent(*client, c2cpp::clientEvent(clientEvent)); } @@ -212,9 +213,9 @@ iox_ListenerResult iox_listener_attach_server_event(iox_listener_t const self, const ENUM iox_ServerEvent serverEvent, void (*callback)(iox_server_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); - IOX_EXPECTS(callback != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); auto result = self->attachEvent( *server, @@ -229,10 +230,10 @@ iox_ListenerResult iox_listener_attach_server_event_with_context_data(iox_listen void (*callback)(iox_server_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); - IOX_EXPECTS(callback != nullptr); - IOX_EXPECTS(contextData != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); + IOX_ENFORCE(contextData != nullptr, "'contextData' must not be a 'nullptr'"); auto result = self->attachEvent(*server, @@ -245,8 +246,8 @@ void iox_listener_detach_server_event(iox_listener_t const self, iox_server_t const server, const ENUM iox_ServerEvent serverEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); self->detachEvent(*server, c2cpp::serverEvent(serverEvent)); } @@ -257,9 +258,9 @@ iox_listener_attach_service_discovery_event(iox_listener_t const self, const ENUM iox_ServiceDiscoveryEvent serviceDiscoveryEvent, void (*callback)(iox_service_discovery_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); - IOX_EXPECTS(callback != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); auto result = self->attachEvent(*serviceDiscovery, @@ -276,10 +277,10 @@ iox_ListenerResult iox_listener_attach_service_discovery_event_with_context_data void (*callback)(iox_service_discovery_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); - IOX_EXPECTS(callback != nullptr); - IOX_EXPECTS(contextData != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); + IOX_ENFORCE(callback != nullptr, "'callback' must not be a 'nullptr'"); + IOX_ENFORCE(contextData != nullptr, "'contextData' must not be a 'nullptr'"); auto result = self->attachEvent(*serviceDiscovery, c2cpp::serviceDiscoveryEvent(serviceDiscoveryEvent), @@ -292,8 +293,8 @@ void iox_listener_detach_service_discovery_event(iox_listener_t const self, iox_service_discovery_t const serviceDiscovery, const ENUM iox_ServiceDiscoveryEvent serviceDiscoveryEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); self->detachEvent(*serviceDiscovery, c2cpp::serviceDiscoveryEvent(serviceDiscoveryEvent)); } diff --git a/iceoryx_binding_c/source/c_node.cpp b/iceoryx_binding_c/source/c_node.cpp index e7d8f634d9..5b52338ea2 100644 --- a/iceoryx_binding_c/source/c_node.cpp +++ b/iceoryx_binding_c/source/c_node.cpp @@ -19,6 +19,7 @@ #include "iceoryx_posh/internal/runtime/node_data.hpp" #include "iceoryx_posh/runtime/node.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/assertions.hpp" using namespace iox; using namespace iox::runtime; @@ -53,7 +54,7 @@ iox_node_t iox_node_create(const char* const nodeName) void iox_node_destroy(iox_node_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); NodeBindingExtension(self).destroy(); } diff --git a/iceoryx_binding_c/source/c_notification_info.cpp b/iceoryx_binding_c/source/c_notification_info.cpp index d943bc1d18..bfadda4ac3 100644 --- a/iceoryx_binding_c/source/c_notification_info.cpp +++ b/iceoryx_binding_c/source/c_notification_info.cpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" #include "iceoryx_posh/runtime/service_discovery.hpp" +#include "iox/assertions.hpp" using namespace iox; using namespace iox::popo; @@ -31,80 +32,80 @@ extern "C" { uint64_t iox_notification_info_get_notification_id(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getNotificationId(); } bool iox_notification_info_does_originate_from_subscriber(iox_notification_info_t const self, iox_sub_t const subscriber) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); return self->doesOriginateFrom(subscriber); } bool iox_notification_info_does_originate_from_user_trigger(iox_notification_info_t const self, iox_user_trigger_t const user_trigger) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(user_trigger != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(user_trigger != nullptr, "'user_trigger' must not be a 'nullptr'"); return self->doesOriginateFrom(user_trigger); } bool iox_notification_info_does_originate_from_client(iox_notification_info_t const self, iox_client_t const client) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); return self->doesOriginateFrom(client); } bool iox_notification_info_does_originate_from_server(iox_notification_info_t const self, iox_server_t const server) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); return self->doesOriginateFrom(server); } bool iox_notification_info_does_originate_from_service_discovery(iox_notification_info_t const self, iox_service_discovery_t const serviceDiscovery) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); return self->doesOriginateFrom(serviceDiscovery); } iox_sub_t iox_notification_info_get_subscriber_origin(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getOrigin(); } iox_user_trigger_t iox_notification_info_get_user_trigger_origin(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getOrigin(); } iox_client_t iox_notification_info_get_client_origin(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getOrigin(); } iox_server_t iox_notification_info_get_server_origin(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getOrigin(); } iox_service_discovery_t iox_notification_info_get_service_discovery_origin(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getOrigin(); } void iox_notification_info_call(iox_notification_info_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); (*self)(); } diff --git a/iceoryx_binding_c/source/c_publisher.cpp b/iceoryx_binding_c/source/c_publisher.cpp index 86f23380b0..042fa301bb 100644 --- a/iceoryx_binding_c/source/c_publisher.cpp +++ b/iceoryx_binding_c/source/c_publisher.cpp @@ -22,9 +22,9 @@ #include "iceoryx_binding_c/internal/cpp2c_service_description_translation.hpp" #include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" - using namespace iox; using namespace iox::popo; using namespace iox::capro; @@ -107,7 +107,7 @@ iox_pub_t iox_pub_init(iox_pub_storage_t* self, void iox_pub_deinit(iox_pub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->m_portData->m_toBeDestroyed.store(true, std::memory_order_relaxed); delete self; @@ -156,44 +156,44 @@ iox_AllocationResult iox_pub_loan_aligned_chunk_with_user_header(iox_pub_t const void iox_pub_release_chunk(iox_pub_t const self, void* const userPayload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userPayload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'"); PublisherPortUser(self->m_portData).releaseChunk(ChunkHeader::fromUserPayload(userPayload)); } void iox_pub_publish_chunk(iox_pub_t const self, void* const userPayload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userPayload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'"); PublisherPortUser(self->m_portData).sendChunk(ChunkHeader::fromUserPayload(userPayload)); } void iox_pub_offer(iox_pub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); PublisherPortUser(self->m_portData).offer(); } void iox_pub_stop_offer(iox_pub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); PublisherPortUser(self->m_portData).stopOffer(); } bool iox_pub_is_offered(iox_pub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return PublisherPortUser(self->m_portData).isOffered(); } bool iox_pub_has_subscribers(iox_pub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return PublisherPortUser(self->m_portData).hasSubscribers(); } iox_service_description_t iox_pub_get_service_description(iox_pub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return TranslateServiceDescription(PublisherPortUser(self->m_portData).getCaProServiceDescription()); } diff --git a/iceoryx_binding_c/source/c_request_header.cpp b/iceoryx_binding_c/source/c_request_header.cpp index 35fc114482..0c710eb85c 100644 --- a/iceoryx_binding_c/source/c_request_header.cpp +++ b/iceoryx_binding_c/source/c_request_header.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_posh/popo/rpc_header.hpp" +#include "iox/assertions.hpp" using namespace iox; using namespace iox::popo; @@ -27,77 +28,77 @@ extern "C" { iox_request_header_t iox_request_header_from_payload(void* const payload) { - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); return RequestHeader::fromPayload(payload); } iox_const_request_header_t iox_request_header_from_payload_const(const void* const payload) { - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); return RequestHeader::fromPayload(payload); } void iox_request_header_set_sequence_id(iox_request_header_t const self, const int64_t sequenceId) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->setSequenceId(sequenceId); } uint8_t iox_request_header_get_rpc_header_version(iox_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getRpcHeaderVersion(); } uint8_t iox_request_header_get_rpc_header_version_const(iox_const_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getRpcHeaderVersion(); } int64_t iox_request_header_get_sequence_id(iox_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getSequenceId(); } int64_t iox_request_header_get_sequence_id_const(iox_const_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getSequenceId(); } void* iox_request_header_get_user_payload(iox_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getUserPayload(); } const void* iox_request_header_get_user_payload_const(iox_const_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getUserPayload(); } iox_chunk_header_t* iox_request_header_get_chunk_header(iox_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return reinterpret_cast(self->getChunkHeader()); } const iox_chunk_header_t* iox_request_header_get_chunk_header_const(iox_const_request_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return reinterpret_cast(self->getChunkHeader()); } diff --git a/iceoryx_binding_c/source/c_response_header.cpp b/iceoryx_binding_c/source/c_response_header.cpp index 9727ab8a5f..6163436e0a 100644 --- a/iceoryx_binding_c/source/c_response_header.cpp +++ b/iceoryx_binding_c/source/c_response_header.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_posh/popo/rpc_header.hpp" +#include "iox/assertions.hpp" using namespace iox; using namespace iox::popo; @@ -27,91 +28,91 @@ extern "C" { iox_response_header_t iox_response_header_from_payload(void* const payload) { - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); return ResponseHeader::fromPayload(payload); } iox_const_response_header_t iox_response_header_from_payload_const(const void* const payload) { - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); return ResponseHeader::fromPayload(payload); } void iox_response_header_set_server_error(iox_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->setServerError(); } bool iox_response_header_has_server_error(iox_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasServerError(); } bool iox_response_header_has_server_error_const(iox_const_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasServerError(); } uint8_t iox_response_header_get_rpc_header_version(iox_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getRpcHeaderVersion(); } uint8_t iox_response_header_get_rpc_header_version_const(iox_const_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getRpcHeaderVersion(); } int64_t iox_response_header_get_sequence_id(iox_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getSequenceId(); } int64_t iox_response_header_get_sequence_id_const(iox_const_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getSequenceId(); } void* iox_response_header_get_user_payload(iox_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getUserPayload(); } const void* iox_response_header_get_user_payload_const(iox_const_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->getUserPayload(); } iox_chunk_header_t* iox_response_header_get_chunk_header(iox_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return reinterpret_cast(self->getChunkHeader()); } const iox_chunk_header_t* iox_response_header_get_chunk_header_const(iox_const_response_header_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return reinterpret_cast(self->getChunkHeader()); } diff --git a/iceoryx_binding_c/source/c_runtime.cpp b/iceoryx_binding_c/source/c_runtime.cpp index 441153fb96..e343156f4b 100644 --- a/iceoryx_binding_c/source/c_runtime.cpp +++ b/iceoryx_binding_c/source/c_runtime.cpp @@ -27,9 +27,9 @@ extern "C" { void iox_runtime_init(const char* const name) { - IOX_EXPECTS_WITH_MSG(name != nullptr, "Runtime name is a nullptr!"); - IOX_EXPECTS_WITH_MSG(strnlen(name, iox::MAX_RUNTIME_NAME_LENGTH + 1) <= MAX_RUNTIME_NAME_LENGTH, - "Runtime name has more than 100 characters!"); + IOX_ENFORCE(name != nullptr, "Runtime name is a nullptr!"); + IOX_ENFORCE(strnlen(name, iox::MAX_RUNTIME_NAME_LENGTH + 1) <= MAX_RUNTIME_NAME_LENGTH, + "Runtime name has more than 100 characters!"); PoshRuntime::initRuntime(RuntimeName_t(iox::TruncateToCapacity, name)); } diff --git a/iceoryx_binding_c/source/c_server.cpp b/iceoryx_binding_c/source/c_server.cpp index 6e6d50e6de..2107b977d8 100644 --- a/iceoryx_binding_c/source/c_server.cpp +++ b/iceoryx_binding_c/source/c_server.cpp @@ -34,7 +34,7 @@ constexpr uint64_t SERVER_OPTIONS_INIT_CHECK_CONSTANT = 333333331737373; void iox_server_options_init(iox_server_options_t* const options) { - IOX_EXPECTS(options != nullptr); + IOX_ENFORCE(options != nullptr, "'options' must not be a 'nullptr'"); ServerOptions serverOptions; options->requestQueueCapacity = serverOptions.requestQueueCapacity; @@ -47,7 +47,7 @@ void iox_server_options_init(iox_server_options_t* const options) bool iox_server_options_is_initialized(const iox_server_options_t* const options) { - IOX_EXPECTS(options != nullptr); + IOX_ENFORCE(options != nullptr, "'options' must not be a 'nullptr'"); return options->initCheck == SERVER_OPTIONS_INIT_CHECK_CONSTANT; } @@ -58,11 +58,12 @@ iox_server_t iox_server_init(iox_server_storage_t* self, const char* const event, const iox_server_options_t* const options) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(service != nullptr); - IOX_EXPECTS(instance != nullptr); - IOX_EXPECTS(event != nullptr); - IOX_EXPECTS(options == nullptr || (options != nullptr && iox_server_options_is_initialized(options))); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(service != nullptr, "'service' must not be a 'nullptr'"); + IOX_ENFORCE(instance != nullptr, "'instance' must not be a 'nullptr'"); + IOX_ENFORCE(event != nullptr, "'event' must not be a 'nullptr'"); + IOX_ENFORCE(options == nullptr || (options != nullptr && iox_server_options_is_initialized(options)), + "'options' must be either a 'nullptr' or the data behind the pointer must be initialized"); ServerOptions serverOptions; if (options != nullptr) @@ -85,15 +86,15 @@ iox_server_t iox_server_init(iox_server_storage_t* self, void iox_server_deinit(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); delete self; } iox_ServerRequestResult iox_server_take_request(iox_server_t const self, const void** const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); auto result = self->take(); if (result.has_error()) @@ -106,8 +107,8 @@ iox_ServerRequestResult iox_server_take_request(iox_server_t const self, const v void iox_server_release_request(iox_server_t const self, const void* const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); self->releaseRequest(payload); } @@ -127,9 +128,9 @@ iox_AllocationResult iox_server_loan_aligned_response(iox_server_t const self, const uint64_t payloadSize, const uint32_t payloadAlignment) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(requestPayload != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(requestPayload != nullptr, "'requestPayload' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); auto result = self->loan(RequestHeader::fromPayload(requestPayload), payloadSize, payloadAlignment); if (result.has_error()) @@ -143,8 +144,8 @@ iox_AllocationResult iox_server_loan_aligned_response(iox_server_t const self, iox_ServerSendResult iox_server_send(iox_server_t const self, void* const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); auto result = self->send(payload); if (result.has_error()) @@ -157,64 +158,64 @@ iox_ServerSendResult iox_server_send(iox_server_t const self, void* const payloa void iox_server_release_response(iox_server_t const self, void* const payload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(payload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'"); self->releaseResponse(payload); } iox_service_description_t iox_server_get_service_description(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return TranslateServiceDescription(self->getServiceDescription()); } void iox_server_offer(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->offer(); } void iox_server_stop_offer(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->stopOffer(); } bool iox_server_is_offered(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->isOffered(); } bool iox_server_has_clients(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasClients(); } bool iox_server_has_requests(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasRequests(); } bool iox_server_has_missed_requests(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasMissedRequests(); } void iox_server_release_queued_requests(iox_server_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->releaseQueuedRequests(); } diff --git a/iceoryx_binding_c/source/c_service_discovery.cpp b/iceoryx_binding_c/source/c_service_discovery.cpp index 4e6e233968..517bff51d6 100644 --- a/iceoryx_binding_c/source/c_service_discovery.cpp +++ b/iceoryx_binding_c/source/c_service_discovery.cpp @@ -29,7 +29,7 @@ extern "C" { iox_service_discovery_t iox_service_discovery_init(iox_service_discovery_storage_t* self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); auto* me = new ServiceDiscovery(); self->do_not_touch_me[0] = reinterpret_cast(me); @@ -38,7 +38,7 @@ iox_service_discovery_t iox_service_discovery_init(iox_service_discovery_storage void iox_service_discovery_deinit(iox_service_discovery_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); delete self; } @@ -52,9 +52,9 @@ uint64_t iox_service_discovery_find_service(iox_service_discovery_t const self, uint64_t* missedServices, const ENUM iox_MessagingPattern pattern) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceContainer != nullptr); - IOX_EXPECTS(missedServices != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceContainer != nullptr, "'serviceContainer' must not be a 'nullptr'"); + IOX_ENFORCE(missedServices != nullptr, "'missedServices' must not be a 'nullptr'"); optional maybeService; if (service != nullptr) @@ -96,8 +96,8 @@ void iox_service_discovery_find_service_apply_callable(iox_service_discovery_t c void (*callable)(const iox_service_description_t), const ENUM iox_MessagingPattern pattern) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(callable != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(callable != nullptr, "'callable' must not be a 'nullptr'"); optional maybeService; if (service != nullptr) @@ -128,8 +128,8 @@ void iox_service_discovery_find_service_apply_callable_with_context_data( void* const contextData, const ENUM iox_MessagingPattern pattern) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(callable != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(callable != nullptr, "'callable' must not be a 'nullptr'"); optional maybeService; if (service != nullptr) diff --git a/iceoryx_binding_c/source/c_subscriber.cpp b/iceoryx_binding_c/source/c_subscriber.cpp index 6962aceb64..9886ebce3b 100644 --- a/iceoryx_binding_c/source/c_subscriber.cpp +++ b/iceoryx_binding_c/source/c_subscriber.cpp @@ -24,9 +24,9 @@ #include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp" #include "iceoryx_posh/mepoo/chunk_header.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" - using namespace iox; using namespace iox::popo; using namespace iox::capro; @@ -125,7 +125,7 @@ iox_sub_t iox_sub_init(iox_sub_storage_t* self, void iox_sub_deinit(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); auto addressOfSelf = reinterpret_cast(self); auto* selfWithStoragePointer = reinterpret_cast(addressOfSelf - sizeof(void*)); @@ -135,25 +135,25 @@ void iox_sub_deinit(iox_sub_t const self) void iox_sub_subscribe(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); SubscriberPortUser(self->m_portData).subscribe(); } void iox_sub_unsubscribe(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); SubscriberPortUser(self->m_portData).unsubscribe(); } iox_SubscribeState iox_sub_get_subscription_state(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return cpp2c::subscribeState(SubscriberPortUser(self->m_portData).getSubscriptionState()); } iox_ChunkReceiveResult iox_sub_take_chunk(iox_sub_t const self, const void** const userPayload) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); auto result = SubscriberPortUser(self->m_portData).tryGetChunk(); if (result.has_error()) { @@ -166,31 +166,31 @@ iox_ChunkReceiveResult iox_sub_take_chunk(iox_sub_t const self, const void** con void iox_sub_release_chunk(iox_sub_t const self, const void* const userPayload) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userPayload != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'"); SubscriberPortUser(self->m_portData).releaseChunk(ChunkHeader::fromUserPayload(userPayload)); } void iox_sub_release_queued_chunks(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); SubscriberPortUser(self->m_portData).releaseQueuedChunks(); } bool iox_sub_has_chunks(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return SubscriberPortUser(self->m_portData).hasNewChunks(); } bool iox_sub_has_lost_chunks(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return SubscriberPortUser(self->m_portData).hasLostChunksSinceLastCall(); } iox_service_description_t iox_sub_get_service_description(iox_sub_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return TranslateServiceDescription(SubscriberPortUser(self->m_portData).getCaProServiceDescription()); } diff --git a/iceoryx_binding_c/source/c_user_trigger.cpp b/iceoryx_binding_c/source/c_user_trigger.cpp index d9c8753315..81a69ca130 100644 --- a/iceoryx_binding_c/source/c_user_trigger.cpp +++ b/iceoryx_binding_c/source/c_user_trigger.cpp @@ -17,6 +17,7 @@ #include "iceoryx_binding_c/internal/cpp2c_enum_translation.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" using namespace iox; @@ -40,19 +41,19 @@ iox_user_trigger_t iox_user_trigger_init(iox_user_trigger_storage_t* self) void iox_user_trigger_deinit(iox_user_trigger_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); delete self; } void iox_user_trigger_trigger(iox_user_trigger_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->trigger(); } bool iox_user_trigger_has_triggered(iox_user_trigger_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->hasTriggered(); } diff --git a/iceoryx_binding_c/source/c_wait_set.cpp b/iceoryx_binding_c/source/c_wait_set.cpp index 767d2e2986..9a599251cd 100644 --- a/iceoryx_binding_c/source/c_wait_set.cpp +++ b/iceoryx_binding_c/source/c_wait_set.cpp @@ -24,6 +24,7 @@ #include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" #include "iceoryx_posh/popo/wait_set.hpp" +#include "iox/assertions.hpp" #include @@ -63,7 +64,7 @@ static uint64_t notification_info_vector_to_c_array(const WaitSet<>::Notificatio iox_ws_t iox_ws_init(iox_ws_storage_t* self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); auto* me = new cpp2c_WaitSet(); self->do_not_touch_me[0] = reinterpret_cast(me); @@ -72,7 +73,7 @@ iox_ws_t iox_ws_init(iox_ws_storage_t* self) void iox_ws_deinit(iox_ws_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); delete self; } @@ -83,8 +84,8 @@ uint64_t iox_ws_timed_wait(iox_ws_t const self, const uint64_t notificationInfoArrayCapacity, uint64_t* missedElements) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(missedElements != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(missedElements != nullptr, "'missedElements' must not be a 'nullptr'"); return notification_info_vector_to_c_array(self->timedWait(units::Duration(timeout)), notificationInfoArray, @@ -97,8 +98,8 @@ uint64_t iox_ws_wait(iox_ws_t const self, const uint64_t notificationInfoArrayCapacity, uint64_t* missedElements) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(missedElements != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(missedElements != nullptr, "'missedElements' must not be a 'nullptr'"); return notification_info_vector_to_c_array( self->wait(), notificationInfoArray, notificationInfoArrayCapacity, missedElements); @@ -106,19 +107,19 @@ uint64_t iox_ws_wait(iox_ws_t const self, uint64_t iox_ws_size(iox_ws_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->size(); } uint64_t iox_ws_capacity(iox_ws_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); return self->capacity(); } void iox_ws_mark_for_destruction(iox_ws_t const self) { - IOX_EXPECTS(self != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); self->markForDestruction(); } @@ -128,8 +129,8 @@ iox_WaitSetResult iox_ws_attach_subscriber_state(iox_ws_t const self, const uint64_t eventId, void (*callback)(iox_sub_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); auto result = self->attachState(*subscriber, c2cpp::subscriberState(subscriberState), eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -142,8 +143,8 @@ iox_WaitSetResult iox_ws_attach_subscriber_state_with_context_data(iox_ws_t cons void (*callback)(iox_sub_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); NotificationCallback notificationCallback; notificationCallback.m_callback = callback; @@ -160,8 +161,8 @@ iox_WaitSetResult iox_ws_attach_subscriber_event(iox_ws_t const self, const uint64_t eventId, void (*callback)(iox_sub_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); auto result = self->attachEvent(*subscriber, c2cpp::subscriberEvent(subscriberEvent), eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -174,8 +175,8 @@ iox_WaitSetResult iox_ws_attach_subscriber_event_with_context_data(iox_ws_t cons void (*callback)(iox_sub_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); NotificationCallback notificationCallback; notificationCallback.m_callback = callback; @@ -191,8 +192,8 @@ iox_WaitSetResult iox_ws_attach_user_trigger_event(iox_ws_t const self, const uint64_t eventId, void (*callback)(iox_user_trigger_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userTrigger != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userTrigger != nullptr, "'userTrigger' must not be a 'nullptr'"); auto result = self->attachEvent(*userTrigger, eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -204,8 +205,8 @@ iox_WaitSetResult iox_ws_attach_user_trigger_event_with_context_data(iox_ws_t co void (*callback)(iox_user_trigger_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userTrigger != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userTrigger != nullptr, "'userTrigger' must not be a 'nullptr'"); NotificationCallback notificationCallback; notificationCallback.m_callback = callback; @@ -219,8 +220,8 @@ void iox_ws_detach_subscriber_event(iox_ws_t const self, iox_sub_t const subscriber, const iox_SubscriberEvent subscriberEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); self->detachEvent(*subscriber, c2cpp::subscriberEvent(subscriberEvent)); } @@ -229,16 +230,16 @@ void iox_ws_detach_subscriber_state(iox_ws_t const self, iox_sub_t const subscriber, const iox_SubscriberState subscriberState) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(subscriber != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(subscriber != nullptr, "'subscriver' must not be a 'nullptr'"); self->detachState(*subscriber, c2cpp::subscriberState(subscriberState)); } void iox_ws_detach_user_trigger_event(iox_ws_t const self, iox_user_trigger_t const userTrigger) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(userTrigger != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(userTrigger != nullptr, "'userTrigger' must not be a 'nullptr'"); self->detachEvent(*userTrigger); } @@ -249,8 +250,8 @@ iox_WaitSetResult iox_ws_attach_client_event(const iox_ws_t self, const uint64_t eventId, void (*callback)(iox_client_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); auto result = self->attachEvent(*client, c2cpp::clientEvent(clientEvent), eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -263,8 +264,8 @@ iox_WaitSetResult iox_ws_attach_client_event_with_context_data(iox_ws_t const se void (*callback)(iox_client_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); NotificationCallback, void> notificationCallback; notificationCallback.m_callback = callback; @@ -280,8 +281,8 @@ iox_WaitSetResult iox_ws_attach_client_state(const iox_ws_t self, const uint64_t eventId, void (*callback)(iox_client_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); auto result = self->attachState(*client, c2cpp::clientState(clientState), eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -294,8 +295,8 @@ iox_WaitSetResult iox_ws_attach_client_state_with_context_data(iox_ws_t const se void (*callback)(iox_client_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); NotificationCallback, void> notificationCallback; notificationCallback.m_callback = callback; @@ -307,16 +308,16 @@ iox_WaitSetResult iox_ws_attach_client_state_with_context_data(iox_ws_t const se void iox_ws_detach_client_event(iox_ws_t const self, iox_client_t const client, const ENUM iox_ClientEvent clientEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); self->detachEvent(*client, c2cpp::clientEvent(clientEvent)); } void iox_ws_detach_client_state(iox_ws_t const self, iox_client_t const client, const ENUM iox_ClientState clientState) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(client != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(client != nullptr, "'client' must not be a 'nullptr'"); self->detachState(*client, c2cpp::clientState(clientState)); } @@ -327,8 +328,8 @@ iox_WaitSetResult iox_ws_attach_server_event(const iox_ws_t self, const uint64_t eventId, void (*callback)(iox_server_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); auto result = self->attachEvent(*server, c2cpp::serverEvent(serverEvent), eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -341,8 +342,8 @@ iox_WaitSetResult iox_ws_attach_server_event_with_context_data(iox_ws_t const se void (*callback)(iox_server_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); NotificationCallback, void> notificationCallback; notificationCallback.m_callback = callback; @@ -358,8 +359,8 @@ iox_WaitSetResult iox_ws_attach_server_state(const iox_ws_t self, const uint64_t eventId, void (*callback)(iox_server_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); auto result = self->attachState(*server, c2cpp::serverState(serverState), eventId, {callback, nullptr}); return (result.has_error()) ? cpp2c::waitSetResult(result.error()) : iox_WaitSetResult::WaitSetResult_SUCCESS; @@ -372,8 +373,8 @@ iox_WaitSetResult iox_ws_attach_server_state_with_context_data(iox_ws_t const se void (*callback)(iox_server_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); NotificationCallback, void> notificationCallback; notificationCallback.m_callback = callback; @@ -385,16 +386,16 @@ iox_WaitSetResult iox_ws_attach_server_state_with_context_data(iox_ws_t const se void iox_ws_detach_server_event(iox_ws_t const self, iox_server_t const server, const ENUM iox_ServerEvent serverEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); self->detachEvent(*server, c2cpp::serverEvent(serverEvent)); } void iox_ws_detach_server_state(iox_ws_t const self, iox_server_t const server, const ENUM iox_ServerState serverState) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(server != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(server != nullptr, "'server' must not be a 'nullptr'"); self->detachState(*server, c2cpp::serverState(serverState)); } @@ -405,8 +406,8 @@ iox_WaitSetResult iox_ws_attach_service_discovery_event(const iox_ws_t self, const uint64_t eventId, void (*callback)(iox_service_discovery_t)) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); auto result = self->attachEvent( *serviceDiscovery, c2cpp::serviceDiscoveryEvent(serviceDiscoveryEvent), eventId, {callback, nullptr}); @@ -421,8 +422,8 @@ iox_ws_attach_service_discovery_event_with_context_data(iox_ws_t const self, void (*callback)(iox_service_discovery_t, void*), void* const contextData) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); NotificationCallback, void> notificationCallback; notificationCallback.m_callback = callback; @@ -437,8 +438,8 @@ void iox_ws_detach_service_discovery_event(iox_ws_t const self, iox_service_discovery_t const serviceDiscovery, const ENUM iox_ServiceDiscoveryEvent serviceDiscoveryEvent) { - IOX_EXPECTS(self != nullptr); - IOX_EXPECTS(serviceDiscovery != nullptr); + IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'"); + IOX_ENFORCE(serviceDiscovery != nullptr, "'serviceDiscovery' must not be a 'nullptr'"); self->detachEvent(*serviceDiscovery, c2cpp::serviceDiscoveryEvent(serviceDiscoveryEvent)); } diff --git a/iceoryx_binding_c/test/moduletests/test_chunk.cpp b/iceoryx_binding_c/test/moduletests/test_chunk.cpp index 46c7bf55ba..a0e519dee5 100644 --- a/iceoryx_binding_c/test/moduletests/test_chunk.cpp +++ b/iceoryx_binding_c/test/moduletests/test_chunk.cpp @@ -173,43 +173,37 @@ TEST_F(Chunk_test, GettingUserHeaderFromConstChunkHeaderWorks) TEST_F(Chunk_test, GettingChunkHeaderToUserPayloadFromNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "2ebe5462-c8f4-4572-b396-ae66f223de2b"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(Chunk_test, GettingChunkHeaderToUserPayloadConstFromNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "c0b27790-66eb-4f43-8f30-ec242508d7fd"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_payload_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(Chunk_test, GettingChunkHeaderToUserHeaderFromNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "375dae26-76ba-40b2-9c33-768aa33d135f"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_header(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_header(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(Chunk_test, GettingChunkHeaderToUserHeaderConstFromNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "96b7691e-d0bf-4cb4-bf4b-39784dc70e92"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_header_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_to_user_header_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(Chunk_test, GettingChunkHeaderFromUserPayloadFromNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "5ced7508-2ee6-4e2b-bf66-e60d8b4d968c"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(Chunk_test, GettingChunkHeaderFromUserPayloadConstFromNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "8814d1c4-a5a9-4fa7-9520-507ca8745242"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_chunk_header_from_user_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_client.cpp b/iceoryx_binding_c/test/moduletests/test_client.cpp index 1ec34def51..42a578735b 100644 --- a/iceoryx_binding_c/test/moduletests/test_client.cpp +++ b/iceoryx_binding_c/test/moduletests/test_client.cpp @@ -153,8 +153,7 @@ TEST_F(iox_client_test, InitializedOptionsAreInitialized) TEST_F(iox_client_test, InitializedOptionsWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "3ae62644-5fb2-45cf-af99-b4daba43d044"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_options_init(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_options_init(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, CheckInitializedOptionsWithNullptrFails) @@ -162,8 +161,7 @@ TEST_F(iox_client_test, CheckInitializedOptionsWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "9a3b7845-170f-4b7f-a0a4-f5b43d96059f"); iox_client_options_t initializedOptions; iox_client_options_init(&initializedOptions); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_options_is_initialized(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_options_is_initialized(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, InitializingClientWithNullptrFails) @@ -177,27 +175,24 @@ TEST_F(iox_client_test, InitializingClientWithNullptrFails) options.responseQueueFullPolicy = QueueFullPolicy_BLOCK_PRODUCER; options.serverTooSlowPolicy = ConsumerTooSlowPolicy_WAIT_FOR_CONSUMER; - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(nullptr, SERVICE, INSTANCE, EVENT, &options); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, nullptr, INSTANCE, EVENT, &options); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, nullptr, EVENT, &options); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, nullptr, &options); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(nullptr, SERVICE, INSTANCE, EVENT, &options); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, nullptr, INSTANCE, EVENT, &options); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, nullptr, EVENT, &options); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, nullptr, &options); }, + iox::er::ENFORCE_VIOLATION); iox_client_options_t emptyOpts; - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, EVENT, &emptyOpts); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_init(&sutStorage, SERVICE, INSTANCE, EVENT, &emptyOpts); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, DeinitClientWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "2f055b75-3cdd-4a55-b292-86b1ffb7a32d"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_deinit(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, LoanAlignedChunkWithNullptrFails) @@ -207,11 +202,10 @@ TEST_F(iox_client_test, LoanAlignedChunkWithNullptrFails) iox_client_t sut = iox_client_init(&sutStorage, SERVICE, INSTANCE, EVENT, nullptr); constexpr uint64_t ALIGNMENT = 128; void* payload = nullptr; - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_client_loan_aligned_request(nullptr, &payload, 32, ALIGNMENT); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_loan_aligned_request(sut, nullptr, 32, ALIGNMENT); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_loan_aligned_request(nullptr, &payload, 32, ALIGNMENT); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_loan_aligned_request(sut, nullptr, 32, ALIGNMENT); }, + iox::er::ENFORCE_VIOLATION); iox_client_deinit(sut); } @@ -224,11 +218,9 @@ TEST_F(iox_client_test, ReleaseClientWithNullptrFails) void* payload = nullptr; EXPECT_THAT(iox_client_loan_request(sut, &payload, 32), Eq(AllocationResult_SUCCESS)); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_request(nullptr, payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_request(nullptr, payload); }, iox::er::ENFORCE_VIOLATION); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_request(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_request(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_client_deinit(sut); } @@ -243,8 +235,7 @@ TEST_F(iox_client_test, SendWithNullptrFails) EXPECT_THAT(iox_client_loan_request(sut, &payload, sizeof(int64_t)), Eq(AllocationResult_SUCCESS)); *static_cast(payload) = 8912389; - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_send(nullptr, payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_send(nullptr, payload); }, iox::er::ENFORCE_VIOLATION); iox_client_deinit(sut); } @@ -252,24 +243,21 @@ TEST_F(iox_client_test, ClientConnectWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "f778de64-e153-4fb7-9535-9bd288979cc9"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_connect(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_connect(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, ClientDisconnectWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "69e69ebc-f8bd-4d70-9eee-de593acc5019"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_disconnect(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_disconnect(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, ClientGetConnectStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "cdf21827-47c8-49d8-bf07-b375dab74a70"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_get_connection_state(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_get_connection_state(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, ClientTakeResponseWithNullptrFails) @@ -282,10 +270,8 @@ TEST_F(iox_client_test, ClientTakeResponseWithNullptrFails) const void* payload = nullptr; EXPECT_THAT(iox_client_take_response(sut, &payload), Eq(ChunkReceiveResult_SUCCESS)); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_take_response(nullptr, &payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_take_response(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_take_response(nullptr, &payload); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_take_response(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_client_deinit(sut); } @@ -301,10 +287,8 @@ TEST_F(iox_client_test, ClientReleasingResponseWithNullptrFails) iox_client_take_response(sut, &payload); EXPECT_THAT(memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U)); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_response(nullptr, payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_response(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_response(nullptr, payload); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_response(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_client_release_response(sut, payload); iox_client_deinit(sut); @@ -313,22 +297,19 @@ TEST_F(iox_client_test, ClientReleasingResponseWithNullptrFails) TEST_F(iox_client_test, ReleasingQueuedResponsesWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "0d36d962-96af-4b82-a19c-4d4dc34f8c37"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_queued_responses(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_release_queued_responses(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, CheckClientHasResponseWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "e2b81347-ce89-4d24-bd18-1cbdd716940e"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_has_responses(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_has_responses(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, CheckClientHasMissedResponseWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "516b27af-5f78-4988-9886-726c414b6b31"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_client_has_missed_responses(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_client_has_missed_responses(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_client_test, InitializedOptionsAreToCPPDefaults) diff --git a/iceoryx_binding_c/test/moduletests/test_listener.cpp b/iceoryx_binding_c/test/moduletests/test_listener.cpp index 133e887572..4d05eb8cb5 100644 --- a/iceoryx_binding_c/test/moduletests/test_listener.cpp +++ b/iceoryx_binding_c/test/moduletests/test_listener.cpp @@ -225,8 +225,7 @@ constexpr std::chrono::milliseconds iox_listener_test::TIMEOUT; TEST_F(iox_listener_test, InitListenerWithNullptrForStorageReturnsNullptr) { ::testing::Test::RecordProperty("TEST_ID", "ee5f8898-c178-4546-9bb4-6e3329f1b632"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_init(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_init(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, CapacityIsCorrect) @@ -298,75 +297,73 @@ TEST_F(iox_listener_test, AttachingSubscriberEventWorks) TEST_F(iox_listener_test, AttachingSubscriberEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "db39c3ef-1518-4769-942e-642d0f58abdb"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event( &m_sut, &m_subscriber[0U], iox_SubscriberEvent::SubscriberEvent_DATA_RECEIVED, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event( nullptr, &m_subscriber[0U], iox_SubscriberEvent::SubscriberEvent_DATA_RECEIVED, &subscriberCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event( &m_sut, nullptr, iox_SubscriberEvent::SubscriberEvent_DATA_RECEIVED, &subscriberCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, AttachingUserTriggerEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "990e8f3c-36f0-4687-8246-ce8a02f969ae"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_user_trigger_event(nullptr, m_userTrigger[0U], &userTriggerCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_attach_user_trigger_event(&m_sut, nullptr, &userTriggerCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_attach_user_trigger_event(&m_sut, m_userTrigger[0U], nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_attach_user_trigger_event(&m_sut, nullptr, &userTriggerCallback); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_attach_user_trigger_event(&m_sut, m_userTrigger[0U], nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, AttachingUserTriggerEventWithContextDataWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b89957be-19fc-4830-810c-50902061e03d"); int someContextData; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_user_trigger_event_with_context_data( nullptr, m_userTrigger[0U], &userTriggerCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_user_trigger_event_with_context_data( &m_sut, nullptr, &userTriggerCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_user_trigger_event_with_context_data( &m_sut, m_userTrigger[0U], nullptr, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_user_trigger_event_with_context_data( &m_sut, m_userTrigger[0U], &userTriggerCallbackWithContextData, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, AttachingSubscriberEventWithContextDataWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "99885218-09f1-4a30-9fb7-287f4b752dd4"); int someContextData; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event_with_context_data(&m_sut, &m_subscriber[0U], @@ -374,8 +371,8 @@ TEST_F(iox_listener_test, AttachingSubscriberEventWithContextDataWithNullptrFail nullptr, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event_with_context_data(nullptr, &m_subscriber[0U], @@ -383,8 +380,8 @@ TEST_F(iox_listener_test, AttachingSubscriberEventWithContextDataWithNullptrFail &subscriberCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event_with_context_data(&m_sut, nullptr, @@ -392,8 +389,8 @@ TEST_F(iox_listener_test, AttachingSubscriberEventWithContextDataWithNullptrFail &subscriberCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_subscriber_event_with_context_data(&m_sut, &m_subscriber[0U], @@ -401,7 +398,7 @@ TEST_F(iox_listener_test, AttachingSubscriberEventWithContextDataWithNullptrFail &subscriberCallbackWithContextData, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, AttachingSubscriberTillListenerFullWorks) @@ -436,41 +433,38 @@ TEST_F(iox_listener_test, DetachingSubscriberTillListenerEmptyWorks) TEST_F(iox_listener_test, DetachingSubscriberEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b1121040-1d32-4e94-a993-5f6885bd0ed0"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_detach_subscriber_event( nullptr, &m_subscriber[0U], iox_SubscriberEvent::SubscriberEvent_DATA_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_detach_subscriber_event(&m_sut, nullptr, iox_SubscriberEvent::SubscriberEvent_DATA_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, DetachingUserTriggerEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "d8ec0c93-1c4e-4e30-a15a-89eeaeb2edda"); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_detach_user_trigger_event(nullptr, m_userTrigger[0U]); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_user_trigger_event(&m_sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_user_trigger_event(nullptr, m_userTrigger[0U]); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_user_trigger_event(&m_sut, nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, CheckListenerSizeWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "44a7b724-e201-4d4e-ad19-daa5eecc3f2a"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_size(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_size(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, CheckListenerCapacityWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b09e9e38-9b4e-4998-8966-6685e15492f9"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_capacity(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_capacity(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_listener_test, AttachingSubscriberEventTwiceFailsWithEVENT_ALREADY_ATTACHED) @@ -580,15 +574,15 @@ TEST_F(iox_listener_test, AttachingClientWithNullptrFails) iox_client_t client = iox_client_init(&clientStorage, "ServiceA", "InstanceA", "EventA", nullptr); EXPECT_THAT(iox_listener_size(&m_sut), Eq(0U)); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event(nullptr, client, ClientEvent_RESPONSE_RECEIVED, &clientCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event(&m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED, &clientCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event(&m_sut, client, ClientEvent_RESPONSE_RECEIVED, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_client_deinit(client); } @@ -601,30 +595,30 @@ TEST_F(iox_listener_test, AttachingClientWithContextDataWithNullptrFails) iox_client_t client = iox_client_init(&clientStorage, "ServiceA", "InstanceA", "EventA", nullptr); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event_with_context_data( nullptr, client, ClientEvent_RESPONSE_RECEIVED, &clientCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event_with_context_data( &m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED, &clientCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event_with_context_data( &m_sut, client, ClientEvent_RESPONSE_RECEIVED, nullptr, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_client_event_with_context_data( &m_sut, client, ClientEvent_RESPONSE_RECEIVED, &clientCallbackWithContextData, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_client_deinit(client); } @@ -642,12 +636,10 @@ TEST_F(iox_listener_test, DettachingClientWithNullptrFails) iox_listener_detach_client_event(&m_sut, client, ClientEvent_RESPONSE_RECEIVED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_detach_client_event(nullptr, client, ClientEvent_RESPONSE_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_detach_client_event(&m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_client_event(nullptr, client, ClientEvent_RESPONSE_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_client_event(&m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); iox_client_deinit(client); } @@ -758,15 +750,15 @@ TEST_F(iox_listener_test, AttachingServerEventWithNullptrFails) EXPECT_THAT(iox_listener_size(&m_sut), Eq(0U)); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event(nullptr, server, ServerEvent_REQUEST_RECEIVED, &serverCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event(&m_sut, nullptr, ServerEvent_REQUEST_RECEIVED, &serverCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event(&m_sut, server, ServerEvent_REQUEST_RECEIVED, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_server_deinit(server); } @@ -779,30 +771,30 @@ TEST_F(iox_listener_test, AttachingServerWithContextDataWithNullptrFails) iox_server_t server = iox_server_init(&serverStorage, "ServiceA", "InstanceA", "EventA", nullptr); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event_with_context_data( nullptr, server, ServerEvent_REQUEST_RECEIVED, &serverCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event_with_context_data( &m_sut, nullptr, ServerEvent_REQUEST_RECEIVED, &serverCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event_with_context_data( &m_sut, server, ServerEvent_REQUEST_RECEIVED, nullptr, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_server_event_with_context_data( &m_sut, server, ServerEvent_REQUEST_RECEIVED, &serverCallbackWithContextData, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_server_deinit(server); } @@ -818,12 +810,10 @@ TEST_F(iox_listener_test, DettachingListenerServerWithNullptrFails) iox_listener_attach_server_event(&m_sut, server, ServerEvent_REQUEST_RECEIVED, &serverCallback); EXPECT_THAT(iox_listener_size(&m_sut), Eq(1U)); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_detach_server_event(nullptr, server, ServerEvent_REQUEST_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_listener_detach_server_event(&m_sut, nullptr, ServerEvent_REQUEST_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_server_event(nullptr, server, ServerEvent_REQUEST_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_listener_detach_server_event(&m_sut, nullptr, ServerEvent_REQUEST_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); iox_server_deinit(server); } @@ -924,24 +914,24 @@ TEST_F(iox_listener_test, AttachingServiceDiscoveryWithNullptrFails) EXPECT_THAT(iox_listener_size(&m_sut), Eq(0U)); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event( nullptr, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, &serviceDiscoveryCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event( &m_sut, nullptr, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, &serviceDiscoveryCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event( &m_sut, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_service_discovery_deinit(serviceDiscovery); } @@ -960,7 +950,7 @@ TEST_F(iox_listener_test, AttachingServiceDiscoveryWithContextDataWithNullptrFai ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, &serviceDiscoveryCallbackWithContextData, &someContextData); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event_with_context_data( nullptr, @@ -969,8 +959,8 @@ TEST_F(iox_listener_test, AttachingServiceDiscoveryWithContextDataWithNullptrFai &serviceDiscoveryCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event_with_context_data( &m_sut, @@ -979,14 +969,14 @@ TEST_F(iox_listener_test, AttachingServiceDiscoveryWithContextDataWithNullptrFai &serviceDiscoveryCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event_with_context_data( &m_sut, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, nullptr, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_attach_service_discovery_event_with_context_data( &m_sut, @@ -995,7 +985,7 @@ TEST_F(iox_listener_test, AttachingServiceDiscoveryWithContextDataWithNullptrFai &serviceDiscoveryCallbackWithContextData, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_service_discovery_deinit(serviceDiscovery); } @@ -1013,18 +1003,18 @@ TEST_F(iox_listener_test, DettachingListenerServiceDiscoveryWithNullptrFails) &m_sut, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, &serviceDiscoveryCallback); EXPECT_THAT(iox_listener_size(&m_sut), Eq(1U)); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_detach_service_discovery_event( nullptr, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_listener_detach_service_discovery_event( &m_sut, nullptr, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_service_discovery_deinit(serviceDiscovery); } diff --git a/iceoryx_binding_c/test/moduletests/test_node.cpp b/iceoryx_binding_c/test/moduletests/test_node.cpp index 78190ad88f..70a5dcf6ae 100644 --- a/iceoryx_binding_c/test/moduletests/test_node.cpp +++ b/iceoryx_binding_c/test/moduletests/test_node.cpp @@ -130,8 +130,7 @@ TEST_F(iox_node_test, getNodeRuntimeNameBufferIsLessThanNodeProcessNameLength) TEST_F(iox_node_test, destroyNodeWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "c5665aef-0710-4300-a99f-f968739e5222"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_node_destroy(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_node_destroy(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_notification_info.cpp b/iceoryx_binding_c/test/moduletests/test_notification_info.cpp index 5c5e249da6..518df879a7 100644 --- a/iceoryx_binding_c/test/moduletests/test_notification_info.cpp +++ b/iceoryx_binding_c/test/moduletests/test_notification_info.cpp @@ -25,6 +25,7 @@ #include "iceoryx_posh/mepoo/mepoo_config.hpp" #include "iceoryx_posh/popo/notification_info.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" +#include "iox/assertions.hpp" #include "iox/detail/hoofs_error_reporting.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" @@ -87,13 +88,9 @@ class iox_notification_info_test : public Test { constexpr uint64_t USER_PAYLOAD_SIZE{100U}; - auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); - - auto getChunkResult = m_memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + auto chunkSettings = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT) + .expect("Valid 'ChunkSettings'"); + return m_memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } static void triggerCallback(iox_sub_t sub [[maybe_unused]]) @@ -260,8 +257,7 @@ TEST_F(iox_notification_info_test, callbackCanBeCalledMultipleTimes) TEST_F(iox_notification_info_test, getNotificationInfoIdWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "d1c2e777-8166-426e-8a33-2193ca438d5f"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_notification_id(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_notification_id(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, doesInfoOriginateFromSubscriberWithNullptrFails) @@ -274,12 +270,11 @@ TEST_F(iox_notification_info_test, doesInfoOriginateFromSubscriberWithNullptrFai auto notificationInfoVector = m_waitSet.wait(); EXPECT_TRUE(iox_notification_info_does_originate_from_user_trigger(notificationInfoVector[0U], &m_userTrigger)); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_notification_info_does_originate_from_subscriber(nullptr, &m_subscriber); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_subscriber(nullptr, &m_subscriber); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_notification_info_does_originate_from_subscriber(notificationInfoVector[0U], nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, doesInfoOriginateFromUserTriggerWithNullptrFails) @@ -292,12 +287,11 @@ TEST_F(iox_notification_info_test, doesInfoOriginateFromUserTriggerWithNullptrFa auto notificationInfoVector = m_waitSet.wait(); EXPECT_TRUE(iox_notification_info_does_originate_from_user_trigger(notificationInfoVector[0U], &m_userTrigger)); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_notification_info_does_originate_from_user_trigger(nullptr, &m_userTrigger); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_user_trigger(nullptr, &m_userTrigger); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_notification_info_does_originate_from_user_trigger(notificationInfoVector[0U], nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, doesOriginateFromClientWithNullptrFails) @@ -305,11 +299,11 @@ TEST_F(iox_notification_info_test, doesOriginateFromClientWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "953b661d-d1f6-47bf-a113-96559f1492aa"); iox_client_t sut = iox_client_t(); iox_notification_info_t notificationInfoVector[2]{}; - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_client(nullptr, sut); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_client(nullptr, sut); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_notification_info_does_originate_from_client(notificationInfoVector[0U], nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); // iox_client_deinit(sut); } @@ -319,11 +313,11 @@ TEST_F(iox_notification_info_test, doesOriginateFromServertWithNullptrFails) iox_server_t sut = iox_server_t(); iox_notification_info_t notificationInfoVector[2]{}; - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_server(nullptr, sut); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_server(nullptr, sut); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_notification_info_does_originate_from_server(notificationInfoVector[0U], nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, doesOriginateFromServiceDiscoveryWithNullptrFails) @@ -331,54 +325,49 @@ TEST_F(iox_notification_info_test, doesOriginateFromServiceDiscoveryWithNullptrF ::testing::Test::RecordProperty("TEST_ID", "6ac25036-34e7-41e3-bce2-d29736b25800"); iox_service_discovery_t sut = iox_service_discovery_t(); iox_notification_info_t notificationInfoVector[2]{}; - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_notification_info_does_originate_from_service_discovery(nullptr, sut); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_does_originate_from_service_discovery(nullptr, sut); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_notification_info_does_originate_from_service_discovery(notificationInfoVector[0U], nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, getSubscriberOriginWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "8b417bb4-3c3a-4a18-ab35-747e59889554"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_subscriber_origin(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_subscriber_origin(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, getUserTriggerOriginWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "c5daa8c5-5eb9-4fa0-9671-7b12c761ca94"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_user_trigger_origin(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_user_trigger_origin(nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, getClientOriginWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "9283fb37-4188-4943-86b9-57381b05f423"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_client_origin(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_client_origin(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, getServiceOriginWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "9c7108cb-17c6-421a-a8a3-baa9d9a91325"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_server_origin(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_server_origin(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, getServiceDiscoveryOriginWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "15bfd2a4-b01a-4fd6-ba39-aca3f5892f78"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_service_discovery_origin(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_get_service_discovery_origin(nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_notification_info_test, notificationInofCallWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "11eb8c97-7274-4fa4-b1d0-eee97619c54b"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_call(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_notification_info_call(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_publisher.cpp b/iceoryx_binding_c/test/moduletests/test_publisher.cpp index 8f44f8a311..2bc6d1b757 100644 --- a/iceoryx_binding_c/test/moduletests/test_publisher.cpp +++ b/iceoryx_binding_c/test/moduletests/test_publisher.cpp @@ -136,8 +136,8 @@ TEST(iox_pub_test_DeathTest, initPublisherWithNotInitializedPublisherOptionsTerm iox_pub_options_t options; iox_pub_storage_t storage; - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_init(&storage, "a", "b", "c", &options); }, - iox::CBindingError::BINDING_C__PUBLISHER_OPTIONS_NOT_INITIALIZED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_init(&storage, "a", "b", "c", &options); }, + iox::CBindingError::BINDING_C__PUBLISHER_OPTIONS_NOT_INITIALIZED); } TEST_F(iox_pub_test, initPublisherWithDefaultOptionsWorks) @@ -352,11 +352,9 @@ TEST_F(iox_pub_test, pubReleaseChunkWithNullptr) ::testing::Test::RecordProperty("TEST_ID", "002fa1a4-e364-41a5-be59-6dbfa6543b98"); void* chunk = nullptr; iox_pub_loan_chunk(&m_sut, &chunk, 100); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_release_chunk(nullptr, chunk); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_release_chunk(nullptr, chunk); }, iox::er::ENFORCE_VIOLATION); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_release_chunk(&m_sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_release_chunk(&m_sut, nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, pubPublishChunckWithNullptr) @@ -367,24 +365,21 @@ TEST_F(iox_pub_test, pubPublishChunckWithNullptr) this->Subscribe(&m_publisherPortData); iox_pub_loan_chunk(&m_sut, &chunk, 100); static_cast(chunk)->dummy = 4711; - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_publish_chunk(nullptr, chunk); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_publish_chunk(&m_sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_publish_chunk(nullptr, chunk); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_publish_chunk(&m_sut, nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, pubOfferWithNullptr) { ::testing::Test::RecordProperty("TEST_ID", "5588dacf-6e6c-44c6-835d-1dfeb03ff2c1"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_offer(nullptr); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_offer(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, pubStopOfferWithNullptr) { ::testing::Test::RecordProperty("TEST_ID", "db267aa8-071e-402d-887e-1a81fd5b40ca"); iox_pub_offer(&m_sut); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_stop_offer(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_stop_offer(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, isPubOfferedWithNullptr) @@ -392,31 +387,27 @@ TEST_F(iox_pub_test, isPubOfferedWithNullptr) ::testing::Test::RecordProperty("TEST_ID", "9b637e0c-c544-45e8-9723-9c54e78df0b0"); iox_pub_offer(&m_sut); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_is_offered(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_is_offered(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, pubHasSubscribersWithNullptr) { ::testing::Test::RecordProperty("TEST_ID", "5f9c319e-0fa5-454d-b416-62c5f7125562"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_has_subscribers(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_has_subscribers(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, pubGetServiceDescriptionWithNullptr) { ::testing::Test::RecordProperty("TEST_ID", "82113c0b-910b-41c3-b22a-f93e756eecd9"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_get_service_description(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_get_service_description(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_pub_test, pubDeinitWithNullptr) { ::testing::Test::RecordProperty("TEST_ID", "6a2ef759-4b29-40d1-bef1-9e2cd4c8ad75"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_deinit(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_pub_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST(iox_pub_options_test, publisherOptionsAreInitializedCorrectly) diff --git a/iceoryx_binding_c/test/moduletests/test_request_header.cpp b/iceoryx_binding_c/test/moduletests/test_request_header.cpp index 3129282694..c556310695 100644 --- a/iceoryx_binding_c/test/moduletests/test_request_header.cpp +++ b/iceoryx_binding_c/test/moduletests/test_request_header.cpp @@ -106,80 +106,70 @@ TEST_F(iox_request_header_test, getChunkHeaderWorks) TEST_F(iox_request_header_test, requestHeaderFromPayloadWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "edc6ecf7-b530-4b0c-b4b8-67bf001ff433"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_from_payload(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_from_payload(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderFromPayloadConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "5c643aab-53fa-4139-8840-2165b0560df7"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_from_payload_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_from_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderSetSequenceIdWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "1a270e15-8dd5-4ed7-a3dd-eeead6e3dbef"); constexpr int64_t SOME_LUCKY_SEQUENCE_ID = 182673231; - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_request_header_set_sequence_id(nullptr, SOME_LUCKY_SEQUENCE_ID); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_set_sequence_id(nullptr, SOME_LUCKY_SEQUENCE_ID); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetRpcHeaderVersionWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "93362715-2db1-46a6-8ac1-aa109b2c885a"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_rpc_header_version(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_rpc_header_version(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetRpcHeaderVersionConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "1960c937-13bd-43fc-9807-e9afc8f049fe"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_rpc_header_version_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_rpc_header_version_const(nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetSequenceIdWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "0b8ca05a-29be-4a4d-9636-b408829454c2"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_sequence_id(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_sequence_id(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetSequenceIdConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "ffbb763e-2e2e-41e8-8193-96ce8ea2a8a8"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_sequence_id_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_sequence_id_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetUserPayloadWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "4b794a6a-6cfe-491d-86e8-1b0e6859497c"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_user_payload(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_user_payload(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetUserPayloadConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "bb8f3020-b010-467c-91f1-6f684f3b36bb"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_user_payload_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_user_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetChunkHeaderWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "df2a439b-1746-4b95-895a-6c42085906c2"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_chunk_header(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_chunk_header(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_request_header_test, requestHeaderGetChunkHeaderConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "57fbe663-a746-45e8-a18d-4b8aa3bfc344"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_chunk_header_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_request_header_get_chunk_header_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_response_header.cpp b/iceoryx_binding_c/test/moduletests/test_response_header.cpp index 973a51206a..eaf4b5b177 100644 --- a/iceoryx_binding_c/test/moduletests/test_response_header.cpp +++ b/iceoryx_binding_c/test/moduletests/test_response_header.cpp @@ -115,92 +115,80 @@ TEST_F(iox_response_header_test, getChunkHeaderWorks) TEST_F(iox_response_header_test, responseHeaderFromPayloadWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "01f6e7c4-7c96-436c-9f3e-756dd873a880"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_from_payload(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_from_payload(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderFromPayloadConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "31aa2eb6-1629-4017-9c03-1dd21585d232"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_from_payload_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_from_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderHasServerErrorWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "a4bac8f1-7f66-43cc-ab10-39b7ad090582"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_has_server_error(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_has_server_error(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderSetServerErrorWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "dc0168fc-019b-4c78-be8e-a76b020ace3c"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_set_server_error(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_set_server_error(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderHasServerErrorConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "e3acb033-95af-4147-a2b1-ee91fe5702eb"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_has_server_error_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_has_server_error_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetRpcHeaderVersionWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "03213308-c7d5-4d12-bc98-e4db27125aca"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_rpc_header_version(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_rpc_header_version(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetRpcHeaderVersionConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "73cbe3f8-4a65-4900-b6a1-6accd6f46631"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_rpc_header_version_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_rpc_header_version_const(nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetSequenceIdWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "6aef7857-00fe-444d-8c91-78173db08bd7"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_sequence_id(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_sequence_id(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetSequenceIdConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "2acc4ea5-45ed-448a-9ae2-0743b8e973d4"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_sequence_id_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_sequence_id_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetUserPayloadWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b883c99b-cb38-48c2-86d1-7023b7d455bc"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_user_payload(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_user_payload(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetUserPayloadConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "30d061cb-2ed4-40da-a44a-db981b178266"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_user_payload_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_user_payload_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetChunkHeaderWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "089f6fc7-f364-495c-b61f-7218cfc2ea36"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_chunk_header(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_chunk_header(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_response_header_test, responseHeaderGetChunkHeaderConstWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "f21d6d60-1538-4121-a52e-b2940764dffb"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_chunk_header_const(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_response_header_get_chunk_header_const(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_runtime.cpp b/iceoryx_binding_c/test/moduletests/test_runtime.cpp index 42d3fba9f5..08b6162c80 100644 --- a/iceoryx_binding_c/test/moduletests/test_runtime.cpp +++ b/iceoryx_binding_c/test/moduletests/test_runtime.cpp @@ -81,19 +81,18 @@ TEST_F(BindingC_Runtime_test, RuntimeNameLengthIsOutOfLimit) ::testing::Test::RecordProperty("TEST_ID", "8fd6735d-f331-4c9c-9a91-3f06d3856d15"); std::string tooLongName(iox::MAX_RUNTIME_NAME_LENGTH + 1, 's'); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_runtime_init(tooLongName.c_str()); ; }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(BindingC_Runtime_test, RuntimeNameIsNullptr) { ::testing::Test::RecordProperty("TEST_ID", "eb1b76c9-5420-42a9-88b3-db2e36e332de"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_runtime_init(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_runtime_init(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(BindingC_Runtime_test, GetInstanceNameIsNullptr) diff --git a/iceoryx_binding_c/test/moduletests/test_server.cpp b/iceoryx_binding_c/test/moduletests/test_server.cpp index 1e8890c69f..8505a69e01 100644 --- a/iceoryx_binding_c/test/moduletests/test_server.cpp +++ b/iceoryx_binding_c/test/moduletests/test_server.cpp @@ -515,39 +515,35 @@ TEST_F(iox_server_test, SendWorks) TEST_F(iox_server_test, InitServerOptionsWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "eaf125c5-213f-4dd5-9a0b-5e6303e5f1d9"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_options_init(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_options_init(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, IsServerOptionsInitializedWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "f4c1d882-7e67-468b-b284-adf6b470b446"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_options_is_initialized(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_options_is_initialized(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, InitServerWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "fee79cac-1ccc-42d0-8bf8-33aa8a0f104e"); iox_server_options_t options; - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(nullptr, SERVICE, INSTANCE, EVENT, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, nullptr, INSTANCE, EVENT, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, SERVICE, nullptr, EVENT, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_server_init(&sutStorage, SERVICE, INSTANCE, nullptr, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, SERVICE, INSTANCE, EVENT, &options); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(nullptr, SERVICE, INSTANCE, EVENT, nullptr); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, nullptr, INSTANCE, EVENT, nullptr); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, SERVICE, nullptr, EVENT, nullptr); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, SERVICE, INSTANCE, nullptr, nullptr); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_init(&sutStorage, SERVICE, INSTANCE, EVENT, &options); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, DeinitServerWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "e1ea0c1d-729f-467d-943e-b4df61c93b56"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_deinit(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerTakeRequestWithNullptrFails) @@ -561,10 +557,8 @@ TEST_F(iox_server_test, ServerTakeRequestWithNullptrFails) const void* payload; - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_take_request(nullptr, &payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_take_request(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_take_request(nullptr, &payload); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_take_request(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_server_deinit(sut); } @@ -579,10 +573,8 @@ TEST_F(iox_server_test, ServerReleaseRequestWithNullptrFails) const void* payload; - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_request(nullptr, &payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_request(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_request(nullptr, &payload); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_request(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_server_deinit(sut); } @@ -599,15 +591,14 @@ TEST_F(iox_server_test, LoanAlignedResponseWithNullptrFails) void* payload = nullptr; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_server_loan_aligned_response(nullptr, requestPayload, &payload, sizeof(int64_t), 10); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_server_loan_aligned_response(sut, nullptr, &payload, sizeof(int64_t), 10); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_loan_aligned_response(sut, nullptr, &payload, sizeof(int64_t), 10); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_server_loan_aligned_response(sut, requestPayload, nullptr, sizeof(int64_t), 10); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); iox_server_deinit(sut); } @@ -620,10 +611,8 @@ TEST_F(iox_server_test, ServerSendWithNullptrFails) receiveRequest(); void* payload = nullptr; - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_send(nullptr, payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_send(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_send(nullptr, payload); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_send(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_server_deinit(sut); } @@ -637,67 +626,57 @@ TEST_F(iox_server_test, ServerReleaseResponseWithNullptrFails) void* payload = nullptr; - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_response(nullptr, payload); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_response(sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_response(nullptr, payload); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_response(sut, nullptr); }, iox::er::ENFORCE_VIOLATION); iox_server_deinit(sut); } TEST_F(iox_server_test, ServerGetServiceDescriptionWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "a01b7aaa-79b8-49bb-b440-bca9bb2f15e3"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_get_service_description(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_get_service_description(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerOfferWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b95f2ebc-fe87-4ade-83b2-51d9faf6e8d7"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_offer(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_offer(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerStopOfferWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "e9ca8373-ce2a-4429-8cea-1cfd58bc9c00"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_stop_offer(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_stop_offer(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, IsServerOfferedWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "34430915-fa84-4824-893b-efbc7b2642e7"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_is_offered(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_is_offered(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerHasClientsWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "72d48f68-392c-405e-8561-1ab44489387b"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_has_clients(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_has_clients(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerHasRequestsWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "919b78a5-5eb7-4d70-99e5-1756ec48fa50"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_has_requests(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_has_requests(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerHasMissedRequestsWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "7b98029b-edfd-4d88-b3f8-66cc9d5dd1c4"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_has_missed_requests(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_has_missed_requests(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_server_test, ServerReleaseQueuedRequestsWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "bc61edf0-0eea-4ba2-aaa3-eccb6a5ace27"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_queued_requests(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_server_release_queued_requests(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp b/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp index 037aeb1d32..5249575109 100644 --- a/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp +++ b/iceoryx_binding_c/test/moduletests/test_service_discovery.cpp @@ -73,8 +73,7 @@ description_vector iox_service_discovery_test::searchResult; TEST(iox_service_discovery_DeathTest, InitServiceDiscoveryWithNullptrForStorageTerminates) { ::testing::Test::RecordProperty("TEST_ID", "be551a9e-7dcf-406a-a74c-7dcb1ee16c30"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_service_discovery_init(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_service_discovery_init(nullptr); }, iox::er::ENFORCE_VIOLATION); } /// @note We test only if the arguments of iox_service_discovery_find_service are correctly passed to @@ -239,8 +238,7 @@ TEST_F(iox_service_discovery_test, FindServiceReturnsCorrectNumberOfServicesWhen TEST_F(iox_service_discovery_test, DeinitServiceDiscoveryWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "cf09c7b3-fb20-44e3-8552-9877d0facacd"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_service_discovery_deinit(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_service_discovery_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_service_discovery_test, FindServiceServiceDiscoveryWithNullptrFails) @@ -249,7 +247,7 @@ TEST_F(iox_service_discovery_test, FindServiceServiceDiscoveryWithNullptrFails) const uint64_t SERVICE_CONTAINER_CAPACITY = 10U; iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY]; uint64_t missedServices = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service(nullptr, nullptr, @@ -260,8 +258,8 @@ TEST_F(iox_service_discovery_test, FindServiceServiceDiscoveryWithNullptrFails) &missedServices, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service(sut, nullptr, @@ -272,8 +270,8 @@ TEST_F(iox_service_discovery_test, FindServiceServiceDiscoveryWithNullptrFails) &missedServices, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service(sut, nullptr, @@ -284,25 +282,25 @@ TEST_F(iox_service_discovery_test, FindServiceServiceDiscoveryWithNullptrFails) nullptr, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_service_discovery_test, FindServiceApplyCallablekServiceDiscoveryWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b44b1ffc-f466-49f7-a7d5-2bf25bfb22a5"); auto findHandler = [](const iox_service_description_t s) { EXPECT_THAT(s.instanceString, StrEq("RouDi_ID")); }; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service_apply_callable( nullptr, nullptr, nullptr, nullptr, findHandler, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service_apply_callable( sut, nullptr, nullptr, nullptr, nullptr, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_service_discovery_test, FindServiceApplyCallableWithContextDataServiceDiscoveryWithNullptrFails) @@ -311,18 +309,18 @@ TEST_F(iox_service_discovery_test, FindServiceApplyCallableWithContextDataServic auto findHandler = [](const iox_service_description_t s, void*) { EXPECT_THAT(s.instanceString, StrEq("RouDi_ID")); }; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service_apply_callable_with_context_data( nullptr, nullptr, nullptr, nullptr, findHandler, &searchResult, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_service_discovery_find_service_apply_callable_with_context_data( sut, nullptr, nullptr, nullptr, nullptr, &searchResult, MessagingPattern_PUB_SUB); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp index 3f8a5dad1f..88d76e6279 100644 --- a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp +++ b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp @@ -92,13 +92,9 @@ class iox_sub_test : public Test { constexpr uint64_t USER_PAYLOAD_SIZE{100U}; - auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); - - auto getChunkResult = m_memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + auto chunkSettings = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT) + .expect("Valid 'ChunkSettings'"); + return m_memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } static iox_sub_t m_triggerCallbackLatestArgument; @@ -141,8 +137,8 @@ TEST_F(iox_sub_test, initSubscriberWithNotInitializedSubscriberOptionsTerminates iox_sub_options_t options; iox_sub_storage_t storage; - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_init(&storage, "a", "b", "c", &options); }, - iox::CBindingError::BINDING_C__SUBSCRIBER_OPTIONS_NOT_INITIALIZED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_init(&storage, "a", "b", "c", &options); }, + iox::CBindingError::BINDING_C__SUBSCRIBER_OPTIONS_NOT_INITIALIZED); } TEST_F(iox_sub_test, initSubscriberWithDefaultOptionsWorks) @@ -433,37 +429,32 @@ TEST_F(iox_sub_test, correctServiceDescriptionReturned) TEST_F(iox_sub_test, deinitSubscriberWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "692761e8-9583-40bb-8d81-0c6604a44465"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_deinit(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subSubscriberWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "de2ed2ad-9b1b-4057-9c2e-29339b706cce"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_subscribe(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_subscribe(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, unsubSubscriberWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "c329d23d-1f06-475e-8075-5542dc0db835"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_unsubscribe(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_unsubscribe(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, getSubscriptionStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "e355b119-659f-4071-8da5-1837f7d25ab2"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_get_subscription_state(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_get_subscription_state(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subscriberTakeChunkWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "10a944a8-e820-4c0e-ade4-e5b0b74d3ff6"); const void* chunk = nullptr; - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_take_chunk(nullptr, &chunk); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_take_chunk(nullptr, &chunk); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subReleaseChunkWithNullptrFails) @@ -476,38 +467,32 @@ TEST_F(iox_sub_test, subReleaseChunkWithNullptrFails) iox_sub_take_chunk(m_sut, &chunk); EXPECT_THAT(m_memoryManager.getMemPoolInfo(0).m_usedChunks, Eq(1U)); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_release_chunk(nullptr, &chunk); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_release_chunk(m_sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_release_chunk(nullptr, &chunk); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_release_chunk(m_sut, nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subReleaseQueuedChunksWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "1652b7cf-f42e-4ff7-b645-299c294c47ff"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_release_queued_chunks(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_release_queued_chunks(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subHasChunksWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "c7180333-78fb-480a-8912-0ac091e38e64"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_has_chunks(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_has_chunks(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subHasLostChunksWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "f2dffab8-82d9-4f81-bd16-89b048dc5a2b"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_has_lost_chunks(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_has_lost_chunks(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_sub_test, subgetServiceDescriptionWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "a8be6396-77c0-412b-8ff5-28b1d8bc0d18"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_get_service_description(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_sub_get_service_description(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST(iox_sub_options_test, subscriberOptionsAreInitializedCorrectly) diff --git a/iceoryx_binding_c/test/moduletests/test_user_trigger.cpp b/iceoryx_binding_c/test/moduletests/test_user_trigger.cpp index a9e510adfa..61d1eb1f48 100644 --- a/iceoryx_binding_c/test/moduletests/test_user_trigger.cpp +++ b/iceoryx_binding_c/test/moduletests/test_user_trigger.cpp @@ -144,22 +144,19 @@ TEST_F(iox_user_trigger_test, disable_trigger_eventingItFromWaitsetCleansup) TEST_F(iox_user_trigger_test, userTriggerDeinitWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "0f418a98-c3d5-4dc7-a550-21e0d2f6adee"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_user_trigger_deinit(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_user_trigger_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_user_trigger_test, userTriggerTriggerWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "da67d02e-b801-40be-b640-c3aaabc4b3a5"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_user_trigger_trigger(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_user_trigger_trigger(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_user_trigger_test, userTriggerHasTriggeredWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "7b79eb0f-6102-402e-b55c-f339e2eb9b77"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_user_trigger_has_triggered(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_user_trigger_has_triggered(nullptr); }, iox::er::ENFORCE_VIOLATION); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_wait_set.cpp b/iceoryx_binding_c/test/moduletests/test_wait_set.cpp index d9a9b12b1f..6f21563ad5 100644 --- a/iceoryx_binding_c/test/moduletests/test_wait_set.cpp +++ b/iceoryx_binding_c/test/moduletests/test_wait_set.cpp @@ -548,82 +548,78 @@ TEST_F(iox_ws_test, MissedElementsIsCorrectWhenAllWereMissed) TEST_F(iox_ws_test, WaitSetInitWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "46fcbcfe-8f54-4154-8d89-f17811ddce44"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_init(nullptr); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_init(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDeinitWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "981c8d9f-7db1-484f-8301-d39ccc7b2301"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_deinit(nullptr); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_deinit(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetTimedWaitWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "2ea969a6-4a0f-41e6-b2d3-532db22bf104"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_timed_wait(m_sut, m_timeout, m_eventInfoStorage, MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_timed_wait( nullptr, m_timeout, m_eventInfoStorage, MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET, &m_missedElements); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetWaitWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "80fda0a6-4a14-466b-a928-752898dee48d"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_wait(m_sut, NULL, 0U, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_wait(nullptr, NULL, 0U, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_wait(m_sut, NULL, 0U, nullptr); }, iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_wait(nullptr, NULL, 0U, nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetSizeWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "1f4da6e0-4912-4863-af2f-4c46d9d843fa"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_size(nullptr); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_size(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetCapacityWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "1ea6d251-02a4-4a5c-beeb-74a8b70bb7cc"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_capacity(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_capacity(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetMarkForDestructionWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "1ca1ea2b-d0e8-4935-ae5c-f47e5f8dc859"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_mark_for_destruction(nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_mark_for_destruction(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachSubscriberStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "6a14d1a2-ac10-4c3c-b7c0-2d1b38e802b2"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_state( nullptr, &m_subscriberVector[0], iox_SubscriberState::SubscriberState_HAS_DATA, 0, &subscriberCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_state( m_sut, nullptr, iox_SubscriberState::SubscriberState_HAS_DATA, 0, &subscriberCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachSubscriberStateWithContextDataWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "367e99e5-0288-4f1f-b49f-655980a9a2c4"); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_state_with_context_data(nullptr, &m_subscriberVector[0], @@ -632,8 +628,8 @@ TEST_F(iox_ws_test, WaitSetAttachSubscriberStateWithContextDataWithNullptrFails) &subscriberCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_state_with_context_data(m_sut, nullptr, @@ -642,13 +638,13 @@ TEST_F(iox_ws_test, WaitSetAttachSubscriberStateWithContextDataWithNullptrFails) &subscriberCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachSubscriberEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "23001644-088f-413b-8f0e-20151638d064"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_event(nullptr, &m_subscriberVector[0], @@ -656,20 +652,20 @@ TEST_F(iox_ws_test, WaitSetAttachSubscriberEventWithNullptrFails) 0, &subscriberCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_event( m_sut, nullptr, iox_SubscriberEvent::SubscriberEvent_DATA_RECEIVED, 0, &subscriberCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachSubscriberEventWithContextDataWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "0c3f2ce8-9b18-409b-913f-41f7e840df66"); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_event_with_context_data(nullptr, &m_subscriberVector[0], @@ -678,8 +674,8 @@ TEST_F(iox_ws_test, WaitSetAttachSubscriberEventWithContextDataWithNullptrFails) &subscriberCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_subscriber_event_with_context_data(m_sut, nullptr, @@ -688,67 +684,63 @@ TEST_F(iox_ws_test, WaitSetAttachSubscriberEventWithContextDataWithNullptrFails) &subscriberCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachUserTriggerEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "6797e1c6-d187-4e42-a2bb-c46efe1536e5"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_user_trigger_event(nullptr, m_userTrigger[0U], 0U, userTriggerCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_attach_user_trigger_event(m_sut, nullptr, 0U, userTriggerCallback); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_attach_user_trigger_event(m_sut, nullptr, 0U, userTriggerCallback); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachUserTriggerEventWithContextDataWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "ef97af83-24ea-4734-967a-5dc6ea056b90"); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_user_trigger_event_with_context_data( nullptr, m_userTrigger[0], 0, &userTriggerCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_user_trigger_event_with_context_data( m_sut, nullptr, 0, &userTriggerCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachSubscriberEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "6a22da45-f7e6-4873-ae5d-31ea8548db93"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_detach_subscriber_event(nullptr, &m_subscriberVector[0U], SubscriberEvent_DATA_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_subscriber_event(m_sut, nullptr, SubscriberEvent_DATA_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_subscriber_event(m_sut, nullptr, SubscriberEvent_DATA_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachSubscriberStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "eb37cf0f-53df-441c-8a3c-42dc5f2b3182"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_detach_subscriber_state(nullptr, &m_subscriberVector[0U], SubscriberState_HAS_DATA); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_subscriber_state(m_sut, nullptr, SubscriberState_HAS_DATA); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_subscriber_state(m_sut, nullptr, SubscriberState_HAS_DATA); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachUserTriggerEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "b34d03e8-4ead-4b84-b4d1-2a7a1a2b2df7"); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_user_trigger_event(nullptr, m_userTrigger[0U]); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_user_trigger_event(m_sut, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_user_trigger_event(nullptr, m_userTrigger[0U]); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_user_trigger_event(m_sut, nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachClientEventWithNullptrFails) @@ -756,12 +748,12 @@ TEST_F(iox_ws_test, WaitSetAttachClientEventWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "7564a392-8720-42b6-a850-b85b363524fd"); iox_client_t client = iox_client_t(); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_client_event(nullptr, client, ClientEvent_RESPONSE_RECEIVED, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_client_event(m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachClientEventWithContextDataWithNullptrFails) @@ -769,7 +761,7 @@ TEST_F(iox_ws_test, WaitSetAttachClientEventWithContextDataWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "0e01b407-379e-462d-bdaf-d30894ee4971"); iox_client_t client = iox_client_t(); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_client_event_with_context_data(nullptr, client, @@ -778,25 +770,23 @@ TEST_F(iox_ws_test, WaitSetAttachClientEventWithContextDataWithNullptrFails) &clientCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_client_event_with_context_data( m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED, 89123, &clientCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachClientStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "255590fc-565e-4cf7-890d-889ea8790439"); iox_client_t client = iox_client_t(); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_attach_client_state(m_sut, nullptr, ClientState_HAS_RESPONSE, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_attach_client_state(nullptr, client, ClientState_HAS_RESPONSE, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_attach_client_state(m_sut, nullptr, ClientState_HAS_RESPONSE, 0, nullptr); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_attach_client_state(nullptr, client, ClientState_HAS_RESPONSE, 0, nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachClientStateWithContextDataWithNullptrFails) @@ -804,42 +794,38 @@ TEST_F(iox_ws_test, WaitSetAttachClientStateWithContextDataWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "a0e41734-9f56-4c1c-bf9f-82c50e19a758"); iox_client_t client = iox_client_t(); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_client_state_with_context_data( m_sut, nullptr, ClientState_HAS_RESPONSE, 0, &clientCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_client_state_with_context_data( nullptr, client, ClientState_HAS_RESPONSE, 0, &clientCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachClientEventWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "d7e243b8-34c4-48e0-8b0a-f988c35835be"); iox_client_t client = iox_client_t(); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_client_event(nullptr, client, ClientEvent_RESPONSE_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_client_event(m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_client_event(nullptr, client, ClientEvent_RESPONSE_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_client_event(m_sut, nullptr, ClientEvent_RESPONSE_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachClientStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "cfc25db4-1675-4968-a6fd-eda0a8a9d54a"); iox_client_t client = iox_client_t(); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_client_state(nullptr, client, ClientState_HAS_RESPONSE); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_client_state(m_sut, nullptr, ClientState_HAS_RESPONSE); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_client_state(nullptr, client, ClientState_HAS_RESPONSE); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_client_state(m_sut, nullptr, ClientState_HAS_RESPONSE); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachServerEventWithNullptrFails) @@ -847,12 +833,12 @@ TEST_F(iox_ws_test, WaitSetAttachServerEventWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "dda23967-4dec-4905-8581-7c126b902b18"); iox_server_t server = iox_server_t(); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_server_event(nullptr, server, ServerEvent_REQUEST_RECEIVED, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_server_event(m_sut, nullptr, ServerEvent_REQUEST_RECEIVED, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachServerEventWithContextDataWithNullptrFails) @@ -860,30 +846,28 @@ TEST_F(iox_ws_test, WaitSetAttachServerEventWithContextDataWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "91a84993-7a86-4f4f-9f36-8795d100080c"); iox_server_t server = iox_server_t(); uint64_t someContextData = 0U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_server_event_with_context_data( nullptr, server, ServerEvent_REQUEST_RECEIVED, 0, serverCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_server_event_with_context_data( m_sut, nullptr, ServerEvent_REQUEST_RECEIVED, 0, serverCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachServerStateWithNullptrFails) { ::testing::Test::RecordProperty("TEST_ID", "fdbe65c0-55a1-44ab-9b5c-e60b31078f5d"); iox_server_t server = iox_server_t(); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_attach_server_state(nullptr, server, ServerState_HAS_REQUEST, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_attach_server_state(m_sut, nullptr, ServerState_HAS_REQUEST, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_attach_server_state(nullptr, server, ServerState_HAS_REQUEST, 0, nullptr); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_attach_server_state(m_sut, nullptr, ServerState_HAS_REQUEST, 0, nullptr); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachServerStateWithContextDataWithNullptrFails) @@ -892,7 +876,7 @@ TEST_F(iox_ws_test, WaitSetAttachServerStateWithContextDataWithNullptrFails) iox_server_t server = iox_server_t(); uint64_t someContextData = 0U; constexpr uint64_t SOME_EVENT_ID = 912371012314; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_server_state_with_context_data(m_sut, server, @@ -901,8 +885,8 @@ TEST_F(iox_ws_test, WaitSetAttachServerStateWithContextDataWithNullptrFails) &serverCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_server_state_with_context_data(m_sut, server, @@ -911,7 +895,7 @@ TEST_F(iox_ws_test, WaitSetAttachServerStateWithContextDataWithNullptrFails) &serverCallbackWithContextData, &someContextData); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachServerEventWithNullptrFails) @@ -919,12 +903,10 @@ TEST_F(iox_ws_test, WaitSetDetachServerEventWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "1310f324-abb9-45ce-8ec7-c23fd20a9c20"); iox_server_t server = iox_server_t(); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_server_event(nullptr, server, ServerEvent_REQUEST_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_server_event(m_sut, nullptr, ServerEvent_REQUEST_RECEIVED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_server_event(nullptr, server, ServerEvent_REQUEST_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_server_event(m_sut, nullptr, ServerEvent_REQUEST_RECEIVED); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachServerStateWithNullptrFails) @@ -932,12 +914,10 @@ TEST_F(iox_ws_test, WaitSetDetachServerStateWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "7247d49a-fb2c-4aaa-acf9-ed077a62e7c0"); iox_server_t server = iox_server_t(); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_server_state(nullptr, server, ServerState_HAS_REQUEST); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( - [&] { iox_ws_detach_server_state(m_sut, nullptr, ServerState_HAS_REQUEST); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_server_state(nullptr, server, ServerState_HAS_REQUEST); }, + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE([&] { iox_ws_detach_server_state(m_sut, nullptr, ServerState_HAS_REQUEST); }, + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachServiceDiscoveryEventWithNullptrFails) @@ -945,18 +925,18 @@ TEST_F(iox_ws_test, WaitSetAttachServiceDiscoveryEventWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "117a9521-62e8-4c9c-b797-a015d97f4eef"); iox_service_discovery_t serviceDiscovery = iox_service_discovery_t(); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_service_discovery_event( m_sut, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_service_discovery_event( m_sut, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, 0, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetAttachServiceDiscoveryEventWithConextDataWithNullptrFails) @@ -964,18 +944,18 @@ TEST_F(iox_ws_test, WaitSetAttachServiceDiscoveryEventWithConextDataWithNullptrF ::testing::Test::RecordProperty("TEST_ID", "1e19d3a7-6231-408d-a3c0-e378dd754c7d"); iox_service_discovery_t serviceDiscovery = iox_service_discovery_t(); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_service_discovery_event_with_context_data( m_sut, nullptr, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, 0, nullptr, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_attach_service_discovery_event_with_context_data( nullptr, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED, 0, nullptr, nullptr); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(iox_ws_test, WaitSetDetachServiceDiscoveryEventWithNullptrFails) @@ -983,15 +963,15 @@ TEST_F(iox_ws_test, WaitSetDetachServiceDiscoveryEventWithNullptrFails) ::testing::Test::RecordProperty("TEST_ID", "c489ea47-6239-4dc7-ba86-c181f034132f"); iox_service_discovery_t serviceDiscovery = iox_service_discovery_t(); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_detach_service_discovery_event( nullptr, serviceDiscovery, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); - IOX_EXPECT_FATAL_FAILURE( + iox::er::ENFORCE_VIOLATION); + IOX_EXPECT_FATAL_FAILURE( [&] { iox_ws_detach_service_discovery_event(m_sut, nullptr, ServiceDiscoveryEvent_SERVICE_REGISTRY_CHANGED); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TIMING_TEST_F(iox_ws_test, WaitIsBlockingTillTriggered, Repeat(5), [&] { diff --git a/iceoryx_examples/iceperf/uds.cpp b/iceoryx_examples/iceperf/uds.cpp index c761848c0f..cb91ce36c2 100644 --- a/iceoryx_examples/iceperf/uds.cpp +++ b/iceoryx_examples/iceperf/uds.cpp @@ -38,7 +38,7 @@ void UDS::initSocketAddress(sockaddr_un& socketAddr, const std::string& socketNa socketAddr.sun_family = AF_LOCAL; constexpr uint64_t NULL_TERMINATION_SIZE{1}; const uint64_t maxDestinationLength = iox::size(socketAddr.sun_path) - NULL_TERMINATION_SIZE; - IOX_ENSURES(maxDestinationLength >= socketName.size() && "Socketname too large!"); + IOX_ENFORCE(maxDestinationLength >= socketName.size(), "Socketname too large!"); strncpy(socketAddr.sun_path, socketName.c_str(), socketName.size()); } diff --git a/iceoryx_hoofs/concurrent/buffer/source/mpmc_loffli.cpp b/iceoryx_hoofs/concurrent/buffer/source/mpmc_loffli.cpp index 345f41f718..127c27d478 100644 --- a/iceoryx_hoofs/concurrent/buffer/source/mpmc_loffli.cpp +++ b/iceoryx_hoofs/concurrent/buffer/source/mpmc_loffli.cpp @@ -25,11 +25,11 @@ namespace concurrent { void MpmcLoFFLi::init(not_null freeIndicesMemory, const uint32_t capacity) noexcept { - IOX_EXPECTS_WITH_MSG(capacity > 0, "A capacity of 0 is not supported!"); + IOX_ENFORCE(capacity > 0, "A capacity of 0 is not supported!"); constexpr uint32_t INTERNALLY_RESERVED_INDICES{1U}; - IOX_EXPECTS_WITH_MSG(capacity < (std::numeric_limits::max() - INTERNALLY_RESERVED_INDICES), - "Requested capacity exceeds limits!"); - IOX_EXPECTS_WITH_MSG(m_head.is_lock_free(), "std::atomic must be lock-free!"); + IOX_ENFORCE(capacity < (std::numeric_limits::max() - INTERNALLY_RESERVED_INDICES), + "Requested capacity exceeds limits!"); + IOX_ENFORCE(m_head.is_lock_free(), "std::atomic must be lock-free!"); m_nextFreeIndex = freeIndicesMemory; m_size = capacity; diff --git a/iceoryx_hoofs/concurrent/sync/include/iox/detail/periodic_task.inl b/iceoryx_hoofs/concurrent/sync/include/iox/detail/periodic_task.inl index b83898e1b6..3ecc9bad22 100644 --- a/iceoryx_hoofs/concurrent/sync/include/iox/detail/periodic_task.inl +++ b/iceoryx_hoofs/concurrent/sync/include/iox/detail/periodic_task.inl @@ -69,7 +69,7 @@ inline void PeriodicTask::stop() noexcept { if (m_taskExecutor.joinable()) { - IOX_EXPECTS(!m_stop->post().has_error()); + m_stop->post().expect("'post' on a semaphore should always be successful"); m_taskExecutor.join(); } } @@ -98,10 +98,7 @@ inline void PeriodicTask::run() noexcept /// @todo iox-#337 use a refactored posix::Timer::wait method returning TIMER_TICK and TIMER_STOPPED once /// available - auto waitResult = m_stop->timedWait(m_interval); - IOX_EXPECTS(!waitResult.has_error()); - - waitState = waitResult.value(); + waitState = m_stop->timedWait(m_interval).expect("'timedWait' on a semaphore should always be successful"); } while (waitState == SemaphoreWaitState::TIMEOUT); } diff --git a/iceoryx_hoofs/container/include/iox/detail/fixed_position_container.inl b/iceoryx_hoofs/container/include/iox/detail/fixed_position_container.inl index d5da965597..72241f8c56 100644 --- a/iceoryx_hoofs/container/include/iox/detail/fixed_position_container.inl +++ b/iceoryx_hoofs/container/include/iox/detail/fixed_position_container.inl @@ -286,7 +286,7 @@ FixedPositionContainer::emplace(Targs&&... args) noexcept } else { - IOX_ENSURES_WITH_MSG(index != 0, "Corruption detected!"); + IOX_ENFORCE(index != 0, "Corruption detected!"); for (auto i = static_cast(index - 1U);; --i) { if (m_status[i] == SlotStatus::USED) @@ -295,7 +295,7 @@ FixedPositionContainer::emplace(Targs&&... args) noexcept m_next[i] = index; break; } - IOX_ENSURES_WITH_MSG(i != 0, "Corruption detected!"); + IOX_ENFORCE(i != 0, "Corruption detected!"); } } @@ -307,9 +307,9 @@ inline typename FixedPositionContainer::Iterator // NOLINTNEXTLINE(readability-function-size) The branch-threshold is only violated due to hidden branches in the error handler macros which do not decrease readability FixedPositionContainer::erase(const IndexType index) noexcept { - IOX_EXPECTS_WITH_MSG(index <= Index::LAST, "Index out of range"); + IOX_ENFORCE(index <= Index::LAST, "Index out of range"); - IOX_ENSURES_WITH_MSG(m_status[index] == SlotStatus::USED, "Trying to erase from index pointing to an empty slot!"); + IOX_ENFORCE(m_status[index] == SlotStatus::USED, "Trying to erase from index pointing to an empty slot!"); const auto it = Iterator{m_next[index], *this}; @@ -442,7 +442,7 @@ FixedPositionContainer::erase(const IndexType index) noexcept return it; } - IOX_ENSURES_WITH_MSG(index != 0, "Corruption detected! Index cannot be 0 at this location!"); + IOX_ENFORCE(index != 0, "Corruption detected! Index cannot be 0 at this location!"); for (auto i = static_cast(index - 1U); !is_removed_from_used_list || !is_added_to_free_list; --i) { if (!is_removed_from_used_list && m_status[i] == SlotStatus::USED) @@ -463,8 +463,8 @@ FixedPositionContainer::erase(const IndexType index) noexcept break; } } - IOX_ENSURES_WITH_MSG(is_removed_from_used_list && is_added_to_free_list, - "Corruption detected! The container is in a corrupt state!"); + IOX_ENFORCE(is_removed_from_used_list && is_added_to_free_list, + "Corruption detected! The container is in a corrupt state!"); return it; } @@ -473,15 +473,15 @@ template inline typename FixedPositionContainer::Iterator FixedPositionContainer::erase(const T* ptr) noexcept { - IOX_EXPECTS_WITH_MSG(ptr != nullptr, "Pointer is a nullptr!"); + IOX_ENFORCE(ptr != nullptr, "Pointer is a nullptr!"); const T* const firstElement = &m_data[0]; - IOX_EXPECTS_WITH_MSG(ptr >= firstElement, "Pointer pointing out of the container!"); + IOX_ENFORCE(ptr >= firstElement, "Pointer pointing out of the container!"); const auto index = static_cast(ptr - firstElement); - IOX_EXPECTS_WITH_MSG(index <= Index::LAST, "Pointer pointing out of the container!"); + IOX_ENFORCE(index <= Index::LAST, "Pointer pointing out of the container!"); - IOX_EXPECTS_WITH_MSG(ptr == &m_data[index], "Pointer is not aligned to an element in the container!"); + IOX_ENFORCE(ptr == &m_data[index], "Pointer is not aligned to an element in the container!"); // NOTE: if the implementation changes from simply forwarding to 'erase(IndexType)' tests need to be written return erase(index); @@ -491,7 +491,7 @@ template inline typename FixedPositionContainer::Iterator FixedPositionContainer::erase(Iterator it) noexcept { - IOX_EXPECTS_WITH_MSG(it.origins_from(*this), "Iterator belongs to a different container!"); + IOX_ENFORCE(it.origins_from(*this), "Iterator belongs to a different container!"); // NOTE: if the implementation changes from simply forwarding to 'erase(IndexType)' tests need to be written return erase(it.to_index()); @@ -501,7 +501,7 @@ template inline typename FixedPositionContainer::ConstIterator FixedPositionContainer::erase(ConstIterator it) noexcept { - IOX_EXPECTS_WITH_MSG(it.origins_from(*this), "Iterator belongs to a different container!"); + IOX_ENFORCE(it.origins_from(*this), "Iterator belongs to a different container!"); // NOTE: if the implementation changes from simply forwarding to 'erase(IndexType)' tests need to be written return erase(it.to_index()); diff --git a/iceoryx_hoofs/container/include/iox/detail/forward_list.inl b/iceoryx_hoofs/container/include/iox/detail/forward_list.inl index 3a8bf26655..f0b56ba4b0 100644 --- a/iceoryx_hoofs/container/include/iox/detail/forward_list.inl +++ b/iceoryx_hoofs/container/include/iox/detail/forward_list.inl @@ -19,6 +19,7 @@ #define IOX_HOOFS_CONTAINER_FORWARD_LIST_INL +#include "iox/assertions.hpp" #include "iox/forward_list.hpp" #include "iox/logging.hpp" @@ -329,7 +330,7 @@ template inline T& forward_list::front() noexcept { auto iter = begin(); - IOX_EXPECTS_WITH_MSG(isValidElementIdx(iter.m_iterListNodeIdx), "Invalid list element"); + IOX_ENFORCE(isValidElementIdx(iter.m_iterListNodeIdx), "Invalid list element"); return *iter; } @@ -337,7 +338,7 @@ template inline const T& forward_list::front() const noexcept { auto citer = cbegin(); - IOX_EXPECTS_WITH_MSG(isValidElementIdx(citer.m_iterListNodeIdx), "Invalid list element"); + IOX_ENFORCE(isValidElementIdx(citer.m_iterListNodeIdx), "Invalid list element"); return *citer; } @@ -556,7 +557,7 @@ inline void forward_list::setNextIdx(const size_type idx, const siz template inline const T* forward_list::getDataPtrFromIdx(const size_type idx) const noexcept { - IOX_EXPECTS_WITH_MSG(isValidElementIdx(idx), "Invalid list element"); + IOX_ENFORCE(isValidElementIdx(idx), "Invalid list element"); // safe since m_data entries are aligned to T // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) @@ -597,14 +598,14 @@ inline bool forward_list::isInvalidIterator(const const_iterator& i { // iterator's member m_iterListNodeIdx and nextIndex are not checked here to be <= END_INDEX as this // should (can) never happen though normal list operations. - IOX_EXPECTS_WITH_MSG(!isInvalidElement(iter.m_iterListNodeIdx), "invalidated iterator"); + IOX_ENFORCE(!isInvalidElement(iter.m_iterListNodeIdx), "invalidated iterator"); return false; } template inline bool forward_list::isInvalidIterOrDifferentLists(const const_iterator& iter) const noexcept { - IOX_EXPECTS_WITH_MSG((this == iter.m_list), "iterator of other list can't be used"); + IOX_ENFORCE((this == iter.m_list), "iterator of other list can't be used"); return isInvalidIterator(iter); } diff --git a/iceoryx_hoofs/container/include/iox/detail/list.inl b/iceoryx_hoofs/container/include/iox/detail/list.inl index a46db49325..57b2982982 100644 --- a/iceoryx_hoofs/container/include/iox/detail/list.inl +++ b/iceoryx_hoofs/container/include/iox/detail/list.inl @@ -18,6 +18,7 @@ #ifndef IOX_HOOFS_CONTAINER_LIST_INL #define IOX_HOOFS_CONTAINER_LIST_INL +#include "iox/assertions.hpp" #include "iox/list.hpp" #include "iox/logging.hpp" @@ -330,7 +331,7 @@ template inline T& list::front() noexcept { auto iter = begin(); - IOX_EXPECTS_WITH_MSG(isValidElementIdx(iter.m_iterListNodeIdx), "invalid list element"); + IOX_ENFORCE(isValidElementIdx(iter.m_iterListNodeIdx), "invalid list element"); return *iter; } @@ -338,7 +339,7 @@ template inline const T& list::front() const noexcept { auto citer = cbegin(); - IOX_EXPECTS_WITH_MSG(isValidElementIdx(citer.m_iterListNodeIdx), "invalid list element"); + IOX_ENFORCE(isValidElementIdx(citer.m_iterListNodeIdx), "invalid list element"); return *citer; } @@ -346,7 +347,7 @@ template inline T& list::back() noexcept { auto iter = end(); - IOX_EXPECTS_WITH_MSG(isValidElementIdx((--iter).m_iterListNodeIdx), "invalid list element"); + IOX_ENFORCE(isValidElementIdx((--iter).m_iterListNodeIdx), "invalid list element"); return *iter; } @@ -354,7 +355,7 @@ template inline const T& list::back() const noexcept { auto citer = cend(); - IOX_EXPECTS_WITH_MSG(isValidElementIdx((--citer).m_iterListNodeIdx), "invalid list element"); + IOX_ENFORCE(isValidElementIdx((--citer).m_iterListNodeIdx), "invalid list element"); return *citer; } @@ -653,7 +654,7 @@ inline void list::setNextIdx(const size_type idx, const size_type n template inline const T* list::getDataPtrFromIdx(const size_type idx) const noexcept { - IOX_EXPECTS_WITH_MSG(isValidElementIdx(idx), "invalid list element"); + IOX_ENFORCE(isValidElementIdx(idx), "invalid list element"); /// @NOLINTJUSTIFICATION provide type safe access to the encapsulated untyped m_data array /// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) @@ -684,14 +685,14 @@ inline bool list::isInvalidIterator(const const_iterator& iter) con // freeList / invalid elements will have the prevIdx set to INVALID_INDEX // additional check on e.g. nextIdx or m_iterListNodeIdx ( inline bool list::isInvalidIterOrDifferentLists(const const_iterator& iter) const noexcept { - IOX_EXPECTS_WITH_MSG((this == iter.m_list), "iterator of other list can't be used"); + IOX_ENFORCE((this == iter.m_list), "iterator of other list can't be used"); return isInvalidIterator(iter); } diff --git a/iceoryx_hoofs/container/include/iox/detail/vector.inl b/iceoryx_hoofs/container/include/iox/detail/vector.inl index 92414006a3..fa5f2045df 100644 --- a/iceoryx_hoofs/container/include/iox/detail/vector.inl +++ b/iceoryx_hoofs/container/include/iox/detail/vector.inl @@ -17,6 +17,7 @@ #ifndef IOX_HOOFS_CONTAINER_VECTOR_INL #define IOX_HOOFS_CONTAINER_VECTOR_INL +#include "iox/assertions.hpp" #include "iox/vector.hpp" #include // std::memcpy, std::memmove @@ -323,7 +324,7 @@ inline T& vector::at(const uint64_t index) noexcept template inline const T& vector::at(const uint64_t index) const noexcept { - IOX_EXPECTS_WITH_MSG(index < m_size, "Out of bounds access"); + IOX_ENFORCE(index < m_size, "Out of bounds access"); return at_unchecked(index); } @@ -342,7 +343,7 @@ inline const T& vector::operator[](const uint64_t index) const noex template inline T& vector::front() noexcept { - IOX_EXPECTS_WITH_MSG(!empty(), "Attempting to access the front of an empty vector"); + IOX_ENFORCE(!empty(), "Attempting to access the front of an empty vector"); return at(0); } @@ -357,7 +358,7 @@ inline const T& vector::front() const noexcept template inline T& vector::back() noexcept { - IOX_EXPECTS_WITH_MSG(!empty(), "Attempting to access the back of an empty vector"); + IOX_ENFORCE(!empty(), "Attempting to access the back of an empty vector"); return at(size() - 1U); } diff --git a/iceoryx_hoofs/container/include/iox/fixed_position_container.hpp b/iceoryx_hoofs/container/include/iox/fixed_position_container.hpp index 8d8102fe5d..ef2a6006a5 100644 --- a/iceoryx_hoofs/container/include/iox/fixed_position_container.hpp +++ b/iceoryx_hoofs/container/include/iox/fixed_position_container.hpp @@ -239,9 +239,8 @@ class FixedPositionContainer final /// - the slot the iterator point to is not in use [[nodiscard]] Value& operator*() const { - IOX_ENSURES_WITH_MSG(m_index <= Index::LAST, "Access with invalid index!"); - IOX_ENSURES_WITH_MSG(m_container.get().m_status[m_index] == SlotStatus::USED, - "Invalid access! Slot not in use!"); + IOX_ENFORCE(m_index <= Index::LAST, "Access with invalid index!"); + IOX_ENFORCE(m_container.get().m_status[m_index] == SlotStatus::USED, "Invalid access! Slot not in use!"); return m_container.get().m_data[m_index]; } @@ -252,9 +251,8 @@ class FixedPositionContainer final /// - the slot the iterator point to is not in use [[nodiscard]] Value* operator->() const { - IOX_ENSURES_WITH_MSG(m_index <= Index::LAST, "Access with invalid index!"); - IOX_ENSURES_WITH_MSG(m_container.get().m_status[m_index] == SlotStatus::USED, - "Invalid access! Slot not in use!"); + IOX_ENFORCE(m_index <= Index::LAST, "Access with invalid index!"); + IOX_ENFORCE(m_container.get().m_status[m_index] == SlotStatus::USED, "Invalid access! Slot not in use!"); return &m_container.get().m_data[m_index]; } @@ -265,9 +263,8 @@ class FixedPositionContainer final /// - the slot the iterator point to is not in use [[nodiscard]] Value* to_ptr() const { - IOX_ENSURES_WITH_MSG(m_index <= Index::LAST, "Access with invalid index!"); - IOX_ENSURES_WITH_MSG(m_container.get().m_status[m_index] == SlotStatus::USED, - "Invalid access! Slot not in use!"); + IOX_ENFORCE(m_index <= Index::LAST, "Access with invalid index!"); + IOX_ENFORCE(m_container.get().m_status[m_index] == SlotStatus::USED, "Invalid access! Slot not in use!"); return &m_container.get().m_data[m_index]; } diff --git a/iceoryx_hoofs/filesystem/source/file_reader.cpp b/iceoryx_hoofs/filesystem/source/file_reader.cpp index 957a43dea5..6f6c27a049 100644 --- a/iceoryx_hoofs/filesystem/source/file_reader.cpp +++ b/iceoryx_hoofs/filesystem/source/file_reader.cpp @@ -52,8 +52,8 @@ FileReader::FileReader(const std::string& fileName, const std::string& filePath, case ErrorMode::Terminate: { m_fileStream.close(); - IOX_LOG(FATAL, "Could not open file '" << fileName << "' from path '" << filePath << "'. Exiting!"); - IOX_ENSURES(false); + IOX_LOG(FATAL, "Could not open file '" << fileName << "' from path '" << filePath << "'!"); + IOX_PANIC("Exiting due to file open failure!"); return; } } diff --git a/iceoryx_hoofs/functional/include/iox/function_ref.hpp b/iceoryx_hoofs/functional/include/iox/function_ref.hpp index 6d012096b3..33527ba858 100644 --- a/iceoryx_hoofs/functional/include/iox/function_ref.hpp +++ b/iceoryx_hoofs/functional/include/iox/function_ref.hpp @@ -20,8 +20,6 @@ #ifndef IOX_HOOFS_FUNCTIONAL_FUNCTION_REF_HPP #define IOX_HOOFS_FUNCTIONAL_FUNCTION_REF_HPP -// AXIVION Next Line AutosarC++19_03-A16.2.2 : Needed for IOX_EXPECTS and IOX_ENSURES macros -#include "iox/assertions.hpp" #include "iox/type_traits.hpp" #include diff --git a/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl b/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl index 8096142615..c2f55c0e72 100644 --- a/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl +++ b/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl @@ -18,6 +18,7 @@ #ifndef IOX_HOOFS_MEMORY_RELATIVE_POINTER_INL #define IOX_HOOFS_MEMORY_RELATIVE_POINTER_INL +#include "iox/assertions.hpp" #include "iox/relative_pointer.hpp" namespace iox @@ -103,7 +104,7 @@ template inline T* RelativePointer::operator->() const noexcept { auto* const ptr{get()}; - IOX_ENSURES(ptr != nullptr); + IOX_ENFORCE(ptr != nullptr, "should not happen unless src is incorrectly used after move"); return ptr; } diff --git a/iceoryx_hoofs/posix/filesystem/source/file.cpp b/iceoryx_hoofs/posix/filesystem/source/file.cpp index e45ebb1979..4f2140a4ee 100644 --- a/iceoryx_hoofs/posix/filesystem/source/file.cpp +++ b/iceoryx_hoofs/posix/filesystem/source/file.cpp @@ -189,7 +189,7 @@ void File::close_fd() noexcept break; } - IOX_ENSURES_WITH_MSG(false, "Unable to close file descriptor due to a corrupted file descriptor."); + IOX_PANIC("Unable to close file descriptor due to a corrupted file descriptor."); } expected File::does_exist(const FilePath& file) noexcept diff --git a/iceoryx_hoofs/posix/filesystem/source/posix_acl.cpp b/iceoryx_hoofs/posix/filesystem/source/posix_acl.cpp index 9b1f88432e..957e4c0980 100644 --- a/iceoryx_hoofs/posix/filesystem/source/posix_acl.cpp +++ b/iceoryx_hoofs/posix/filesystem/source/posix_acl.cpp @@ -97,8 +97,6 @@ expected PosixAcl::createACL(const function freeACL = [&](acl_t acl) { auto aclFreeCall = IOX_POSIX_CALL(acl_free)(acl).successReturnValue(0).evaluate(); // We ensure here instead of returning as this lambda will be called by unique_ptr - /// NOLINTJUSTIFICATION @todo iox-#1032 will be replaced with refactored error handling - /// NOLINTNEXTLINE(hicpp-no-array-decay,cppcoreguidelines-pro-bounds-array-to-pointer-decay) IOX_ENFORCE(!aclFreeCall.has_error(), "Could not free ACL memory"); }; diff --git a/iceoryx_hoofs/posix/ipc/include/iox/detail/named_pipe.inl b/iceoryx_hoofs/posix/ipc/include/iox/detail/named_pipe.inl index f52015de23..b91929c972 100644 --- a/iceoryx_hoofs/posix/ipc/include/iox/detail/named_pipe.inl +++ b/iceoryx_hoofs/posix/ipc/include/iox/detail/named_pipe.inl @@ -27,13 +27,11 @@ expected NamedPipe::trySend(const iox::string& me { static_assert(N <= MAX_MESSAGE_SIZE, "Size exceeds transmission limit!"); - auto result = m_data->sendSemaphore().tryWait(); - IOX_EXPECTS(!result.has_error()); - - if (*result) + auto hasData = m_data->sendSemaphore().tryWait().expect("'tryWait' on a semaphore should always be successful"); + if (hasData) { IOX_DISCARD_RESULT(m_data->messages.push(message)); - IOX_EXPECTS(!m_data->receiveSemaphore().post().has_error()); + m_data->receiveSemaphore().post().expect("'post' on a semaphore should always be successful"); return ok(); } return err(PosixIpcChannelError::TIMEOUT); @@ -44,9 +42,9 @@ expected NamedPipe::send(const iox::string& messa { static_assert(N <= MAX_MESSAGE_SIZE, "Size exceeds transmission limit!"); - IOX_EXPECTS(!m_data->sendSemaphore().wait().has_error()); + m_data->sendSemaphore().wait().expect("'wait' on a semaphore should always be successful"); IOX_DISCARD_RESULT(m_data->messages.push(message)); - IOX_EXPECTS(!m_data->receiveSemaphore().post().has_error()); + m_data->receiveSemaphore().post().expect("'post' on a semaphore should always be successful"); return ok(); } @@ -57,13 +55,13 @@ expected NamedPipe::timedSend(const iox::string& { static_assert(N <= MAX_MESSAGE_SIZE, "Size exceeds transmission limit!"); - auto result = m_data->sendSemaphore().timedWait(timeout); - IOX_EXPECTS(!result.has_error()); + auto waitState = + m_data->sendSemaphore().timedWait(timeout).expect("'timedWait' on a semaphore should always be successful"); - if (*result == SemaphoreWaitState::NO_TIMEOUT) + if (waitState == SemaphoreWaitState::NO_TIMEOUT) { IOX_DISCARD_RESULT(m_data->messages.push(message)); - IOX_EXPECTS(!m_data->receiveSemaphore().post().has_error()); + m_data->receiveSemaphore().post().expect("'post' on a semaphore should always be successful"); return ok(); } return err(PosixIpcChannelError::TIMEOUT); @@ -72,11 +70,11 @@ expected NamedPipe::timedSend(const iox::string& template expected NamedPipe::receive(iox::string& message) const noexcept { - IOX_EXPECTS(!m_data->receiveSemaphore().wait().has_error()); + m_data->receiveSemaphore().wait().expect("'wait' on a semaphore should always be successful"); auto msg = m_data->messages.pop(); if (msg.has_value()) { - IOX_EXPECTS(!m_data->sendSemaphore().post().has_error()); + m_data->sendSemaphore().post().expect("'post' on a semaphore should always be successful"); message = *msg; return ok(); } @@ -86,15 +84,13 @@ expected NamedPipe::receive(iox::string& message) template expected NamedPipe::tryReceive(iox::string& message) const noexcept { - auto result = m_data->receiveSemaphore().tryWait(); - IOX_EXPECTS(!result.has_error()); - - if (*result) + auto hasData = m_data->receiveSemaphore().tryWait().expect("'tryWait' on a semaphore should always be successful"); + if (hasData) { auto msg = m_data->messages.pop(); if (msg.has_value()) { - IOX_EXPECTS(!m_data->sendSemaphore().post().has_error()); + m_data->sendSemaphore().post().expect("'post' on a semaphore should always be successful"); message = *msg; } return err(PosixIpcChannelError::INTERNAL_LOGIC_ERROR); @@ -107,15 +103,15 @@ template expected NamedPipe::timedReceive(iox::string& message, const units::Duration& timeout) const noexcept { - auto result = m_data->receiveSemaphore().timedWait(timeout); - IOX_EXPECTS(!result.has_error()); + auto waitState = + m_data->receiveSemaphore().timedWait(timeout).expect("'timedWait' on a semaphore should always be successful"); - if (*result == SemaphoreWaitState::NO_TIMEOUT) + if (waitState == SemaphoreWaitState::NO_TIMEOUT) { auto msg = m_data->messages.pop(); if (msg.has_value()) { - IOX_EXPECTS(!m_data->sendSemaphore().post().has_error()); + m_data->sendSemaphore().post().expect("'post' on a semaphore should always be successful"); message = *msg; return ok(); } @@ -125,4 +121,4 @@ expected NamedPipe::timedReceive(iox::string& mes } } // namespace iox -#endif \ No newline at end of file +#endif diff --git a/iceoryx_hoofs/posix/sync/source/thread.cpp b/iceoryx_hoofs/posix/sync/source/thread.cpp index 95021df30c..608b501b53 100644 --- a/iceoryx_hoofs/posix/sync/source/thread.cpp +++ b/iceoryx_hoofs/posix/sync/source/thread.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iox/thread.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" #include "iox/posix_call.hpp" @@ -47,8 +48,8 @@ ThreadName_t getThreadName() noexcept (threadHandle, &tempName[0], MAX_THREAD_NAME_LENGTH + 1U).successReturnValue(0).evaluate().or_else([](auto& r) { // String length limit is ensured through MAX_THREAD_NAME_LENGTH // ERANGE (string too small) intentionally not handled to avoid untestable and dead code - IOX_LOG(ERROR, "This should never happen! " << r.getHumanReadableErrnum()); - IOX_ENSURES(false && "internal logic error"); + IOX_LOG(FATAL, "This should never happen! " << r.getHumanReadableErrnum()); + IOX_PANIC("Internal logic error"); }); return ThreadName_t(TruncateToCapacity, &tempName[0]); diff --git a/iceoryx_hoofs/posix/time/source/deadline_timer.cpp b/iceoryx_hoofs/posix/time/source/deadline_timer.cpp index 5c9933e51b..650181f94e 100644 --- a/iceoryx_hoofs/posix/time/source/deadline_timer.cpp +++ b/iceoryx_hoofs/posix/time/source/deadline_timer.cpp @@ -16,6 +16,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iox/deadline_timer.hpp" +#include "iox/assertions.hpp" #include "iox/posix_call.hpp" #include "iceoryx_platform/time.hpp" @@ -58,11 +59,11 @@ iox::units::Duration deadline_timer::remainingTime() const noexcept iox::units::Duration deadline_timer::getCurrentMonotonicTime() noexcept { timespec time_since_epoch{0, 0}; - IOX_ENSURES_WITH_MSG(!IOX_POSIX_CALL(iox_clock_gettime)(CLOCK_MONOTONIC, &time_since_epoch) - .failureReturnValue(-1) - .evaluate() - .has_error(), - "An error which should never happen occured during 'iox_clock_gettime'!"); + IOX_ENFORCE(!IOX_POSIX_CALL(iox_clock_gettime)(CLOCK_MONOTONIC, &time_since_epoch) + .failureReturnValue(-1) + .evaluate() + .has_error(), + "An error which should never happen occured during 'iox_clock_gettime'!"); return iox::units::Duration{time_since_epoch}; } } // namespace iox diff --git a/iceoryx_hoofs/posix/utility/source/posix_scheduler.cpp b/iceoryx_hoofs/posix/utility/source/posix_scheduler.cpp index b6fe00331b..4a6bbd8287 100644 --- a/iceoryx_hoofs/posix/utility/source/posix_scheduler.cpp +++ b/iceoryx_hoofs/posix/utility/source/posix_scheduler.cpp @@ -28,16 +28,8 @@ int32_t getSchedulerPriorityMinimum(const Scheduler scheduler) noexcept auto result = IOX_POSIX_CALL(sched_get_priority_min)(static_cast(scheduler)).failureReturnValue(-1).evaluate(); if (result.has_error()) { - IOX_LOG(ERROR, - "The \"sched_get_priority_min\" should never fail. This can only be caused by an internal logic error " - "or a non posix compliant system."); - - // NOLINTJUSTIFICATION Required to provide an error message to the user - // NOLINTNEXTLINE(hicpp-no-array-decay,cppcoreguidelines-pro-bounds-array-to-pointer-decay) - IOX_ENSURES(false - && "This should never happen! Either the system is not posix compliant or and invalid integer was " - "casted to the enum class Scheduler."); - return -1; + IOX_PANIC("The \"sched_get_priority_min\" should never fail! Either the system is not POSIX compliant or an " + "invalid integer was casted to the \"Scheduler\" enum class."); } return result.value().value; } @@ -47,16 +39,8 @@ int32_t getSchedulerPriorityMaximum(const Scheduler scheduler) noexcept auto result = IOX_POSIX_CALL(sched_get_priority_max)(static_cast(scheduler)).failureReturnValue(-1).evaluate(); if (result.has_error()) { - IOX_LOG(ERROR, - "The \"sched_get_priority_max\" should never fail. This can only be caused by an internal logic " - "error or a non posix compliant system."); - - // NOLINTJUSTIFICATION Required to provide an error message to the user - // NOLINTNEXTLINE(hicpp-no-array-decay,cppcoreguidelines-pro-bounds-array-to-pointer-decay) - IOX_ENSURES(false - && "This should never happen! Either the system is not posix compliant or and invalid integer was " - "casted to the enum class Scheduler."); - return -1; + IOX_PANIC("The \"sched_get_priority_max\" should never fail! Either the system is not POSIX compliant or an " + "invalid integer was casted to the \"Scheduler\" enum class."); } return result.value().value; } diff --git a/iceoryx_hoofs/posix/utility/source/system_configuration.cpp b/iceoryx_hoofs/posix/utility/source/system_configuration.cpp index 85817cc6fd..b30a140d5f 100644 --- a/iceoryx_hoofs/posix/utility/source/system_configuration.cpp +++ b/iceoryx_hoofs/posix/utility/source/system_configuration.cpp @@ -17,6 +17,7 @@ #include "iox/detail/system_configuration.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" #include "iox/posix_call.hpp" @@ -32,8 +33,8 @@ uint64_t pageSize() noexcept .failureReturnValue(-1) .evaluate() .or_else([](auto& r) { - IOX_LOG(ERROR, "This should never happen: " << r.getHumanReadableErrnum()); - IOX_ENSURES(false && "Internal logic error"); + IOX_LOG(FATAL, "This should never happen: " << r.getHumanReadableErrnum()); + IOX_PANIC("Internal logic error"); }) .value() .value); diff --git a/iceoryx_hoofs/primitives/include/iox/algorithm.hpp b/iceoryx_hoofs/primitives/include/iox/algorithm.hpp index 6f61eab3f2..6ae14ef217 100644 --- a/iceoryx_hoofs/primitives/include/iox/algorithm.hpp +++ b/iceoryx_hoofs/primitives/include/iox/algorithm.hpp @@ -179,7 +179,11 @@ struct greater_or_equal greater_or_equal(T t) noexcept : m_value(t) { - IOX_EXPECTS(t >= Minimum); + if (t < Minimum) + { + IOX_LOG(FATAL, "The value '" << t << "' is below '" << Minimum << "'"); + IOX_PANIC("Violating invariant of 'greater_or_equal'"); + } } // AXIVION Next Construct AutosarC++19_03-A13.5.2,AutosarC++19_03-A13.5.3:this class should behave like a T but @@ -204,8 +208,11 @@ struct range range(T t) noexcept : m_value(t) { - // AXIVION Next Construct AutosarC++19_03-A1.4.3 : False positive! 't >= Minimum' depends on input parameter - IOX_EXPECTS((t >= Minimum) && (t <= Maximum)); + if (t < Minimum || t > Maximum) + { + IOX_LOG(FATAL, "The value '" << t << "' is out of the range [" << Minimum << ", " << Maximum << "]"); + IOX_PANIC("Violating invariant of 'range'"); + } } // AXIVION Next Construct AutosarC++19_03-A13.5.2, AutosarC++19_03-A13.5.3: this class should behave like a T but diff --git a/iceoryx_hoofs/reporting/include/iox/assertions.hpp b/iceoryx_hoofs/reporting/include/iox/assertions.hpp index 98df007500..1e1881dee8 100644 --- a/iceoryx_hoofs/reporting/include/iox/assertions.hpp +++ b/iceoryx_hoofs/reporting/include/iox/assertions.hpp @@ -80,35 +80,6 @@ #define IOX_UNREACHABLE() \ iox::er::forwardPanic(IOX_CURRENT_SOURCE_LOCATION, "Reached code that was supposed to be unreachable.") - -/// @todo iox-#1032 replace IOX_EXPECTS and IOX_ENSURES with IOX_ENFORCE -// implementing C++ Core Guideline, I.6. Prefer Expects -// see: -// https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-expects -// NOLINTJUSTIFICATION array decay: needed for source code location, safely wrapped in macro -// NOLINTBEGIN(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) -#define IOX_EXPECTS(condition) IOX_ENFORCE(condition, "") -// NOLINTEND(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) - -// NOLINTJUSTIFICATION array decay: needed for source code location, safely wrapped in macro -// NOLINTBEGIN(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) -#define IOX_EXPECTS_WITH_MSG(condition, msg) IOX_ENFORCE(condition, msg) -// NOLINTEND(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) - -// implementing C++ Core Guideline, I.8. Prefer Ensures -// see: -// https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-ensures -// NOLINTJUSTIFICATION array decay: needed for source code location, safely wrapped in macro -// NOLINTBEGIN(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) -#define IOX_ENSURES(condition) IOX_ENFORCE(condition, "") -// NOLINTEND(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) - -// NOLINTJUSTIFICATION array decay: needed for source code location, safely wrapped in macro -// NOLINTBEGIN(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) -#define IOX_ENSURES_WITH_MSG(condition, msg) IOX_ENFORCE(condition, msg) -// NOLINTEND(hicpp-no-array-decay, cppcoreguidelines-pro-bounds-array-to-pointer-decay) - - // NOLINTEND(cppcoreguidelines-macro-usage) #endif // IOX_HOOFS_REPORTING_ASSERTIONS_HPP diff --git a/iceoryx_hoofs/reporting/include/iox/detail/hoofs_error_reporting.hpp b/iceoryx_hoofs/reporting/include/iox/detail/hoofs_error_reporting.hpp index 823a59651c..5da1ad8a24 100644 --- a/iceoryx_hoofs/reporting/include/iox/detail/hoofs_error_reporting.hpp +++ b/iceoryx_hoofs/reporting/include/iox/detail/hoofs_error_reporting.hpp @@ -30,6 +30,7 @@ // additional includes #include "iox/error_reporting/types.hpp" +#include "iox/log/logstream.hpp" namespace iox { @@ -38,11 +39,8 @@ namespace iox // NOLINTJUSTIFICATION This macro is usee to define an enum and an array with corresponding enum tag names // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define IOX_HOOFS_ERRORS(error) \ - error(EXPECTS_ENSURES_FAILED) \ error(DO_NOT_USE_AS_ERROR_THIS_IS_AN_INTERNAL_MARKER) // keep this always at the end of the error list - // EXPECTS_ENSURES_FAILED is used as a temporary solution to make IOX_EXPECTS/IOX_ENSURES testable - // clang-format on // DO NOT TOUCH THE ENUM, you can doodle around with the lines above!!! @@ -54,6 +52,12 @@ enum class HoofsError : iox::er::ErrorCode::type const char* asStringLiteral(const HoofsError error) noexcept; +inline log::LogStream& operator<<(log::LogStream& stream, HoofsError value) noexcept +{ + stream << asStringLiteral(value); + return stream; +} + class HoofsErrorType { public: diff --git a/iceoryx_hoofs/reporting/include/iox/error_reporting/custom/default/error_reporting_impl.hpp b/iceoryx_hoofs/reporting/include/iox/error_reporting/custom/default/error_reporting_impl.hpp index c4b787301e..411b680357 100644 --- a/iceoryx_hoofs/reporting/include/iox/error_reporting/custom/default/error_reporting_impl.hpp +++ b/iceoryx_hoofs/reporting/include/iox/error_reporting/custom/default/error_reporting_impl.hpp @@ -54,7 +54,7 @@ namespace er // Custom panic with location [[noreturn]] inline void panic(const SourceLocation& location) { - IOX_ERROR_INTERNAL_LOG_PANIC(location, "Panic"); + IOX_ERROR_INTERNAL_LOG_PANIC(location, "[PANIC]"); panic(); } @@ -64,7 +64,7 @@ namespace er template [[noreturn]] inline void panic(const SourceLocation& location, Message&& msg) { - IOX_ERROR_INTERNAL_LOG_PANIC(location, "Panic " << msg); + IOX_ERROR_INTERNAL_LOG_PANIC(location, "[PANIC] " << msg); panic(); } @@ -80,8 +80,8 @@ inline void report(const SourceLocation& location, Kind, const Error& error) auto errorName = toErrorName(error); IOX_ERROR_INTERNAL_LOG(location, - "'" << errorName << "' (code " << code.value << ") in module '" << moduleName << "' (id " - << module.value << ")"); + "[" << errorName << " (code = " << code.value << ")] in module [" << moduleName + << " (id = " << module.value << ")]"); auto& h = ErrorHandler::get(); h.onReportError(ErrorDescriptor(location, code, module)); } @@ -100,8 +100,8 @@ inline void report(const SourceLocation& location, iox::er::FatalKind kind, cons auto errorName = toErrorName(error); IOX_ERROR_INTERNAL_LOG_FATAL(location, - "'" << kind.name << "' '" << errorName << "' (code " << code.value << ") in module '" - << moduleName << "' (id " << module.value << ")"); + "[" << kind.name << "] [" << errorName << " (code = " << code.value << ")] in module [" + << moduleName << " (id = " << module.value << ")]"); auto& h = ErrorHandler::get(); h.onReportError(ErrorDescriptor(location, code, module)); } @@ -119,11 +119,11 @@ inline void report(const SourceLocation& location, Kind kind, const Error& error auto module = toModule(error); if constexpr (std::is_same::value) { - IOX_ERROR_INTERNAL_LOG_FATAL(location, kind.name); + IOX_ERROR_INTERNAL_LOG_FATAL(location, "[" << kind.name << "]"); } else { - IOX_ERROR_INTERNAL_LOG_FATAL(location, kind.name << " " << std::forward(msg)); + IOX_ERROR_INTERNAL_LOG_FATAL(location, "[" << kind.name << "] " << std::forward(msg)); } auto& h = ErrorHandler::get(); h.onReportViolation(ErrorDescriptor(location, code, module)); diff --git a/iceoryx_hoofs/reporting/include/iox/error_reporting/error_kind.hpp b/iceoryx_hoofs/reporting/include/iox/error_reporting/error_kind.hpp index 8829582dee..f8f8efca18 100644 --- a/iceoryx_hoofs/reporting/include/iox/error_reporting/error_kind.hpp +++ b/iceoryx_hoofs/reporting/include/iox/error_reporting/error_kind.hpp @@ -44,7 +44,7 @@ struct AssertViolationKind struct EnforceViolationKind { - static constexpr char const* name = "EnforceViolation"; + static constexpr char const* name = "Enforce Violation"; }; template diff --git a/iceoryx_hoofs/reporting/include/iox/error_reporting/error_logging.hpp b/iceoryx_hoofs/reporting/include/iox/error_reporting/error_logging.hpp index 815b692119..503cb5ba48 100644 --- a/iceoryx_hoofs/reporting/include/iox/error_reporting/error_logging.hpp +++ b/iceoryx_hoofs/reporting/include/iox/error_reporting/error_logging.hpp @@ -31,7 +31,7 @@ location.line, \ location.function, \ iox::log::LogLevel::ERROR, \ - location.file << " line " << location.line << ": " << msg_stream) + location.file << ":" << location.line << " " << msg_stream) /// @brief Log the location of a fatal error. /// @param location the location of the error @@ -41,7 +41,7 @@ location.line, \ location.function, \ iox::log::LogLevel::FATAL, \ - location.file << " line " << location.line << ": " << msg_stream) + location.file << ":" << location.line << " " << msg_stream) /// @brief Log a panic invocation. /// @param location the location of the panic invocation. diff --git a/iceoryx_hoofs/reporting/include/iox/error_reporting/violation.hpp b/iceoryx_hoofs/reporting/include/iox/error_reporting/violation.hpp index 309f9f2152..23693e5871 100644 --- a/iceoryx_hoofs/reporting/include/iox/error_reporting/violation.hpp +++ b/iceoryx_hoofs/reporting/include/iox/error_reporting/violation.hpp @@ -112,6 +112,9 @@ class Violation }; } // namespace er + +const char* asStringLiteral(const er::ViolationErrorCode error) noexcept; + } // namespace iox #endif // IOX_HOOFS_ERROR_REPORTING_VIOLATION_HPP diff --git a/iceoryx_hoofs/test/mocktests/test_fatal_failure.cpp b/iceoryx_hoofs/test/mocktests/test_fatal_failure.cpp index 630198099a..aa19a0a2a9 100644 --- a/iceoryx_hoofs/test/mocktests/test_fatal_failure.cpp +++ b/iceoryx_hoofs/test/mocktests/test_fatal_failure.cpp @@ -29,8 +29,7 @@ TEST(FatalFailure, UsingExpectFatalFailureWorks) { ::testing::Test::RecordProperty("TEST_ID", "26393210-9738-462f-9d35-dbd53fbae9d2"); - auto hasFatalFailure = IOX_EXPECT_FATAL_FAILURE([&] { IOX_ENFORCE(false, ""); }, - iox::er::Violation{iox::er::ViolationErrorCode::ENFORCE_VIOLATION}); + auto hasFatalFailure = IOX_EXPECT_FATAL_FAILURE([&] { IOX_ENFORCE(false, ""); }, iox::er::ENFORCE_VIOLATION); EXPECT_TRUE(hasFatalFailure); } diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_mpmc_loffli.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_mpmc_loffli.cpp index b79e06f4df..503cbb7197 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_mpmc_loffli.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_mpmc_loffli.cpp @@ -56,8 +56,7 @@ TEST_F(MpmcLoFFLi_test, Misuse_NullptrMemory) MpmcLoFFLi loFFLi; - IOX_EXPECT_FATAL_FAILURE([&] { loFFLi.init(nullptr, 1); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { loFFLi.init(nullptr, 1); }, iox::er::ENFORCE_VIOLATION); } TEST_F(MpmcLoFFLi_test, Misuse_ZeroSize) @@ -68,8 +67,7 @@ TEST_F(MpmcLoFFLi_test, Misuse_ZeroSize) uint32_t memoryLoFFLi[4]; MpmcLoFFLi loFFLi; - IOX_EXPECT_FATAL_FAILURE([&] { loFFLi.init(&memoryLoFFLi[0], 0); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { loFFLi.init(&memoryLoFFLi[0], 0); }, iox::er::ENFORCE_VIOLATION); // NOLINTEND(hicpp-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) } @@ -81,8 +79,7 @@ TEST_F(MpmcLoFFLi_test, Misuse_SizeToLarge) uint32_t memoryLoFFLi[4]; MpmcLoFFLi loFFLi; - IOX_EXPECT_FATAL_FAILURE([&] { loFFLi.init(&memoryLoFFLi[0], UINT32_MAX - 1); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { loFFLi.init(&memoryLoFFLi[0], UINT32_MAX - 1); }, iox::er::ENFORCE_VIOLATION); // NOLINTEND(hicpp-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) } diff --git a/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp b/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp index b65ccc1283..9a4968c93b 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp @@ -2263,8 +2263,7 @@ TEST_F(FixedPositionContainer_test, EraseOnEmptyContainerCallsErrorHandler) { ::testing::Test::RecordProperty("TEST_ID", "943c9f2d-0ebd-4593-a721-884c952fef0d"); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(Sut::Index::FIRST); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(Sut::Index::FIRST); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseOnEmptySlotCallsErrorHandler) @@ -2276,8 +2275,7 @@ TEST_F(FixedPositionContainer_test, EraseOnEmptySlotCallsErrorHandler) constexpr SutComplex::IndexType INDEX_TO_ERASE{Sut::Index::LAST / 2U}; sut.erase(INDEX_TO_ERASE); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(INDEX_TO_ERASE); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(INDEX_TO_ERASE); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithOutOfBoundsIndexCallsErrorHandler) @@ -2288,8 +2286,7 @@ TEST_F(FixedPositionContainer_test, EraseWithOutOfBoundsIndexCallsErrorHandler) constexpr SutComplex::IndexType INDEX_TO_ERASE{Sut::Index::LAST + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(INDEX_TO_ERASE); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(INDEX_TO_ERASE); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithNullptrCallsErrorHandler) @@ -2298,7 +2295,7 @@ TEST_F(FixedPositionContainer_test, EraseWithNullptrCallsErrorHandler) fillSut(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(nullptr); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(nullptr); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithPointerPointingOutOfContainerCallsErrorHandler) @@ -2311,11 +2308,9 @@ TEST_F(FixedPositionContainer_test, EraseWithPointerPointingOutOfContainerCallsE // NOLINTJUSTIFICATION required for test // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(ptr_first - 1U); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(ptr_first - 1U); }, iox::er::ENFORCE_VIOLATION); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(ptr_first + CAPACITY); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(ptr_first + CAPACITY); }, iox::er::ENFORCE_VIOLATION); // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) } @@ -2330,8 +2325,7 @@ TEST_F(FixedPositionContainer_test, EraseWithUnalignedPointerCallsErrorHandler) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast, performance-no-int-to-ptr) auto* ptr_unaligned = reinterpret_cast(reinterpret_cast(ptr_first) + 1U); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(ptr_unaligned); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(ptr_unaligned); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithEndIteratorCallsErrorHandler) @@ -2341,7 +2335,7 @@ TEST_F(FixedPositionContainer_test, EraseWithEndIteratorCallsErrorHandler) fillSut(); Sut::Iterator it = sut.end(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithIteratorNotOriginatingFromContainerCallsErrorHandler) @@ -2354,7 +2348,7 @@ TEST_F(FixedPositionContainer_test, EraseWithIteratorNotOriginatingFromContainer sut2.emplace(666U); Sut::Iterator it = sut2.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithEndConstIteratorCallsErrorHandler) @@ -2364,7 +2358,7 @@ TEST_F(FixedPositionContainer_test, EraseWithEndConstIteratorCallsErrorHandler) fillSut(); Sut::ConstIterator it = sut.end(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, EraseWithConstIteratorNotOriginatingFromContainerCallsErrorHandler) @@ -2377,7 +2371,7 @@ TEST_F(FixedPositionContainer_test, EraseWithConstIteratorNotOriginatingFromCont sut2.emplace(666U); Sut::ConstIterator it = sut2.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(it); }, iox::er::ENFORCE_VIOLATION); } // END test erase @@ -2992,11 +2986,9 @@ TEST_F(FixedPositionContainer_test, DereferencingEndIteratorCallsErrorHandler) { ::testing::Test::RecordProperty("TEST_ID", "f2ccf248-97f8-4265-9bb4-9c8e7cb79e67"); - IOX_EXPECT_FATAL_FAILURE([&] { auto _ [[maybe_unused]] = *sut.end(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { auto _ [[maybe_unused]] = *sut.end(); }, iox::er::ENFORCE_VIOLATION); - IOX_EXPECT_FATAL_FAILURE([&] { auto _ [[maybe_unused]] = *sut.cend(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { auto _ [[maybe_unused]] = *sut.cend(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, DereferencingInvalidIteratorCallsErrorHandler) @@ -3006,8 +2998,7 @@ TEST_F(FixedPositionContainer_test, DereferencingInvalidIteratorCallsErrorHandle auto it = sut.emplace(135U); sut.erase(it); - IOX_EXPECT_FATAL_FAILURE([&] { auto _ [[maybe_unused]] = *it; }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { auto _ [[maybe_unused]] = *it; }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, ArrowOperatorOnNonConstItertorLeadsToNonConstPointer) @@ -3060,11 +3051,9 @@ TEST_F(FixedPositionContainer_test, ArrowOperatorOnEndIteratorCallsErrorHandler) { ::testing::Test::RecordProperty("TEST_ID", "74e20989-69dd-451c-9d6d-f65044a7d7b6"); - IOX_EXPECT_FATAL_FAILURE([&] { sut_complex.end()->ref(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut_complex.end()->ref(); }, iox::er::ENFORCE_VIOLATION); - IOX_EXPECT_FATAL_FAILURE([&] { sut_complex.cend()->ref(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut_complex.cend()->ref(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, ArrowOperatorOnInvalidIteratorCallsErrorHandler) @@ -3074,7 +3063,7 @@ TEST_F(FixedPositionContainer_test, ArrowOperatorOnInvalidIteratorCallsErrorHand auto it = sut_complex.emplace(135U); sut_complex.erase(it); - IOX_EXPECT_FATAL_FAILURE([&] { it->ref(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { it->ref(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, ToPtrOnNonConstItertorLeadsToNonConstPointer) @@ -3126,11 +3115,9 @@ TEST_F(FixedPositionContainer_test, ToPtrOnEndIteratorCallsErrorHandler) { ::testing::Test::RecordProperty("TEST_ID", "51b76d04-6c8c-486e-88c9-8b6b760c41d4"); - IOX_EXPECT_FATAL_FAILURE([&] { auto* _ [[maybe_unused]] = sut.end().to_ptr(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { auto* _ [[maybe_unused]] = sut.end().to_ptr(); }, iox::er::ENFORCE_VIOLATION); - IOX_EXPECT_FATAL_FAILURE([&] { const auto* _ [[maybe_unused]] = sut.cend().to_ptr(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { const auto* _ [[maybe_unused]] = sut.cend().to_ptr(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, ToPtrOnInvalidIteratorCallsErrorHandler) @@ -3140,8 +3127,7 @@ TEST_F(FixedPositionContainer_test, ToPtrOnInvalidIteratorCallsErrorHandler) auto it = sut.emplace(135U); sut.erase(it); - IOX_EXPECT_FATAL_FAILURE([&] { auto* _ [[maybe_unused]] = it.to_ptr(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { auto* _ [[maybe_unused]] = it.to_ptr(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(FixedPositionContainer_test, ToIndexOnIteratorReturnsCorrespondingIndex) diff --git a/iceoryx_hoofs/test/moduletests/test_container_forward_list.cpp b/iceoryx_hoofs/test/moduletests/test_container_forward_list.cpp index e9d957b0cb..a92a4746f7 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_forward_list.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_forward_list.cpp @@ -202,7 +202,7 @@ TEST_F(forward_list_test, FullWhenFilledWithMoreThanCapacityElements) } EXPECT_THAT(sut.full(), Eq(true)); - IOX_EXPECT_FATAL_FAILURE([&] { sut.emplace_front(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.emplace_front(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements) { @@ -574,8 +574,7 @@ TEST_F(forward_list_test, EmplaceAfterWithWrongListIterator) ++cnt; } - IOX_EXPECT_FATAL_FAILURE([&] { sut11.emplace_after(iterOfSut12, cnt); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut11.emplace_after(iterOfSut12, cnt); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, PushFrontConstCustomSuccessfullWhenSpaceAvailableLValue) @@ -1074,38 +1073,32 @@ TEST_F(forward_list_test, IteratorComparisonOfDifferentLists) auto iterSut1 = sut11.begin(); auto iterSut2 = sut12.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.before_begin(); iterSut2 = sut12.before_begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.end(); iterSut2 = sut12.end(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.begin(); iterSut2 = sut12.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.before_begin(); iterSut2 = sut12.before_begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.end(); iterSut2 = sut12.end(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, iox::er::ENFORCE_VIOLATION); } @@ -1895,7 +1888,7 @@ TEST_F(forward_list_test, invalidIteratorErase) auto iter = sut.begin(); sut.pop_front(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase_after(iter); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase_after(iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, invalidIteratorIncrement) @@ -1910,7 +1903,7 @@ TEST_F(forward_list_test, invalidIteratorIncrement) auto iter = sut.cbegin(); sut.pop_front(); - IOX_EXPECT_FATAL_FAILURE([&] { ++iter; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { ++iter; }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, invalidIteratorComparison) @@ -1925,8 +1918,7 @@ TEST_F(forward_list_test, invalidIteratorComparison) auto iter = sut.cbegin(); sut.pop_front(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut.cbegin() == iter); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut.cbegin() == iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, invalidIteratorComparisonUnequal) @@ -1941,8 +1933,7 @@ TEST_F(forward_list_test, invalidIteratorComparisonUnequal) sut.pop_front(); auto iter2 = sut.cbegin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter2 != iter); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter2 != iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, invalidIteratorDereferencing) @@ -1957,7 +1948,7 @@ TEST_F(forward_list_test, invalidIteratorDereferencing) auto iter = sut.cbegin(); sut.pop_front(); - IOX_EXPECT_FATAL_FAILURE([&] { sut.remove(*iter); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.remove(*iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, invalidIteratorAddressOfOperator) @@ -1972,8 +1963,7 @@ TEST_F(forward_list_test, invalidIteratorAddressOfOperator) auto iter = sut.cbegin(); sut.pop_front(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->value == 12U); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->value == 12U); }, iox::er::ENFORCE_VIOLATION); } TEST_F(forward_list_test, ListIsCopyableViaMemcpy) diff --git a/iceoryx_hoofs/test/moduletests/test_container_list.cpp b/iceoryx_hoofs/test/moduletests/test_container_list.cpp index c19c7bcf9c..24cc96d180 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_list.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_list.cpp @@ -179,7 +179,7 @@ TEST_F(list_test, FullWhenFilledWithMoreThanCapacityElements) { ::testing::Test::RecordProperty("TEST_ID", "585bb3d9-112c-4db8-af5e-e4c646723515"); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { for (uint64_t i = 0U; i < sut.capacity(); ++i) { @@ -189,7 +189,7 @@ TEST_F(list_test, FullWhenFilledWithMoreThanCapacityElements) EXPECT_THAT(sut.full(), Eq(true)); sut.emplace_front(); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, NotFullWhenFilledWithCapacityAndEraseOneElements) { @@ -636,8 +636,7 @@ TEST_F(list_test, EmplaceBackWithMoreThanCapacityElements) } else { - IOX_EXPECT_FATAL_FAILURE([&] { sut1.emplace_back(cnt); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut1.emplace_back(cnt); }, iox::er::ENFORCE_VIOLATION); } ++cnt; } @@ -671,8 +670,7 @@ TEST_F(list_test, EmplaceWithWrongListIterator) ++cnt; } - IOX_EXPECT_FATAL_FAILURE([&] { sut11.emplace(iterOfSut2, cnt); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut11.emplace(iterOfSut2, cnt); }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, PushFrontConstCustomSuccessfullWhenSpaceAvailableLValue) @@ -1407,38 +1405,32 @@ TEST_F(list_test, IteratorComparisonOfDifferentLists) auto iterSut1 = sut11.begin(); auto iterSut2 = sut12.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.begin(); iterSut2 = sut12.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.end(); iterSut2 = sut12.end(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 == iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.begin(); iterSut2 = sut12.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.begin(); iterSut2 = sut12.begin(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, iox::er::ENFORCE_VIOLATION); iterSut1 = sut11.end(); iterSut2 = sut12.end(); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iterSut1 != iterSut2); }, iox::er::ENFORCE_VIOLATION); } @@ -2221,7 +2213,7 @@ TEST_F(list_test, invalidIteratorErase) sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(iter); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.erase(iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, invalidIteratorIncrement) @@ -2237,7 +2229,7 @@ TEST_F(list_test, invalidIteratorIncrement) ++iter; sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { ++iter; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { ++iter; }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, invalidIteratorDecrement) @@ -2253,7 +2245,7 @@ TEST_F(list_test, invalidIteratorDecrement) ++iter; sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { --iter; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { --iter; }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, invalidIteratorComparison) @@ -2270,8 +2262,7 @@ TEST_F(list_test, invalidIteratorComparison) auto iter2 [[maybe_unused]] = sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut.cbegin() == iter); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut.cbegin() == iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, invalidIteratorComparisonUnequal) @@ -2288,8 +2279,7 @@ TEST_F(list_test, invalidIteratorComparisonUnequal) auto iter2 = sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter2 != iter); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter2 != iter); }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, invalidIteratorDereferencing) @@ -2305,8 +2295,7 @@ TEST_F(list_test, invalidIteratorDereferencing) ++iter; auto iter2 [[maybe_unused]] = sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT((*iter).value); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT((*iter).value); }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, invalidIteratorAddressOfOperator) @@ -2322,8 +2311,7 @@ TEST_F(list_test, invalidIteratorAddressOfOperator) ++iter; auto iter2 [[maybe_unused]] = sut.erase(iter); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->value == 12U); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(iter->value == 12U); }, iox::er::ENFORCE_VIOLATION); } TEST_F(list_test, ListIsCopyableViaMemcpy) diff --git a/iceoryx_hoofs/test/moduletests/test_container_vector.cpp b/iceoryx_hoofs/test/moduletests/test_container_vector.cpp index 96c0d45f66..c94346c2cc 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_vector.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_vector.cpp @@ -883,7 +883,7 @@ TEST_F(vector_test, AccessOfNonExistingElementOnEmptyVectorLeadTermination) ASSERT_THAT(sut.empty(), Eq(true)); const uint64_t accessOffset{sut.size() + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut.at(accessOffset); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.at(accessOffset); }, iox::er::ENFORCE_VIOLATION); } TEST_F(vector_test, AccessOfNonExistingElementOnPartiallyFilledVectorLeadTermination) @@ -897,7 +897,7 @@ TEST_F(vector_test, AccessOfNonExistingElementOnPartiallyFilledVectorLeadTermina } const uint64_t accessOffset{sut.size() + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut.at(accessOffset); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.at(accessOffset); }, iox::er::ENFORCE_VIOLATION); } TEST_F(vector_test, AccessOfNonExistingElementOnFullVectorLeadTermination) @@ -913,7 +913,7 @@ TEST_F(vector_test, AccessOfNonExistingElementOnFullVectorLeadTermination) ASSERT_THAT(sut.size(), Eq(VECTOR_CAPACITY)); const uint64_t accessOffset{sut.size() + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut.at(accessOffset); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.at(accessOffset); }, iox::er::ENFORCE_VIOLATION); } TEST_F(vector_test, OutOfBoundsAccessOnEmptyVectorLeadsToTermination) @@ -923,7 +923,7 @@ TEST_F(vector_test, OutOfBoundsAccessOnEmptyVectorLeadsToTermination) ASSERT_THAT(sut.empty(), Eq(true)); const uint64_t accessOffset{sut.size() + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut[accessOffset]; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut[accessOffset]; }, iox::er::ENFORCE_VIOLATION); } TEST_F(vector_test, OutOfBoundsAccessOnPartiallyFilledVectorLeadsToTermination) @@ -937,7 +937,7 @@ TEST_F(vector_test, OutOfBoundsAccessOnPartiallyFilledVectorLeadsToTermination) } const uint64_t accessOffset{sut.size() + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut[accessOffset]; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut[accessOffset]; }, iox::er::ENFORCE_VIOLATION); } TEST_F(vector_test, OutOfBoundsAccessOnFullVectorLeadsToTermination) @@ -951,7 +951,7 @@ TEST_F(vector_test, OutOfBoundsAccessOnFullVectorLeadsToTermination) } const uint64_t accessOffset{sut.size() + 1U}; - IOX_EXPECT_FATAL_FAILURE([&] { sut[accessOffset]; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut[accessOffset]; }, iox::er::ENFORCE_VIOLATION); } TEST_F(vector_test, EraseOfFrontElementCallsDTorAndMove) diff --git a/iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp index 525ebb5b6c..e5a29e37ee 100644 --- a/iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp @@ -79,7 +79,7 @@ void ExpectDoesCallTerminateWhenObjectIsInvalid(const ExpectCall& callExpect) { SutType sut = FactoryType::createInvalidObject(); - IOX_EXPECT_FATAL_FAILURE([&] { callExpect(sut); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { callExpect(sut); }, iox::er::FATAL); } TYPED_TEST(FunctionalInterface_test, ExpectDoesCallTerminateWhenObjectIsInvalid_LValueCase) diff --git a/iceoryx_hoofs/test/moduletests/test_filesystem_file_reader.cpp b/iceoryx_hoofs/test/moduletests/test_filesystem_file_reader.cpp index d98ac743e9..8e79ae96b8 100644 --- a/iceoryx_hoofs/test/moduletests/test_filesystem_file_reader.cpp +++ b/iceoryx_hoofs/test/moduletests/test_filesystem_file_reader.cpp @@ -166,11 +166,10 @@ TEST_F(FileReader_test, errorTerminateMode) const std::string fileName{"ISaidNo!"}; const std::string filePath{"InTheMiddleOfNowhere"}; - IOX_EXPECT_FATAL_FAILURE( - [&] { iox::FileReader reader(fileName, filePath, iox::FileReader::ErrorMode::Terminate); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { iox::FileReader reader(fileName, filePath, iox::FileReader::ErrorMode::Terminate); }, + iox::er::FATAL); - const std::string expectedOutput = "Could not open file 'ISaidNo!' from path 'InTheMiddleOfNowhere'. Exiting!"; + const std::string expectedOutput = "Could not open file 'ISaidNo!' from path 'InTheMiddleOfNowhere'!"; iox::testing::TestingLogger::checkLogMessageIfLogLevelIsSupported( iox::log::LogLevel::FATAL, [&](const auto& logMessages) { ASSERT_THAT(logMessages.size(), Gt(1U)); diff --git a/iceoryx_hoofs/test/moduletests/test_vocabulary_expected.cpp b/iceoryx_hoofs/test/moduletests/test_vocabulary_expected.cpp index 5165b1ae92..8f9187740c 100644 --- a/iceoryx_hoofs/test/moduletests/test_vocabulary_expected.cpp +++ b/iceoryx_hoofs/test/moduletests/test_vocabulary_expected.cpp @@ -669,8 +669,7 @@ TEST_F(expected_test, AccessingValueOfLValueExpectedWhichContainsErrorWithArrowO expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut->m_a); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut->m_a); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingValueOfConstLValueExpectedWhichContainsErrorWithArrowOpLeadsToErrorHandlerCall) @@ -679,8 +678,7 @@ TEST_F(expected_test, AccessingValueOfConstLValueExpectedWhichContainsErrorWithA const expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut->m_a); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut->m_a); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingValueOfLValueExpectedWhichContainsErrorWithDerefOpLeadsToErrorHandlerCall) @@ -689,7 +687,7 @@ TEST_F(expected_test, AccessingValueOfLValueExpectedWhichContainsErrorWithDerefO expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { *sut; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { *sut; }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingValueOfConstLValueExpectedWhichContainsErrorWithDerefOpLeadsToErrorHandlerCall) @@ -698,7 +696,7 @@ TEST_F(expected_test, AccessingValueOfConstLValueExpectedWhichContainsErrorWithD const expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { *sut; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { *sut; }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingValueOfLValueExpectedWhichContainsErrorLeadsToErrorHandlerCall) @@ -707,7 +705,7 @@ TEST_F(expected_test, AccessingValueOfLValueExpectedWhichContainsErrorLeadsToErr expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { sut.value(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.value(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingValueOfConstLValueExpectedWhichContainsErrorLeadsToErrorHandlerCall) @@ -716,7 +714,7 @@ TEST_F(expected_test, AccessingValueOfConstLValueExpectedWhichContainsErrorLeads const expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { sut.value(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.value(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingValueOfRValueExpectedWhichContainsErrorLeadsToErrorHandlerCall) @@ -725,7 +723,7 @@ TEST_F(expected_test, AccessingValueOfRValueExpectedWhichContainsErrorLeadsToErr expected sut = err(TestError::ERROR1); - IOX_EXPECT_FATAL_FAILURE([&] { std::move(sut).value(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { std::move(sut).value(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingErrorOfLValueExpectedWhichContainsValueLeadsToErrorHandlerCall) @@ -735,7 +733,7 @@ TEST_F(expected_test, AccessingErrorOfLValueExpectedWhichContainsValueLeadsToErr constexpr int VALID_VALUE{42}; expected sut = ok(VALID_VALUE, VALID_VALUE); - IOX_EXPECT_FATAL_FAILURE([&] { sut.error(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.error(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingErrorOfConstLValueExpectedWhichContainsValueLeadsToErrorHandlerCall) @@ -745,7 +743,7 @@ TEST_F(expected_test, AccessingErrorOfConstLValueExpectedWhichContainsValueLeads constexpr int VALID_VALUE{42}; const expected sut = ok(VALID_VALUE, VALID_VALUE); - IOX_EXPECT_FATAL_FAILURE([&] { sut.error(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.error(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, AccessingErrorOfRValueExpectedWhichContainsValueLeadsToErrorHandlerCall) @@ -755,7 +753,7 @@ TEST_F(expected_test, AccessingErrorOfRValueExpectedWhichContainsValueLeadsToErr constexpr int VALID_VALUE{42}; expected sut = ok(VALID_VALUE, VALID_VALUE); - IOX_EXPECT_FATAL_FAILURE([&] { std::move(sut).error(); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { std::move(sut).error(); }, iox::er::ENFORCE_VIOLATION); } TEST_F(expected_test, TwoVoidValueTypeExpectedWithEqualErrorAreEqual) diff --git a/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp b/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp index 190d5f8b0d..1ace2955b3 100644 --- a/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp +++ b/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp @@ -2885,8 +2885,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaAtFails) { ::testing::Test::RecordProperty("TEST_ID", "89817818-f05a-4ceb-8663-9727d227048c"); - IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject.at(0U); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject.at(0U); }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaAtFails) @@ -2896,8 +2895,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaAtFails) using MyString = typename TestFixture::stringType; constexpr auto STRINGCAP = MyString().capacity(); - IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject.at(STRINGCAP); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject.at(STRINGCAP); }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessFirstPositionOfNonEmptyStringViaAtReturnsCorrectCharacter) @@ -2932,7 +2930,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaConstAtFails) constexpr auto STRINGCAP = MyString().capacity(); const string sut; - IOX_EXPECT_FATAL_FAILURE([&] { sut.at(0U); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.at(0U); }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaConstAtFails) @@ -2943,7 +2941,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaConstAtFails) constexpr auto STRINGCAP = MyString().capacity(); const string sut; - IOX_EXPECT_FATAL_FAILURE([&] { sut.at(STRINGCAP); }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.at(STRINGCAP); }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessFirstPositionOfNotEmptyStringViaConstAtReturnsCorrectCharacter) @@ -2972,7 +2970,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaSubscriptOperatorFail { ::testing::Test::RecordProperty("TEST_ID", "95ced457-1aec-47e9-a496-0197ea3f4600"); - IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject[0U]; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject[0U]; }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaSubscriptOperatorFails) @@ -2982,8 +2980,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaSubscriptOperatorFails) using MyString = typename TestFixture::stringType; constexpr auto STRINGCAP = MyString().capacity(); - IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject[STRINGCAP]; }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { this->testSubject[STRINGCAP]; }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessFirstPositionOfNotEmptyStringViaSubscriptOperatorReturnsCorrectCharacter) @@ -3018,7 +3015,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOfEmptyStringViaConstSubscriptOperato constexpr auto STRINGCAP = MyString().capacity(); const string sut; - IOX_EXPECT_FATAL_FAILURE([&] { sut[0U]; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut[0U]; }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaConstSubscriptOperatorFails) @@ -3029,7 +3026,7 @@ TYPED_TEST(stringTyped_test, AccessPositionOutOfBoundsViaConstSubscriptOperatorF constexpr auto STRINGCAP = MyString().capacity(); const string sut; - IOX_EXPECT_FATAL_FAILURE([&] { sut[STRINGCAP]; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut[STRINGCAP]; }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(stringTyped_test, AccessFirstPositionOfNotEmptyStringViaConstSubscriptOperatorReturnsCorrectCharacter) diff --git a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.hpp b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.hpp index 401ca36b8f..11edb6f9b8 100644 --- a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.hpp +++ b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.hpp @@ -17,9 +17,12 @@ #ifndef IOX_HOOFS_TESTING_FATAL_FAILURE_HPP #define IOX_HOOFS_TESTING_FATAL_FAILURE_HPP +#include "iox/error_reporting/error_kind.hpp" +#include "iox/error_reporting/types.hpp" #include "iox/function_ref.hpp" -#include "iox/optional.hpp" +#include "iox/logging.hpp" +#include "iceoryx_hoofs/testing/error_reporting/testing_support.hpp" #include "test.hpp" #include @@ -37,8 +40,7 @@ namespace testing /// @code /// TEST(MyTest, valueOnNulloptIsFatal) { /// iox::optional sut; -/// IOX_EXPECT_FATAL_FAILURE( -/// [&] { sut.value(); }, iox::er::ErrorCode::REQUIRED_CONDITION_VIOLATION)); +/// IOX_EXPECT_FATAL_FAILURE([&] { sut.value(); }, iox::er::ENFORCE_VIOLATION)); /// } /// @endcode /// @tparam[in] ErrorType The error type which is expected, e.g. 'iox::HoofsError' @@ -63,7 +65,6 @@ bool IOX_EXPECT_NO_FATAL_FAILURE(const function_ref testFunction); } // namespace testing } // namespace iox - #include "iceoryx_hoofs/testing/fatal_failure.inl" #endif // IOX_HOOFS_TESTING_FATAL_FAILURE_HPP diff --git a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl index cf38aec8bd..cf51733107 100644 --- a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl +++ b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl @@ -18,7 +18,6 @@ #ifndef IOX_HOOFS_TESTING_FATAL_FAILURE_INL #define IOX_HOOFS_TESTING_FATAL_FAILURE_INL -#include "iceoryx_hoofs/testing/error_reporting/testing_support.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" namespace iox @@ -26,18 +25,52 @@ namespace iox namespace testing { template +// NOLINTJUSTIFICATION The complexity comes from the expanded macros; without the expansions the function is quite readable +// NOLINTNEXTLINE(readability-function-size, readability-function-cognitive-complexity) inline bool IOX_EXPECT_FATAL_FAILURE(const function_ref testFunction, const ErrorType expectedError [[maybe_unused]]) { iox::testing::ErrorHandler::instance().reset(); runInTestThread([&] { testFunction(); }); IOX_TESTING_EXPECT_PANIC(); + auto hasPanicked = iox::testing::hasPanicked(); + + auto hasExpectedError{false}; + if constexpr (std::is_same_v) + { + hasExpectedError = hasPanicked; + if (!hasExpectedError) + { + IOX_LOG(ERROR, "Expected '" << iox::er::FatalKind::name << "' but it did not happen!"); + } + } + else if constexpr (std::is_same_v) + { + hasExpectedError = iox::testing::hasEnforceViolation(); + if (!hasExpectedError) + { + IOX_LOG(ERROR, "Expected '" << iox::er::EnforceViolationKind::name << "' but it did not happen!"); + } + } + else if constexpr (std::is_same_v) + { + hasExpectedError = iox::testing::hasAssertViolation(); + if (!hasExpectedError) + { + IOX_LOG(ERROR, "Expected '" << iox::er::AssertViolationKind::name << "' but it did not happen!"); + } + } + else + { + hasExpectedError = iox::testing::hasError(expectedError); + if (!hasExpectedError) + { + IOX_LOG(ERROR, "Expected an '" << expectedError << "' error but it did not happen!"); + } + } - /// @todo iox-#1032 'hasViolation' should not be necessary - auto hasExpectedError = - iox::testing::hasError(expectedError) || iox::testing::hasViolation() || iox::testing::hasPanicked(); EXPECT_TRUE(hasExpectedError); - return hasExpectedError; + return hasExpectedError && hasPanicked; } inline bool IOX_EXPECT_NO_FATAL_FAILURE(const function_ref testFunction) diff --git a/iceoryx_hoofs/time/source/duration.cpp b/iceoryx_hoofs/time/source/duration.cpp index 309f534eae..5cc437629e 100644 --- a/iceoryx_hoofs/time/source/duration.cpp +++ b/iceoryx_hoofs/time/source/duration.cpp @@ -17,6 +17,7 @@ #include "iox/duration.hpp" #include "iceoryx_platform/platform_correction.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" #include "iox/posix_call.hpp" @@ -52,7 +53,7 @@ struct timespec Duration::timespec(const TimeSpecReference reference) const noex // AXIVION Next Construct AutosarC++19_03-M0.1.2, AutosarC++19_03-M0.1.9, FaultDetection-DeadBranches : False positive! Branching depends on input parameter // AXIVION Next Construct AutosarC++19_03-M5.0.3: False positive! CLOCK_REALTIME and CLOCK_MONOTONIC are of type clockid_t const iox_clockid_t clockId{(reference == TimeSpecReference::Epoch) ? CLOCK_REALTIME : CLOCK_MONOTONIC}; - IOX_ENSURES_WITH_MSG( + IOX_ENFORCE( !IOX_POSIX_CALL(iox_clock_gettime)(clockId, &referenceTime).failureReturnValue(-1).evaluate().has_error(), "An error which should never happen occured during 'iox_clock_gettime'!"); diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl index c0e160e691..32abb8953e 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl @@ -17,6 +17,7 @@ #ifndef IOX_HOOFS_VOCABULARY_EXPECTED_INL #define IOX_HOOFS_VOCABULARY_EXPECTED_INL +#include "iox/assertions.hpp" #include "iox/expected.hpp" namespace iox @@ -148,7 +149,7 @@ inline ErrorType& expected::error_checked() & noexcept template inline const ErrorType& expected::error_checked() const& noexcept { - IOX_EXPECTS_WITH_MSG(has_error(), "Trying to access an error but a value is stored!"); + IOX_ENFORCE(has_error(), "Trying to access an error but a value is stored!"); return m_store.error_unchecked(); } @@ -198,7 +199,7 @@ template template inline const enable_if_non_void_t& expected::value_checked() const& noexcept { - IOX_EXPECTS_WITH_MSG(has_value(), "Trying to access a value but an error is stored!"); + IOX_ENFORCE(has_value(), "Trying to access a value but an error is stored!"); return m_store.value_unchecked(); } diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/optional.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/optional.inl index 2ae0a6f65c..309abee25f 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/optional.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/optional.inl @@ -239,7 +239,7 @@ inline void optional::reset() noexcept template inline T& optional::value() & noexcept { - IOX_EXPECTS(has_value()); + IOX_ENFORCE(has_value(), "Calling 'value' on an 'optional' which does not have a value"); // AXIVION Next Construct AutosarC++19_03-M5.2.8 : The optional has the type T defined // during compile time and the type is unchangeable during the lifetime of the object. // All accesses to the underlying data is done via the same static type and therefore the @@ -258,7 +258,7 @@ inline const T& optional::value() const& noexcept template inline T&& optional::value() && noexcept { - IOX_EXPECTS(has_value()); + IOX_ENFORCE(has_value(), "Calling 'value' on an 'optional' which does not have a value"); // AXIVION Next Construct AutosarC++19_03-M5.2.8 : The optional has the type T defined // during compile time and the type is unchangeable during the lifetime of the object. // All accesses to the underlying data is done via the same static type and therefore the diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/span_iterator.hpp b/iceoryx_hoofs/vocabulary/include/iox/detail/span_iterator.hpp index 2cd87fb2e1..b65aa2eaa6 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/span_iterator.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/span_iterator.hpp @@ -17,7 +17,7 @@ #ifndef IOX_HOOFS_VOCABULARY_SPAN_ITERATOR_HPP #define IOX_HOOFS_VOCABULARY_SPAN_ITERATOR_HPP -// Use 'assert's as 'IOX_EXPECTS' is not useable inside 'constexpr' functions +// Use 'assert's as 'IOX_ASSERT'/'IOX_ENFORCE' is not useable inside 'constexpr' functions #include #include // for reverse_iterator, distance, random_access_... diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl index a0d33431f4..5bcb8491bb 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl @@ -18,9 +18,11 @@ #ifndef IOX_HOOFS_VOCABULARY_STRING_INL #define IOX_HOOFS_VOCABULARY_STRING_INL -#include "iox/logging.hpp" #include "iox/string.hpp" +#include "iox/assertions.hpp" +#include "iox/logging.hpp" + namespace iox { template @@ -600,7 +602,7 @@ inline constexpr char& string::at(const uint64_t pos) noexcept template inline constexpr const char& string::at(const uint64_t pos) const noexcept { - IOX_EXPECTS_WITH_MSG((pos < size()), "Out of bounds access!"); + IOX_ENFORCE((pos < size()), "Out of bounds access!"); return m_rawstring[pos]; } diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/variant_internal.hpp b/iceoryx_hoofs/vocabulary/include/iox/detail/variant_internal.hpp index 040826e3fd..ceae1b9cd2 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/variant_internal.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/variant_internal.hpp @@ -178,7 +178,7 @@ struct call_at_index } else { - IOX_EXPECTS_WITH_MSG(false, "Could not call destructor for variant element"); + IOX_PANIC("Could not call destructor for variant element"); } } @@ -190,7 +190,7 @@ struct call_at_index } else { - IOX_EXPECTS_WITH_MSG(false, "Could not call move assignment for variant element"); + IOX_PANIC("Could not call move assignment for variant element"); } } @@ -202,7 +202,7 @@ struct call_at_index } else { - IOX_EXPECTS_WITH_MSG(false, "Could not call move constructor for variant element"); + IOX_PANIC("Could not call move constructor for variant element"); } } @@ -214,7 +214,7 @@ struct call_at_index } else { - IOX_EXPECTS_WITH_MSG(false, "Could not call copy assignment for variant element"); + IOX_PANIC("Could not call copy assignment for variant element"); } } @@ -226,7 +226,7 @@ struct call_at_index } else { - IOX_EXPECTS_WITH_MSG(false, "Could not call copy constructor for variant element"); + IOX_PANIC("Could not call copy constructor for variant element"); } } @@ -236,7 +236,7 @@ struct call_at_index { return *reinterpret_cast(lhs) == *reinterpret_cast(rhs); } - IOX_EXPECTS_WITH_MSG(false, "Could not call equality operator for variant element"); + IOX_PANIC("Could not call equality operator for variant element"); return false; } }; diff --git a/iceoryx_hoofs/vocabulary/include/iox/not_null.hpp b/iceoryx_hoofs/vocabulary/include/iox/not_null.hpp index e54a10bb0b..fb9bc2113f 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/not_null.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/not_null.hpp @@ -32,7 +32,7 @@ struct not_null not_null(T t) noexcept : m_value(t) { - IOX_EXPECTS(t != nullptr); + IOX_ENFORCE(t != nullptr, "Parameter must not be a 'nullptr'"); } // AXIVION Next Construct AutosarC++19_03-A13.5.2,AutosarC++19_03-A13.5.3:this should behave like a pointer which never can be nullptr, diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/segment_manager.inl b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/segment_manager.inl index b25cd54e9a..8c8888cd6b 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/segment_manager.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/segment_manager.inl @@ -21,6 +21,7 @@ #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "iceoryx_posh/internal/mepoo/segment_manager.hpp" #include "iceoryx_posh/internal/posh_error_reporting.hpp" +#include "iox/assertions.hpp" namespace iox { @@ -31,7 +32,14 @@ inline SegmentManager::SegmentManager(const SegmentConfig& segmentC BumpAllocator* managementAllocator) noexcept : m_managementAllocator(managementAllocator) { - IOX_EXPECTS(segmentConfig.m_sharedMemorySegments.capacity() <= m_segmentContainer.capacity()); + if (segmentConfig.m_sharedMemorySegments.capacity() > m_segmentContainer.capacity()) + { + IOX_LOG(FATAL, + "Trying to add " << segmentConfig.m_sharedMemorySegments.capacity() + << " segments while the 'SegmentManager' can manage only " + << m_segmentContainer.capacity()); + IOX_PANIC("Too many segments"); + } for (const auto& segmentEntry : segmentConfig.m_sharedMemorySegments) { createSegment(segmentEntry); diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.hpp index 2720b6ddaa..c5de76cb24 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.hpp @@ -18,6 +18,7 @@ #ifndef IOX_POSH_POPO_BUILDING_BLOCKS_VARIANT_QUEUE_HPP #define IOX_POSH_POPO_BUILDING_BLOCKS_VARIANT_QUEUE_HPP +#include "iox/assertions.hpp" #include "iox/detail/mpmc_resizeable_lockfree_queue.hpp" #include "iox/detail/spsc_fifo.hpp" #include "iox/detail/spsc_sofi.hpp" diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.inl index 327dd18b31..9505508d3b 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/variant_queue.inl @@ -204,8 +204,7 @@ inline bool VariantQueue::setCapacity(const uint64_t newCap case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { /// @todo iox-#1147 must be implemented for FiFo - IOX_EXPECTS(false); - return false; + IOX_PANIC("'setCapacity' for 'SpscFifo' is not yet implemented"); } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/wait_set.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/wait_set.inl index 12ad83f8bb..686120b6f7 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/wait_set.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/wait_set.inl @@ -305,7 +305,7 @@ inline void WaitSet::removeTrigger(const uint64_t uniqueTriggerId) noe { trigger->invalidate(); trigger.reset(); - IOX_ENSURES(m_indexRepository.push(uniqueTriggerId)); + IOX_ENFORCE(m_indexRepository.push(uniqueTriggerId), "Released trigger ID to the index repository!"); return; } } @@ -348,7 +348,8 @@ WaitSet::createVectorWithTriggeredTriggers() noexcept if (!doRemoveNotificationId && trigger->isStateConditionSatisfied()) { - IOX_EXPECTS(triggers.push_back(&m_triggerArray[index]->getNotificationInfo())); + IOX_ENFORCE(triggers.push_back(&m_triggerArray[index]->getNotificationInfo()), + "Adding trigger to the notification vector!"); doRemoveNotificationId = (trigger->getTriggerType() == TriggerType::EVENT_BASED); } diff --git a/iceoryx_posh/include/iceoryx_posh/internal/posh_error_reporting.hpp b/iceoryx_posh/include/iceoryx_posh/internal/posh_error_reporting.hpp index 4caaa5d236..64dd88a0e2 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/posh_error_reporting.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/posh_error_reporting.hpp @@ -31,6 +31,7 @@ // additional includes #include "iox/error_reporting/types.hpp" +#include "iox/log/logstream.hpp" namespace iox { @@ -182,6 +183,12 @@ enum class PoshError : iox::er::ErrorCode::type const char* asStringLiteral(const PoshError error) noexcept; +inline log::LogStream& operator<<(log::LogStream& stream, PoshError value) noexcept +{ + stream << asStringLiteral(value); + return stream; +} + class PoshErrorType { public: diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.hpp index f555984fae..a1923a42e2 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.hpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "iceoryx_posh/internal/popo/ports/publisher_port_data.hpp" #include "iceoryx_posh/roudi/introspection_types.hpp" +#include "iox/assertions.hpp" #include "iox/detail/periodic_task.hpp" #include "iox/fixed_position_container.hpp" #include "iox/function.hpp" diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.inl index ba3cd59153..e3b19412b7 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/port_introspection.inl @@ -74,9 +74,9 @@ inline bool PortIntrospection::registerPublisherP template inline void PortIntrospection::run() noexcept { - IOX_EXPECTS(m_publisherPort.has_value()); - IOX_EXPECTS(m_publisherPortThroughput.has_value()); - IOX_EXPECTS(m_publisherPortSubscriberPortsData.has_value()); + IOX_ENFORCE(m_publisherPort.has_value(), "Port must be initialized"); + IOX_ENFORCE(m_publisherPortThroughput.has_value(), "Port must be initialized"); + IOX_ENFORCE(m_publisherPortSubscriberPortsData.has_value(), "Port must be initialized"); // this is a field, there needs to be a sample before activate is called sendPortData(); diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.hpp index 8913ffb3cd..85719a1a47 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.hpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp" #include "iceoryx_posh/roudi/introspection_types.hpp" +#include "iox/assertions.hpp" #include "iox/detail/periodic_task.hpp" #include "iox/function.hpp" #include "iox/list.hpp" diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.inl index b24dbb6b3f..ba61dfde2c 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/process_introspection.inl @@ -156,7 +156,7 @@ template inline void ProcessIntrospection::run() noexcept { // @todo iox-#518 error handling for non debug builds - IOX_EXPECTS(m_publisherPort.has_value()); + IOX_ENFORCE(m_publisherPort.has_value(), "Port must be initialized"); // this is a field, there needs to be a sample before activate is called send(); diff --git a/iceoryx_posh/include/iceoryx_posh/popo/wait_set.hpp b/iceoryx_posh/include/iceoryx_posh/popo/wait_set.hpp index 8fa7ab3b93..7f949b6ca3 100644 --- a/iceoryx_posh/include/iceoryx_posh/popo/wait_set.hpp +++ b/iceoryx_posh/include/iceoryx_posh/popo/wait_set.hpp @@ -28,6 +28,7 @@ #include "iceoryx_posh/popo/trigger_handle.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iox/algorithm.hpp" +#include "iox/assertions.hpp" #include "iox/function.hpp" #include "iox/function_ref.hpp" #include "iox/stack.hpp" diff --git a/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp b/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp index de0845c1de..c4dc6c2052 100644 --- a/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp +++ b/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp @@ -17,6 +17,7 @@ #include "iceoryx_posh/roudi_env/runtime_test_interface.hpp" #include "iceoryx_posh/internal/runtime/posh_runtime_impl.hpp" +#include "iox/assertions.hpp" namespace iox { @@ -36,9 +37,9 @@ RuntimeTestInterface::RuntimeTestInterface() { std::lock_guard lock(RuntimeTestInterface::s_runtimeAccessMutex); - IOX_EXPECTS_WITH_MSG(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory, - "The RuntimeTestInterface can only be used in combination with the " - "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); + IOX_ENFORCE(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory, + "The RuntimeTestInterface can only be used in combination with the " + "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); PoshRuntime::setRuntimeFactory(RuntimeTestInterface::runtimeFactoryGetInstance); } @@ -100,8 +101,10 @@ PoshRuntime& RuntimeTestInterface::runtimeFactoryGetInstance(optional @@ -50,17 +50,16 @@ MemPool::MemPool(const greater_or_equal chunkS { if (isMultipleOfAlignment(chunkSize)) { - IOX_EXPECTS_WITH_MSG(m_chunkSize <= std::numeric_limits::max() / m_numberOfChunks, - "Chunk size * number of chunks must not exceed the maximum value of uint64_t!"); - auto allocationResult = chunkMemoryAllocator.allocate(static_cast(m_numberOfChunks) * m_chunkSize, - CHUNK_MEMORY_ALIGNMENT); - IOX_EXPECTS(allocationResult.has_value()); - m_rawMemory = static_cast(allocationResult.value()); - - allocationResult = - managementAllocator.allocate(freeList_t::requiredIndexMemorySize(m_numberOfChunks), CHUNK_MEMORY_ALIGNMENT); - IOX_EXPECTS(allocationResult.has_value()); - auto* memoryFreeList = allocationResult.value(); + IOX_ENFORCE(m_chunkSize <= std::numeric_limits::max() / m_numberOfChunks, + "Chunk size * number of chunks must not exceed the maximum value of uint64_t!"); + + m_rawMemory = static_cast( + chunkMemoryAllocator.allocate(static_cast(m_numberOfChunks) * m_chunkSize, CHUNK_MEMORY_ALIGNMENT) + .expect("Allocating raw memory for 'MemPool'")); + + auto* memoryFreeList = + managementAllocator.allocate(freeList_t::requiredIndexMemorySize(m_numberOfChunks), CHUNK_MEMORY_ALIGNMENT) + .expect("Allocating free list memory for 'MemPool'"); m_freeIndices.init(static_cast(memoryFreeList), m_numberOfChunks); } else @@ -114,7 +113,14 @@ MemPool::pointerToIndex(const void* const chunk, const uint64_t chunkSize, const { const auto offset = static_cast(static_cast(chunk) - static_cast(rawMemoryBase)); - IOX_EXPECTS(offset % chunkSize == 0); + if (offset % chunkSize != 0) + { + IOX_LOG(FATAL, + "Trying to convert a pointer to an index which is not aligned to the array! Base address: " + << iox::log::hex(rawMemoryBase) << "; item size: " << chunkSize + << "; pointer address: " << iox::log::hex(chunk)); + IOX_PANIC("Invalid access"); + } const auto index = static_cast(offset / chunkSize); return index; @@ -122,10 +128,26 @@ MemPool::pointerToIndex(const void* const chunk, const uint64_t chunkSize, const void MemPool::freeChunk(const void* chunk) noexcept { + const auto memPoolStartAddress = m_rawMemory.get(); const auto offsetToLastChunk = m_chunkSize * (m_numberOfChunks - 1U); - IOX_EXPECTS(m_rawMemory.get() <= chunk && chunk <= static_cast(m_rawMemory.get()) + offsetToLastChunk); + if (chunk < memPoolStartAddress) + { + IOX_LOG(FATAL, + "Try to free chunk with address " << iox::log::hex(chunk) << " while the memory pool starts at address " + << iox::log::hex(memPoolStartAddress)); + IOX_PANIC("Invalid chunk to free"); + } + + if (chunk > static_cast(memPoolStartAddress) + offsetToLastChunk) + { + IOX_LOG(FATAL, + "Try to free chunk with address " << iox::log::hex(chunk) + << " while the last valid memory pool address is " + << iox::log::hex(memPoolStartAddress)); + IOX_PANIC("Invalid chunk to free"); + } - const auto index = pointerToIndex(chunk, m_chunkSize, m_rawMemory.get()); + const auto index = pointerToIndex(chunk, m_chunkSize, memPoolStartAddress); if (!m_freeIndices.push(index)) { diff --git a/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp b/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp index 69173df233..32116ac622 100644 --- a/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp +++ b/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_posh/internal/mepoo/shm_safe_unmanaged_chunk.hpp" +#include "iox/assertions.hpp" namespace iox { @@ -44,8 +45,8 @@ ShmSafeUnmanagedChunk::ShmSafeUnmanagedChunk(mepoo::SharedChunk chunk) noexcept RelativePointer ptr{chunk.release()}; auto id = ptr.getId(); auto offset = ptr.getOffset(); - IOX_ENSURES(id <= RelativePointerData::ID_RANGE && "RelativePointer id must fit into id type!"); - IOX_ENSURES(offset <= RelativePointerData::OFFSET_RANGE && "RelativePointer offset must fit into offset type!"); + IOX_ENFORCE(id <= RelativePointerData::ID_RANGE, "RelativePointer id must fit into id type!"); + IOX_ENFORCE(offset <= RelativePointerData::OFFSET_RANGE, "RelativePointer offset must fit into offset type!"); /// @todo iox-#1196 Unify types to uint64_t m_chunkManagement = RelativePointerData(static_cast(id), offset); } diff --git a/iceoryx_posh/source/popo/listener.cpp b/iceoryx_posh/source/popo/listener.cpp index 6c934c4c22..19c1c6fdad 100644 --- a/iceoryx_posh/source/popo/listener.cpp +++ b/iceoryx_posh/source/popo/listener.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_posh/popo/listener.hpp" +#include "iox/assertions.hpp" namespace iox { @@ -92,7 +93,7 @@ bool Listener::IndexManager_t::pop(uint32_t& value) noexcept void Listener::IndexManager_t::push(const uint32_t index) noexcept { - IOX_EXPECTS(m_loffli.push(index)); + IOX_ENFORCE(m_loffli.push(index), "Releasing used index back to free list"); --m_indicesInUse; } diff --git a/iceoryx_posh/source/popo/ports/client_port_roudi.cpp b/iceoryx_posh/source/popo/ports/client_port_roudi.cpp index 61581c6211..35e1e47bb2 100644 --- a/iceoryx_posh/source/popo/ports/client_port_roudi.cpp +++ b/iceoryx_posh/source/popo/ports/client_port_roudi.cpp @@ -17,6 +17,7 @@ #include "iceoryx_posh/internal/popo/ports/client_port_roudi.hpp" #include "iceoryx_posh/internal/posh_error_reporting.hpp" +#include "iox/assertions.hpp" namespace iox { @@ -151,11 +152,11 @@ ClientPortRouDi::handleCaProMessageForStateConnectRequested(const capro::CaproMe switch (caProMessage.m_type) { case capro::CaproMessageType::ACK: - IOX_EXPECTS_WITH_MSG(caProMessage.m_chunkQueueData != nullptr, "Invalid request queue passed to client"); - IOX_EXPECTS(!m_chunkSender - .tryAddQueue(static_cast(caProMessage.m_chunkQueueData), - caProMessage.m_historyCapacity) - .has_error()); + IOX_ENFORCE(caProMessage.m_chunkQueueData != nullptr, "Invalid request queue passed to client"); + m_chunkSender + .tryAddQueue(static_cast(caProMessage.m_chunkQueueData), + caProMessage.m_historyCapacity) + .expect("Adding server request queue to client"); getMembers()->m_connectionState.store(ConnectionState::CONNECTED, std::memory_order_relaxed); return nullopt; diff --git a/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp b/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp index 4db8f04a0f..a58e141c17 100644 --- a/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/internal/mepoo/memory_manager.hpp" #include "iox/algorithm.hpp" +#include "iox/assertions.hpp" #include "iox/bump_allocator.hpp" #include "iox/memory.hpp" @@ -53,9 +54,8 @@ uint64_t MemPoolCollectionMemoryBlock::alignment() const noexcept void MemPoolCollectionMemoryBlock::onMemoryAvailable(not_null memory) noexcept { BumpAllocator allocator(memory, size()); - auto allocationResult = allocator.allocate(sizeof(mepoo::MemoryManager), alignof(mepoo::MemoryManager)); - IOX_EXPECTS(allocationResult.has_value()); - auto* memoryManager = allocationResult.value(); + auto* memoryManager = allocator.allocate(sizeof(mepoo::MemoryManager), alignof(mepoo::MemoryManager)) + .expect("There should be enough memory for the 'MemoryManager'"); m_memoryManager = new (memoryManager) mepoo::MemoryManager; m_memoryManager->configureMemoryManager(m_memPoolConfig, allocator, allocator); diff --git a/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp b/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp index 61ff9267ea..17434e2fe9 100644 --- a/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp @@ -17,6 +17,7 @@ #include "iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp" +#include "iox/assertions.hpp" #include "iox/bump_allocator.hpp" #include "iox/memory.hpp" @@ -50,9 +51,8 @@ uint64_t MemPoolSegmentManagerMemoryBlock::alignment() const noexcept void MemPoolSegmentManagerMemoryBlock::onMemoryAvailable(not_null memory) noexcept { BumpAllocator allocator(memory, size()); - auto allocationResult = allocator.allocate(sizeof(mepoo::SegmentManager<>), alignof(mepoo::SegmentManager<>)); - IOX_EXPECTS(allocationResult.has_value()); - auto* segmentManager = allocationResult.value(); + auto* segmentManager = allocator.allocate(sizeof(mepoo::SegmentManager<>), alignof(mepoo::SegmentManager<>)) + .expect("There should be enough memory for the 'SegmentManager'"); m_segmentManager = new (segmentManager) mepoo::SegmentManager<>(m_segmentConfig, &allocator); } diff --git a/iceoryx_posh/source/roudi/port_manager.cpp b/iceoryx_posh/source/roudi/port_manager.cpp index 8f666a14ed..5ad13497e9 100644 --- a/iceoryx_posh/source/roudi/port_manager.cpp +++ b/iceoryx_posh/source/roudi/port_manager.cpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/internal/posh_error_reporting.hpp" #include "iceoryx_posh/popo/publisher_options.hpp" #include "iceoryx_posh/roudi/introspection_types.hpp" +#include "iox/assertions.hpp" #include "iox/logging.hpp" #include "iox/vector.hpp" @@ -218,9 +219,10 @@ void PortManager::doDiscoveryForSubscriberPort(SubscriberPortType& subscriberPor << caproMessage.m_serviceDescription << "'!"); capro::CaproMessage nackMessage(capro::CaproMessageType::NACK, subscriberPort.getCaProServiceDescription()); - auto returnMessage = subscriberPort.dispatchCaProMessageAndGetPossibleResponse(nackMessage); - // No response on NACK messages - IOX_ENSURES(!returnMessage.has_value()); + subscriberPort.dispatchCaProMessageAndGetPossibleResponse(nackMessage).and_then([](auto& response) { + IOX_LOG(FATAL, "Got response '" << response.m_type << "'"); + IOX_PANIC("Expected no response on NACK messages"); + }); } } else @@ -238,7 +240,7 @@ void PortManager::doDiscoveryForSubscriberPort(SubscriberPortType& subscriberPor void PortManager::destroyClientPort(popo::ClientPortData* const clientPortData) noexcept { - IOX_ENSURES(clientPortData != nullptr && "clientPortData must not be a nullptr"); + IOX_ENFORCE(clientPortData != nullptr, "clientPortData must not be a nullptr"); // create temporary client ports to orderly shut this client down popo::ClientPortRouDi clientPortRoudi(*clientPortData); @@ -248,7 +250,7 @@ void PortManager::destroyClientPort(popo::ClientPortData* const clientPortData) // process DISCONNECT for this client in RouDi and distribute it clientPortRoudi.tryGetCaProMessage().and_then([this, &clientPortRoudi](auto caproMessage) { - IOX_ENSURES(caproMessage.m_type == capro::CaproMessageType::DISCONNECT); + IOX_ENFORCE(caproMessage.m_type == capro::CaproMessageType::DISCONNECT, "Received wrong 'CaproMessageType'!"); /// @todo iox-#1128 report to port introspection this->sendToAllMatchingServerPorts(caproMessage, clientPortRoudi); @@ -300,9 +302,10 @@ void PortManager::doDiscoveryForClientPort(popo::ClientPortRouDi& clientPort) no << clientPort.getRuntimeName() << "' and with service description '" << caproMessage.m_serviceDescription << "'!"); capro::CaproMessage nackMessage(capro::CaproMessageType::NACK, clientPort.getCaProServiceDescription()); - auto returnMessage = clientPort.dispatchCaProMessageAndGetPossibleResponse(nackMessage); - // No response on NACK messages - IOX_ENSURES(!returnMessage.has_value()); + clientPort.dispatchCaProMessageAndGetPossibleResponse(nackMessage).and_then([](auto& response) { + IOX_LOG(FATAL, "Got response '" << response.m_type << "'"); + IOX_PANIC("Expected no response on NACK messages"); + }); } } else @@ -331,7 +334,7 @@ void PortManager::makeAllServerPortsToStopOffer() noexcept void PortManager::destroyServerPort(popo::ServerPortData* const serverPortData) noexcept { - IOX_ENSURES(serverPortData != nullptr && "serverPortData must not be a nullptr"); + IOX_ENFORCE(serverPortData != nullptr, "serverPortData must not be a nullptr"); // create temporary server ports to orderly shut this server down popo::ServerPortRouDi serverPortRoudi{*serverPortData}; @@ -341,8 +344,9 @@ void PortManager::destroyServerPort(popo::ServerPortData* const serverPortData) // process STOP_OFFER for this server in RouDi and distribute it serverPortRoudi.tryGetCaProMessage().and_then([this, &serverPortRoudi](auto caproMessage) { - IOX_ENSURES(caproMessage.m_type == capro::CaproMessageType::STOP_OFFER); - IOX_ENSURES(caproMessage.m_serviceType == capro::CaproServiceType::SERVER); + IOX_ENFORCE(caproMessage.m_type == capro::CaproMessageType::STOP_OFFER, "Received wrong 'CaproMessageType'!"); + IOX_ENFORCE(caproMessage.m_serviceType == capro::CaproServiceType::SERVER, + "Received wrong 'CaproServiceType'!"); /// @todo iox-#1128 report to port introspection this->removeServerFromServiceRegistry(caproMessage.m_serviceDescription); @@ -568,13 +572,12 @@ bool PortManager::sendToAllMatchingPublisherPorts(const capro::CaproMessage& mes if (publisherResponse.has_value()) { // send response to subscriber port - auto returnMessage = - subscriberSource.dispatchCaProMessageAndGetPossibleResponse(publisherResponse.value()); + subscriberSource.dispatchCaProMessageAndGetPossibleResponse(publisherResponse.value()) + .and_then([](auto& response) { + IOX_LOG(FATAL, "Got response '" << response.m_type << "'"); + IOX_PANIC("Expected no response on ACK or NACK messages"); + }); - // ACK or NACK are sent back to the subscriber port, no further response from this one expected - IOX_ENSURES(!returnMessage.has_value()); - - // inform introspection m_portIntrospection.reportMessage(publisherResponse.value(), subscriberSource.getUniqueID()); } publisherFound = true; @@ -609,7 +612,7 @@ void PortManager::sendToAllMatchingSubscriberPorts(const capro::CaproMessage& me if (subscriberResponse.has_value()) { // we only expect reaction on OFFER - IOX_EXPECTS(capro::CaproMessageType::OFFER == message.m_type); + IOX_ENFORCE(capro::CaproMessageType::OFFER == message.m_type, "Received wrong 'CaproMessageType'!"); // inform introspection m_portIntrospection.reportMessage(subscriberResponse.value()); @@ -619,13 +622,12 @@ void PortManager::sendToAllMatchingSubscriberPorts(const capro::CaproMessage& me if (publisherResponse.has_value()) { // sende responsee to subscriber port - auto returnMessage = - subscriberPort.dispatchCaProMessageAndGetPossibleResponse(publisherResponse.value()); - - // ACK or NACK are sent back to the subscriber port, no further response from this one expected - IOX_ENSURES(!returnMessage.has_value()); + subscriberPort.dispatchCaProMessageAndGetPossibleResponse(publisherResponse.value()) + .and_then([](auto& response) { + IOX_LOG(FATAL, "Got response '" << response.m_type << "'"); + IOX_PANIC("Expected no response on ACK or NACK messages"); + }); - // inform introspection m_portIntrospection.reportMessage(publisherResponse.value()); } } @@ -665,7 +667,8 @@ void PortManager::sendToAllMatchingClientPorts(const capro::CaproMessage& messag if (clientResponse.has_value()) { // we only expect reaction on CONNECT - IOX_EXPECTS(capro::CaproMessageType::CONNECT == clientResponse.value().m_type); + IOX_ENFORCE(capro::CaproMessageType::CONNECT == clientResponse.value().m_type, + "Received wrong 'CaproMessageType'!"); /// @todo iox-#518 inform port introspection about client @@ -673,11 +676,12 @@ void PortManager::sendToAllMatchingClientPorts(const capro::CaproMessage& messag auto serverResponse = serverSource.dispatchCaProMessageAndGetPossibleResponse(clientResponse.value()); if (serverResponse.has_value()) { - // sende responsee to client port - auto returnMessage = clientPort.dispatchCaProMessageAndGetPossibleResponse(serverResponse.value()); - - // ACK or NACK are sent back to the client port, no further response from this one expected - IOX_ENSURES(!returnMessage.has_value()); + // send response to client port + clientPort.dispatchCaProMessageAndGetPossibleResponse(serverResponse.value()) + .and_then([](auto& response) { + IOX_LOG(FATAL, "Got response '" << response.m_type << "'"); + IOX_PANIC("Expected no response on ACK or NACK messages"); + }); /// @todo iox-#1128 inform port introspection about server } @@ -702,10 +706,11 @@ bool PortManager::sendToAllMatchingServerPorts(const capro::CaproMessage& messag if (serverResponse.has_value()) { // send response to client port - auto returnMessage = clientSource.dispatchCaProMessageAndGetPossibleResponse(serverResponse.value()); - - // ACK or NACK are sent back to the client port, no further response from this one expected - IOX_ENSURES(!returnMessage.has_value()); + clientSource.dispatchCaProMessageAndGetPossibleResponse(serverResponse.value()) + .and_then([](auto& response) { + IOX_LOG(FATAL, "Got response '" << response.m_type << "'"); + IOX_PANIC("Expected no response on ACK or NACK messages"); + }); /// @todo iox-#1128 inform port introspection about client } @@ -872,7 +877,7 @@ void PortManager::destroyPublisherPort(PublisherPortRouDiType::MemberType_t* con // process STOP_OFFER for this publisher in RouDi and distribute it publisherPortRoudi.tryGetCaProMessage().and_then([this, &publisherPortRoudi](auto caproMessage) { - IOX_ENSURES(caproMessage.m_type == capro::CaproMessageType::STOP_OFFER); + IOX_ENFORCE(caproMessage.m_type == capro::CaproMessageType::STOP_OFFER, "Received wrong 'CaproMessageType'!"); m_portIntrospection.reportMessage(caproMessage); this->removePublisherFromServiceRegistry(caproMessage.m_serviceDescription); @@ -902,7 +907,7 @@ void PortManager::destroySubscriberPort(SubscriberPortType::MemberType_t* const // process UNSUB for this subscriber in RouDi and distribute it subscriberPortRoudi.tryGetCaProMessage().and_then([this, &subscriberPortRoudi](auto caproMessage) { - IOX_ENSURES(caproMessage.m_type == capro::CaproMessageType::UNSUB); + IOX_ENFORCE(caproMessage.m_type == capro::CaproMessageType::UNSUB, "Received wrong 'CaproMessageType'!"); m_portIntrospection.reportMessage(caproMessage); this->sendToAllMatchingPublisherPorts(caproMessage, subscriberPortRoudi); diff --git a/iceoryx_posh/source/runtime/heartbeat.cpp b/iceoryx_posh/source/runtime/heartbeat.cpp index 5e66011241..6b35bd67dc 100644 --- a/iceoryx_posh/source/runtime/heartbeat.cpp +++ b/iceoryx_posh/source/runtime/heartbeat.cpp @@ -53,7 +53,7 @@ uint64_t Heartbeat::milliseconds_since_epoch() noexcept { }; - IOX_ENSURES_WITH_MSG( + IOX_ENFORCE( !IOX_POSIX_CALL(iox_clock_gettime)(CLOCK_MONOTONIC, &timepoint).failureReturnValue(-1).evaluate().has_error(), "An error which should never happen occured during 'iox_clock_gettime'!"); diff --git a/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp b/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp index b39aafd5aa..cd890c24eb 100644 --- a/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp +++ b/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp @@ -18,6 +18,7 @@ #include "iceoryx_posh/internal/runtime/ipc_runtime_interface.hpp" #include "iceoryx_posh/internal/posh_error_reporting.hpp" #include "iceoryx_posh/version/version_info.hpp" +#include "iox/assertions.hpp" #include "iox/detail/convert.hpp" #include "iox/into.hpp" #include "iox/posix_user.hpp" @@ -89,7 +90,7 @@ IpcRuntimeInterface::IpcRuntimeInterface(const RuntimeName_t& roudiName, IpcMessage sendBuffer; int pid = getpid(); - IOX_EXPECTS(pid >= 0); + IOX_ENFORCE(pid >= 0, "'getpid' must always return a positive number"); sendBuffer << IpcMessageTypeToString(IpcMessageType::REG) << m_runtimeName << convert::toString(pid) << convert::toString(PosixUser::getUserOfCurrentProcess().getID()) << convert::toString(transmissionTimestamp) @@ -147,8 +148,8 @@ IpcRuntimeInterface::IpcRuntimeInterface(const RuntimeName_t& roudiName, UntypedRelativePointer::offset_t IpcRuntimeInterface::getSegmentManagerAddressOffset() const noexcept { - IOX_ENSURES(m_segmentManagerAddressOffset.has_value() - && "No segment manager available! Should have been fetched in the c'tor"); + IOX_ENFORCE(m_segmentManagerAddressOffset.has_value(), + "No segment manager available! Should have been fetched in the c'tor"); return m_segmentManagerAddressOffset.value(); } diff --git a/iceoryx_posh/test/moduletests/test_capro_service.cpp b/iceoryx_posh/test/moduletests/test_capro_service.cpp index 389574d595..c15a06b6d5 100644 --- a/iceoryx_posh/test/moduletests/test_capro_service.cpp +++ b/iceoryx_posh/test/moduletests/test_capro_service.cpp @@ -134,7 +134,7 @@ TEST_F(ServiceDescription_test, ClassHashSubsriptOperatorOutOfBoundsFails) testHash[3] = 4U; - IOX_EXPECT_FATAL_FAILURE([&] { testHash[4] = 5U; }, iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { testHash[4] = 5U; }, iox::er::FATAL); } /// END CLASSHASH TESTS diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp index 5c454972a6..0152bd535b 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp @@ -370,12 +370,12 @@ TEST(ChunkHeader_test, ConstructorTerminatesWhenUserPayloadSizeExceedsChunkSize) ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { ChunkHeader sut(CHUNK_SIZE, chunkSettings); ; }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::ENFORCE_VIOLATION); } // BEGIN PARAMETERIZED TESTS FOR CHUNK HEADER diff --git a/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp b/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp index 99595466eb..80d0c07ba5 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp @@ -440,8 +440,7 @@ TEST_F(MemoryManager_test, addMemPoolWithChunkCountZeroShouldFail) ::testing::Test::RecordProperty("TEST_ID", "be653b65-a2d1-42eb-98b5-d161c6ba7c08"); mempoolconf.addMemPool({32, 0}); - IOX_EXPECT_FATAL_FAILURE([&] { sut->configureMemoryManager(mempoolconf, *allocator, *allocator); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut->configureMemoryManager(mempoolconf, *allocator, *allocator); }, iox::er::FATAL); } TEST(MemoryManagerEnumString_test, asStringLiteralConvertsEnumValuesToStrings) diff --git a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp index bbc1f59588..cf5d151587 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp @@ -177,11 +177,11 @@ TEST_F(MemPool_test, MempoolCtorWhenChunkSizeIsSmallerThanChunkMemoryAlignmentGe ::testing::Test::RecordProperty("TEST_ID", "52df897a-0847-476c-9d2f-99cb16432199"); constexpr uint32_t CHUNK_SIZE_SMALLER_THAN_MEMORY_ALIGNMENT = iox::mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT - 1U; - IOX_EXPECT_FATAL_FAILURE( + IOX_EXPECT_FATAL_FAILURE( [&] { iox::mepoo::MemPool sut(CHUNK_SIZE_SMALLER_THAN_MEMORY_ALIGNMENT, NUMBER_OF_CHUNKS, allocator, allocator); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + iox::er::FATAL); } TEST_F(MemPool_test, MempoolCtorWhenNumberOfChunksIsZeroGetsTerminated) @@ -189,9 +189,8 @@ TEST_F(MemPool_test, MempoolCtorWhenNumberOfChunksIsZeroGetsTerminated) ::testing::Test::RecordProperty("TEST_ID", "a5c43e1b-e5b5-4a69-8c4c-8b95752ade8e"); constexpr uint32_t INVALID_NUMBER_OF_CHUNKS = 0U; - IOX_EXPECT_FATAL_FAILURE( - [&] { iox::mepoo::MemPool sut(CHUNK_SIZE, INVALID_NUMBER_OF_CHUNKS, allocator, allocator); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE( + [&] { iox::mepoo::MemPool sut(CHUNK_SIZE, INVALID_NUMBER_OF_CHUNKS, allocator, allocator); }, iox::er::FATAL); } TEST_F(MemPool_test, GetChunkMethodWhenAllTheChunksAreUsedReturnsNullPointer) { @@ -278,8 +277,7 @@ TEST_F(MemPool_test, FreeChunkMethodWhenTheChunkIndexIsInvalidReturnsError) constexpr uint32_t INVALID_INDEX{1U}; chunks.push_back(reinterpret_cast(sut.getChunk())); - IOX_EXPECT_FATAL_FAILURE([&] { sut.freeChunk(chunks[INVALID_INDEX]); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { sut.freeChunk(chunks[INVALID_INDEX]); }, iox::er::ENFORCE_VIOLATION); } TEST_F(MemPool_test, GetMinFreeMethodReturnsTheNumberOfFreeChunks) diff --git a/iceoryx_posh/test/moduletests/test_mepoo_shm_safe_unmanaged_chunk.cpp b/iceoryx_posh/test/moduletests/test_mepoo_shm_safe_unmanaged_chunk.cpp index c5c58ab1be..26eb8b5fa8 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_shm_safe_unmanaged_chunk.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_shm_safe_unmanaged_chunk.cpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/internal/mepoo/shared_chunk.hpp" #include "iceoryx_posh/mepoo/chunk_header.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" +#include "iox/assertions.hpp" #include "iox/bump_allocator.hpp" #include "test.hpp" @@ -42,13 +43,10 @@ class ShmSafeUnmanagedChunk_test : public Test SharedChunk getChunkFromMemoryManager() { - auto chunkSettingsResult = iox::mepoo::ChunkSettings::create(sizeof(bool), alignof(bool)); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); + auto chunkSettings = + iox::mepoo::ChunkSettings::create(sizeof(bool), alignof(bool)).expect("Valid 'ChunkSettings'"); - auto getChunkResult = memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + return memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } iox::mepoo::MemoryManager memoryManager; diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp index eab1609e2a..1fea4c17b7 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp @@ -137,8 +137,7 @@ TYPED_TEST(ChunkDistributor_test, AddingNullptrQueueDoesNotWork) auto sutData = this->getChunkDistributorData(); typename TestFixture::ChunkDistributor_t sut(sutData.get()); - IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut.tryAddQueue(nullptr)); }, - iox::HoofsError::EXPECTS_ENSURES_FAILED); + IOX_EXPECT_FATAL_FAILURE([&] { IOX_DISCARD_RESULT(sut.tryAddQueue(nullptr)); }, iox::er::ENFORCE_VIOLATION); } TYPED_TEST(ChunkDistributor_test, NewChunkDistributorHasNoQueues) diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp index d9ed3d4c1d..437bcaa631 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp @@ -25,6 +25,7 @@ #include "iceoryx_posh/internal/posh_error_reporting.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" #include "iceoryx_posh/testing/mocks/chunk_mock.hpp" +#include "iox/assertions.hpp" #include "iox/bump_allocator.hpp" #include "iceoryx_hoofs/testing/error_reporting/testing_support.hpp" @@ -65,13 +66,10 @@ class ChunkReceiver_test : public Test iox::mepoo::SharedChunk getChunkFromMemoryManager() { - auto chunkSettingsResult = iox::mepoo::ChunkSettings::create(sizeof(DummySample), alignof(DummySample)); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); + auto chunkSettings = iox::mepoo::ChunkSettings::create(sizeof(DummySample), alignof(DummySample)) + .expect("Valid 'ChunkSettings'"); - auto getChunkResult = m_memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + return m_memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } static constexpr size_t MEGABYTE = 1 << 20; diff --git a/iceoryx_posh/test/moduletests/test_popo_client_port.cpp b/iceoryx_posh/test/moduletests/test_popo_client_port.cpp index dde86788db..b937c9914b 100644 --- a/iceoryx_posh/test/moduletests/test_popo_client_port.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_client_port.cpp @@ -26,6 +26,7 @@ #include "iceoryx_hoofs/testing/error_reporting/testing_support.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" +#include "iox/assertions.hpp" #include "test.hpp" namespace @@ -139,16 +140,13 @@ class ClientPort_test : public Test iox::mepoo::SharedChunk getChunkFromMemoryManager(uint64_t userPayloadSize, uint32_t userHeaderSize) { - auto chunkSettingsResult = iox::mepoo::ChunkSettings::create(userPayloadSize, - iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, - userHeaderSize, - iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); - - auto getChunkResult = m_memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + auto chunkSettings = iox::mepoo::ChunkSettings::create(userPayloadSize, + iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, + userHeaderSize, + iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT) + .expect("Valid 'ChunkSettings'"); + + return m_memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } /// @return true if all pushes succeed, false if a push failed and a chunk was lost diff --git a/iceoryx_posh/test/moduletests/test_popo_server_port_common.hpp b/iceoryx_posh/test/moduletests/test_popo_server_port_common.hpp index c18536534c..1caba66313 100644 --- a/iceoryx_posh/test/moduletests/test_popo_server_port_common.hpp +++ b/iceoryx_posh/test/moduletests/test_popo_server_port_common.hpp @@ -24,6 +24,7 @@ #include "iceoryx_hoofs/testing/watch_dog.hpp" #include "iceoryx_posh/internal/mepoo/memory_manager.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" +#include "iox/assertions.hpp" #include "test.hpp" @@ -103,16 +104,13 @@ class ServerPort_test : public Test SharedChunk getChunkFromMemoryManager(uint64_t userPayloadSize, uint32_t userHeaderSize) { - auto chunkSettingsResult = ChunkSettings::create(userPayloadSize, - iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, - userHeaderSize, - iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); - - auto getChunkResult = m_memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + auto chunkSettings = ChunkSettings::create(userPayloadSize, + iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, + userHeaderSize, + iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT) + .expect("Valid 'ChunkSettings'"); + + return m_memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } static constexpr uint64_t DUMMY_DATA{0U}; @@ -129,9 +127,9 @@ class ServerPort_test : public Test uint64_t getRequestData(const RequestHeader* requestHeader) { - IOX_ENSURES(requestHeader != nullptr && "requestHeader must not be a nullptr"); + IOX_ENFORCE(requestHeader != nullptr, "requestHeader must not be a nullptr"); auto userPayload = ChunkHeader::fromUserHeader(requestHeader)->userPayload(); - IOX_ENSURES(userPayload != nullptr && "userPayload must not be a nullptr"); + IOX_ENFORCE(userPayload != nullptr, "userPayload must not be a nullptr"); return *static_cast(userPayload); } diff --git a/iceoryx_posh/test/moduletests/test_popo_used_chunk_list.cpp b/iceoryx_posh/test/moduletests/test_popo_used_chunk_list.cpp index 4d5141c9c8..035bf9cae5 100644 --- a/iceoryx_posh/test/moduletests/test_popo_used_chunk_list.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_used_chunk_list.cpp @@ -18,6 +18,7 @@ #include "iceoryx_posh/internal/mepoo/memory_manager.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" +#include "iox/assertions.hpp" #include "iox/bump_allocator.hpp" #include "test.hpp" @@ -47,14 +48,11 @@ class UsedChunkList_test : public Test SharedChunk getChunkFromMemoryManager() { constexpr uint64_t USER_PAYLOAD_SIZE{32U}; - auto chunkSettingsResult = - iox::mepoo::ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); - IOX_ENSURES(chunkSettingsResult.has_value()); - auto& chunkSettings = chunkSettingsResult.value(); - - auto getChunkResult = memoryManager.getChunk(chunkSettings); - IOX_ENSURES(getChunkResult.has_value()); - return getChunkResult.value(); + auto chunkSettings = + iox::mepoo::ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT) + .expect("Valid 'ChunkSettings'"); + + return memoryManager.getChunk(chunkSettings).expect("Obtaining chunk"); } void createMultipleChunks(uint32_t numberOfChunks, std::function testHook) diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp index 67e11182b2..3a8a58f4fc 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp @@ -19,6 +19,7 @@ #include "iceoryx_posh/internal/mepoo/memory_manager.hpp" #include "iceoryx_posh/mepoo/chunk_header.hpp" +#include "iox/assertions.hpp" #include "iox/memory.hpp" #include @@ -43,7 +44,7 @@ class ChunkMock auto chunkSettingsResult = iox::mepoo::ChunkSettings::create( userPayloadSize, userPayloadAlignment, userHeaderSize, userHeaderAlignment); - IOX_ENSURES_WITH_MSG(chunkSettingsResult.has_value(), "Invalid parameter for ChunkMock"); + IOX_ENFORCE(chunkSettingsResult.has_value(), "Invalid parameter for ChunkMock"); auto& chunkSettings = chunkSettingsResult.value(); auto chunkSize = chunkSettings.requiredChunkSize(); diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp index 5dd5464a43..413926179e 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp @@ -18,6 +18,8 @@ #define IOX_POSH_MOCKS_POSH_RUNTIME_MOCK_HPP #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/assertions.hpp" + #include using namespace ::testing; @@ -28,10 +30,10 @@ class PoshRuntimeMock : public iox::runtime::PoshRuntime static std::unique_ptr create(const iox::RuntimeName_t& name) { auto& runtime = mockRuntime(); - IOX_EXPECTS_WITH_MSG(!runtime.has_value(), "Using multiple PoshRuntimeMock in parallel is not supported!"); - IOX_EXPECTS_WITH_MSG(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory, - "The PoshRuntimeMock can only be used in combination with the " - "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); + IOX_ENFORCE(!runtime.has_value(), "Using multiple PoshRuntimeMock in parallel is not supported!"); + IOX_ENFORCE(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory, + "The PoshRuntimeMock can only be used in combination with the " + "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); runtime = new PoshRuntimeMock(name); PoshRuntime::setRuntimeFactory(mockRuntimeFactory); @@ -88,9 +90,8 @@ class PoshRuntimeMock : public iox::runtime::PoshRuntime static PoshRuntime& mockRuntimeFactory(iox::optional name) noexcept { auto& runtime = mockRuntime(); - IOX_EXPECTS_WITH_MSG(!name.has_value(), "PoshRuntime::initRuntime must not be used with a PoshRuntimeMock!"); - IOX_EXPECTS_WITH_MSG(runtime.has_value(), - "This should never happen! If you see this, something went horribly wrong!"); + IOX_ENFORCE(!name.has_value(), "PoshRuntime::initRuntime must not be used with a PoshRuntimeMock!"); + IOX_ENFORCE(runtime.has_value(), "This should never happen! If you see this, something went horribly wrong!"); return *runtime.value(); }