From 46cdc3e09d863024952dc3c7de3529c3f41a78fc Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 4 Jan 2022 22:04:48 +0100 Subject: [PATCH] iox-#841 Remove workaround for mock due to GMock 1.8 limitation --- iceoryx_posh/test/mocks/posh_runtime_mock.hpp | 119 +++++------------- .../test/mocks/roudi_memory_block_mock.hpp | 33 +---- .../test/mocks/roudi_memory_provider_mock.hpp | 6 +- .../test/moduletests/test_popo_sample.cpp | 8 +- .../moduletests/test_roudi_memory_block.cpp | 6 +- .../moduletests/test_roudi_memory_manager.cpp | 28 ++--- .../test_roudi_memory_provider.cpp | 32 ++--- .../test_roudi_posix_shm_memory_provider.cpp | 18 +-- 8 files changed, 84 insertions(+), 166 deletions(-) diff --git a/iceoryx_posh/test/mocks/posh_runtime_mock.hpp b/iceoryx_posh/test/mocks/posh_runtime_mock.hpp index aecd923ff72..676b1490892 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 a8c5865967a..ab471f8cfaa 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 57bf4c4c5e1..4626807680b 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_popo_sample.cpp b/iceoryx_posh/test/moduletests/test_popo_sample.cpp index 22f4d68e1a4..88ea8cb58f0 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_roudi_memory_block.cpp b/iceoryx_posh/test/moduletests/test_roudi_memory_block.cpp index 2fd0adda9ef..a035fe3de4a 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 13e31e759cd..e006d9ea2d2 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 23021d12d6a..8ee4986fd77 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 9c36a08428e..a8cef025012 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));