diff --git a/CHANGELOG.md b/CHANGELOG.md index d564ace1bb..f8e78ed747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ - Make `cxx::string::capacity` a `static` method[\#979](https://github.com/eclipse-iceoryx/iceoryx/issues/979) - Restructure iceoryx tools [\#471](https://github.com/eclipse-iceoryx/iceoryx/issues/471) - Use cxx::expected for MemoryManager::getChunk [\#954](https://github.com/eclipse-iceoryx/iceoryx/pull/991) +- Upgrade GTest/GMock to v1.10 [\#841](https://github.com/eclipse-iceoryx/iceoryx/issues/841) **API Breaking Changes:** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c47d21213..f8cf2361a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -179,7 +179,7 @@ All new code should follow the folder structure. ## Testing We use [Google test](https://github.com/google/googletest) for our unit and integration tests. We require compatibility -with the version 1.8.1. +with the version 1.10.0. Have a look at our [best practice guidelines](./doc/website/advanced/best-practice-for-testing.md) for writing tests and [installation guide for contributors](./doc/website/advanced/installation-guide-for-contributors.md#build-and-run-tests) for building them. diff --git a/cmake/googletest/0001-remove-werror-from-build-flags.patch b/cmake/googletest/0001-remove-werror-from-build-flags.patch index e43dc69c57..2a08f5390e 100644 --- a/cmake/googletest/0001-remove-werror-from-build-flags.patch +++ b/cmake/googletest/0001-remove-werror-from-build-flags.patch @@ -1,8 +1,15 @@ --- /googletest/cmake/internal_utils.cmake +++ /googletest/cmake/internal_utils.cmake.new -@@ -99,7 +99,7 @@ - set(cxx_no_exception_flags "-EHs-c- -D_HAS_EXCEPTIONS=0") - set(cxx_no_rtti_flags "-GR-") +@@ -82,13 +82,13 @@ macro(config_compiler_and_linker) + # http://stackoverflow.com/questions/3232669 explains the issue. + set(cxx_base_flags "${cxx_base_flags} -wd4702") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +- set(cxx_base_flags "-Wall -Wshadow -Werror -Wconversion") ++ set(cxx_base_flags "-Wall -Wshadow -Wconversion") + set(cxx_exception_flags "-fexceptions") + set(cxx_no_exception_flags "-fno-exceptions") + set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") + set(cxx_no_rtti_flags "-fno-rtti") elseif (CMAKE_COMPILER_IS_GNUCXX) - set(cxx_base_flags "-Wall -Wshadow -Werror") + set(cxx_base_flags "-Wall -Wshadow") diff --git a/cmake/googletest/googletest.cmake.in b/cmake/googletest/googletest.cmake.in index c942922efd..93fb020130 100644 --- a/cmake/googletest/googletest.cmake.in +++ b/cmake/googletest/googletest.cmake.in @@ -19,26 +19,13 @@ cmake_minimum_required(VERSION 3.5) project(googletest-download NONE) include(ExternalProject) -if(WIN32) - ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.10.0 - SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/googletest/src" - BINARY_DIR "${CMAKE_BINARY_DIR}/dependencies/googletest/build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) -else() - ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.8.1 - SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/googletest/src" - BINARY_DIR "${CMAKE_BINARY_DIR}/dependencies/googletest/build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) -endif(WIN32) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.10.0 + SOURCE_DIR "${CMAKE_BINARY_DIR}/dependencies/googletest/src" + BINARY_DIR "${CMAKE_BINARY_DIR}/dependencies/googletest/build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/doc/website/advanced/best-practice-for-testing.md b/doc/website/advanced/best-practice-for-testing.md index d75869e6e0..daaad219fd 100644 --- a/doc/website/advanced/best-practice-for-testing.md +++ b/doc/website/advanced/best-practice-for-testing.md @@ -230,7 +230,7 @@ They also exert all the good practices mentioned previously, like clear and dist There are situations when test cases only vary in the type applied to the `sut`. In this case typed tests can be used to reduce repetition. The there is a section for [typed tests](https://github.com/google/googletest/blob/master/docs/advanced.md#typed-tests) in the advanced gtest documentation. -A more thorough [example](https://github.com/google/googletest/blob/release-1.8.1/googletest/samples/sample6_unittest.cc) is in the gtest github repository. +A more thorough [example](https://github.com/google/googletest/blob/release-1.10.0/googletest/samples/sample6_unittest.cc) is in the gtest github repository. ## Parameterized Tests @@ -245,7 +245,7 @@ The block post mentions tuples to pass multiple parameters at once. Since tuples Some classes are hard to test or to reach a full coverage. This might be due to external access or interaction with the operating system. Mocks can help to have full control over the `sut` and reliably cause error conditions to test the negative code path. -There is an [extensive gmock documentation](https://github.com/google/googletest/tree/release-1.8.1/googlemock/docs) in the gtest github repository. +There is an [extensive gmock documentation](https://github.com/google/googletest/tree/release-1.10.0/googlemock/docs) in the gtest github repository. ## Pitfalls Some tests require creating dummy classes and it might be that the same name is chosen multiple times, e.g. “class DummyData {...};”. diff --git a/iceoryx_hoofs/test/integrationtests/test_lockfree_queue_stresstest.cpp b/iceoryx_hoofs/test/integrationtests/test_lockfree_queue_stresstest.cpp index 983f31179b..300b474542 100644 --- a/iceoryx_hoofs/test/integrationtests/test_lockfree_queue_stresstest.cpp +++ b/iceoryx_hoofs/test/integrationtests/test_lockfree_queue_stresstest.cpp @@ -349,11 +349,8 @@ using LargeQueue = TestQueue<1000000>; typedef ::testing::Types TestQueues; // typedef ::testing::Types TestQueues; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(LockFreeQueueStressTest, TestQueues); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(LockFreeQueueStressTest, TestQueues); + ///@brief Tests concurrent operation of one prodcuer and one consumer /// The producer pushes a fixed number of data elements which the consumer pops and checks. diff --git a/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp b/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp index 5199a7638a..fb40f385c6 100644 --- a/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp +++ b/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp @@ -366,11 +366,7 @@ using HalfFull3 = HalfFull; /// @endcode typedef ::testing::Types TestConfigs; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(ResizeableLockFreeQueueStressTest, TestConfigs); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(ResizeableLockFreeQueueStressTest, TestConfigs); ///@brief Tests concurrent operation of multiple producers and consumers diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp index 558f86d68a..2f703c4faf 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp @@ -28,11 +28,9 @@ using namespace ::testing; constexpr uint32_t Size{4}; using LoFFLiTestSubjects = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(LoFFLi_test, LoFFLiTestSubjects); -#pragma GCC diagnostic pop + +TYPED_TEST_SUITE(LoFFLi_test, LoFFLiTestSubjects); + template class LoFFLi_test : public Test diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp index 835efdaea6..8a563bdfcb 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp @@ -67,11 +67,8 @@ using TriggerQueueTestSubjects = Types, TriggerQueue, TriggerQueue>; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(TriggerQueue_test, TriggerQueueTestSubjects); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(TriggerQueue_test, TriggerQueueTestSubjects); + TYPED_TEST(TriggerQueue_test, EmptyOnConstruction) { diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_helplets.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_helplets.cpp index 2083032ec6..9c46bf06d7 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_helplets.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_helplets.cpp @@ -196,11 +196,8 @@ class Helplets_test_isPowerOfTwo : public Helplets_test using HelpletsIsPowerOfTwoTypes = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(Helplets_test_isPowerOfTwo, HelpletsIsPowerOfTwoTypes); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(Helplets_test_isPowerOfTwo, HelpletsIsPowerOfTwoTypes); + TYPED_TEST(Helplets_test_isPowerOfTwo, OneIsPowerOfTwo) { diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp index faa850b725..6956d31402 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_string.cpp @@ -33,11 +33,9 @@ class stringTyped_test : public Test }; using Implementations = Types, string<15>, string<100>, string<1000>>; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(stringTyped_test, Implementations); -#pragma GCC diagnostic pop + +TYPED_TEST_SUITE(stringTyped_test, Implementations); + TEST(string_test, CapacityReturnsSpecifiedCapacity) { diff --git a/iceoryx_hoofs/test/moduletests/test_index_queue.cpp b/iceoryx_hoofs/test/moduletests/test_index_queue.cpp index 9d67567adc..8b80760146 100644 --- a/iceoryx_hoofs/test/moduletests/test_index_queue.cpp +++ b/iceoryx_hoofs/test/moduletests/test_index_queue.cpp @@ -60,11 +60,7 @@ TEST(LockFreeQueueTest, capacityIsConsistent) typedef ::testing::Types, IndexQueue<10>, IndexQueue<1000>> TestQueues; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(IndexQueueTest, TestQueues); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(IndexQueueTest, TestQueues); TYPED_TEST(IndexQueueTest, defaultConstructedQueueIsEmpty) diff --git a/iceoryx_hoofs/test/moduletests/test_ipc_channel.cpp b/iceoryx_hoofs/test/moduletests/test_ipc_channel.cpp index 9fea513377..0c003ea966 100644 --- a/iceoryx_hoofs/test/moduletests/test_ipc_channel.cpp +++ b/iceoryx_hoofs/test/moduletests/test_ipc_channel.cpp @@ -93,11 +93,8 @@ const size_t IpcChannel_test::MaxMsgSize = IpcChannelType::MAX_MESSAGE_SIZE; template constexpr uint64_t IpcChannel_test::MaxMsgNumber; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(IpcChannel_test, IpcChannelTypes); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(IpcChannel_test, IpcChannelTypes); + TYPED_TEST(IpcChannel_test, CreateWithTooLargeMessageSizeLeadsToError) { diff --git a/iceoryx_hoofs/test/moduletests/test_lockfree_queue.cpp b/iceoryx_hoofs/test/moduletests/test_lockfree_queue.cpp index e5c2b64962..cf95ab155b 100644 --- a/iceoryx_hoofs/test/moduletests/test_lockfree_queue.cpp +++ b/iceoryx_hoofs/test/moduletests/test_lockfree_queue.cpp @@ -169,11 +169,8 @@ typedef ::testing::Types TestConfigs; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(LockFreeQueueTest, TestConfigs); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(LockFreeQueueTest, TestConfigs); + TEST(LockFreeQueueTest, capacityIsConsistent) { diff --git a/iceoryx_hoofs/test/moduletests/test_lockfree_queue_buffer.cpp b/iceoryx_hoofs/test/moduletests/test_lockfree_queue_buffer.cpp index ed11d107a8..b70c169430 100644 --- a/iceoryx_hoofs/test/moduletests/test_lockfree_queue_buffer.cpp +++ b/iceoryx_hoofs/test/moduletests/test_lockfree_queue_buffer.cpp @@ -87,11 +87,8 @@ TEST(LockFreeQueueBufferTest, capacityIsCorrect) typedef ::testing::Types, Buffer> TestBuffers; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(LockFreeQueueBufferTest, TestBuffers); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(LockFreeQueueBufferTest, TestBuffers); + TYPED_TEST(LockFreeQueueBufferTest, accessElements) { diff --git a/iceoryx_hoofs/test/moduletests/test_lockfree_queue_cyclic_index.cpp b/iceoryx_hoofs/test/moduletests/test_lockfree_queue_cyclic_index.cpp index 494f33bba4..44dd21f386 100644 --- a/iceoryx_hoofs/test/moduletests/test_lockfree_queue_cyclic_index.cpp +++ b/iceoryx_hoofs/test/moduletests/test_lockfree_queue_cyclic_index.cpp @@ -50,11 +50,8 @@ class LockFreeQueueCyclicIndexTest : public ::testing::Test typedef ::testing::Types, CyclicIndex<2>, CyclicIndex<10>, CyclicIndex<1000>> TestIndices; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(LockFreeQueueCyclicIndexTest, TestIndices); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(LockFreeQueueCyclicIndexTest, TestIndices); + // note that in all tests we will check whether the getCycle and getIndex methods // behave as expected after certain operations (mainly addition), diff --git a/iceoryx_hoofs/test/moduletests/test_logger.cpp b/iceoryx_hoofs/test/moduletests/test_logger.cpp index 57fe2c5574..73d81ba6c9 100644 --- a/iceoryx_hoofs/test/moduletests/test_logger.cpp +++ b/iceoryx_hoofs/test/moduletests/test_logger.cpp @@ -158,19 +158,15 @@ class IoxLoggerLogLevel_test : public TestWithParam, public } }; -/// we require INSTANTIATE_TEST_CASE_P since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -INSTANTIATE_TEST_CASE_P(AllLogLevel, - IoxLoggerLogLevel_test, - Values(iox::log::LogLevel::kOff, - iox::log::LogLevel::kFatal, - iox::log::LogLevel::kError, - iox::log::LogLevel::kWarn, - iox::log::LogLevel::kInfo, - iox::log::LogLevel::kDebug, - iox::log::LogLevel::kVerbose)); -#pragma GCC diagnostic pop +INSTANTIATE_TEST_SUITE_P(AllLogLevel, + IoxLoggerLogLevel_test, + Values(iox::log::LogLevel::kOff, + iox::log::LogLevel::kFatal, + iox::log::LogLevel::kError, + iox::log::LogLevel::kWarn, + iox::log::LogLevel::kInfo, + iox::log::LogLevel::kDebug, + iox::log::LogLevel::kVerbose)); TEST_P(IoxLoggerLogLevel_test, LogLevel) { diff --git a/iceoryx_hoofs/test/moduletests/test_logstream.cpp b/iceoryx_hoofs/test/moduletests/test_logstream.cpp index 33a9d88cca..5706380ea1 100644 --- a/iceoryx_hoofs/test/moduletests/test_logstream.cpp +++ b/iceoryx_hoofs/test/moduletests/test_logstream.cpp @@ -193,11 +193,8 @@ class IoxLogStreamHexBin_test : public IoxLogStream_test using LogHexBinTypes = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(IoxLogStreamHexBin_test, LogHexBinTypes); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(IoxLogStreamHexBin_test, LogHexBinTypes); + template void testStreamOperatorLogHex(Logger_Mock& loggerMock, LogType logValue) @@ -263,11 +260,8 @@ TYPED_TEST(IoxLogStreamHexBin_test, StreamOperatorLogBin_ValueMax) using ArithmeticTypes = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(IoxLogStreamArithmetic_test, ArithmeticTypes); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(IoxLogStreamArithmetic_test, ArithmeticTypes); + template class IoxLogStreamArithmetic_test : public IoxLogStream_test diff --git a/iceoryx_hoofs/test/moduletests/test_posix_signal_handler.cpp b/iceoryx_hoofs/test/moduletests/test_posix_signal_handler.cpp index 9140e7caba..69f46533ed 100644 --- a/iceoryx_hoofs/test/moduletests/test_posix_signal_handler.cpp +++ b/iceoryx_hoofs/test/moduletests/test_posix_signal_handler.cpp @@ -80,7 +80,7 @@ class SignalHandler_test : public Test using Implementations = Types, SignalType, SignalType, SignalType>; -TYPED_TEST_CASE(SignalHandler_test, Implementations); +TYPED_TEST_SUITE(SignalHandler_test, Implementations); TYPED_TEST(SignalHandler_test, RegisteringSignalGuardCallbackWorks) { diff --git a/iceoryx_hoofs/test/moduletests/test_relative_pointer.cpp b/iceoryx_hoofs/test/moduletests/test_relative_pointer.cpp index 02a00775a8..b8f4da79b3 100644 --- a/iceoryx_hoofs/test/moduletests/test_relative_pointer.cpp +++ b/iceoryx_hoofs/test/moduletests/test_relative_pointer.cpp @@ -68,11 +68,8 @@ class base_relative_ptr_test : public Test typedef testing::Types Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(base_relative_ptr_test, Types); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(base_relative_ptr_test, Types); + TYPED_TEST(base_relative_ptr_test, ConstrTests) { diff --git a/iceoryx_hoofs/test/moduletests/test_relocatable_ptr.cpp b/iceoryx_hoofs/test/moduletests/test_relocatable_ptr.cpp index 14ffffc04c..cfef99d3ac 100644 --- a/iceoryx_hoofs/test/moduletests/test_relocatable_ptr.cpp +++ b/iceoryx_hoofs/test/moduletests/test_relocatable_ptr.cpp @@ -185,11 +185,8 @@ class Relocatable_ptr_test : public Test typedef ::testing::Types TestTypes; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(Relocatable_ptr_typed_test, TestTypes); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(Relocatable_ptr_typed_test, TestTypes); + TYPED_TEST(Relocatable_ptr_typed_test, wrappedPointerTypeIsCorrect) { diff --git a/iceoryx_hoofs/test/moduletests/test_resizeable_lockfree_queue.cpp b/iceoryx_hoofs/test/moduletests/test_resizeable_lockfree_queue.cpp index ce85312e2f..06b6d72151 100644 --- a/iceoryx_hoofs/test/moduletests/test_resizeable_lockfree_queue.cpp +++ b/iceoryx_hoofs/test/moduletests/test_resizeable_lockfree_queue.cpp @@ -85,12 +85,8 @@ using IntQueue = iox::concurrent::ResizeableLockFreeQueue; typedef ::testing::Types, IntegerQueue<11>, IntQueue<10>> TestQueues; +TYPED_TEST_SUITE(ResizeableLockFreeQueueTest, TestQueues); -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(ResizeableLockFreeQueueTest, TestQueues); -#pragma GCC diagnostic pop TEST(ResizeableLockFreeQueueTest, maxCapacityIsConsistent) { diff --git a/iceoryx_hoofs/test/moduletests/test_semaphore_module.cpp b/iceoryx_hoofs/test/moduletests/test_semaphore_module.cpp index 7809b131f7..ac4a3e4ac3 100644 --- a/iceoryx_hoofs/test/moduletests/test_semaphore_module.cpp +++ b/iceoryx_hoofs/test/moduletests/test_semaphore_module.cpp @@ -108,11 +108,7 @@ class SemaphoreCreate_test : public Test } }; -/// we require INSTANTIATE_TEST_CASE since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -INSTANTIATE_TEST_CASE_P(Semaphore_test, Semaphore_test, Values(&createNamedSemaphore, &createUnnamedSemaphore)); -#pragma GCC diagnostic pop +INSTANTIATE_TEST_SUITE_P(Semaphore_test, Semaphore_test, Values(&createNamedSemaphore, &createUnnamedSemaphore)); TEST_F(SemaphoreCreate_test, CreateNamedSemaphore) { diff --git a/iceoryx_posh/test/mocks/posh_runtime_mock.hpp b/iceoryx_posh/test/mocks/posh_runtime_mock.hpp index aecd923ff7..676b149089 100644 --- a/iceoryx_posh/test/mocks/posh_runtime_mock.hpp +++ b/iceoryx_posh/test/mocks/posh_runtime_mock.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -45,28 +45,37 @@ class PoshRuntimeMock : public iox::runtime::PoshRuntime mockRuntime().reset(); } - /// @todo iox-#841 simplify this when we switch to gmock v1.10 - MOCK_METHOD2(findServiceMock, - iox::cxx::expected( - const iox::cxx::variant, - const iox::cxx::variant)); - MOCK_METHOD1(offerServiceMock, bool(const iox::capro::ServiceDescription&)); - MOCK_METHOD1(stopOfferServiceMock, bool(const iox::capro::ServiceDescription&)); - MOCK_METHOD3(getMiddlewarePublisherMock, - iox::PublisherPortUserType::MemberType_t*(const iox::capro::ServiceDescription&, - const iox::popo::PublisherOptions&, - const iox::runtime::PortConfigInfo&)); - MOCK_METHOD3(getMiddlewareSubscriberMock, - iox::SubscriberPortUserType::MemberType_t*(const iox::capro::ServiceDescription&, - const iox::popo::SubscriberOptions&, - const iox::runtime::PortConfigInfo&)); - MOCK_METHOD2(getMiddlewareInterfaceMock, - iox::popo::InterfacePortData*(const iox::capro::Interfaces, const iox::NodeName_t&)); - MOCK_METHOD0(getMiddlewareApplicationMock, iox::popo::ApplicationPortData*()); - MOCK_METHOD0(getMiddlewareConditionVariableMock, iox::popo::ConditionVariableData*()); - MOCK_METHOD1(createNodeMock, iox::runtime::NodeData*(const iox::runtime::NodeProperty&)); - MOCK_METHOD0(getServiceRegistryChangeCounterMock, const std::atomic*()); - MOCK_METHOD2(sendRequestToRouDiMock, bool(const iox::runtime::IpcMessage&, iox::runtime::IpcMessage&)); + MOCK_METHOD((iox::cxx::expected), + findService, + ((const iox::cxx::variant), + (const iox::cxx::variant)), + (noexcept, override)); + MOCK_METHOD(bool, offerService, (const iox::capro::ServiceDescription&), (noexcept, override)); + MOCK_METHOD(bool, stopOfferService, (const iox::capro::ServiceDescription&), (noexcept, override)); + MOCK_METHOD(iox::PublisherPortUserType::MemberType_t*, + getMiddlewarePublisher, + (const iox::capro::ServiceDescription&, + const iox::popo::PublisherOptions&, + const iox::runtime::PortConfigInfo&), + (noexcept, override)); + MOCK_METHOD(iox::SubscriberPortUserType::MemberType_t*, + getMiddlewareSubscriber, + (const iox::capro::ServiceDescription&, + const iox::popo::SubscriberOptions&, + const iox::runtime::PortConfigInfo&), + (noexcept, override)); + MOCK_METHOD(iox::popo::InterfacePortData*, + getMiddlewareInterface, + (const iox::capro::Interfaces, const iox::NodeName_t&), + (noexcept, override)); + MOCK_METHOD(iox::popo::ApplicationPortData*, getMiddlewareApplication, (), (noexcept, override)); + MOCK_METHOD(iox::popo::ConditionVariableData*, getMiddlewareConditionVariable, (), (noexcept, override)); + MOCK_METHOD(iox::runtime::NodeData*, createNode, (const iox::runtime::NodeProperty&), (noexcept, override)); + MOCK_METHOD(const std::atomic*, getServiceRegistryChangeCounter, (), (noexcept, override)); + MOCK_METHOD(bool, + sendRequestToRouDi, + (const iox::runtime::IpcMessage&, iox::runtime::IpcMessage&), + (noexcept, override)); private: PoshRuntimeMock(const iox::RuntimeName_t& name) @@ -88,70 +97,6 @@ class PoshRuntimeMock : public iox::runtime::PoshRuntime static iox::cxx::optional runtime = iox::cxx::nullopt; return runtime; } - - iox::cxx::expected - findService(const iox::cxx::variant service, - const iox::cxx::variant instance) noexcept override - { - return findServiceMock(service, instance); - } - - bool offerService(const iox::capro::ServiceDescription& serviceDescription) noexcept override - { - return offerServiceMock(serviceDescription); - } - - bool stopOfferService(const iox::capro::ServiceDescription& serviceDescription) noexcept override - { - return stopOfferServiceMock(serviceDescription); - } - - iox::PublisherPortUserType::MemberType_t* - getMiddlewarePublisher(const iox::capro::ServiceDescription& service, - const iox::popo::PublisherOptions& publisherOptions = {}, - const iox::runtime::PortConfigInfo& portConfigInfo = {}) noexcept override - { - return getMiddlewarePublisherMock(service, publisherOptions, portConfigInfo); - } - - iox::SubscriberPortUserType::MemberType_t* - getMiddlewareSubscriber(const iox::capro::ServiceDescription& service, - const iox::popo::SubscriberOptions& subscriberOptions = {}, - const iox::runtime::PortConfigInfo& portConfigInfo = {}) noexcept override - { - return getMiddlewareSubscriberMock(service, subscriberOptions, portConfigInfo); - } - - iox::popo::InterfacePortData* getMiddlewareInterface(const iox::capro::Interfaces interface, - const iox::NodeName_t& nodeName = {}) noexcept override - { - return getMiddlewareInterfaceMock(interface, nodeName); - } - - iox::popo::ApplicationPortData* getMiddlewareApplication() noexcept override - { - return getMiddlewareApplicationMock(); - } - - iox::popo::ConditionVariableData* getMiddlewareConditionVariable() noexcept override - { - return getMiddlewareConditionVariableMock(); - } - - iox::runtime::NodeData* createNode(const iox::runtime::NodeProperty& nodeProperty) noexcept override - { - return createNodeMock(nodeProperty); - } - - const std::atomic* getServiceRegistryChangeCounter() noexcept override - { - return getServiceRegistryChangeCounterMock(); - } - - bool sendRequestToRouDi(const iox::runtime::IpcMessage& msg, iox::runtime::IpcMessage& answer) noexcept override - { - return sendRequestToRouDiMock(msg, answer); - } }; #endif // IOX_POSH_MOCKS_CHUNK_MOCK_HPP diff --git a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp index a8c5865967..ab471f8cfa 100644 --- a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp +++ b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,33 +24,10 @@ class MemoryBlockMock final : public iox::roudi::MemoryBlock { public: - /// @note with gmock 1.8 it is not possible to mock functions with the noexcept specifier, therefore this - /// interesting mock implementation - - uint64_t size() const noexcept override - { - return sizeMock(); - } - - uint64_t alignment() const noexcept override - { - return alignmentMock(); - } - - void onMemoryAvailable(iox::cxx::not_null memory) noexcept override - { - onMemoryAvailableMock(memory); - } - - void destroy() noexcept override - { - destroyMock(); - } - - MOCK_CONST_METHOD0(sizeMock, uint64_t()); - MOCK_CONST_METHOD0(alignmentMock, uint64_t()); - MOCK_METHOD1(onMemoryAvailableMock, void(iox::cxx::not_null)); - MOCK_METHOD0(destroyMock, void()); + MOCK_METHOD(uint64_t, size, (), (const, noexcept, override)); + MOCK_METHOD(uint64_t, alignment, (), (const, noexcept, override)); + MOCK_METHOD(void, onMemoryAvailable, (iox::cxx::not_null), (noexcept, override)); + MOCK_METHOD(void, destroy, (), (noexcept, override)); }; #endif // IOX_POSH_MOCKS_ROUDI_MEMORY_BLOCK_MOCK_HPP diff --git a/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp b/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp index 57bf4c4c5e..4626807680 100644 --- a/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp +++ b/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ class MemoryProviderTestImpl : public iox::roudi::MemoryProvider dummyMemory = static_cast(iox::cxx::alignedAlloc(alignment, size)); return iox::cxx::success(dummyMemory); } - MOCK_METHOD2(createMemoryMock, void(uint64_t, uint64_t)); + MOCK_METHOD(void, createMemoryMock, (uint64_t, uint64_t), (noexcept)); iox::cxx::expected destroyMemory() noexcept override { @@ -63,7 +63,7 @@ class MemoryProviderTestImpl : public iox::roudi::MemoryProvider return iox::cxx::success(); } - MOCK_METHOD0(destroyMemoryMock, void()); + MOCK_METHOD(void, destroyMemoryMock, (), (noexcept)); uint8_t* dummyMemory{nullptr}; diff --git a/iceoryx_posh/test/moduletests/test_base_port.cpp b/iceoryx_posh/test/moduletests/test_base_port.cpp index 2f1f2cd105..e465aad337 100644 --- a/iceoryx_posh/test/moduletests/test_base_port.cpp +++ b/iceoryx_posh/test/moduletests/test_base_port.cpp @@ -49,11 +49,7 @@ std::vector uniquePortIds; using PortDataTypes = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(BasePort_test, PortDataTypes); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(BasePort_test, PortDataTypes); // port data factories diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp index b6505f13c3..c205c26920 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp @@ -412,34 +412,34 @@ class ChunkHeader_AlteringUserPayloadWithoutUserHeader : public ::testing::TestW // without a user-header, the user-payload is located right after the ChunkHeader, therefore the payload size and // alignment parameters are made dependant on the ChunkHeader -INSTANTIATE_TEST_CASE_P(ChunkHeader_test, - ChunkHeader_AlteringUserPayloadWithoutUserHeader, - ::testing::Values( - // alignment = 0 - PayloadParams{0U, 0U}, - PayloadParams{1U, 0U}, - PayloadParams{sizeof(ChunkHeader), 0U}, - PayloadParams{sizeof(ChunkHeader) * 42U, 0U}, - // alignment = 1 - PayloadParams{0U, 1U}, - PayloadParams{1U, 1U}, - PayloadParams{sizeof(ChunkHeader), 1U}, - PayloadParams{sizeof(ChunkHeader) * 42U, 1U}, - // alignment = alignof(ChunkHeader) / 2 - PayloadParams{0U, alignof(ChunkHeader) / 2}, - PayloadParams{1U, alignof(ChunkHeader) / 2}, - PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) / 2}, - PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) / 2}, - // alignment = alignof(ChunkHeader) - PayloadParams{0U, alignof(ChunkHeader)}, - PayloadParams{1U, alignof(ChunkHeader)}, - PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader)}, - PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader)}, - // alignment = alignof(ChunkHeader) * 2 - PayloadParams{0U, alignof(ChunkHeader) * 2}, - PayloadParams{1U, alignof(ChunkHeader) * 2}, - PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) * 2}, - PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) * 2})); +INSTANTIATE_TEST_SUITE_P(ChunkHeader_test, + ChunkHeader_AlteringUserPayloadWithoutUserHeader, + ::testing::Values( + // alignment = 0 + PayloadParams{0U, 0U}, + PayloadParams{1U, 0U}, + PayloadParams{sizeof(ChunkHeader), 0U}, + PayloadParams{sizeof(ChunkHeader) * 42U, 0U}, + // alignment = 1 + PayloadParams{0U, 1U}, + PayloadParams{1U, 1U}, + PayloadParams{sizeof(ChunkHeader), 1U}, + PayloadParams{sizeof(ChunkHeader) * 42U, 1U}, + // alignment = alignof(ChunkHeader) / 2 + PayloadParams{0U, alignof(ChunkHeader) / 2}, + PayloadParams{1U, alignof(ChunkHeader) / 2}, + PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) / 2}, + PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) / 2}, + // alignment = alignof(ChunkHeader) + PayloadParams{0U, alignof(ChunkHeader)}, + PayloadParams{1U, alignof(ChunkHeader)}, + PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader)}, + PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader)}, + // alignment = alignof(ChunkHeader) * 2 + PayloadParams{0U, alignof(ChunkHeader) * 2}, + PayloadParams{1U, alignof(ChunkHeader) * 2}, + PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) * 2}, + PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) * 2})); TEST_P(ChunkHeader_AlteringUserPayloadWithoutUserHeader, CheckIntegrityOfChunkHeaderWithoutUserHeader) { @@ -468,34 +468,34 @@ class ChunkHeader_AlteringUserPayloadWithUserHeader : public ::testing::TestWith // with a user-header, the user-payload is located right after the UserPayloadOffset_t, therefore the user-payload size // and alignment parameters are made dependant on the UserPayloadOffset_t -INSTANTIATE_TEST_CASE_P(ChunkHeader_test, - ChunkHeader_AlteringUserPayloadWithUserHeader, - ::testing::Values( - // alignment = 0 - PayloadParams{0U, 0U}, - PayloadParams{1U, 0U}, - PayloadParams{sizeof(UserPayloadOffset_t), 0U}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 0U}, - // alignment = 1 - PayloadParams{0U, 1U}, - PayloadParams{1U, 1U}, - PayloadParams{sizeof(UserPayloadOffset_t), 1U}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 1U}, - // alignment = alignof(UserPayloadOffset_t) / 2 - PayloadParams{0U, alignof(UserPayloadOffset_t) / 2}, - PayloadParams{1U, alignof(UserPayloadOffset_t) / 2}, - PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) / 2}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) / 2}, - // alignment = alignof(UserPayloadOffset_t) - PayloadParams{0U, alignof(UserPayloadOffset_t)}, - PayloadParams{1U, alignof(UserPayloadOffset_t)}, - PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t)}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t)}, - // alignment = alignof(UserPayloadOffset_t) * 2 - PayloadParams{0U, alignof(UserPayloadOffset_t) * 2}, - PayloadParams{1U, alignof(UserPayloadOffset_t) * 2}, - PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) * 2}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) * 2})); +INSTANTIATE_TEST_SUITE_P(ChunkHeader_test, + ChunkHeader_AlteringUserPayloadWithUserHeader, + ::testing::Values( + // alignment = 0 + PayloadParams{0U, 0U}, + PayloadParams{1U, 0U}, + PayloadParams{sizeof(UserPayloadOffset_t), 0U}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 0U}, + // alignment = 1 + PayloadParams{0U, 1U}, + PayloadParams{1U, 1U}, + PayloadParams{sizeof(UserPayloadOffset_t), 1U}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 1U}, + // alignment = alignof(UserPayloadOffset_t) / 2 + PayloadParams{0U, alignof(UserPayloadOffset_t) / 2}, + PayloadParams{1U, alignof(UserPayloadOffset_t) / 2}, + PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) / 2}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) / 2}, + // alignment = alignof(UserPayloadOffset_t) + PayloadParams{0U, alignof(UserPayloadOffset_t)}, + PayloadParams{1U, alignof(UserPayloadOffset_t)}, + PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t)}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t)}, + // alignment = alignof(UserPayloadOffset_t) * 2 + PayloadParams{0U, alignof(UserPayloadOffset_t) * 2}, + PayloadParams{1U, alignof(UserPayloadOffset_t) * 2}, + PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) * 2}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) * 2})); TEST_P(ChunkHeader_AlteringUserPayloadWithUserHeader, CheckIntegrityOfChunkHeaderWithUserHeader) { diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp index ed60815727..8afd04d8bf 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp @@ -232,39 +232,39 @@ class ChunkSettings_AlteringUserPayloadWithoutUserHeader : public ::testing::Tes // without a user-header, the user-payload is located right after the ChunkHeader, therefore the user-payload size and // alignment parameters are made dependant on the ChunkHeader -INSTANTIATE_TEST_CASE_P(ChunkSettings_test, - ChunkSettings_AlteringUserPayloadWithoutUserHeader, - ::testing::Values( - // alignment = 0 - PayloadParams{0U, 0U}, - PayloadParams{1U, 0U}, - PayloadParams{sizeof(ChunkHeader), 0U}, - PayloadParams{sizeof(ChunkHeader) * 42U, 0U}, - // alignment = 1 - PayloadParams{0U, 1U}, - PayloadParams{1U, 1U}, - PayloadParams{sizeof(ChunkHeader), 1U}, - PayloadParams{sizeof(ChunkHeader) * 42U, 1U}, - // alignment = alignof(ChunkHeader) / 2 - PayloadParams{0U, alignof(ChunkHeader) / 2}, - PayloadParams{1U, alignof(ChunkHeader) / 2}, - PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) / 2}, - PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) / 2}, - // alignment = alignof(ChunkHeader) - PayloadParams{0U, alignof(ChunkHeader)}, - PayloadParams{1U, alignof(ChunkHeader)}, - PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader)}, - PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader)}, - // alignment = alignof(ChunkHeader) * 2 - PayloadParams{0U, alignof(ChunkHeader) * 2}, - PayloadParams{1U, alignof(ChunkHeader) * 2}, - PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) * 2}, - PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) * 2}, - // alignment = PayloadParams::MAX_ALIGNMENT - PayloadParams{0U, PayloadParams::MAX_ALIGNMENT}, - PayloadParams{1U, PayloadParams::MAX_ALIGNMENT}, - PayloadParams{sizeof(ChunkHeader), PayloadParams::MAX_ALIGNMENT}, - PayloadParams{sizeof(ChunkHeader) * 42U, PayloadParams::MAX_ALIGNMENT})); +INSTANTIATE_TEST_SUITE_P(ChunkSettings_test, + ChunkSettings_AlteringUserPayloadWithoutUserHeader, + ::testing::Values( + // alignment = 0 + PayloadParams{0U, 0U}, + PayloadParams{1U, 0U}, + PayloadParams{sizeof(ChunkHeader), 0U}, + PayloadParams{sizeof(ChunkHeader) * 42U, 0U}, + // alignment = 1 + PayloadParams{0U, 1U}, + PayloadParams{1U, 1U}, + PayloadParams{sizeof(ChunkHeader), 1U}, + PayloadParams{sizeof(ChunkHeader) * 42U, 1U}, + // alignment = alignof(ChunkHeader) / 2 + PayloadParams{0U, alignof(ChunkHeader) / 2}, + PayloadParams{1U, alignof(ChunkHeader) / 2}, + PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) / 2}, + PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) / 2}, + // alignment = alignof(ChunkHeader) + PayloadParams{0U, alignof(ChunkHeader)}, + PayloadParams{1U, alignof(ChunkHeader)}, + PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader)}, + PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader)}, + // alignment = alignof(ChunkHeader) * 2 + PayloadParams{0U, alignof(ChunkHeader) * 2}, + PayloadParams{1U, alignof(ChunkHeader) * 2}, + PayloadParams{sizeof(ChunkHeader), alignof(ChunkHeader) * 2}, + PayloadParams{sizeof(ChunkHeader) * 42U, alignof(ChunkHeader) * 2}, + // alignment = PayloadParams::MAX_ALIGNMENT + PayloadParams{0U, PayloadParams::MAX_ALIGNMENT}, + PayloadParams{1U, PayloadParams::MAX_ALIGNMENT}, + PayloadParams{sizeof(ChunkHeader), PayloadParams::MAX_ALIGNMENT}, + PayloadParams{sizeof(ChunkHeader) * 42U, PayloadParams::MAX_ALIGNMENT})); TEST_P(ChunkSettings_AlteringUserPayloadWithoutUserHeader, RequiredChunkSizeIsCorrect) { @@ -301,39 +301,39 @@ class ChunkSettings_AlteringUserPayloadWithUserHeader : public ::testing::TestWi // with a user-header, the user-payload is located right after the UserPayloadOffset_t, therefore the user-payload size // and alignment parameters are made dependant on the UserPayloadOffset_t -INSTANTIATE_TEST_CASE_P(ChunkSettings_test, - ChunkSettings_AlteringUserPayloadWithUserHeader, - ::testing::Values( - // alignment = 0 - PayloadParams{0U, 0U}, - PayloadParams{1U, 0U}, - PayloadParams{sizeof(UserPayloadOffset_t), 0U}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 0U}, - // alignment = 1 - PayloadParams{0U, 1U}, - PayloadParams{1U, 1U}, - PayloadParams{sizeof(UserPayloadOffset_t), 1U}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 1U}, - // alignment = alignof(UserPayloadOffset_t) / 2 - PayloadParams{0U, alignof(UserPayloadOffset_t) / 2}, - PayloadParams{1U, alignof(UserPayloadOffset_t) / 2}, - PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) / 2}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) / 2}, - // alignment = alignof(UserPayloadOffset_t) - PayloadParams{0U, alignof(UserPayloadOffset_t)}, - PayloadParams{1U, alignof(UserPayloadOffset_t)}, - PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t)}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t)}, - // alignment = alignof(UserPayloadOffset_t) * 2 - PayloadParams{0U, alignof(UserPayloadOffset_t) * 2}, - PayloadParams{1U, alignof(UserPayloadOffset_t) * 2}, - PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) * 2}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) * 2}, - // alignment = PayloadParams::MAX_ALIGNMENT - PayloadParams{0U, PayloadParams::MAX_ALIGNMENT}, - PayloadParams{1U, PayloadParams::MAX_ALIGNMENT}, - PayloadParams{sizeof(UserPayloadOffset_t), PayloadParams::MAX_ALIGNMENT}, - PayloadParams{sizeof(UserPayloadOffset_t) * 42U, PayloadParams::MAX_ALIGNMENT})); +INSTANTIATE_TEST_SUITE_P(ChunkSettings_test, + ChunkSettings_AlteringUserPayloadWithUserHeader, + ::testing::Values( + // alignment = 0 + PayloadParams{0U, 0U}, + PayloadParams{1U, 0U}, + PayloadParams{sizeof(UserPayloadOffset_t), 0U}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 0U}, + // alignment = 1 + PayloadParams{0U, 1U}, + PayloadParams{1U, 1U}, + PayloadParams{sizeof(UserPayloadOffset_t), 1U}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, 1U}, + // alignment = alignof(UserPayloadOffset_t) / 2 + PayloadParams{0U, alignof(UserPayloadOffset_t) / 2}, + PayloadParams{1U, alignof(UserPayloadOffset_t) / 2}, + PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) / 2}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) / 2}, + // alignment = alignof(UserPayloadOffset_t) + PayloadParams{0U, alignof(UserPayloadOffset_t)}, + PayloadParams{1U, alignof(UserPayloadOffset_t)}, + PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t)}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t)}, + // alignment = alignof(UserPayloadOffset_t) * 2 + PayloadParams{0U, alignof(UserPayloadOffset_t) * 2}, + PayloadParams{1U, alignof(UserPayloadOffset_t) * 2}, + PayloadParams{sizeof(UserPayloadOffset_t), alignof(UserPayloadOffset_t) * 2}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, alignof(UserPayloadOffset_t) * 2}, + // alignment = PayloadParams::MAX_ALIGNMENT + PayloadParams{0U, PayloadParams::MAX_ALIGNMENT}, + PayloadParams{1U, PayloadParams::MAX_ALIGNMENT}, + PayloadParams{sizeof(UserPayloadOffset_t), PayloadParams::MAX_ALIGNMENT}, + PayloadParams{sizeof(UserPayloadOffset_t) * 42U, PayloadParams::MAX_ALIGNMENT})); uint32_t expectedChunkSizeWithUserHeader(const PayloadParams& userPayload, uint32_t userHeaderSize) { diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp index b426693c6e..98901302b9 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp @@ -36,11 +36,9 @@ using namespace iox::cxx; using namespace iox::mepoo; using ChunkDistributorTestSubjects = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(ChunkDistributor_test, ChunkDistributorTestSubjects); -#pragma GCC diagnostic pop + +TYPED_TEST_SUITE(ChunkDistributor_test, ChunkDistributorTestSubjects); + template class ChunkDistributor_test : public Test diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp index 46cf32922e..f5e949116f 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_queue.cpp @@ -82,11 +82,8 @@ using ChunkQueueSubjects = TypeDefinitions, TypeDefinitions>; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(ChunkQueue_test, ChunkQueueSubjects); -#pragma GCC diagnostic pop +TYPED_TEST_SUITE(ChunkQueue_test, ChunkQueueSubjects); + template class ChunkQueue_test : public Test, public ChunkQueue_testBase @@ -239,11 +236,9 @@ TYPED_TEST(ChunkQueue_test, AttachSecondConditionVariable) /// @note this could be changed to a parameterized ChunkQueueSaturatingFIFO_test when there are more FIFOs available using ChunkQueueFiFoTestSubjects = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(ChunkQueueFiFo_test, ChunkQueueFiFoTestSubjects); -#pragma GCC diagnostic pop + +TYPED_TEST_SUITE(ChunkQueueFiFo_test, ChunkQueueFiFoTestSubjects); + template class ChunkQueueFiFo_test : public Test, public ChunkQueue_testBase @@ -301,11 +296,9 @@ TYPED_TEST(ChunkQueueFiFo_test, PushFull) /// @note this could be changed to a parameterized ChunkQueueOverflowingFIFO_test when there are more FIFOs available using ChunkQueueSoFiSubjects = Types; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(ChunkQueueSoFi_test, ChunkQueueSoFiSubjects); -#pragma GCC diagnostic pop + +TYPED_TEST_SUITE(ChunkQueueSoFi_test, ChunkQueueSoFiSubjects); + template class ChunkQueueSoFi_test : public Test, public ChunkQueue_testBase diff --git a/iceoryx_posh/test/moduletests/test_popo_sample.cpp b/iceoryx_posh/test/moduletests/test_popo_sample.cpp index 22f4d68e1a..88ea8cb58f 100644 --- a/iceoryx_posh/test/moduletests/test_popo_sample.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_sample.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ class MockPublisherInterface : public iox::popo::PublisherInterface auto s = std::move(sample); // this step is necessary since the mock method doesn't execute the move return publishMock(std::move(s)); } - MOCK_METHOD1_T(publishMock, void(iox::popo::Sample&&)); + MOCK_METHOD(void, publishMock, ((iox::popo::Sample &&)), (noexcept)); }; class SampleTest : public Test @@ -125,10 +125,6 @@ TEST_F(SampleTest, CallingGetUserHeaderFromNonConstTypeReturnsCorrectAddress) auto sut = iox::popo::Sample(std::move(testSamplePtr), mockPublisherInterface); - // this line is actually not needed for the tests but if it is not present gmock raises a unused-function warning in - // gmock-spec-builders.h which breaks the build with -Werror - EXPECT_CALL(mockPublisherInterface, publishMock).Times(0); - // ===== Test ===== // auto& userHeader = sut.getUserHeader(); diff --git a/iceoryx_posh/test/moduletests/test_popo_toml_gateway_config_parser.cpp b/iceoryx_posh/test/moduletests/test_popo_toml_gateway_config_parser.cpp index 90ed69fed2..19a035c111 100644 --- a/iceoryx_posh/test/moduletests/test_popo_toml_gateway_config_parser.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_toml_gateway_config_parser.cpp @@ -74,25 +74,20 @@ class TomlGatewayConfigParserSuiteTest : public TestWithParam, TypedUniqueId>; -/// we require TYPED_TEST since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -TYPED_TEST_CASE(TypedUniqueId_test, Implementations); -#pragma GCC diagnostic pop + +TYPED_TEST_SUITE(TypedUniqueId_test, Implementations); + TYPED_TEST(TypedUniqueId_test, DefaultConstructorIncrementsID) { diff --git a/iceoryx_posh/test/moduletests/test_roudi_config_toml_file_provider.cpp b/iceoryx_posh/test/moduletests/test_roudi_config_toml_file_provider.cpp index abbfe536a2..69284a5742 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_config_toml_file_provider.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_config_toml_file_provider.cpp @@ -54,10 +54,7 @@ TEST_F(RoudiConfigTomlFileProvider_test, ParseDefaultConfigIsSuccessful) EXPECT_FALSE(result.has_error()); } -/// we require INSTANTIATE_TEST_CASE_P since we support gtest 1.8 for our safety targets -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( ParseAllMalformedInputConfigFiles, RoudiConfigTomlFileProvider_test, Values(ParseErrorInputFile_t{iox::roudi::RouDiConfigFileParseError::NO_GENERAL_SECTION, @@ -78,7 +75,7 @@ INSTANTIATE_TEST_CASE_P( "roudi_config_error_mempool_without_chunk_count.toml"}, ParseErrorInputFile_t{iox::roudi::RouDiConfigFileParseError::EXCEPTION_IN_PARSER, "toml_parser_exception.toml"})); -#pragma GCC diagnostic pop + TEST_P(RoudiConfigTomlFileProvider_test, ParseMalformedInputFileCausesError) { diff --git a/iceoryx_posh/test/moduletests/test_roudi_memory_block.cpp b/iceoryx_posh/test/moduletests/test_roudi_memory_block.cpp index 2fd0adda9e..a035fe3de4 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_memory_block.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_memory_block.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2019, 2021 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,8 +33,8 @@ class MemoryBlock_Test : public Test public: void SetUp() override { - EXPECT_CALL(sut, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE)); - EXPECT_CALL(sut, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); + EXPECT_CALL(sut, size()).WillRepeatedly(Return(MEMORY_SIZE)); + EXPECT_CALL(sut, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); } void TearDown() override diff --git a/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp b/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp index 13e31e759c..e006d9ea2d 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020, 2021 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -78,12 +78,12 @@ TEST_F(RouDiMemoryManager_Test, CallingCreateMemoryWithMemoryProviderSucceeds) uint64_t MEMORY_ALIGNMENT_1{8}; uint64_t MEMORY_SIZE_2{32}; uint64_t MEMORY_ALIGNMENT_2{16}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_1)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); - EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)); - EXPECT_CALL(memoryBlock2, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_2)); - EXPECT_CALL(memoryBlock2, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_2)); - EXPECT_CALL(memoryBlock2, onMemoryAvailableMock(_)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE_1)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); + EXPECT_CALL(memoryBlock1, onMemoryAvailable(_)); + EXPECT_CALL(memoryBlock2, size()).WillRepeatedly(Return(MEMORY_SIZE_2)); + EXPECT_CALL(memoryBlock2, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT_2)); + EXPECT_CALL(memoryBlock2, onMemoryAvailable(_)); IOX_DISCARD_RESULT(memoryProvider1.addMemoryBlock(&memoryBlock1)); IOX_DISCARD_RESULT(memoryProvider2.addMemoryBlock(&memoryBlock2)); @@ -93,8 +93,8 @@ TEST_F(RouDiMemoryManager_Test, CallingCreateMemoryWithMemoryProviderSucceeds) EXPECT_THAT(sut.createAndAnnounceMemory().has_error(), Eq(false)); - EXPECT_CALL(memoryBlock1, destroyMock()); - EXPECT_CALL(memoryBlock2, destroyMock()); + EXPECT_CALL(memoryBlock1, destroy()); + EXPECT_CALL(memoryBlock2, destroy()); } TEST_F(RouDiMemoryManager_Test, CallingCreateMemoryWithMemoryProviderError) @@ -112,9 +112,9 @@ TEST_F(RouDiMemoryManager_Test, RouDiMemoryManagerDTorTriggersMemoryProviderDest { uint64_t MEMORY_SIZE_1{16}; uint64_t MEMORY_ALIGNMENT_1{8}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_1)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); - EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE_1)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); + EXPECT_CALL(memoryBlock1, onMemoryAvailable(_)); IOX_DISCARD_RESULT(memoryProvider1.addMemoryBlock(&memoryBlock1)); @@ -122,9 +122,9 @@ TEST_F(RouDiMemoryManager_Test, RouDiMemoryManagerDTorTriggersMemoryProviderDest RouDiMemoryManager sutDestroy; ASSERT_FALSE(sutDestroy.addMemoryProvider(&memoryProvider1).has_error()); ASSERT_FALSE(sutDestroy.createAndAnnounceMemory().has_error()); - EXPECT_CALL(memoryBlock1, destroyMock()).Times(1); + EXPECT_CALL(memoryBlock1, destroy()).Times(1); } - EXPECT_CALL(memoryBlock1, destroyMock()).Times(0); + EXPECT_CALL(memoryBlock1, destroy()).Times(0); } TEST_F(RouDiMemoryManager_Test, AddMemoryProviderExceedsCapacity) diff --git a/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp b/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp index 23021d12d6..8ee4986fd7 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2019, 2021 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -69,12 +69,12 @@ class MemoryProvider_Test : public Test iox::cxx::expected commonSetup() { EXPECT_FALSE(sut.addMemoryBlock(&memoryBlock1).has_error()); - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(COMMON_SETUP_MEMORY_SIZE)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(COMMON_SETUP_MEMORY_ALIGNMENT)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(COMMON_SETUP_MEMORY_SIZE)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(COMMON_SETUP_MEMORY_ALIGNMENT)); EXPECT_CALL(sut, createMemoryMock(COMMON_SETUP_MEMORY_SIZE, COMMON_SETUP_MEMORY_ALIGNMENT)).Times(1); EXPECT_CALL(sut, destroyMemoryMock()); - EXPECT_CALL(memoryBlock1, destroyMock()); + EXPECT_CALL(memoryBlock1, destroy()); return sut.create(); } @@ -178,8 +178,8 @@ TEST_F(MemoryProvider_Test, CreationFailed) ASSERT_FALSE(sutFailure.addMemoryBlock(&memoryBlock1).has_error()); uint64_t MEMORY_SIZE{16}; uint64_t MEMORY_ALIGNMENT{8}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); auto expectError = sutFailure.create(); ASSERT_THAT(expectError.has_error(), Eq(true)); @@ -193,7 +193,7 @@ TEST_F(MemoryProvider_Test, CreateAndAnnounceWithOneMemoryBlock) { ASSERT_FALSE(commonSetup().has_error()); - EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock1, onMemoryAvailable(_)).Times(1); sut.announceMemoryAvailable(); EXPECT_THAT(sut.isAvailableAnnounced(), Eq(true)); @@ -207,23 +207,23 @@ TEST_F(MemoryProvider_Test, CreateAndAnnounceWithMultipleMemoryBlocks) uint64_t MEMORY_ALIGNMENT_1{8}; uint64_t MEMORY_SIZE_2{32}; uint64_t MEMORY_ALIGNMENT_2{16}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_1)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); - EXPECT_CALL(memoryBlock2, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_2)); - EXPECT_CALL(memoryBlock2, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_2)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE_1)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); + EXPECT_CALL(memoryBlock2, size()).WillRepeatedly(Return(MEMORY_SIZE_2)); + EXPECT_CALL(memoryBlock2, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT_2)); EXPECT_CALL(sut, createMemoryMock(MEMORY_SIZE_1 + MEMORY_SIZE_2, std::max(MEMORY_ALIGNMENT_1, MEMORY_ALIGNMENT_2))) .Times(1); EXPECT_THAT(sut.create().has_error(), Eq(false)); - EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)).Times(1); - EXPECT_CALL(memoryBlock2, onMemoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock1, onMemoryAvailable(_)).Times(1); + EXPECT_CALL(memoryBlock2, onMemoryAvailable(_)).Times(1); sut.announceMemoryAvailable(); EXPECT_THAT(sut.isAvailableAnnounced(), Eq(true)); EXPECT_CALL(sut, destroyMemoryMock()); - EXPECT_CALL(memoryBlock1, destroyMock()); - EXPECT_CALL(memoryBlock2, destroyMock()); + EXPECT_CALL(memoryBlock1, destroy()); + EXPECT_CALL(memoryBlock2, destroy()); } TEST_F(MemoryProvider_Test, AddMemoryBlockAfterCreation) @@ -248,7 +248,7 @@ TEST_F(MemoryProvider_Test, MultipleAnnouncesAreSuppressed) { ASSERT_FALSE(commonSetup().has_error()); - EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock1, onMemoryAvailable(_)).Times(1); sut.announceMemoryAvailable(); sut.announceMemoryAvailable(); // this shouldn't trigger a second memoryAvailable call on memoryBlock1 diff --git a/iceoryx_posh/test/moduletests/test_roudi_posix_shm_memory_provider.cpp b/iceoryx_posh/test/moduletests/test_roudi_posix_shm_memory_provider.cpp index 9c36a08428..a8cef02501 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_posix_shm_memory_provider.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_posix_shm_memory_provider.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -70,14 +70,14 @@ TEST_F(PosixShmMemoryProvider_Test, CreateMemory) ASSERT_FALSE(sut.addMemoryBlock(&memoryBlock1).has_error()); uint64_t MEMORY_SIZE{16}; uint64_t MEMORY_ALIGNMENT{8}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); EXPECT_THAT(sut.create().has_error(), Eq(false)); EXPECT_THAT(shmExists(), Eq(true)); - EXPECT_CALL(memoryBlock1, destroyMock()); + EXPECT_CALL(memoryBlock1, destroy()); } TEST_F(PosixShmMemoryProvider_Test, DestroyMemory) @@ -87,12 +87,12 @@ TEST_F(PosixShmMemoryProvider_Test, DestroyMemory) ASSERT_FALSE(sut.addMemoryBlock(&memoryBlock1).has_error()); uint64_t MEMORY_SIZE{16}; uint64_t MEMORY_ALIGNMENT{8}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); ASSERT_FALSE(sut.create().has_error()); - EXPECT_CALL(memoryBlock1, destroyMock()); + EXPECT_CALL(memoryBlock1, destroy()); ASSERT_FALSE(sut.destroy().has_error()); @@ -106,8 +106,8 @@ TEST_F(PosixShmMemoryProvider_Test, CreationFailedWithAlignmentExceedingPageSize ASSERT_FALSE(sut.addMemoryBlock(&memoryBlock1).has_error()); uint64_t MEMORY_SIZE{16}; uint64_t MEMORY_ALIGNMENT{iox::posix::pageSize() + 8U}; - EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE)); - EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); + EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE)); + EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT)); auto expectFailed = sut.create(); ASSERT_THAT(expectFailed.has_error(), Eq(true));