diff --git a/doc/design/chunk_header.md b/doc/design/chunk_header.md index 63564be1e9..3de914bf28 100644 --- a/doc/design/chunk_header.md +++ b/doc/design/chunk_header.md @@ -43,26 +43,26 @@ Framing with terminology ``` class ChunkHeader { - uint32_t chunkSize; + uint32_t userHeaderSize{0U}; uint8_t chunkHeaderVersion; uint8_t reserved{0}; uint16_t userHeaderId; popo::UniquePortId originId; // underlying type = uint64_t uint64_t sequenceNumber; - uint32_t userHeaderSize{0U}; + uint64_t chunkSize; uint32_t userPayloadSize{0U}; uint32_t userPayloadAlignment{1U}; UserPayloadOffset_t userPayloadOffset; // alias to uint32_t }; ``` -- **chunkSize** is the size of the whole chunk +- **userHeaderSize** is the size of the chunk occupied by the user-header - **chunkHeaderVersion** is used to detect incompatibilities for record&replay functionality - **reserved** is currently not used and set to `0` - **userHeaderId** is currently not used and set to `NO_USER_HEADER` - **originId** is the unique identifier of the publisher the chunk was sent from - **sequenceNumber** is a serial number for the sent chunks -- **userHeaderSize** is the size of the chunk occupied by the user-header +- **chunkSize** is the size of the whole chunk - **userPayloadSize** is the size of the chunk occupied by the user-payload - **userPayloadAlignment** is the alignment of the chunk occupied by the user-payload - **userPayloadOffset** is the offset of the user-payload relative to the begin of the chunk diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 4e3e1944f0..3963b0ffb8 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -1293,3 +1293,9 @@ #include "iox/mpmc_lockfree_queue.hpp" iox::concurrent::MpmcLockFreeQueue q; ``` + +59. Payload Size for Memory Chunks is now `uin64_t`. + Hence the `ChunkHeader` (iceoryx_posh/mepoo/chunk_header.hpp) layout changes + and `m_chunkHeaderVersion` is getting increased. + Moreover many functions' signatures are also affected by this change. + diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/client.h b/iceoryx_binding_c/include/iceoryx_binding_c/client.h index 3979008dfe..986414f09f 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/client.h +++ b/iceoryx_binding_c/include/iceoryx_binding_c/client.h @@ -89,7 +89,7 @@ void iox_client_deinit(iox_client_t const self); /// for a custom user-payload alignment please use 'iox_client_loan_aligned_request' ENUM iox_AllocationResult iox_client_loan_request(iox_client_t const self, void** const payload, - const uint32_t payloadSize); + const uint64_t payloadSize); /// @brief allocates a request in the shared memory with a custom alignment for the user-payload /// @param[in] self handle of the client @@ -100,7 +100,7 @@ ENUM iox_AllocationResult iox_client_loan_request(iox_client_t const self, /// describes the error ENUM iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self, void** const payload, - const uint32_t payloadSize, + const uint64_t payloadSize, const uint32_t payloadAlignment); diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/publisher.h b/iceoryx_binding_c/include/iceoryx_binding_c/publisher.h index 022d29e49b..3fed75af8f 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/publisher.h +++ b/iceoryx_binding_c/include/iceoryx_binding_c/publisher.h @@ -87,7 +87,7 @@ void iox_pub_deinit(iox_pub_t const self); /// for a custom user-payload alignment please use 'iox_pub_loan_aligned_chunk' ENUM iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, void** const userPayload, - const uint32_t userPayloadSize); + const uint64_t userPayloadSize); /// @brief allocates a chunk in the shared memory with a custom alignment for the user-payload /// @param[in] self handle of the publisher @@ -98,7 +98,7 @@ ENUM iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, /// describes the error ENUM iox_AllocationResult iox_pub_loan_aligned_chunk(iox_pub_t const self, void** const userPayload, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment); /// @brief allocates a chunk in the shared memory with a section for the user-header and a custom alignment for the @@ -113,7 +113,7 @@ ENUM iox_AllocationResult iox_pub_loan_aligned_chunk(iox_pub_t const self, /// describes the error ENUM iox_AllocationResult iox_pub_loan_aligned_chunk_with_user_header(iox_pub_t const self, void** const userPayload, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment); diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/server.h b/iceoryx_binding_c/include/iceoryx_binding_c/server.h index d88ce05f46..d53bf4aa95 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/server.h +++ b/iceoryx_binding_c/include/iceoryx_binding_c/server.h @@ -103,7 +103,7 @@ void iox_server_release_request(iox_server_t const self, const void* const paylo ENUM iox_AllocationResult iox_server_loan_response(iox_server_t const self, const void* const requestPayload, void** const payload, - const uint32_t payloadSize); + const uint64_t payloadSize); /// @brief allocates a response in the shared memory /// @param[in] self handle of the server @@ -116,7 +116,7 @@ ENUM iox_AllocationResult iox_server_loan_response(iox_server_t const self, ENUM iox_AllocationResult iox_server_loan_aligned_response(iox_server_t const self, const void* const requestPayload, void** const payload, - const uint32_t payloadSize, + const uint64_t payloadSize, const uint32_t payloadAlignment); /// @brief sends a previously loaned response diff --git a/iceoryx_binding_c/source/c_client.cpp b/iceoryx_binding_c/source/c_client.cpp index 4eaa63b0a5..88f8da9e70 100644 --- a/iceoryx_binding_c/source/c_client.cpp +++ b/iceoryx_binding_c/source/c_client.cpp @@ -92,14 +92,14 @@ void iox_client_deinit(iox_client_t const self) delete self; } -iox_AllocationResult iox_client_loan_request(iox_client_t const self, void** const payload, const uint32_t payloadSize) +iox_AllocationResult iox_client_loan_request(iox_client_t const self, void** const payload, const uint64_t payloadSize) { return iox_client_loan_aligned_request(self, payload, payloadSize, IOX_C_CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); } iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self, void** const payload, - const uint32_t payloadSize, + const uint64_t payloadSize, const uint32_t payloadAlignment) { IOX_EXPECTS(self != nullptr); diff --git a/iceoryx_binding_c/source/c_publisher.cpp b/iceoryx_binding_c/source/c_publisher.cpp index 98b6eb7310..5e6b2287e3 100644 --- a/iceoryx_binding_c/source/c_publisher.cpp +++ b/iceoryx_binding_c/source/c_publisher.cpp @@ -113,7 +113,7 @@ void iox_pub_deinit(iox_pub_t const self) delete self; } -iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, void** const userPayload, const uint32_t userPayloadSize) +iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, void** const userPayload, const uint64_t userPayloadSize) { return iox_pub_loan_aligned_chunk_with_user_header(self, userPayload, @@ -125,7 +125,7 @@ iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, void** const userP iox_AllocationResult iox_pub_loan_aligned_chunk(iox_pub_t const self, void** const userPayload, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment) { return iox_pub_loan_aligned_chunk_with_user_header(self, @@ -138,7 +138,7 @@ iox_AllocationResult iox_pub_loan_aligned_chunk(iox_pub_t const self, iox_AllocationResult iox_pub_loan_aligned_chunk_with_user_header(iox_pub_t const self, void** const userPayload, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) diff --git a/iceoryx_binding_c/source/c_server.cpp b/iceoryx_binding_c/source/c_server.cpp index 9d8be6897a..4857ae7b6e 100644 --- a/iceoryx_binding_c/source/c_server.cpp +++ b/iceoryx_binding_c/source/c_server.cpp @@ -115,7 +115,7 @@ void iox_server_release_request(iox_server_t const self, const void* const paylo iox_AllocationResult iox_server_loan_response(iox_server_t const self, const void* const requestPayload, void** const payload, - const uint32_t payloadSize) + const uint64_t payloadSize) { return iox_server_loan_aligned_response( self, requestPayload, payload, payloadSize, IOX_C_CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); @@ -124,7 +124,7 @@ iox_AllocationResult iox_server_loan_response(iox_server_t const self, iox_AllocationResult iox_server_loan_aligned_response(iox_server_t const self, const void* const requestPayload, void** const payload, - const uint32_t payloadSize, + const uint64_t payloadSize, const uint32_t payloadAlignment) { IOX_EXPECTS(self != nullptr); diff --git a/iceoryx_binding_c/test/moduletests/test_chunk.cpp b/iceoryx_binding_c/test/moduletests/test_chunk.cpp index 7491ee78b3..79ff5d7778 100644 --- a/iceoryx_binding_c/test/moduletests/test_chunk.cpp +++ b/iceoryx_binding_c/test/moduletests/test_chunk.cpp @@ -60,7 +60,7 @@ class Chunk_test : public RouDi_GTest TEST_F(Chunk_test, GettingChunkHeaderFromNonConstUserPayloadWorks) { ::testing::Test::RecordProperty("TEST_ID", "a044b28d-ad7e-45ed-a0e2-e431ef1eacf0"); - constexpr uint32_t USER_PAYLOAD_SIZE(42U); + constexpr uint64_t USER_PAYLOAD_SIZE(42U); void* userPayload{nullptr}; ASSERT_EQ(iox_pub_loan_chunk(publisher, &userPayload, USER_PAYLOAD_SIZE), AllocationResult_SUCCESS); @@ -76,7 +76,7 @@ TEST_F(Chunk_test, GettingChunkHeaderFromNonConstUserPayloadWorks) TEST_F(Chunk_test, GettingChunkHeaderFromConstUserPayloadWorks) { ::testing::Test::RecordProperty("TEST_ID", "9f7bb07a-f0dd-4b58-af84-5daec365d9e2"); - constexpr uint32_t USER_PAYLOAD_SIZE(42U); + constexpr uint64_t USER_PAYLOAD_SIZE(42U); void* userPayload{nullptr}; ASSERT_EQ(iox_pub_loan_chunk(publisher, &userPayload, USER_PAYLOAD_SIZE), AllocationResult_SUCCESS); const void* constUserPayload = userPayload; @@ -93,7 +93,7 @@ TEST_F(Chunk_test, GettingChunkHeaderFromConstUserPayloadWorks) TEST_F(Chunk_test, UserPayloadChunkHeaderUserPayloadRoundtripWorksForNonConst) { ::testing::Test::RecordProperty("TEST_ID", "ea220aac-4d7d-41c2-92ea-7f929b824555"); - constexpr uint32_t USER_PAYLOAD_SIZE(42U); + constexpr uint64_t USER_PAYLOAD_SIZE(42U); void* userPayload{nullptr}; ASSERT_EQ(iox_pub_loan_chunk(publisher, &userPayload, USER_PAYLOAD_SIZE), AllocationResult_SUCCESS); const void* constUserPayload = userPayload; @@ -107,7 +107,7 @@ TEST_F(Chunk_test, UserPayloadChunkHeaderUserPayloadRoundtripWorksForNonConst) TEST_F(Chunk_test, UserPayloadChunkHeaderUserPayloadRoundtripWorksForConst) { ::testing::Test::RecordProperty("TEST_ID", "e094616d-6d99-4b7f-a619-dd98ec7d1e44"); - constexpr uint32_t USER_PAYLOAD_SIZE(42U); + constexpr uint64_t USER_PAYLOAD_SIZE(42U); void* userPayload{nullptr}; ASSERT_EQ(iox_pub_loan_chunk(publisher, &userPayload, USER_PAYLOAD_SIZE), AllocationResult_SUCCESS); @@ -120,7 +120,7 @@ TEST_F(Chunk_test, UserPayloadChunkHeaderUserPayloadRoundtripWorksForConst) TEST_F(Chunk_test, GettingUserHeaderFromNonConstChunkHeaderWorks) { ::testing::Test::RecordProperty("TEST_ID", "a0df7284-a377-4c6a-b22b-454d3f7c7b88"); - constexpr uint32_t USER_PAYLOAD_SIZE(42U); + constexpr uint64_t USER_PAYLOAD_SIZE(42U); constexpr uint32_t USER_PAYLOAD_ALIGNMENT(64U); constexpr uint32_t USER_HEADER_SIZE = 16U; constexpr uint32_t USER_HEADER_ALIGNMENT = 8U; @@ -146,7 +146,7 @@ TEST_F(Chunk_test, GettingUserHeaderFromNonConstChunkHeaderWorks) TEST_F(Chunk_test, GettingUserHeaderFromConstChunkHeaderWorks) { ::testing::Test::RecordProperty("TEST_ID", "77f4a193-7f44-43ce-8bd8-f9916b8d83dd"); - constexpr uint32_t USER_PAYLOAD_SIZE(42U); + constexpr uint64_t USER_PAYLOAD_SIZE(42U); constexpr uint32_t USER_PAYLOAD_ALIGNMENT(64U); constexpr uint32_t USER_HEADER_SIZE = 16U; constexpr uint32_t USER_HEADER_ALIGNMENT = 8U; diff --git a/iceoryx_binding_c/test/moduletests/test_listener.cpp b/iceoryx_binding_c/test/moduletests/test_listener.cpp index 455ebdcc28..efe1086937 100644 --- a/iceoryx_binding_c/test/moduletests/test_listener.cpp +++ b/iceoryx_binding_c/test/moduletests/test_listener.cpp @@ -199,7 +199,7 @@ class iox_listener_test : public Test vector m_userTrigger; static constexpr uint32_t NUM_CHUNKS_IN_POOL = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY + 2U; - static constexpr uint32_t CHUNK_SIZE = 128U; + static constexpr uint64_t CHUNK_SIZE = 128U; static constexpr uint64_t MEMORY_SIZE = 1024U * 1024U * 100U; uint8_t m_memory[MEMORY_SIZE]; BumpAllocator m_memoryAllocator{m_memory, MEMORY_SIZE}; @@ -511,7 +511,7 @@ TIMING_TEST_F(iox_listener_test, SubscriberCallbackIsCalledSampleIsReceived, Rep Eq(iox_ListenerResult::ListenerResult_SUCCESS)); Subscribe(m_subscriber[0U]); - constexpr uint32_t USER_PAYLOAD_SIZE{100U}; + constexpr uint64_t USER_PAYLOAD_SIZE{100U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); @@ -537,7 +537,7 @@ TIMING_TEST_F(iox_listener_test, SubscriberCallbackWithContextDataIsCalledSample Eq(iox_ListenerResult::ListenerResult_SUCCESS)); Subscribe(m_subscriber[0U]); - constexpr uint32_t USER_PAYLOAD_SIZE{100U}; + constexpr uint64_t USER_PAYLOAD_SIZE{100U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); diff --git a/iceoryx_binding_c/test/moduletests/test_notification_info.cpp b/iceoryx_binding_c/test/moduletests/test_notification_info.cpp index 281811afff..414ff7b450 100644 --- a/iceoryx_binding_c/test/moduletests/test_notification_info.cpp +++ b/iceoryx_binding_c/test/moduletests/test_notification_info.cpp @@ -84,7 +84,7 @@ class iox_notification_info_test : public Test iox::mepoo::SharedChunk getChunkFromMemoryManager() { - constexpr uint32_t USER_PAYLOAD_SIZE{100U}; + 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()); @@ -105,7 +105,7 @@ class iox_notification_info_test : public Test UserTrigger m_userTrigger; static constexpr uint32_t NUM_CHUNKS_IN_POOL = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY + 2; - static constexpr uint32_t CHUNK_SIZE = 128U; + static constexpr uint64_t CHUNK_SIZE = 128U; static constexpr size_t MEMORY_SIZE = 1024 * 1024 * 100; uint8_t m_memory[MEMORY_SIZE]; BumpAllocator m_memoryAllocator{m_memory, MEMORY_SIZE}; diff --git a/iceoryx_binding_c/test/moduletests/test_publisher.cpp b/iceoryx_binding_c/test/moduletests/test_publisher.cpp index b5a6d9646a..90e0baf6f1 100644 --- a/iceoryx_binding_c/test/moduletests/test_publisher.cpp +++ b/iceoryx_binding_c/test/moduletests/test_publisher.cpp @@ -98,7 +98,7 @@ class iox_pub_test : public Test static constexpr size_t MEMORY_SIZE = 1024 * 1024; uint8_t m_memory[MEMORY_SIZE]; static constexpr uint32_t NUM_CHUNKS_IN_POOL = 20; - static constexpr uint32_t CHUNK_SIZE = 256; + static constexpr uint64_t CHUNK_SIZE = 256; using ChunkQueueData_t = popo::ChunkQueueData; ChunkQueueData_t m_chunkQueueData{iox::popo::QueueFullPolicy::DISCARD_OLDEST_DATA, @@ -284,7 +284,7 @@ TEST_F(iox_pub_test, allocate_chunkFailsWhenHoldingToManyChunksInParallel) TEST_F(iox_pub_test, allocate_chunkFailsWhenOutOfChunks) { ::testing::Test::RecordProperty("TEST_ID", "7563ed4c-a6d5-487d-9c6c-937d8e8c3d1d"); - constexpr uint32_t USER_PAYLOAD_SIZE{100U}; + constexpr uint64_t USER_PAYLOAD_SIZE{100U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); diff --git a/iceoryx_binding_c/test/moduletests/test_server.cpp b/iceoryx_binding_c/test/moduletests/test_server.cpp index dd7738cbb6..15bf295579 100644 --- a/iceoryx_binding_c/test/moduletests/test_server.cpp +++ b/iceoryx_binding_c/test/moduletests/test_server.cpp @@ -66,7 +66,7 @@ class iox_server_test : public Test return &*sutPort; } - void receiveRequest(const int64_t requestValue = 0, const uint32_t chunkSize = sizeof(int64_t)) + void receiveRequest(const int64_t requestValue = 0, const uint64_t chunkSize = sizeof(int64_t)) { auto chunk = memoryManager.getChunk(*iox::mepoo::ChunkSettings::create( chunkSize, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, sizeof(RequestHeader))); diff --git a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp index c9111f18c8..37393c56fa 100644 --- a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp +++ b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp @@ -89,7 +89,7 @@ class iox_sub_test : public Test iox::mepoo::SharedChunk getChunkFromMemoryManager() { - constexpr uint32_t USER_PAYLOAD_SIZE{100U}; + 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()); @@ -104,7 +104,7 @@ class iox_sub_test : public Test static constexpr size_t MEMORY_SIZE = 1024 * 1024 * 100; uint8_t m_memory[MEMORY_SIZE]; static constexpr uint32_t NUM_CHUNKS_IN_POOL = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY + 2U; - static constexpr uint32_t CHUNK_SIZE = 128U; + static constexpr uint64_t CHUNK_SIZE = 128U; BumpAllocator m_memoryAllocator{m_memory, MEMORY_SIZE}; MePooConfig m_mempoolconf; diff --git a/iceoryx_meta/build_options.cmake b/iceoryx_meta/build_options.cmake index 09dd40b3db..90fc1357ea 100644 --- a/iceoryx_meta/build_options.cmake +++ b/iceoryx_meta/build_options.cmake @@ -34,6 +34,7 @@ option(ROUDI_ENVIRONMENT "Build RouDi Environment for testing, is enabled when b option(ADDRESS_SANITIZER "Build with address sanitizer" OFF) option(THREAD_SANITIZER "Build with thread sanitizer" OFF) option(TEST_WITH_ADDITIONAL_USER "Build Test with additional user accounts for testing access control" OFF) +option(TEST_WITH_HUGE_PAYLOAD "Build Tests which use payload bigger than 2GB" OFF) option(TOML_CONFIG "TOML support for RouDi with dynamic configuration" ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # "Create compile_commands.json file" @@ -90,5 +91,6 @@ function(show_config_options) message(" ADDRESS_SANITIZER....................: " ${ADDRESS_SANITIZER}) message(" THREAD_SANITIZER.....................: " ${THREAD_SANITIZER}) message(" TEST_WITH_ADDITIONAL_USER ...........: " ${TEST_WITH_ADDITIONAL_USER}) + message(" TEST_WITH_HUGE_PAYLOAD ..............: " ${TEST_WITH_HUGE_PAYLOAD}) message(" TOML_CONFIG..........................: " ${TOML_CONFIG}) endfunction() diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp index b525d38982..e65e324df6 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp @@ -37,12 +37,12 @@ struct MemPoolInfo MemPoolInfo(const uint32_t usedChunks, const uint32_t minFreeChunks, const uint32_t numChunks, - const uint32_t chunkSize) noexcept; + const uint64_t chunkSize) noexcept; uint32_t m_usedChunks{0}; uint32_t m_minFreeChunks{0}; uint32_t m_numChunks{0}; - uint32_t m_chunkSize{0}; + uint64_t m_chunkSize{0}; }; class MemPool @@ -51,7 +51,7 @@ class MemPool using freeList_t = concurrent::MpmcLoFFLi; static constexpr uint64_t CHUNK_MEMORY_ALIGNMENT = 8U; // default alignment for 64 bit - MemPool(const greater_or_equal chunkSize, + MemPool(const greater_or_equal chunkSize, const greater_or_equal numberOfChunks, iox::BumpAllocator& managementAllocator, iox::BumpAllocator& chunkMemoryAllocator) noexcept; @@ -62,7 +62,7 @@ class MemPool MemPool& operator=(MemPool&&) = delete; void* getChunk() noexcept; - uint32_t getChunkSize() const noexcept; + uint64_t getChunkSize() const noexcept; uint32_t getChunkCount() const noexcept; uint32_t getUsedChunks() const noexcept; uint32_t getMinFree() const noexcept; @@ -75,7 +75,7 @@ class MemPool /// @param[in] chunkSize is the size of the chunk /// @param[in] rawMemoryBase it the pointer to the raw memory of the MemPool /// @return the pointer to the chunk - static void* indexToPointer(const uint32_t index, const uint32_t chunkSize, void* const rawMemoryBase) noexcept; + static void* indexToPointer(const uint32_t index, const uint64_t chunkSize, void* const rawMemoryBase) noexcept; /// @brief Converts a pointer to a chunk in the MemPool to an index /// @param[in] chunk is the pointer to the chunk @@ -83,15 +83,15 @@ class MemPool /// @param[in] rawMemoryBase it the pointer to the raw memory of the MemPool /// @return the index to the chunk static uint32_t - pointerToIndex(const void* const chunk, const uint32_t chunkSize, const void* const rawMemoryBase) noexcept; + pointerToIndex(const void* const chunk, const uint64_t chunkSize, const void* const rawMemoryBase) noexcept; private: void adjustMinFree() noexcept; - bool isMultipleOfAlignment(const uint32_t value) const noexcept; + bool isMultipleOfAlignment(const uint64_t value) const noexcept; RelativePointer m_rawMemory; - uint32_t m_chunkSize{0U}; + uint64_t m_chunkSize{0U}; /// needs to be 32 bit since loffli supports only 32 bit numbers /// (cas is only 64 bit and we need the other 32 bit for the aba counter) uint32_t m_numberOfChunks{0U}; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/memory_manager.hpp b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/memory_manager.hpp index f267289ac9..588a5c1df8 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/memory_manager.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/memory_manager.hpp @@ -46,7 +46,7 @@ struct MePooConfig; class MemoryManager { - using MaxChunkPayloadSize_t = range::max() - sizeof(ChunkHeader)>; + using MaxChunkPayloadSize_t = range::max() - sizeof(ChunkHeader)>; public: enum class Error @@ -81,12 +81,12 @@ class MemoryManager static uint64_t requiredFullMemorySize(const MePooConfig& mePooConfig) noexcept; private: - static uint32_t sizeWithChunkHeaderStruct(const MaxChunkPayloadSize_t size) noexcept; + static uint64_t sizeWithChunkHeaderStruct(const MaxChunkPayloadSize_t size) noexcept; void printMemPoolVector(log::LogStream& log) const noexcept; void addMemPool(BumpAllocator& managementAllocator, BumpAllocator& chunkMemoryAllocator, - const greater_or_equal chunkPayloadSize, + const greater_or_equal chunkPayloadSize, const greater_or_equal numberOfChunks) noexcept; void generateChunkManagementPool(BumpAllocator& managementAllocator) noexcept; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/typed_mem_pool.inl b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/typed_mem_pool.inl index 2db4056ef0..e68d33c503 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/typed_mem_pool.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/typed_mem_pool.inl @@ -30,7 +30,7 @@ template inline TypedMemPool::TypedMemPool(const greater_or_equal numberOfChunks, BumpAllocator& managementAllocator, BumpAllocator& chunkMemoryAllocator) noexcept - : m_memPool(static_cast(requiredChunkSize()), numberOfChunks, managementAllocator, chunkMemoryAllocator) + : m_memPool(requiredChunkSize(), numberOfChunks, managementAllocator, chunkMemoryAllocator) , m_chunkManagementPool(sizeof(ChunkManagement), numberOfChunks, managementAllocator, managementAllocator) { } @@ -101,7 +101,7 @@ inline uint64_t TypedMemPool::requiredChunkSize() noexcept // this is safe since we use correct values for size and alignment auto& chunkSettings = chunkSettingsResult.value(); - return align(static_cast(chunkSettings.requiredChunkSize()), MemPool::CHUNK_MEMORY_ALIGNMENT); + return align(chunkSettings.requiredChunkSize(), MemPool::CHUNK_MEMORY_ALIGNMENT); } template diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.hpp index 95ac75a952..2456825394 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.hpp @@ -99,7 +99,7 @@ class ChunkSender : public ChunkDistributor tryAllocate(const UniquePortId originId, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) noexcept; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.inl index ed9eb1e7db..81b7fe4a69 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_sender.inl @@ -96,7 +96,7 @@ inline typename ChunkSender::MemberType_t* ChunkSender inline expected ChunkSender::tryAllocate(const UniquePortId originId, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) noexcept @@ -113,7 +113,7 @@ ChunkSender::tryAllocate(const UniquePortId originId, } const auto& chunkSettings = chunkSettingsResult.value(); - const uint32_t requiredChunkSize = chunkSettings.requiredChunkSize(); + const uint64_t requiredChunkSize = chunkSettings.requiredChunkSize(); auto& lastChunkUnmanaged = getMembers()->m_lastChunkUnmanaged; mepoo::ChunkHeader* lastChunkChunkHeader = diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/client_port_user.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/client_port_user.hpp index d4f2291dca..ad4a8989eb 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/client_port_user.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/client_port_user.hpp @@ -81,7 +81,7 @@ class ClientPortUser : public BasePort /// @param[in] userPayloadAlignment, alignment of the user-paylaod without additional headers /// @return on success pointer to a RequestHeader which can be used to access the chunk-header, user-header and /// user-payload fields, error if not - expected allocateRequest(const uint32_t userPayloadSize, + expected allocateRequest(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment) noexcept; /// @brief Releases an allocated request without sending it diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/publisher_port_user.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/publisher_port_user.hpp index a045948e82..a33777e318 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/publisher_port_user.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/publisher_port_user.hpp @@ -56,7 +56,7 @@ class PublisherPortUser : public BasePort /// to omit a user-header /// @return on success pointer to a ChunkHeader which can be used to access the chunk-header, user-header and /// user-payload fields, error if not - expected tryAllocateChunk(const uint32_t userPayloadSize, + expected tryAllocateChunk(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize = 0U, const uint32_t userHeaderAlignment = 1U) noexcept; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/server_port_user.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/server_port_user.hpp index e5332fedd3..44aaed17ef 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/server_port_user.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/server_port_user.hpp @@ -135,7 +135,7 @@ class ServerPortUser : public BasePort /// @return on success pointer to a ChunkHeader which can be used to access the chunk-header, user-header and /// user-payload fields, error if not expected allocateResponse(const RequestHeader* const requestHeader, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment) noexcept; /// @brief Releases an allocated response without sending it diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.hpp index 085f3a397b..b71ef84242 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.hpp @@ -48,7 +48,7 @@ class UntypedClientImpl : public BaseClientT /// @return A pointer to the payload of a chunk of memory with the requested size or /// an AllocationError if no chunk could be loaned. /// @note An AllocationError occurs if no chunk is available in the shared memory. - expected loan(const uint32_t payloadSize, const uint32_t payloadAlignment) noexcept; + expected loan(const uint64_t payloadSize, const uint32_t payloadAlignment) noexcept; /// @brief Releases the ownership of the request chunk provided by the payload pointer. /// @param requestPayload pointer to the payload of the chunk to be released diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.inl index b83c4b486a..76d0f42f10 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_client_impl.inl @@ -37,7 +37,7 @@ UntypedClientImpl::~UntypedClientImpl() noexcept } template -expected UntypedClientImpl::loan(const uint32_t payloadSize, +expected UntypedClientImpl::loan(const uint64_t payloadSize, const uint32_t payloadAlignment) noexcept { auto allocationResult = port().allocateRequest(payloadSize, payloadAlignment); diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.hpp index a63697a2bb..2ef7c99a28 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.hpp @@ -48,7 +48,7 @@ class UntypedPublisherImpl : public BasePublisherType /// @note An AllocationError occurs if no chunk is available in the shared memory. /// expected - loan(const uint32_t userPayloadSize, + loan(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment = iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, const uint32_t userHeaderSize = iox::CHUNK_NO_USER_HEADER_SIZE, const uint32_t userHeaderAlignment = iox::CHUNK_NO_USER_HEADER_ALIGNMENT) noexcept; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.inl index 0bcd24d98e..f372caaf07 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_publisher_impl.inl @@ -40,7 +40,7 @@ inline void UntypedPublisherImpl::publish(void* const userPay template inline expected -UntypedPublisherImpl::loan(const uint32_t userPayloadSize, +UntypedPublisherImpl::loan(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) noexcept diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.hpp index 5f5497506b..5a7274d1cc 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.hpp @@ -62,7 +62,7 @@ class UntypedServerImpl : public BaseServerT /// an AllocationError if no chunk could be loaned. /// @note An AllocationError occurs if no chunk is available in the shared memory. expected loan(const RequestHeader* const requestHeader, - const uint32_t payloadSize, + const uint64_t payloadSize, const uint32_t payloadAlignment) noexcept; /// @brief Sends the provided memory chunk as response to the client. diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.inl index b887f16d48..58340e33d9 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/untyped_server_impl.inl @@ -60,7 +60,7 @@ void UntypedServerImpl::releaseRequest(const void* const requestPay template expected UntypedServerImpl::loan(const RequestHeader* const requestHeader, - const uint32_t payloadSize, + const uint64_t payloadSize, const uint32_t payloadAlignment) noexcept { auto allocationResult = port().allocateResponse(requestHeader, payloadSize, payloadAlignment); diff --git a/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_header.hpp b/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_header.hpp index d888881414..ebad3fc8aa 100644 --- a/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_header.hpp +++ b/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_header.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2024 by Bartlomiej Kozaryna . 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. @@ -46,7 +47,7 @@ struct ChunkHeader /// @brief constructs and initializes a ChunkHeader /// @param[in] chunkSize is the size of the chunk the ChunkHeader is constructed /// @param[in] chunkSettings are the settings like user-payload size and user-header alignment - ChunkHeader(const uint32_t chunkSize, const ChunkSettings& chunkSettings) noexcept; + ChunkHeader(const uint64_t chunkSize, const ChunkSettings& chunkSettings) noexcept; // copy/move ctors/assignment operators are deleted since the calculations for the user-header and user-payload // alignment are dependent on the address of the this pointer @@ -60,7 +61,7 @@ struct ChunkHeader /// - data width of members changes /// - members are rearranged /// - semantic meaning of a member changes - static constexpr uint8_t CHUNK_HEADER_VERSION{1U}; + static constexpr uint8_t CHUNK_HEADER_VERSION{2U}; /// @brief User-Header id for no user-header static constexpr uint16_t NO_USER_HEADER{0x0000}; @@ -113,11 +114,11 @@ struct ChunkHeader /// @brief Calculates the used size of the chunk with the ChunkHeader, user-heander and user-payload /// @return the used size of the chunk - uint32_t usedSizeOfChunk() const noexcept; + uint64_t usedSizeOfChunk() const noexcept; /// @brief The size of the whole chunk, including the header /// @return the chunk size - uint32_t chunkSize() const noexcept; + uint64_t chunkSize() const noexcept; /// @brief The size of the chunk occupied by the user-header /// @return the user-header size @@ -125,7 +126,7 @@ struct ChunkHeader /// @brief The size of the chunk occupied by the user-payload /// @return the user-payload size - uint32_t userPayloadSize() const noexcept; + uint64_t userPayloadSize() const noexcept; /// @brief The alignment of the chunk occupied by the user-payload /// @return the user-payload alignment @@ -152,11 +153,10 @@ struct ChunkHeader private: // the order of these members must be changed carefully and if this happens, the m_chunkHeaderVersion // needs to be adapted in order to be able to detect incompatibilities between publisher/subscriber - // or record&replay, m_chunkSize and m_chunkHeaderVersion should therefore neither changed the type, - // nor the position + // or record&replay, m_chunkHeaderVersion should therefore neither changed the type, + // nor the position (offset from the beginning) - // size of the whole chunk, including the header - uint32_t m_chunkSize{0U}; + uint32_t m_userHeaderSize{0U}; uint8_t m_chunkHeaderVersion{CHUNK_HEADER_VERSION}; // reserved for future functionality and used to indicate the padding bytes; currently not used and set to '0' uint8_t m_reserved{0}; @@ -164,8 +164,9 @@ struct ChunkHeader uint16_t m_userHeaderId{NO_USER_HEADER}; popo::UniquePortId m_originId{popo::InvalidPortId}; uint64_t m_sequenceNumber{0U}; - uint32_t m_userHeaderSize{0U}; - uint32_t m_userPayloadSize{0U}; + // size of the whole chunk, including the header + uint64_t m_chunkSize{0U}; + uint64_t m_userPayloadSize{0U}; uint32_t m_userPayloadAlignment{1U}; UserPayloadOffset_t m_userPayloadOffset{sizeof(ChunkHeader)}; }; diff --git a/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_settings.hpp b/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_settings.hpp index 93326bc8ff..90184fb154 100644 --- a/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_settings.hpp +++ b/iceoryx_posh/include/iceoryx_posh/mepoo/chunk_settings.hpp @@ -45,18 +45,18 @@ class ChunkSettings /// @param[in] userHeaderSize is the size of the user-header /// @param[in] userHeaderAlignment is the alignment for the user-header static expected - create(const uint32_t userPayloadSize, + create(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment = iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, const uint32_t userHeaderSize = iox::CHUNK_NO_USER_HEADER_SIZE, const uint32_t userHeaderAlignment = iox::CHUNK_NO_USER_HEADER_ALIGNMENT) noexcept; /// @brief getter method for the chunk size fulfilling the user-payload and user-header requirements /// @return the chunk size - uint32_t requiredChunkSize() const noexcept; + uint64_t requiredChunkSize() const noexcept; /// @brief getter method for the user-payload size /// @return the user-payload size - uint32_t userPayloadSize() const noexcept; + uint64_t userPayloadSize() const noexcept; /// @brief getter method for the user-payload alignment /// @return the user-payload alignment @@ -71,22 +71,22 @@ class ChunkSettings uint32_t userHeaderAlignment() const noexcept; private: - ChunkSettings(const uint32_t userPayloadSize, + ChunkSettings(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment, - const uint32_t requiredChunkSize) noexcept; + const uint64_t requiredChunkSize) noexcept; - static uint64_t calculateRequiredChunkSize(const uint32_t userPayloadSize, - const uint32_t userPayloadAlignment, - const uint32_t userHeaderSize) noexcept; + static expected calculateRequiredChunkSize(const uint64_t userPayloadSize, + const uint32_t userPayloadAlignment, + const uint32_t userHeaderSize) noexcept; private: - uint32_t m_userPayloadSize{0U}; + uint64_t m_userPayloadSize{0U}; uint32_t m_userPayloadAlignment{0U}; uint32_t m_userHeaderSize{0U}; uint32_t m_userHeaderAlignment{0U}; - uint32_t m_requiredChunkSize{0U}; + uint64_t m_requiredChunkSize{0U}; }; } // namespace mepoo diff --git a/iceoryx_posh/include/iceoryx_posh/mepoo/mepoo_config.hpp b/iceoryx_posh/include/iceoryx_posh/mepoo/mepoo_config.hpp index 6ff37ad9b8..2a254ce160 100644 --- a/iceoryx_posh/include/iceoryx_posh/mepoo/mepoo_config.hpp +++ b/iceoryx_posh/include/iceoryx_posh/mepoo/mepoo_config.hpp @@ -35,12 +35,12 @@ struct MePooConfig struct Entry { /// @brief set the size and count of memory chunks - Entry(uint32_t f_size, uint32_t f_chunkCount) noexcept - : m_size(f_size) - , m_chunkCount(f_chunkCount) + Entry(uint64_t size, uint32_t chunkCount) noexcept + : m_size(size) + , m_chunkCount(chunkCount) { } - uint32_t m_size{0}; + uint64_t m_size{0}; uint32_t m_chunkCount{0}; }; @@ -56,7 +56,7 @@ struct MePooConfig /// @brief Function for adding new entry /// @param[in] Entry structure of mempool configuration - void addMemPool(Entry f_entry) noexcept; + void addMemPool(Entry entry) noexcept; /// @brief Function for creating default memory pools MePooConfig& setDefaults() noexcept; diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp index a1dc44bf5d..5185bc2177 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/introspection_types.hpp @@ -39,8 +39,8 @@ struct MemPoolInfo uint32_t m_usedChunks{0}; uint32_t m_minFreeChunks{0}; uint32_t m_numChunks{0}; - uint32_t m_chunkSize{0}; - uint32_t m_chunkPayloadSize{0}; + uint64_t m_chunkSize{0}; + uint64_t m_chunkPayloadSize{0}; }; /// @brief container for MemPoolInfo structs of all available mempools. @@ -95,8 +95,8 @@ const capro::ServiceDescription struct PortThroughputData { uint64_t m_publisherPortID{0}; - uint32_t m_sampleSize{0}; - uint32_t m_chunkSize{0}; + uint64_t m_sampleSize{0}; + uint64_t m_chunkSize{0}; double m_chunksPerMinute{0}; uint64_t m_lastSendIntervalInNanoseconds{0}; bool m_isField{false}; diff --git a/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp index 7035694d32..dccebdf701 100644 --- a/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp +++ b/iceoryx_posh/roudi_env/include/iceoryx_posh/roudi_env/minimal_roudi_config.hpp @@ -29,7 +29,7 @@ namespace roudi_env class MinimalRouDiConfigBuilder { /// @brief Set the payload chunk size. Default = 128 - IOX_BUILDER_PARAMETER(uint32_t, payloadChunkSize, 128) + IOX_BUILDER_PARAMETER(uint64_t, payloadChunkSize, 128) /// @brief Set the payload chunk count. Default = 10 IOX_BUILDER_PARAMETER(uint32_t, payloadChunkCount, 10) diff --git a/iceoryx_posh/source/mepoo/chunk_header.cpp b/iceoryx_posh/source/mepoo/chunk_header.cpp index 7d2a646afc..f7449adc7d 100644 --- a/iceoryx_posh/source/mepoo/chunk_header.cpp +++ b/iceoryx_posh/source/mepoo/chunk_header.cpp @@ -24,9 +24,9 @@ namespace mepoo { constexpr uint8_t ChunkHeader::CHUNK_HEADER_VERSION; -ChunkHeader::ChunkHeader(const uint32_t chunkSize, const ChunkSettings& chunkSettings) noexcept - : m_chunkSize(chunkSize) - , m_userHeaderSize(chunkSettings.userHeaderSize()) +ChunkHeader::ChunkHeader(const uint64_t chunkSize, const ChunkSettings& chunkSettings) noexcept + : m_userHeaderSize(chunkSettings.userHeaderSize()) + , m_chunkSize(chunkSize) , m_userPayloadSize(chunkSettings.userPayloadSize()) , m_userPayloadAlignment(chunkSettings.userPayloadAlignment()) { @@ -175,12 +175,12 @@ const ChunkHeader* ChunkHeader::fromUserHeader(const void* const userHeader) noe return ChunkHeader::fromUserHeader(const_cast(userHeader)); } -uint32_t ChunkHeader::usedSizeOfChunk() const noexcept +uint64_t ChunkHeader::usedSizeOfChunk() const noexcept { - return static_cast(overflowSafeUsedSizeOfChunk()); + return overflowSafeUsedSizeOfChunk(); } -uint32_t ChunkHeader::chunkSize() const noexcept +uint64_t ChunkHeader::chunkSize() const noexcept { return m_chunkSize; } @@ -190,7 +190,7 @@ uint32_t ChunkHeader::userHeaderSize() const noexcept return m_userHeaderSize; } -uint32_t ChunkHeader::userPayloadSize() const noexcept +uint64_t ChunkHeader::userPayloadSize() const noexcept { return m_userPayloadSize; } diff --git a/iceoryx_posh/source/mepoo/chunk_settings.cpp b/iceoryx_posh/source/mepoo/chunk_settings.cpp index 7a53672b8b..b4848cfca2 100644 --- a/iceoryx_posh/source/mepoo/chunk_settings.cpp +++ b/iceoryx_posh/source/mepoo/chunk_settings.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2024 by Bartlomiej Kozaryna . 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. @@ -23,11 +24,11 @@ namespace iox { namespace mepoo { -ChunkSettings::ChunkSettings(const uint32_t userPayloadSize, +ChunkSettings::ChunkSettings(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment, - const uint32_t requiredChunkSize) noexcept + const uint64_t requiredChunkSize) noexcept : m_userPayloadSize(userPayloadSize) , m_userPayloadAlignment(userPayloadAlignment) , m_userHeaderSize(userHeaderSize) @@ -36,7 +37,7 @@ ChunkSettings::ChunkSettings(const uint32_t userPayloadSize, { } -expected ChunkSettings::create(const uint32_t userPayloadSize, +expected ChunkSettings::create(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) noexcept @@ -63,23 +64,20 @@ expected ChunkSettings::create(const uint32 return err(ChunkSettings::Error::USER_HEADER_SIZE_NOT_MULTIPLE_OF_ITS_ALIGNMENT); } - uint64_t requiredChunkSize = - calculateRequiredChunkSize(userPayloadSize, adjustedUserPayloadAlignment, userHeaderSize); - - if (requiredChunkSize > std::numeric_limits::max()) + auto expectChunkSize = calculateRequiredChunkSize(userPayloadSize, adjustedUserPayloadAlignment, userHeaderSize); + if (expectChunkSize.has_error()) { - return err(ChunkSettings::Error::REQUIRED_CHUNK_SIZE_EXCEEDS_MAX_CHUNK_SIZE); + return err(expectChunkSize.get_error()); } + uint64_t requiredChunkSize = expectChunkSize.value(); - return ok(ChunkSettings{userPayloadSize, - adjustedUserPayloadAlignment, - userHeaderSize, - adjustedUserHeaderAlignment, - static_cast(requiredChunkSize)}); + + return ok(ChunkSettings{ + userPayloadSize, adjustedUserPayloadAlignment, userHeaderSize, adjustedUserHeaderAlignment, requiredChunkSize}); } -uint64_t ChunkSettings::calculateRequiredChunkSize(const uint32_t userPayloadSize, - const uint32_t userPayloadAlignment, - const uint32_t userHeaderSize) noexcept + +expected ChunkSettings::calculateRequiredChunkSize( + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize) noexcept { // have a look at »Required Chunk Size Calculation« in chunk_header.md for more details regarding the calculation if (userHeaderSize == 0) @@ -87,17 +85,29 @@ uint64_t ChunkSettings::calculateRequiredChunkSize(const uint32_t userPayloadSiz // the most simple case with no user-header and the user-payload adjacent to the ChunkHeader if (userPayloadAlignment <= alignof(mepoo::ChunkHeader)) { + if (userPayloadSize > std::numeric_limits::max() - sizeof(ChunkHeader)) + { + return err(ChunkSettings::Error::REQUIRED_CHUNK_SIZE_EXCEEDS_MAX_CHUNK_SIZE); + } + uint64_t requiredChunkSize = sizeof(ChunkHeader) + userPayloadSize; - return requiredChunkSize; + return ok(requiredChunkSize); } // the second most simple case with no user-header but the user-payload alignment // exceeds the ChunkHeader alignment and is therefore not necessarily adjacent uint64_t preUserPayloadAlignmentOverhang = sizeof(ChunkHeader) - alignof(ChunkHeader); + + if (userPayloadSize + > std::numeric_limits::max() - preUserPayloadAlignmentOverhang - userPayloadAlignment) + { + return err(ChunkSettings::Error::REQUIRED_CHUNK_SIZE_EXCEEDS_MAX_CHUNK_SIZE); + } + uint64_t requiredChunkSize = preUserPayloadAlignmentOverhang + userPayloadAlignment + userPayloadSize; - return requiredChunkSize; + return ok(requiredChunkSize); } // the most complex case with a user-header @@ -106,17 +116,23 @@ uint64_t ChunkSettings::calculateRequiredChunkSize(const uint32_t userPayloadSiz uint64_t headerSize = sizeof(ChunkHeader) + userHeaderSize; uint64_t preUserPayloadAlignmentOverhang = align(headerSize, ALIGNMENT_OF_USER_PAYLOAD_OFFSET_T); uint64_t maxPadding = algorithm::maxVal(SIZE_OF_USER_PAYLOAD_OFFSET_T, static_cast(userPayloadAlignment)); + + if (userPayloadSize > std::numeric_limits::max() - preUserPayloadAlignmentOverhang - maxPadding) + { + return err(ChunkSettings::Error::REQUIRED_CHUNK_SIZE_EXCEEDS_MAX_CHUNK_SIZE); + } + uint64_t requiredChunkSize = preUserPayloadAlignmentOverhang + maxPadding + userPayloadSize; - return requiredChunkSize; + return ok(requiredChunkSize); } -uint32_t ChunkSettings::requiredChunkSize() const noexcept +uint64_t ChunkSettings::requiredChunkSize() const noexcept { return m_requiredChunkSize; } -uint32_t ChunkSettings::userPayloadSize() const noexcept +uint64_t ChunkSettings::userPayloadSize() const noexcept { return m_userPayloadSize; } diff --git a/iceoryx_posh/source/mepoo/mem_pool.cpp b/iceoryx_posh/source/mepoo/mem_pool.cpp index efa1f2b216..a4bfb2fe56 100644 --- a/iceoryx_posh/source/mepoo/mem_pool.cpp +++ b/iceoryx_posh/source/mepoo/mem_pool.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // Copyright (c) 2023 by Mathias Kraus . All rights reserved. +// Copyright (c) 2024 by Bartlomiej Kozaryna . 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. @@ -29,7 +30,7 @@ namespace mepoo MemPoolInfo::MemPoolInfo(const uint32_t usedChunks, const uint32_t minFreeChunks, const uint32_t numChunks, - const uint32_t chunkSize) noexcept + const uint64_t chunkSize) noexcept : m_usedChunks(usedChunks) , m_minFreeChunks(minFreeChunks) , m_numChunks(numChunks) @@ -39,7 +40,7 @@ MemPoolInfo::MemPoolInfo(const uint32_t usedChunks, constexpr uint64_t MemPool::CHUNK_MEMORY_ALIGNMENT; -MemPool::MemPool(const greater_or_equal chunkSize, +MemPool::MemPool(const greater_or_equal chunkSize, const greater_or_equal numberOfChunks, iox::BumpAllocator& managementAllocator, iox::BumpAllocator& chunkMemoryAllocator) noexcept @@ -49,6 +50,8 @@ 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()); @@ -63,14 +66,13 @@ MemPool::MemPool(const greater_or_equal chunkS else { IOX_LOG(FATAL, - "Chunk size must be multiple of '" << CHUNK_MEMORY_ALIGNMENT << "'! Requested size is " - << static_cast(chunkSize) << " for " - << static_cast(numberOfChunks) << " chunks!"); + "Chunk size must be multiple of '" << CHUNK_MEMORY_ALIGNMENT << "'! Requested size is " << chunkSize + << " for " << numberOfChunks << " chunks!"); errorHandler(PoshError::MEPOO__MEMPOOL_CHUNKSIZE_MUST_BE_MULTIPLE_OF_CHUNK_MEMORY_ALIGNMENT); } } -bool MemPool::isMultipleOfAlignment(const uint32_t value) const noexcept +bool MemPool::isMultipleOfAlignment(const uint64_t value) const noexcept { return (value % CHUNK_MEMORY_ALIGNMENT == 0U); } @@ -101,14 +103,14 @@ void* MemPool::getChunk() noexcept return indexToPointer(index, m_chunkSize, m_rawMemory.get()); } -void* MemPool::indexToPointer(uint32_t index, uint32_t chunkSize, void* const rawMemoryBase) noexcept +void* MemPool::indexToPointer(uint32_t index, uint64_t chunkSize, void* const rawMemoryBase) noexcept { const auto offset = static_cast(index) * chunkSize; return static_cast(static_cast(rawMemoryBase) + offset); } uint32_t -MemPool::pointerToIndex(const void* const chunk, const uint32_t chunkSize, const void* const rawMemoryBase) noexcept +MemPool::pointerToIndex(const void* const chunk, const uint64_t chunkSize, const void* const rawMemoryBase) noexcept { const auto offset = static_cast(static_cast(chunk) - static_cast(rawMemoryBase)); @@ -120,7 +122,7 @@ MemPool::pointerToIndex(const void* const chunk, const uint32_t chunkSize, const void MemPool::freeChunk(const void* chunk) noexcept { - const auto offsetToLastChunk = static_cast(m_chunkSize) * (m_numberOfChunks - 1U); + const auto offsetToLastChunk = m_chunkSize * (m_numberOfChunks - 1U); IOX_EXPECTS(m_rawMemory.get() <= chunk && chunk <= static_cast(m_rawMemory.get()) + offsetToLastChunk); const auto index = pointerToIndex(chunk, m_chunkSize, m_rawMemory.get()); @@ -133,7 +135,7 @@ void MemPool::freeChunk(const void* chunk) noexcept m_usedChunks.fetch_sub(1U, std::memory_order_relaxed); } -uint32_t MemPool::getChunkSize() const noexcept +uint64_t MemPool::getChunkSize() const noexcept { return m_chunkSize; } diff --git a/iceoryx_posh/source/mepoo/memory_manager.cpp b/iceoryx_posh/source/mepoo/memory_manager.cpp index ceb9558b53..509ad935eb 100644 --- a/iceoryx_posh/source/mepoo/memory_manager.cpp +++ b/iceoryx_posh/source/mepoo/memory_manager.cpp @@ -40,10 +40,10 @@ void MemoryManager::printMemPoolVector(log::LogStream& log) const noexcept void MemoryManager::addMemPool(BumpAllocator& managementAllocator, BumpAllocator& chunkMemoryAllocator, - const greater_or_equal chunkPayloadSize, + const greater_or_equal chunkPayloadSize, const greater_or_equal numberOfChunks) noexcept { - uint32_t adjustedChunkSize = sizeWithChunkHeaderStruct(static_cast(chunkPayloadSize)); + uint64_t adjustedChunkSize = sizeWithChunkHeaderStruct(static_cast(chunkPayloadSize)); if (m_denyAddMemPool) { IOX_LOG(FATAL, "After the generation of the chunk management pool you are not allowed to create new mempools."); @@ -58,8 +58,8 @@ void MemoryManager::addMemPool(BumpAllocator& managementAllocator, return log; } << "These mempools must be added in an increasing chunk size ordering. The newly added MemPool [ " "ChunkSize = " - << adjustedChunkSize << ", ChunkPayloadSize = " << static_cast(chunkPayloadSize) - << ", ChunkCount = " << static_cast(numberOfChunks) << "] breaks that requirement!"); + << adjustedChunkSize << ", ChunkPayloadSize = " << chunkPayloadSize << ", ChunkCount = " << numberOfChunks + << "] breaks that requirement!"); errorHandler(iox::PoshError::MEPOO__MEMPOOL_CONFIG_MUST_BE_ORDERED_BY_INCREASING_SIZE); } @@ -70,7 +70,7 @@ void MemoryManager::addMemPool(BumpAllocator& managementAllocator, void MemoryManager::generateChunkManagementPool(BumpAllocator& managementAllocator) noexcept { m_denyAddMemPool = true; - uint32_t chunkSize = sizeof(ChunkManagement); + uint64_t chunkSize = sizeof(ChunkManagement); m_chunkManagementPool.emplace_back(chunkSize, m_totalNumberOfChunks, managementAllocator, managementAllocator); } @@ -88,9 +88,9 @@ MemPoolInfo MemoryManager::getMemPoolInfo(const uint32_t index) const noexcept return m_memPoolVector[index].getInfo(); } -uint32_t MemoryManager::sizeWithChunkHeaderStruct(const MaxChunkPayloadSize_t size) noexcept +uint64_t MemoryManager::sizeWithChunkHeaderStruct(const MaxChunkPayloadSize_t size) noexcept { - return size + static_cast(sizeof(ChunkHeader)); + return size + sizeof(ChunkHeader); } uint64_t MemoryManager::requiredChunkMemorySize(const MePooConfig& mePooConfig) noexcept @@ -149,11 +149,11 @@ expected MemoryManager::getChunk(const ChunkS MemPool* memPoolPointer{nullptr}; const auto requiredChunkSize = chunkSettings.requiredChunkSize(); - uint32_t aquiredChunkSize = 0U; + uint64_t aquiredChunkSize = 0U; for (auto& memPool : m_memPoolVector) { - uint32_t chunkSizeOfMemPool = memPool.getChunkSize(); + uint64_t chunkSizeOfMemPool = memPool.getChunkSize(); if (chunkSizeOfMemPool >= requiredChunkSize) { chunk = memPool.getChunk(); diff --git a/iceoryx_posh/source/mepoo/mepoo_config.cpp b/iceoryx_posh/source/mepoo/mepoo_config.cpp index 2f6809e04e..090ee26a1d 100644 --- a/iceoryx_posh/source/mepoo/mepoo_config.cpp +++ b/iceoryx_posh/source/mepoo/mepoo_config.cpp @@ -28,11 +28,11 @@ const MePooConfig::MePooConfigContainerType* MePooConfig::getMemPoolConfig() con return &m_mempoolConfig; } -void MePooConfig::addMemPool(MePooConfig::Entry f_entry) noexcept +void MePooConfig::addMemPool(MePooConfig::Entry entry) noexcept { if (m_mempoolConfig.size() < m_mempoolConfig.capacity()) { - m_mempoolConfig.push_back(f_entry); + m_mempoolConfig.push_back(entry); } else { diff --git a/iceoryx_posh/source/popo/ports/client_port_user.cpp b/iceoryx_posh/source/popo/ports/client_port_user.cpp index c3f3bd2f0b..055b91b046 100644 --- a/iceoryx_posh/source/popo/ports/client_port_user.cpp +++ b/iceoryx_posh/source/popo/ports/client_port_user.cpp @@ -38,7 +38,7 @@ ClientPortUser::MemberType_t* ClientPortUser::getMembers() noexcept return reinterpret_cast(BasePort::getMembers()); } -expected ClientPortUser::allocateRequest(const uint32_t userPayloadSize, +expected ClientPortUser::allocateRequest(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment) noexcept { auto allocateResult = m_chunkSender.tryAllocate( diff --git a/iceoryx_posh/source/popo/ports/publisher_port_user.cpp b/iceoryx_posh/source/popo/ports/publisher_port_user.cpp index 48fa494635..a8003fe789 100644 --- a/iceoryx_posh/source/popo/ports/publisher_port_user.cpp +++ b/iceoryx_posh/source/popo/ports/publisher_port_user.cpp @@ -39,7 +39,7 @@ PublisherPortUser::MemberType_t* PublisherPortUser::getMembers() noexcept } expected -PublisherPortUser::tryAllocateChunk(const uint32_t userPayloadSize, +PublisherPortUser::tryAllocateChunk(const uint64_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) noexcept diff --git a/iceoryx_posh/source/popo/ports/server_port_user.cpp b/iceoryx_posh/source/popo/ports/server_port_user.cpp index 834109db3a..6113d3330c 100644 --- a/iceoryx_posh/source/popo/ports/server_port_user.cpp +++ b/iceoryx_posh/source/popo/ports/server_port_user.cpp @@ -85,7 +85,7 @@ bool ServerPortUser::hasLostRequestsSinceLastCall() noexcept expected ServerPortUser::allocateResponse(const RequestHeader* const requestHeader, - const uint32_t userPayloadSize, + const uint64_t userPayloadSize, const uint32_t userPayloadAlignment) noexcept { if (requestHeader == nullptr) diff --git a/iceoryx_posh/source/roudi/roudi_config_toml_file_provider.cpp b/iceoryx_posh/source/roudi/roudi_config_toml_file_provider.cpp index ef12414669..3fecc87743 100644 --- a/iceoryx_posh/source/roudi/roudi_config_toml_file_provider.cpp +++ b/iceoryx_posh/source/roudi/roudi_config_toml_file_provider.cpp @@ -144,7 +144,7 @@ TomlRouDiConfigFileProvider::parse(std::istream& stream) noexcept for (auto mempool : *mempools) { - auto chunkSize = mempool->get_as("size"); + auto chunkSize = mempool->get_as("size"); auto chunkCount = mempool->get_as("count"); if (!chunkSize) { diff --git a/iceoryx_posh/test/integrationtests/test_client_server.cpp b/iceoryx_posh/test/integrationtests/test_client_server.cpp index 7ca80fcd78..58f9b51622 100644 --- a/iceoryx_posh/test/integrationtests/test_client_server.cpp +++ b/iceoryx_posh/test/integrationtests/test_client_server.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2024 by Bartlomiej Kozaryna . 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. @@ -35,6 +36,8 @@ using namespace iox::capro; using namespace iox::runtime; using namespace iox::roudi_env; +constexpr uint64_t SIZE_LARGER_THAN_4GB = std::numeric_limits::max() + 41065UL; + class DummyRequest { public: @@ -59,8 +62,19 @@ class DummyResponse uint64_t sum{0U}; }; +struct BigPayloadStruct +{ + uint8_t bigPayload[SIZE_LARGER_THAN_4GB]{0U}; +}; + class ClientServer_test : public RouDi_GTest { + protected: + ClientServer_test(iox::RouDiConfig_t&& roudiConfig) + : RouDi_GTest(std::move(roudiConfig)) + { + } + public: ClientServer_test() : RouDi_GTest(MinimalRouDiConfigBuilder().create()) @@ -82,6 +96,30 @@ class ClientServer_test : public RouDi_GTest }; constexpr iox::units::Duration ClientServer_test::DEADLOCK_TIMEOUT; +class BigPayloadClientServer_test : public ClientServer_test +{ + static constexpr uint64_t additionalSizeForUserHeader = + 2 * std::max(sizeof(iox::popo::RequestHeader), sizeof(iox::popo::ResponseHeader)); + + public: + BigPayloadClientServer_test() + : ClientServer_test(MinimalRouDiConfigBuilder() + .payloadChunkSize(SIZE_LARGER_THAN_4GB + additionalSizeForUserHeader) + .payloadChunkCount(2) + .create()) + { + } + + void SetUp() override + { + PoshRuntime::initRuntime("together"); + deadlockWatchdog.watchAndActOnFailure([] { std::terminate(); }); + } + + static constexpr iox::units::Duration DEADLOCK_TIMEOUT{10_s}; + Watchdog deadlockWatchdog{DEADLOCK_TIMEOUT}; +}; + TEST_F(ClientServer_test, TypedApiWithMatchingOptionsWorks) { ::testing::Test::RecordProperty("TEST_ID", "a14eb330-1b7d-4243-be4d-009f9e67a232"); @@ -450,4 +488,129 @@ TEST_F(ClientServer_test, ClientTakesResponseUnblocksServerSendingResponse) EXPECT_THAT(wasResponseSent.load(), Eq(true)); } +#ifdef TEST_WITH_HUGE_PAYLOAD + +TEST_F(BigPayloadClientServer_test, TypedApiWithBigPayloadWithMatchingOptionsWorks) +{ + ::testing::Test::RecordProperty("TEST_ID", "9838d2dc-bd87-42aa-b581-a9526e35e46a"); + + constexpr int64_t SEQUENCE_ID{73}; + constexpr uint64_t FIRST{4095}; + constexpr uint64_t LAST{SIZE_LARGER_THAN_4GB - 1}; + constexpr uint64_t STEP{4096}; + constexpr uint8_t SHIFT{13U}; + + Client client{sd}; + Server server{sd}; + + // send request + { + auto loanResult = client.loan(); + ASSERT_FALSE(loanResult.has_error()); + auto& request = loanResult.value(); + request.getRequestHeader().setSequenceId(SEQUENCE_ID); + uint8_t valueCounter = 0; + for (uint64_t i = FIRST; i <= LAST; i += STEP) + { + request->bigPayload[i] = valueCounter; + valueCounter++; + } + ASSERT_FALSE(client.send(std::move(request)).has_error()); + } + + // take request and send response + { + auto takeResult = server.take(); + ASSERT_FALSE(takeResult.has_error()); + auto& request = takeResult.value(); + + auto loanResult = server.loan(request); + ASSERT_FALSE(loanResult.has_error()); + auto& response = loanResult.value(); + for (uint64_t i = FIRST; i <= LAST; i += STEP) + { + response->bigPayload[i] = request->bigPayload[i] + SHIFT; + } + ASSERT_FALSE(server.send(std::move(response)).has_error()); + } + + // take response + { + auto takeResult = client.take(); + ASSERT_FALSE(takeResult.has_error()); + auto& response = takeResult.value(); + EXPECT_THAT(response.getResponseHeader().getSequenceId(), Eq(SEQUENCE_ID)); + uint8_t valueCounter = 0; + for (uint64_t i = FIRST; i <= LAST; i += STEP) + { + ASSERT_THAT(response->bigPayload[i], Eq(static_cast(valueCounter + SHIFT))); + valueCounter++; + } + } +} + +TEST_F(BigPayloadClientServer_test, UntypedApiWithBigPayloadWithMatchingOptionsWorks) +{ + ::testing::Test::RecordProperty("TEST_ID", "3c784d7f-6fe8-2137-b267-7f3e70a307f3"); + + constexpr int64_t SEQUENCE_ID{37}; + constexpr uint64_t FIRST{4095}; + constexpr uint64_t LAST{SIZE_LARGER_THAN_4GB - 1}; + constexpr uint64_t STEP{4096}; + constexpr uint8_t SHIFT{13U}; + + UntypedClient client{sd}; + UntypedServer server{sd}; + + // send request + { + auto loanResult = client.loan(sizeof(BigPayloadStruct), alignof(BigPayloadStruct)); + ASSERT_FALSE(loanResult.has_error()); + auto request = static_cast(loanResult.value()); + RequestHeader::fromPayload(request)->setSequenceId(SEQUENCE_ID); + uint8_t valueCounter = 0; + for (uint64_t i = FIRST; i <= LAST; i += STEP) + { + request->bigPayload[i] = valueCounter; + valueCounter++; + } + ASSERT_FALSE(client.send(request).has_error()); + } + + // take request and send response + { + auto takeResult = server.take(); + ASSERT_FALSE(takeResult.has_error()); + auto request = static_cast(takeResult.value()); + + auto loanResult = + server.loan(RequestHeader::fromPayload(request), sizeof(BigPayloadStruct), alignof(BigPayloadStruct)); + ASSERT_FALSE(loanResult.has_error()); + auto response = static_cast(loanResult.value()); + for (uint64_t i = FIRST; i <= LAST; i += STEP) + { + response->bigPayload[i] = request->bigPayload[i] + SHIFT; + } + ASSERT_FALSE(server.send(response).has_error()); + server.releaseRequest(request); + } + + // take response + { + auto takeResult = client.take(); + ASSERT_FALSE(takeResult.has_error()); + auto response = static_cast(takeResult.value()); + EXPECT_THAT(ResponseHeader::fromPayload(response)->getSequenceId(), Eq(SEQUENCE_ID)); + uint8_t valueCounter = 0; + for (uint64_t i = FIRST; i <= LAST; i += STEP) + { + ASSERT_THAT(response->bigPayload[i], Eq(static_cast(valueCounter + SHIFT))); + valueCounter++; + } + client.releaseResponse(response); + } +} + +#endif // RUN_BIG_PAYLOAD_TESTS + } // namespace diff --git a/iceoryx_posh/test/integrationtests/test_popo_chunk_building_blocks.cpp b/iceoryx_posh/test/integrationtests/test_popo_chunk_building_blocks.cpp index 32353418e0..f9c5bd111a 100644 --- a/iceoryx_posh/test/integrationtests/test_popo_chunk_building_blocks.cpp +++ b/iceoryx_posh/test/integrationtests/test_popo_chunk_building_blocks.cpp @@ -41,7 +41,7 @@ struct DummySample }; static constexpr uint32_t NUM_CHUNKS_IN_POOL = 9 * iox::MAX_SUBSCRIBER_QUEUE_CAPACITY; -static constexpr uint32_t SMALL_CHUNK = 128; +static constexpr uint64_t SMALL_CHUNK = 128; static constexpr uint32_t CHUNK_META_INFO_SIZE = 256; static constexpr size_t MEMORY_SIZE = NUM_CHUNKS_IN_POOL * (SMALL_CHUNK + CHUNK_META_INFO_SIZE); alignas(64) static uint8_t g_memory[MEMORY_SIZE]; diff --git a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp index 4b77d5041f..92a6148ead 100644 --- a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp +++ b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp @@ -56,7 +56,7 @@ constexpr uint32_t NUMBER_OF_PUBLISHERS = 17U; constexpr uint32_t ITERATIONS = 1000U; constexpr uint32_t NUM_CHUNKS_IN_POOL = NUMBER_OF_PUBLISHERS * ITERATIONS; -constexpr uint32_t SMALL_CHUNK = 128U; +constexpr uint64_t SMALL_CHUNK = 128U; constexpr uint32_t CHUNK_META_INFO_SIZE = 256U; constexpr size_t MEMORY_SIZE = NUM_CHUNKS_IN_POOL * (SMALL_CHUNK + CHUNK_META_INFO_SIZE); alignas(64) static uint8_t g_memory[MEMORY_SIZE]; diff --git a/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp b/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp index 23bbdf5941..25e1de438b 100644 --- a/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp +++ b/iceoryx_posh/test/integrationtests/test_publisher_subscriber_communication.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // Copyright (c) 2022 by NXP. All rights reserved. +// Copyright (c) 2024 by Bartlomiej Kozaryna . 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. @@ -41,6 +42,8 @@ using namespace iox::popo; using namespace iox::roudi_env; using namespace iox::testing; +constexpr uint64_t SIZE_LARGER_THAN_4GB = std::numeric_limits::max() + 41065UL; + template struct ComplexDataType { @@ -48,8 +51,19 @@ struct ComplexDataType T complexType; }; +struct BigPayloadStruct +{ + uint8_t bigPayload[SIZE_LARGER_THAN_4GB]; +}; + class PublisherSubscriberCommunication_test : public RouDi_GTest { + protected: + PublisherSubscriberCommunication_test(iox::RouDiConfig_t&& roudiConfig) + : RouDi_GTest(std::move(roudiConfig)) + { + } + public: PublisherSubscriberCommunication_test() : RouDi_GTest(MinimalRouDiConfigBuilder().payloadChunkSize(512).create()) @@ -134,6 +148,29 @@ class PublisherSubscriberCommunication_test : public RouDi_GTest "PublisherSubscriberCommunication", "IntegrationTest", "AllHailHypnotoad"}; }; +class PublisherSubscriberCommunicationWithBigPayload_test : public PublisherSubscriberCommunication_test +{ + static constexpr uint64_t additionalSizeForUserHeader = + 2 * std::max(sizeof(iox::popo::RequestHeader), sizeof(iox::popo::ResponseHeader)); + + public: + PublisherSubscriberCommunicationWithBigPayload_test() + : PublisherSubscriberCommunication_test( + MinimalRouDiConfigBuilder() + .payloadChunkSize(SIZE_LARGER_THAN_4GB + additionalSizeForUserHeader) + .payloadChunkCount(2) + .create()) + { + } + + void SetUp() + { + runtime::PoshRuntime::initRuntime("PublisherSubscriberCommunication_test"); + m_watchdog.watchAndActOnFailure([] { std::terminate(); }); + }; + Watchdog m_watchdog{units::Duration::fromSeconds(10)}; +}; + // intentional reference to unique pointer, we do not want to pass ownership in this helper function // and at call site we already have unique pointers template @@ -713,4 +750,38 @@ TEST_F(PublisherSubscriberCommunication_test, PublisherUniqueIdMatchesReceivedSa } } +#ifdef TEST_WITH_HUGE_PAYLOAD + +TEST_F(PublisherSubscriberCommunicationWithBigPayload_test, SendingComplexDataType_BigPayloadStruct) +{ + ::testing::Test::RecordProperty("TEST_ID", "f612a4ef-5f3a-4951-8f2e-bbc28f6b1a66"); + + using Type_t = ComplexDataType; + auto publisher = createPublisher(); + auto subscriber = createSubscriber(); + + constexpr uint64_t PAGE_SIZE = 4096; + + ASSERT_FALSE(publisher->loan() + .and_then([](auto& sample) { + for (uint64_t i = PAGE_SIZE - 1; i < SIZE_LARGER_THAN_4GB; i += PAGE_SIZE) + { + sample->complexType.bigPayload[i] = static_cast(i / PAGE_SIZE); + } + sample.publish(); + }) + .has_error()); + + EXPECT_FALSE(subscriber->take() + .and_then([](auto& sample) { + for (uint64_t i = PAGE_SIZE - 1; i < SIZE_LARGER_THAN_4GB; i += PAGE_SIZE) + { + ASSERT_THAT(sample->complexType.bigPayload[i], Eq(static_cast(i / PAGE_SIZE))); + } + }) + .has_error()); +} + +#endif + } // namespace diff --git a/iceoryx_posh/test/mocks/client_mock.hpp b/iceoryx_posh/test/mocks/client_mock.hpp index b5997ee78e..de4a20c5f6 100644 --- a/iceoryx_posh/test/mocks/client_mock.hpp +++ b/iceoryx_posh/test/mocks/client_mock.hpp @@ -48,7 +48,7 @@ class MockClientPortUser : public MockBasePort MOCK_METHOD((iox::expected), allocateRequest, - (const uint32_t, const uint32_t), + (const uint64_t, const uint32_t), (noexcept)); MOCK_METHOD(void, releaseRequest, (const iox::popo::RequestHeader* const), (noexcept)); MOCK_METHOD((iox::expected), diff --git a/iceoryx_posh/test/mocks/publisher_mock.hpp b/iceoryx_posh/test/mocks/publisher_mock.hpp index 0a52e954cc..f12f7fd336 100644 --- a/iceoryx_posh/test/mocks/publisher_mock.hpp +++ b/iceoryx_posh/test/mocks/publisher_mock.hpp @@ -55,7 +55,7 @@ class MockPublisherPortUser MOCK_CONST_METHOD0(getServiceDescription, iox::capro::ServiceDescription()); MOCK_METHOD4(tryAllocateChunk, iox::expected( - const uint32_t, const uint32_t, const uint32_t, const uint32_t)); + const uint64_t, const uint32_t, const uint32_t, const uint32_t)); MOCK_METHOD1(releaseChunk, void(iox::mepoo::ChunkHeader* const)); MOCK_METHOD1(sendChunk, void(iox::mepoo::ChunkHeader* const)); MOCK_METHOD0(tryGetPreviousChunk, iox::optional()); diff --git a/iceoryx_posh/test/mocks/server_mock.hpp b/iceoryx_posh/test/mocks/server_mock.hpp index a8c519aafa..770cc9a4ec 100644 --- a/iceoryx_posh/test/mocks/server_mock.hpp +++ b/iceoryx_posh/test/mocks/server_mock.hpp @@ -56,7 +56,7 @@ class MockServerPortUser : public MockBasePort MOCK_METHOD(bool, hasLostRequestsSinceLastCall, (), (noexcept)); MOCK_METHOD((iox::expected), allocateResponse, - (const iox::popo::RequestHeader* const, const uint32_t, const uint32_t), + (const iox::popo::RequestHeader* const, const uint64_t, const uint32_t), (noexcept)); MOCK_METHOD(void, releaseResponse, (const iox::popo::ResponseHeader* const), (noexcept)); MOCK_METHOD((iox::expected), diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp index d9094728a2..73210d476a 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp @@ -39,8 +39,8 @@ using UserPayloadOffset_t = ChunkHeader::UserPayloadOffset_t; TEST(ChunkHeader_test, ChunkHeaderHasInitializedMembers) { ::testing::Test::RecordProperty("TEST_ID", "b998bcb8-7db0-457d-a25a-86eae34f68dd"); - constexpr uint32_t CHUNK_SIZE{753U}; - constexpr uint32_t USER_PAYLOAD_SIZE{8U}; + constexpr uint64_t CHUNK_SIZE{753U}; + constexpr uint64_t USER_PAYLOAD_SIZE{8U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT); @@ -52,7 +52,7 @@ TEST(ChunkHeader_test, ChunkHeaderHasInitializedMembers) EXPECT_THAT(sut.chunkSize(), Eq(CHUNK_SIZE)); // deliberately used a magic number to make the test fail when CHUNK_HEADER_VERSION changes - EXPECT_THAT(sut.chunkHeaderVersion(), Eq(1U)); + EXPECT_THAT(sut.chunkHeaderVersion(), Eq(2U)); EXPECT_THAT(sut.originId(), Eq(iox::popo::UniquePortId(iox::popo::InvalidPortId))); @@ -79,19 +79,19 @@ TEST(ChunkHeader_test, ChunkHeaderBinaryCompatibilityCheck) // When this struct is touched, the CHUNK_HEADER_VERSION must be changed struct ExpectedChunkHeaderLayout { - uint32_t chunkSize{0U}; + uint32_t userHeaderSize{0U}; uint8_t chunkHeaderVersion{0U}; uint8_t reserved{0U}; uint16_t userHeaderId{0}; uint64_t originId{0U}; uint64_t sequenceNumber{0U}; - uint32_t userHeaderSize{0U}; - uint32_t userPayloadSize{0U}; + uint64_t chunkSize{0U}; + uint64_t userPayloadSize{0U}; uint32_t userPayloadAlignment{0U}; uint32_t userPayloadOffset{0U}; }; - constexpr auto EXPECTED_CHUNK_HEADER_VERSION{1U}; + constexpr auto EXPECTED_CHUNK_HEADER_VERSION{2U}; EXPECT_THAT(ChunkHeader::CHUNK_HEADER_VERSION, Eq(EXPECTED_CHUNK_HEADER_VERSION)); EXPECT_THAT(sizeof(ChunkHeader), Eq(sizeof(ExpectedChunkHeaderLayout))); @@ -158,8 +158,8 @@ TEST(ChunkHeader_test, ChunkHeaderUserPayloadSizeTypeIsLargeEnoughForMempoolChun TEST(ChunkHeader_test, UserPayloadFunctionCalledFromNonConstChunkHeaderWorks) { ::testing::Test::RecordProperty("TEST_ID", "d6b0fcce-8b49-429c-a1d2-c047b4b2e368"); - constexpr uint32_t CHUNK_SIZE{753U}; - constexpr uint32_t USER_PAYLOAD_SIZE{8U}; + constexpr uint64_t CHUNK_SIZE{753U}; + constexpr uint64_t USER_PAYLOAD_SIZE{8U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); @@ -176,8 +176,8 @@ TEST(ChunkHeader_test, UserPayloadFunctionCalledFromNonConstChunkHeaderWorks) TEST(ChunkHeader_test, UserPayloadFunctionCalledFromConstChunkHeaderWorks) { ::testing::Test::RecordProperty("TEST_ID", "091451db-09ed-4aa4-bcfe-d45c0c6d6c14"); - constexpr uint32_t CHUNK_SIZE{753U}; - constexpr uint32_t USER_PAYLOAD_SIZE{8U}; + constexpr uint64_t CHUNK_SIZE{753U}; + constexpr uint64_t USER_PAYLOAD_SIZE{8U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); @@ -210,8 +210,8 @@ TEST(ChunkHeader_test, UserHeaderFunctionCalledFromNonConstChunkHeaderWorks) ::testing::Test::RecordProperty("TEST_ID", "2ddbb681-e8bb-42e0-9546-e9fd64c44be0"); alignas(ChunkHeader) static uint8_t storage[1024 * 1024]; - constexpr uint32_t CHUNK_SIZE{753U}; - constexpr uint32_t USER_PAYLOAD_SIZE{8U}; + constexpr uint64_t CHUNK_SIZE{753U}; + constexpr uint64_t USER_PAYLOAD_SIZE{8U}; constexpr uint32_t USER_HEADER_SIZE{16U}; constexpr uint32_t USER_HEADER_ALIGNMENT{8U}; @@ -233,8 +233,8 @@ TEST(ChunkHeader_test, UserHeaderFunctionCalledFromConstChunkHeaderWorks) ::testing::Test::RecordProperty("TEST_ID", "04f902b9-0870-4ba4-b761-856e9bbfcd85"); alignas(ChunkHeader) static uint8_t storage[1024 * 1024]; - constexpr uint32_t CHUNK_SIZE{753U}; - constexpr uint32_t USER_PAYLOAD_SIZE{8U}; + constexpr uint64_t CHUNK_SIZE{753U}; + constexpr uint64_t USER_PAYLOAD_SIZE{8U}; constexpr uint32_t USER_HEADER_SIZE{16U}; constexpr uint32_t USER_HEADER_ALIGNMENT{8U}; @@ -333,8 +333,8 @@ TEST(ChunkHeader_test, FromUserHeaderFunctionCalledWithConstParamReturnsConstTyp TEST(ChunkHeader_test, UsedChunkSizeIsSizeOfChunkHeaderWhenUserPayloadIsZero) { ::testing::Test::RecordProperty("TEST_ID", "67d3907e-5090-4814-b726-2a37e8780395"); - constexpr uint32_t CHUNK_SIZE{2 * sizeof(ChunkHeader)}; - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t CHUNK_SIZE{2 * sizeof(ChunkHeader)}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); @@ -348,8 +348,8 @@ TEST(ChunkHeader_test, UsedChunkSizeIsSizeOfChunkHeaderWhenUserPayloadIsZero) TEST(ChunkHeader_test, UsedChunkSizeIsSizeOfChunkHeaderPlusOneWhenUserPayloadIsOne) { ::testing::Test::RecordProperty("TEST_ID", "5a0cd3a1-3edc-441a-9ba6-486a463ad9d7"); - constexpr uint32_t CHUNK_SIZE{2 * sizeof(ChunkHeader)}; - constexpr uint32_t USER_PAYLOAD_SIZE{1U}; + constexpr uint64_t CHUNK_SIZE{2 * sizeof(ChunkHeader)}; + constexpr uint64_t USER_PAYLOAD_SIZE{1U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); @@ -363,8 +363,8 @@ TEST(ChunkHeader_test, UsedChunkSizeIsSizeOfChunkHeaderPlusOneWhenUserPayloadIsO TEST(ChunkHeader_test, ConstructorTerminatesWhenUserPayloadSizeExceedsChunkSize) { ::testing::Test::RecordProperty("TEST_ID", "c8f911eb-ed0d-495a-8858-9fc45f5a06e8"); - constexpr uint32_t CHUNK_SIZE{128U}; - constexpr uint32_t USER_PAYLOAD_SIZE{2U * CHUNK_SIZE}; + constexpr uint64_t CHUNK_SIZE{128U}; + constexpr uint64_t USER_PAYLOAD_SIZE{2U * CHUNK_SIZE}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); @@ -382,7 +382,7 @@ TEST(ChunkHeader_test, ConstructorTerminatesWhenUserPayloadSizeExceedsChunkSize) struct PayloadParams { - uint32_t size{0U}; + uint64_t size{0U}; uint32_t alignment{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; }; diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp index 9cbe124060..2a4ca2f4af 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp @@ -34,7 +34,7 @@ using UserPayloadOffset_t = iox::mepoo::ChunkHeader::UserPayloadOffset_t; TEST(ChunkSettings_test, CallingUserPayloadSizeReturnsCorrectValue) { ::testing::Test::RecordProperty("TEST_ID", "09b4d176-7fab-4957-8eb7-9c274dfa0ab1"); - constexpr uint32_t USER_PAYLOAD_SIZE{42U}; + constexpr uint64_t USER_PAYLOAD_SIZE{42U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{128U}; constexpr uint32_t USER_HEADER_SIZE{64U}; constexpr uint32_t USER_HEADER_ALIGNMENT{4U}; @@ -50,7 +50,7 @@ TEST(ChunkSettings_test, CallingUserPayloadSizeReturnsCorrectValue) TEST(ChunkSettings_test, CallingUserPayloadAlignmentReturnsCorrectValue) { ::testing::Test::RecordProperty("TEST_ID", "310e7342-9654-4c27-8be8-419b63f5c783"); - constexpr uint32_t USER_PAYLOAD_SIZE{42U}; + constexpr uint64_t USER_PAYLOAD_SIZE{42U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{128U}; constexpr uint32_t USER_HEADER_SIZE{64U}; constexpr uint32_t USER_HEADER_ALIGNMENT{4U}; @@ -66,7 +66,7 @@ TEST(ChunkSettings_test, CallingUserPayloadAlignmentReturnsCorrectValue) TEST(ChunkSettings_test, CallingUserHeaderSizeReturnsCorrectValue) { ::testing::Test::RecordProperty("TEST_ID", "c39d8d59-1f37-428c-b902-16e8eb8f80e7"); - constexpr uint32_t USER_PAYLOAD_SIZE{42U}; + constexpr uint64_t USER_PAYLOAD_SIZE{42U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{128U}; constexpr uint32_t USER_HEADER_SIZE{64U}; constexpr uint32_t USER_HEADER_ALIGNMENT{4U}; @@ -82,7 +82,7 @@ TEST(ChunkSettings_test, CallingUserHeaderSizeReturnsCorrectValue) TEST(ChunkSettings_test, CallingUserHeaderAlignmentReturnsCorrectValue) { ::testing::Test::RecordProperty("TEST_ID", "cf75ffae-7ace-4eb7-b6ab-c6dfc7e3251e"); - constexpr uint32_t USER_PAYLOAD_SIZE{42U}; + constexpr uint64_t USER_PAYLOAD_SIZE{42U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{128U}; constexpr uint32_t USER_HEADER_SIZE{64U}; constexpr uint32_t USER_HEADER_ALIGNMENT{4U}; @@ -98,12 +98,12 @@ TEST(ChunkSettings_test, CallingUserHeaderAlignmentReturnsCorrectValue) TEST(ChunkSettings_test, CallingRequiredChunkSizeReturnsCorrectValue) { ::testing::Test::RecordProperty("TEST_ID", "8e8ba2a5-467b-4bf3-9231-2228187c9ca7"); - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; constexpr uint32_t USER_HEADER_SIZE{iox::CHUNK_NO_USER_HEADER_SIZE}; constexpr uint32_t USER_HEADER_ALIGNMENT{iox::CHUNK_NO_USER_HEADER_ALIGNMENT}; - constexpr uint32_t EXPECTED_SIZE{sizeof(ChunkHeader)}; + constexpr uint64_t EXPECTED_SIZE{sizeof(ChunkHeader)}; auto sutResult = ChunkSettings::create(USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT, USER_HEADER_SIZE, USER_HEADER_ALIGNMENT); @@ -120,7 +120,7 @@ TEST(ChunkSettings_test, CallingRequiredChunkSizeReturnsCorrectValue) TEST(ChunkSettings_test, NoCustomUserPayloadAlignmentAndTooLargeUserPayload_Fails) { ::testing::Test::RecordProperty("TEST_ID", "1ac315d5-fb8d-4529-b141-110fe7c7988d"); - constexpr uint32_t USER_PAYLOAD_SIZE{std::numeric_limits::max()}; + constexpr uint64_t USER_PAYLOAD_SIZE{std::numeric_limits::max()}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; constexpr uint32_t USER_HEADER_SIZE{iox::CHUNK_NO_USER_HEADER_SIZE}; constexpr uint32_t USER_HEADER_ALIGNMENT{iox::CHUNK_NO_USER_HEADER_ALIGNMENT}; @@ -135,7 +135,7 @@ TEST(ChunkSettings_test, NoCustomUserPayloadAlignmentAndTooLargeUserPayload_Fail TEST(ChunkSettings_test, CustomUserPayloadAlignmentAndTooLargeUserPayload_Fails) { ::testing::Test::RecordProperty("TEST_ID", "fade135d-636f-4b06-8f5d-b33eece1175c"); - constexpr uint32_t USER_PAYLOAD_SIZE{std::numeric_limits::max()}; + constexpr uint64_t USER_PAYLOAD_SIZE{std::numeric_limits::max()}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{alignof(ChunkHeader) * 2}; constexpr uint32_t USER_HEADER_SIZE{iox::CHUNK_NO_USER_HEADER_SIZE}; constexpr uint32_t USER_HEADER_ALIGNMENT{iox::CHUNK_NO_USER_HEADER_ALIGNMENT}; @@ -150,7 +150,7 @@ TEST(ChunkSettings_test, CustomUserPayloadAlignmentAndTooLargeUserPayload_Fails) TEST(ChunkSettings_test, UserHeaderAndTooLargeUserPayload_Fails) { ::testing::Test::RecordProperty("TEST_ID", "b61df037-6dae-4350-896e-9ffad96db028"); - constexpr uint32_t USER_PAYLOAD_SIZE{std::numeric_limits::max()}; + constexpr uint64_t USER_PAYLOAD_SIZE{std::numeric_limits::max()}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{alignof(ChunkHeader) * 2}; constexpr uint32_t USER_HEADER_SIZE{8U}; constexpr uint32_t USER_HEADER_ALIGNMENT{8U}; @@ -169,7 +169,7 @@ TEST(ChunkSettings_test, UserHeaderAndTooLargeUserPayload_Fails) TEST(ChunkSettings_test, UserPayloadAlignmentNotPowerOfTwo_Fails) { ::testing::Test::RecordProperty("TEST_ID", "76ad6bad-5175-4475-8834-7a569cb0e489"); - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{13U}; constexpr uint32_t USER_HEADER_SIZE{0U}; constexpr uint32_t USER_HEADER_ALIGNMENT{1U}; @@ -184,7 +184,7 @@ TEST(ChunkSettings_test, UserPayloadAlignmentNotPowerOfTwo_Fails) TEST(ChunkSettings_test, UserHeaderAlignmentNotPowerOfTwo_Fails) { ::testing::Test::RecordProperty("TEST_ID", "2287e0f5-5206-4033-8b23-01fc9ee7d14f"); - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{1U}; constexpr uint32_t USER_HEADER_SIZE{0U}; constexpr uint32_t USER_HEADER_ALIGNMENT{42}; @@ -199,7 +199,7 @@ TEST(ChunkSettings_test, UserHeaderAlignmentNotPowerOfTwo_Fails) TEST(ChunkSettings_test, UserHeaderAlignmentLargerThanChunkHeaderAlignment_Fails) { ::testing::Test::RecordProperty("TEST_ID", "6425744a-0ef7-47c3-8819-5c51bb41add7"); - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; constexpr uint32_t USER_HEADER_SIZE{8U}; constexpr uint32_t USER_HEADER_ALIGNMENT{2 * alignof(ChunkHeader)}; @@ -214,7 +214,7 @@ TEST(ChunkSettings_test, UserHeaderAlignmentLargerThanChunkHeaderAlignment_Fails TEST(ChunkSettings_test, UserHeaderSizeNotMultipleOfAlignment_Fails) { ::testing::Test::RecordProperty("TEST_ID", "a5f5d9a0-ee02-45f3-8d72-ef493ddbac8e"); - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; constexpr uint32_t USER_HEADER_SIZE{12U}; constexpr uint32_t USER_HEADER_ALIGNMENT{8U}; @@ -232,7 +232,7 @@ TEST(ChunkSettings_test, UserHeaderSizeNotMultipleOfAlignment_Fails) struct PayloadParams { - uint32_t size{0U}; + uint64_t size{0U}; uint32_t alignment{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; static constexpr uint32_t MAX_ALIGNMENT{1ULL << 31}; @@ -286,18 +286,17 @@ TEST_P(ChunkSettings_AlteringUserPayloadWithoutUserHeader, RequiredChunkSizeIsCo SCOPED_TRACE(std::string("User-Payload: size = ") + iox::convert::toString(userPayload.size) + std::string("; alignment = ") + iox::convert::toString(userPayload.alignment)); - const uint32_t expectedSize = [&userPayload] { + const uint64_t expectedSize = [&userPayload] { if (userPayload.alignment <= alignof(ChunkHeader)) { // user-payload is always adjacent - return static_cast(sizeof(ChunkHeader)) + userPayload.size; + return sizeof(ChunkHeader) + userPayload.size; } else { // user-payload is not necessarily adjacent auto preUserPayloadAlignmentOverhangOfChunkHeder = sizeof(ChunkHeader) - alignof(ChunkHeader); - return static_cast(preUserPayloadAlignmentOverhangOfChunkHeder) + userPayload.alignment - + userPayload.size; + return preUserPayloadAlignmentOverhangOfChunkHeder + userPayload.alignment + userPayload.size; } }(); @@ -348,7 +347,7 @@ INSTANTIATE_TEST_SUITE_P(ChunkSettings_test, PayloadParams{sizeof(UserPayloadOffset_t), PayloadParams::MAX_ALIGNMENT}, PayloadParams{sizeof(UserPayloadOffset_t) * 42U, PayloadParams::MAX_ALIGNMENT})); -uint32_t expectedChunkSizeWithUserHeader(const PayloadParams& userPayload, uint32_t userHeaderSize) +uint64_t expectedChunkSizeWithUserHeader(const PayloadParams& userPayload, uint32_t userHeaderSize) { const uint32_t userHeaderSizeAndPaddingToBackOffset = iox::algorithm::maxVal(userHeaderSize, static_cast(alignof(UserPayloadOffset_t))); @@ -356,16 +355,15 @@ uint32_t expectedChunkSizeWithUserHeader(const PayloadParams& userPayload, uint3 if (userPayload.alignment <= alignof(UserPayloadOffset_t)) { // back-offset is always adjacent to the user-header (as much as possible with the alignment constraints) - constexpr uint32_t BACK_OFFSET_SIZE{sizeof(UserPayloadOffset_t)}; - return static_cast(sizeof(ChunkHeader)) + userHeaderSizeAndPaddingToBackOffset + BACK_OFFSET_SIZE - + userPayload.size; + constexpr uint64_t BACK_OFFSET_SIZE{sizeof(UserPayloadOffset_t)}; + return sizeof(ChunkHeader) + userHeaderSizeAndPaddingToBackOffset + BACK_OFFSET_SIZE + userPayload.size; } else { // back-offset is not necessarily adjacent to the user-header - const uint32_t paddingBytesAndBackOffsetSize = userPayload.alignment; - return static_cast(sizeof(ChunkHeader)) + userHeaderSizeAndPaddingToBackOffset - + paddingBytesAndBackOffsetSize + userPayload.size; + const uint64_t paddingBytesAndBackOffsetSize = userPayload.alignment; + return sizeof(ChunkHeader) + userHeaderSizeAndPaddingToBackOffset + paddingBytesAndBackOffsetSize + + userPayload.size; } } @@ -397,7 +395,7 @@ TEST_P(ChunkSettings_AlteringUserPayloadWithUserHeader, continue; } - const uint32_t expectedSize = expectedChunkSizeWithUserHeader(userPayload, userHeaderSize); + const uint64_t expectedSize = expectedChunkSizeWithUserHeader(userPayload, userHeaderSize); auto sutResult = ChunkSettings::create(userPayload.size, userPayload.alignment, userHeaderSize, userHeaderAlignment); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_config.cpp b/iceoryx_posh/test/moduletests/test_mepoo_config.cpp index f853a588d7..02b55bdc7f 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_config.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_config.cpp @@ -40,7 +40,7 @@ TEST_F(MePooConfig_Test, AddMemPoolMethodAddsTheCorrespondingMempoolInTheMemPool { ::testing::Test::RecordProperty("TEST_ID", "e2e10dcf-039a-4865-a8fa-5a716994f213"); MePooConfig sut; - constexpr uint32_t SIZE{128U}; + constexpr uint64_t SIZE{128U}; constexpr uint32_t CHUNK_COUNT{100U}; sut.addMemPool({SIZE, CHUNK_COUNT}); @@ -54,7 +54,7 @@ TEST_F(MePooConfig_Test, AddingMempoolWhenTheMemPoolConfigContainerIsFullReturns { ::testing::Test::RecordProperty("TEST_ID", "67227cee-44e2-445f-ba6b-5066e7348757"); MePooConfig sut; - constexpr uint32_t SIZE{128U}; + constexpr uint64_t SIZE{128U}; constexpr uint32_t CHUNK_COUNT{100U}; for (size_t i = 0U; i < iox::MAX_NUMBER_OF_MEMPOOLS; i++) @@ -95,7 +95,7 @@ TEST_F(MePooConfig_Test, GetMemoryConfigMethodReturnsTheMemPoolConfigContainerWi ::testing::Test::RecordProperty("TEST_ID", "45abbd55-9d30-4fdc-abf8-4dd85c2d48b4"); MePooConfig sut; constexpr uint32_t CHUNK_COUNT{100U}; - constexpr uint32_t SIZE{128U}; + constexpr uint64_t SIZE{128U}; sut.addMemPool({SIZE, CHUNK_COUNT}); const MePooConfig::MePooConfigContainerType* mempoolconfptr = sut.getMemPoolConfig(); @@ -110,7 +110,7 @@ TEST_F(MePooConfig_Test, OptimizeMethodCombinesTwoMempoolWithSameSizeAndDoublesT ::testing::Test::RecordProperty("TEST_ID", "b39e5bc5-4352-4427-be72-deeed45d937d"); MePooConfig sut; constexpr uint32_t CHUNK_COUNT{100U}; - constexpr uint32_t SIZE{100U}; + constexpr uint64_t SIZE{100U}; sut.addMemPool({SIZE, CHUNK_COUNT}); sut.addMemPool({SIZE, CHUNK_COUNT}); @@ -125,9 +125,9 @@ TEST_F(MePooConfig_Test, OptimizeMethodRemovesTheMempoolWithSizeZeroInTheMemPool ::testing::Test::RecordProperty("TEST_ID", "56209c3e-8b69-45cd-8ea5-ef347152ff7c"); MePooConfig sut; constexpr uint32_t CHUNK_COUNT{100U}; - constexpr uint32_t SIZE_1{64U}; - constexpr uint32_t SIZE_2{0U}; - constexpr uint32_t SIZE_3{128U}; + constexpr uint64_t SIZE_1{64U}; + constexpr uint64_t SIZE_2{0U}; + constexpr uint64_t SIZE_3{128U}; sut.addMemPool({SIZE_1, CHUNK_COUNT}); sut.addMemPool({SIZE_2, CHUNK_COUNT}); sut.addMemPool({SIZE_3, CHUNK_COUNT}); @@ -144,9 +144,9 @@ TEST_F(MePooConfig_Test, OptimizeMethodSortsTheAddedMempoolsInTheMemPoolConfigCo ::testing::Test::RecordProperty("TEST_ID", "c9034d02-9fa9-404f-955c-12f647b3a946"); MePooConfig sut; constexpr uint32_t CHUNK_COUNT{100U}; - constexpr uint32_t SIZE_1{512U}; - constexpr uint32_t SIZE_2{128U}; - constexpr uint32_t SIZE_3{256U}; + constexpr uint64_t SIZE_1{512U}; + constexpr uint64_t SIZE_2{128U}; + constexpr uint64_t SIZE_3{256U}; sut.addMemPool({SIZE_1, CHUNK_COUNT}); sut.addMemPool({SIZE_2, CHUNK_COUNT}); sut.addMemPool({SIZE_3, CHUNK_COUNT}); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp b/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp index 2b01a8e0b3..87c2cf4156 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_memory_manager.cpp @@ -64,10 +64,10 @@ class MemoryManager_test : public Test return chunkStore; } - static constexpr uint32_t CHUNK_SIZE_32{32U}; - static constexpr uint32_t CHUNK_SIZE_64{64U}; - static constexpr uint32_t CHUNK_SIZE_128{128}; - static constexpr uint32_t CHUNK_SIZE_256{256U}; + static constexpr uint64_t CHUNK_SIZE_32{32U}; + static constexpr uint64_t CHUNK_SIZE_64{64U}; + static constexpr uint64_t CHUNK_SIZE_128{128}; + static constexpr uint64_t CHUNK_SIZE_256{256U}; iox::BumpAllocator* allocator; void* rawMemory; @@ -167,7 +167,7 @@ TEST_F(MemoryManager_test, GetChunkMethodWithNoMemPoolInMemConfigReturnsError) EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); - constexpr uint32_t USER_PAYLOAD_SIZE{15U}; + constexpr uint64_t USER_PAYLOAD_SIZE{15U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); @@ -199,7 +199,7 @@ TEST_F(MemoryManager_test, GetChunkMethodWithChunkSizeGreaterThanAvailableChunkS EXPECT_EQ(errorLevel, iox::ErrorLevel::SEVERE); }); - constexpr uint32_t USER_PAYLOAD_SIZE{200U}; + constexpr uint64_t USER_PAYLOAD_SIZE{200U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); @@ -218,7 +218,7 @@ TEST_F(MemoryManager_test, GetChunkMethodWhenNoFreeChunksInMemPoolConfigReturnsE { ::testing::Test::RecordProperty("TEST_ID", "0f201458-040e-43b1-a51b-698c2957ca7c"); constexpr uint32_t CHUNK_COUNT{1U}; - constexpr uint32_t PAYLOAD_SIZE{100U}; + constexpr uint64_t PAYLOAD_SIZE{100U}; mempoolconf.addMemPool({CHUNK_SIZE_128, CHUNK_COUNT}); sut->configureMemoryManager(mempoolconf, *allocator, *allocator); auto chunkSettingsResult = ChunkSettings::create(PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); @@ -250,7 +250,7 @@ TEST_F(MemoryManager_test, VerifyGetChunkMethodWhenTheRequestedChunkIsAvailableI mempoolconf.addMemPool({CHUNK_SIZE_128, CHUNK_COUNT}); sut->configureMemoryManager(mempoolconf, *allocator, *allocator); - constexpr uint32_t USER_PAYLOAD_SIZE{50U}; + constexpr uint64_t USER_PAYLOAD_SIZE{50U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); @@ -268,7 +268,7 @@ TEST_F(MemoryManager_test, getChunkSingleMemPoolAllChunks) mempoolconf.addMemPool({128, CHUNK_COUNT}); sut->configureMemoryManager(mempoolconf, *allocator, *allocator); - constexpr uint32_t USER_PAYLOAD_SIZE{50U}; + constexpr uint64_t USER_PAYLOAD_SIZE{50U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); @@ -458,7 +458,7 @@ TEST_F(MemoryManager_test, freeChunkMultiMemPoolFullToEmptyToFull) TEST_F(MemoryManager_test, getChunkWithUserPayloadSizeZeroShouldNotFail) { ::testing::Test::RecordProperty("TEST_ID", "9fbfe1ff-9d59-449b-b164-433bbb031125"); - constexpr uint32_t USER_PAYLOAD_SIZE{0U}; + constexpr uint64_t USER_PAYLOAD_SIZE{0U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp index c2a7b16ac3..07cf283957 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp @@ -33,7 +33,7 @@ class MemPool_test : public Test { public: static constexpr uint32_t NUMBER_OF_CHUNKS{100U}; - static constexpr uint32_t CHUNK_SIZE{64U}; + static constexpr uint64_t CHUNK_SIZE{64U}; using FreeListIndex_t = iox::mepoo::MemPool::freeList_t::Index_t; static constexpr FreeListIndex_t LOFFLI_MEMORY_REQUIREMENT{ @@ -60,7 +60,7 @@ TEST_F(MemPool_test, MempoolIndexToPointerConversionForIndexZeroWorks) ::testing::Test::RecordProperty("TEST_ID", "107222a6-7a48-44f1-93c5-9a1f56f3d319"); constexpr uint32_t INDEX{0}; - constexpr uint32_t CHUNK_SIZE{128}; + constexpr uint64_t CHUNK_SIZE{128}; uint8_t* const RAW_MEMORY_BASE{reinterpret_cast(0x7f60d90c5000ULL)}; uint8_t* const EXPECTED_CHUNK_PTR{RAW_MEMORY_BASE}; @@ -74,7 +74,7 @@ TEST_F(MemPool_test, MempoolIndexToPointerConversionForIndexOneWorks) ::testing::Test::RecordProperty("TEST_ID", "fda231af-87a9-4292-be1e-e443aa7cff63"); constexpr uint32_t INDEX{1}; - constexpr uint32_t CHUNK_SIZE{128}; + constexpr uint64_t CHUNK_SIZE{128}; uint8_t* const RAW_MEMORY_BASE{reinterpret_cast(0x7f60d90c5000ULL)}; uint8_t* const EXPECTED_CHUNK_PTR{RAW_MEMORY_BASE + CHUNK_SIZE}; @@ -88,9 +88,9 @@ TEST_F(MemPool_test, MempoolIndexToPointerConversionForMemoryOffsetsLargerThan4G ::testing::Test::RecordProperty("TEST_ID", "2112326a-5ec3-4bc8-9aa3-500ffef202fd"); constexpr uint32_t INDEX{42}; - constexpr uint32_t MB{1UL << 20}; + constexpr uint64_t MB{1UL << 20}; constexpr uint64_t GB{1ULL << 30}; - constexpr uint32_t CHUNK_SIZE{128 * MB}; + constexpr uint64_t CHUNK_SIZE{128 * MB}; uint8_t* const RAW_MEMORY_BASE{reinterpret_cast(0x7f60d90c5000ULL)}; uint8_t* const EXPECTED_CHUNK_PTR{RAW_MEMORY_BASE + static_cast(INDEX) * CHUNK_SIZE}; @@ -104,7 +104,7 @@ TEST_F(MemPool_test, MempoolPointerToIndexConversionForIndexZeroWorks) { ::testing::Test::RecordProperty("TEST_ID", "37b23350-b562-4e89-a452-2f3d328bc016"); - constexpr uint32_t CHUNK_SIZE{128}; + constexpr uint64_t CHUNK_SIZE{128}; uint8_t* const RAW_MEMORY_BASE{reinterpret_cast(0x7f60d90c5000ULL)}; uint8_t* const CHUNK_PTR{RAW_MEMORY_BASE}; constexpr uint32_t EXPECTED_INDEX{0}; @@ -118,7 +118,7 @@ TEST_F(MemPool_test, MempoolPointerToIndexConversionForIndexOneWorks) { ::testing::Test::RecordProperty("TEST_ID", "64349d9a-1a97-4ba0-a04f-07c929befe38"); - constexpr uint32_t CHUNK_SIZE{128}; + constexpr uint64_t CHUNK_SIZE{128}; uint8_t* const RAW_MEMORY_BASE{reinterpret_cast(0x7f60d90c5000ULL)}; uint8_t* const CHUNK_PTR{RAW_MEMORY_BASE + CHUNK_SIZE}; constexpr uint32_t EXPECTED_INDEX{1}; @@ -132,9 +132,9 @@ TEST_F(MemPool_test, MempoolPointeToIndexConversionForMemoryOffsetsLargerThan4GB { ::testing::Test::RecordProperty("TEST_ID", "45e09ada-97b9-435d-a59a-d377d4e4fb69"); - constexpr uint32_t MB{1UL << 20}; + constexpr uint64_t MB{1UL << 20}; constexpr uint64_t GB{1ULL << 30}; - constexpr uint32_t CHUNK_SIZE{128 * MB}; + constexpr uint64_t CHUNK_SIZE{128 * MB}; uint8_t* const RAW_MEMORY_BASE{reinterpret_cast(0x7f60d90c5000ULL)}; constexpr uint32_t EXPECTED_INDEX{42}; uint8_t* const CHUNK_PTR{RAW_MEMORY_BASE + static_cast(EXPECTED_INDEX) * CHUNK_SIZE}; @@ -164,7 +164,7 @@ TEST_F(MemPool_test, MempoolCtorWhenChunkSizeIsNotAMultipleOfAlignmentReturnErro ::testing::Test::RecordProperty("TEST_ID", "ee06090a-8e3c-4df2-b74e-ed50e29b84e6"); char memory[8192U]; iox::BumpAllocator allocator{memory, 100U}; - constexpr uint32_t NOT_ALLIGNED_CHUNKED_SIZE{33U}; + constexpr uint64_t NOT_ALLIGNED_CHUNKED_SIZE{33U}; iox::optional detectedError; auto errorHandlerGuard = iox::ErrorHandlerMock::setTemporaryErrorHandler( diff --git a/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp b/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp index 2e421e7148..2d7ad28ff4 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp @@ -206,7 +206,7 @@ TEST_F(MePooSegment_test, GetMemoryManager) auto config = sut->getMemoryManager().getMemPoolInfo(0); ASSERT_THAT(config.m_numChunks, Eq(100U)); - constexpr uint32_t USER_PAYLOAD_SIZE{128U}; + constexpr uint64_t USER_PAYLOAD_SIZE{128U}; auto chunkSettingsResult = ChunkSettings::create(USER_PAYLOAD_SIZE, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT); ASSERT_FALSE(chunkSettingsResult.has_error()); auto& chunkSettings = chunkSettingsResult.value(); 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 35053c0a14..c5c58ab1be 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 @@ -58,7 +58,7 @@ class ShmSafeUnmanagedChunk_test : public Test static constexpr size_t MEMORY_SIZE = 100 * KILOBYTE; std::unique_ptr m_memory{new char[MEMORY_SIZE]}; static constexpr uint32_t NUM_CHUNKS_IN_POOL = 100; - static constexpr uint32_t CHUNK_SIZE = 128; + static constexpr uint64_t CHUNK_SIZE = 128; iox::BumpAllocator m_memoryAllocator{m_memory.get(), MEMORY_SIZE}; }; diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp index c8b65ecc89..4530b4594a 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_receiver.cpp @@ -77,7 +77,7 @@ class ChunkReceiver_test : public Test std::unique_ptr m_memory{new char[MEMORY_SIZE]}; static constexpr uint32_t NUM_CHUNKS_IN_POOL = iox::MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY + iox::MAX_SUBSCRIBER_QUEUE_CAPACITY; - static constexpr uint32_t CHUNK_SIZE = 128; + static constexpr uint64_t CHUNK_SIZE = 128; iox::BumpAllocator m_memoryAllocator{m_memory.get(), MEMORY_SIZE}; iox::mepoo::MePooConfig m_mempoolconf; diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp index 3f5f2a2a99..60a1b96fb5 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp @@ -72,8 +72,8 @@ class ChunkSender_test : public Test static constexpr size_t MEMORY_SIZE = 1024 * 1024; uint8_t m_memory[MEMORY_SIZE]; static constexpr uint32_t NUM_CHUNKS_IN_POOL = 20; - static constexpr uint32_t SMALL_CHUNK = 128; - static constexpr uint32_t BIG_CHUNK = 256; + static constexpr uint64_t SMALL_CHUNK = 128; + static constexpr uint64_t BIG_CHUNK = 256; static constexpr uint64_t HISTORY_CAPACITY = 4; static constexpr uint32_t MAX_NUMBER_QUEUES = 128; @@ -118,7 +118,7 @@ class ChunkSender_test : public Test TEST_F(ChunkSender_test, allocate_OneChunkWithoutUserHeaderAndSmallUserPayloadAlignmentResultsInSmallChunk) { ::testing::Test::RecordProperty("TEST_ID", "3c60fd47-6637-4a9f-bf1b-1b5f707a0cdf"); - constexpr uint32_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; + constexpr uint64_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT}; auto maybeChunkHeader = m_chunkSender.tryAllocate( UniquePortId(), USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT, USER_HEADER_SIZE, USER_HEADER_ALIGNMENT); @@ -129,7 +129,7 @@ TEST_F(ChunkSender_test, allocate_OneChunkWithoutUserHeaderAndSmallUserPayloadAl TEST_F(ChunkSender_test, allocate_OneChunkWithoutUserHeaderAndLargeUserPayloadAlignmentResultsInLargeChunk) { ::testing::Test::RecordProperty("TEST_ID", "a1743fc6-65a2-4218-be6b-b0b8c2e7d1f7"); - constexpr uint32_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; + constexpr uint64_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; constexpr uint32_t USER_PAYLOAD_ALIGNMENT{SMALL_CHUNK}; auto maybeChunkHeader = m_chunkSender.tryAllocate( UniquePortId(), USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT, USER_HEADER_SIZE, USER_HEADER_ALIGNMENT); diff --git a/iceoryx_posh/test/moduletests/test_popo_client.cpp b/iceoryx_posh/test/moduletests/test_popo_client.cpp index e0bcde7540..972534cec3 100644 --- a/iceoryx_posh/test/moduletests/test_popo_client.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_client.cpp @@ -50,7 +50,7 @@ class Client_test : public Test } static constexpr uint64_t PAYLOAD_SIZE{sizeof(DummyRequest)}; - static constexpr uint64_t PAYLOAD_ALIGNMENT{alignof(DummyRequest)}; + static constexpr uint32_t PAYLOAD_ALIGNMENT{alignof(DummyRequest)}; ChunkMock requestMock; ChunkMock responseMock; diff --git a/iceoryx_posh/test/moduletests/test_popo_client_port.cpp b/iceoryx_posh/test/moduletests/test_popo_client_port.cpp index 4cb70141f4..5f6d8e7c4b 100644 --- a/iceoryx_posh/test/moduletests/test_popo_client_port.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_client_port.cpp @@ -133,7 +133,7 @@ class ClientPort_test : public Test return m_memoryManager.getMemPoolInfo(0U).m_usedChunks; } - iox::mepoo::SharedChunk getChunkFromMemoryManager(uint32_t userPayloadSize, uint32_t userHeaderSize) + iox::mepoo::SharedChunk getChunkFromMemoryManager(uint64_t userPayloadSize, uint32_t userHeaderSize) { auto chunkSettingsResult = iox::mepoo::ChunkSettings::create(userPayloadSize, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, @@ -152,7 +152,7 @@ class ClientPort_test : public Test { for (auto i = 0U; i < numberOfPushes; ++i) { - constexpr uint32_t USER_PAYLOAD_SIZE{10}; + constexpr uint64_t USER_PAYLOAD_SIZE{10}; auto sharedChunk = getChunkFromMemoryManager(USER_PAYLOAD_SIZE, sizeof(ResponseHeader)); if (!chunkQueuePusher.push(sharedChunk)) { @@ -167,7 +167,7 @@ class ClientPort_test : public Test private: static constexpr uint32_t NUM_CHUNKS = 1024U; - static constexpr uint32_t CHUNK_SIZE = 128U; + static constexpr uint64_t CHUNK_SIZE = 128U; static constexpr size_t MEMORY_SIZE = 1024U * 1024U; uint8_t m_memory[MEMORY_SIZE]; iox::BumpAllocator m_memoryAllocator{m_memory, MEMORY_SIZE}; @@ -206,7 +206,7 @@ class ClientPort_test : public Test iox::optional clientPortForStateTransitionTests; public: - static constexpr uint32_t USER_PAYLOAD_SIZE{32U}; + static constexpr uint64_t USER_PAYLOAD_SIZE{32U}; static constexpr uint32_t USER_PAYLOAD_ALIGNMENT{8U}; ServerChunkQueueData_t serverChunkQueueData{iox::popo::QueueFullPolicy::DISCARD_OLDEST_DATA, @@ -398,7 +398,7 @@ TEST_F(ClientPort_test, GetResponseOnConnectedClientPortWithNonEmptyResponseQueu constexpr int64_t SEQUENCE_ID{13U}; auto& sut = clientPortWithConnectOnCreate; - constexpr uint32_t USER_PAYLOAD_SIZE{10}; + constexpr uint64_t USER_PAYLOAD_SIZE{10}; auto sharedChunk = getChunkFromMemoryManager(USER_PAYLOAD_SIZE, sizeof(ResponseHeader)); new (sharedChunk.getChunkHeader()->userHeader()) ResponseHeader(iox::UniqueId(), RpcBaseHeader::UNKNOWN_CLIENT_QUEUE_INDEX, SEQUENCE_ID); @@ -435,7 +435,7 @@ TEST_F(ClientPort_test, ReleaseResponseWithValidResponseReleasesChunkToTheMempoo ::testing::Test::RecordProperty("TEST_ID", "3f625d3e-9ef3-4329-9c80-95af0327cbc0"); auto& sut = clientPortWithConnectOnCreate; - constexpr uint32_t USER_PAYLOAD_SIZE{10}; + constexpr uint64_t USER_PAYLOAD_SIZE{10}; iox::optional sharedChunk{ getChunkFromMemoryManager(USER_PAYLOAD_SIZE, sizeof(ResponseHeader))}; @@ -459,7 +459,7 @@ TEST_F(ClientPort_test, ReleaseQueuedResponsesReleasesAllChunksToTheMempool) ::testing::Test::RecordProperty("TEST_ID", "d51674b7-ad92-47cc-85d9-06169e8a813b"); auto& sut = clientPortWithConnectOnCreate; - constexpr uint32_t USER_PAYLOAD_SIZE{10}; + constexpr uint64_t USER_PAYLOAD_SIZE{10}; constexpr uint32_t NUMBER_OF_QUEUED_RESPONSES{3}; for (uint32_t i = 0; i < NUMBER_OF_QUEUED_RESPONSES; ++i) @@ -487,7 +487,7 @@ TEST_F(ClientPort_test, HasNewResponseOnNonEmptyResponseQueueReturnsTrue) ::testing::Test::RecordProperty("TEST_ID", "2b0dbb32-2d5b-4eac-96d3-6cf7a8cbac15"); auto& sut = clientPortWithConnectOnCreate; - constexpr uint32_t USER_PAYLOAD_SIZE{10}; + constexpr uint64_t USER_PAYLOAD_SIZE{10}; auto sharedChunk = getChunkFromMemoryManager(USER_PAYLOAD_SIZE, sizeof(ResponseHeader)); sut.responseQueuePusher.push(sharedChunk); @@ -499,7 +499,7 @@ TEST_F(ClientPort_test, HasNewResponseOnEmptyResponseQueueAfterPreviouslyNotEmpt ::testing::Test::RecordProperty("TEST_ID", "9cd91de8-9687-436a-9d7d-95d2754eee30"); auto& sut = clientPortWithConnectOnCreate; - constexpr uint32_t USER_PAYLOAD_SIZE{10}; + constexpr uint64_t USER_PAYLOAD_SIZE{10}; auto sharedChunk = getChunkFromMemoryManager(USER_PAYLOAD_SIZE, sizeof(ResponseHeader)); sut.responseQueuePusher.push(sharedChunk); diff --git a/iceoryx_posh/test/moduletests/test_popo_publisher_port.cpp b/iceoryx_posh/test/moduletests/test_popo_publisher_port.cpp index c9c30f04ca..f7147b0dc5 100644 --- a/iceoryx_posh/test/moduletests/test_popo_publisher_port.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_publisher_port.cpp @@ -63,8 +63,8 @@ class PublisherPort_test : public Test static constexpr size_t MEMORY_SIZE = 1024 * 1024; uint8_t m_memory[MEMORY_SIZE]; static constexpr uint32_t NUM_CHUNKS_IN_POOL = 20; - static constexpr uint32_t SMALL_CHUNK = 128; - static constexpr uint32_t BIG_CHUNK = 256; + static constexpr uint64_t SMALL_CHUNK = 128; + static constexpr uint64_t BIG_CHUNK = 256; static constexpr uint32_t USER_PAYLOAD_ALIGNMENT = iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT; static constexpr uint32_t USER_HEADER_SIZE = iox::CHUNK_NO_USER_HEADER_SIZE; @@ -238,7 +238,7 @@ TEST_F(PublisherPort_test, TEST_F(PublisherPort_test, allocatingAChunkWithoutUserHeaderAndSmallUserPayloadAlignmentResultsInSmallChunk) { ::testing::Test::RecordProperty("TEST_ID", "467e0f06-3450-4cc9-ab84-5ccd5efab69d"); - constexpr uint32_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; + constexpr uint64_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; auto maybeChunkHeader = m_sutNoOfferOnCreateUserSide.tryAllocateChunk( USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT, USER_HEADER_SIZE, USER_HEADER_ALIGNMENT); @@ -249,7 +249,7 @@ TEST_F(PublisherPort_test, allocatingAChunkWithoutUserHeaderAndSmallUserPayloadA TEST_F(PublisherPort_test, allocatingAChunkWithoutUserHeaderAndLargeUserPayloadAlignmentResultsInLargeChunk) { ::testing::Test::RecordProperty("TEST_ID", "3bdf0578-93b3-470d-84af-9139919665db"); - constexpr uint32_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; + constexpr uint64_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; constexpr uint32_t LARGE_USER_PAYLOAD_ALIGNMENT{SMALL_CHUNK}; auto maybeChunkHeader = m_sutNoOfferOnCreateUserSide.tryAllocateChunk( USER_PAYLOAD_SIZE, LARGE_USER_PAYLOAD_ALIGNMENT, USER_HEADER_SIZE, USER_HEADER_ALIGNMENT); @@ -261,7 +261,7 @@ TEST_F(PublisherPort_test, allocatingAChunkWithoutUserHeaderAndLargeUserPayloadA TEST_F(PublisherPort_test, allocatingAChunkWithLargeUserHeaderResultsInLargeChunk) { ::testing::Test::RecordProperty("TEST_ID", "598e04d8-8a37-43ef-b686-64e7b2723ffe"); - constexpr uint32_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; + constexpr uint64_t USER_PAYLOAD_SIZE{SMALL_CHUNK / 2}; constexpr uint32_t LARGE_USER_HEADER_SIZE{SMALL_CHUNK}; auto maybeChunkHeader = m_sutNoOfferOnCreateUserSide.tryAllocateChunk( USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT, LARGE_USER_HEADER_SIZE, USER_HEADER_ALIGNMENT); diff --git a/iceoryx_posh/test/moduletests/test_popo_server.cpp b/iceoryx_posh/test/moduletests/test_popo_server.cpp index 091f95c98c..b535e46831 100644 --- a/iceoryx_posh/test/moduletests/test_popo_server.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_server.cpp @@ -50,7 +50,7 @@ class Server_test : public Test } static constexpr uint64_t PAYLOAD_SIZE{sizeof(DummyResponse)}; - static constexpr uint64_t PAYLOAD_ALIGNMENT{alignof(DummyResponse)}; + static constexpr uint32_t PAYLOAD_ALIGNMENT{alignof(DummyResponse)}; ChunkMock requestMock; ChunkMock responseMock; 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 db29d403c3..c18536534c 100644 --- a/iceoryx_posh/test/moduletests/test_popo_server_port_common.hpp +++ b/iceoryx_posh/test/moduletests/test_popo_server_port_common.hpp @@ -101,7 +101,7 @@ class ServerPort_test : public Test return m_memoryManager.getMemPoolInfo(0U).m_usedChunks; } - SharedChunk getChunkFromMemoryManager(uint32_t userPayloadSize, uint32_t userHeaderSize) + SharedChunk getChunkFromMemoryManager(uint64_t userPayloadSize, uint32_t userHeaderSize) { auto chunkSettingsResult = ChunkSettings::create(userPayloadSize, iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, @@ -119,7 +119,7 @@ class ServerPort_test : public Test SharedChunk getChunkWithInitializedRequestHeaderAndData(const uint64_t data = DUMMY_DATA) { - constexpr uint32_t USER_PAYLOAD_SIZE{sizeof(uint64_t)}; + constexpr uint64_t USER_PAYLOAD_SIZE{sizeof(uint64_t)}; auto sharedChunk = getChunkFromMemoryManager(USER_PAYLOAD_SIZE, sizeof(RequestHeader)); new (sharedChunk.getChunkHeader()->userHeader()) RequestHeader(clientChunkQueueData.m_uniqueId, RpcBaseHeader::UNKNOWN_CLIENT_QUEUE_INDEX); @@ -163,7 +163,7 @@ class ServerPort_test : public Test SutServerPort& sut, std::function testFunction) { constexpr uint64_t USER_PAYLOAD_SIZE{8}; - constexpr uint64_t USER_PAYLOAD_ALIGNMENT{8}; + constexpr uint32_t USER_PAYLOAD_ALIGNMENT{8}; constexpr uint64_t NUMBER_OF_REQUESTS{1U}; pushRequests(sut.requestQueuePusher, NUMBER_OF_REQUESTS); @@ -182,7 +182,7 @@ class ServerPort_test : public Test static constexpr uint32_t NUM_CHUNKS = iox::MAX_REQUESTS_ALLOCATED_SIMULTANEOUSLY + iox::MAX_RESPONSES_ALLOCATED_SIMULTANEOUSLY + iox::MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY + iox::MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY + 16U; - static constexpr uint32_t CHUNK_SIZE = 128U; + static constexpr uint64_t CHUNK_SIZE = 128U; static constexpr size_t MEMORY_SIZE = 1024U * 1024U; uint8_t m_memory[MEMORY_SIZE]; iox::BumpAllocator m_memoryAllocator{m_memory, MEMORY_SIZE}; @@ -222,7 +222,7 @@ class ServerPort_test : public Test iox::optional clientPortForStateTransitionTests; public: - static constexpr uint32_t USER_PAYLOAD_SIZE{32U}; + static constexpr uint64_t USER_PAYLOAD_SIZE{32U}; static constexpr uint32_t USER_PAYLOAD_ALIGNMENT{8U}; ClientChunkQueueData_t clientChunkQueueData{iox::popo::QueueFullPolicy::DISCARD_OLDEST_DATA, diff --git a/iceoryx_posh/test/moduletests/test_popo_server_port_user.cpp b/iceoryx_posh/test/moduletests/test_popo_server_port_user.cpp index 745fa6dfb9..b9489260c1 100644 --- a/iceoryx_posh/test/moduletests/test_popo_server_port_user.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_server_port_user.cpp @@ -568,7 +568,7 @@ TEST_F(ServerPort_test, AllocateResponseWithNullptrAsRequestHeaderCallsErrorHand auto& sut = serverPortWithOfferOnCreate; constexpr uint64_t USER_PAYLOAD_SIZE{8U}; - constexpr uint64_t USER_PAYLOAD_ALIGNMENT{8U}; + constexpr uint32_t USER_PAYLOAD_ALIGNMENT{8U}; constexpr RequestHeader* REQUEST_HEADER_NULLPTR{nullptr}; sut.portUser.allocateResponse(REQUEST_HEADER_NULLPTR, USER_PAYLOAD_SIZE, USER_PAYLOAD_ALIGNMENT) @@ -586,7 +586,7 @@ TEST_F(ServerPort_test, auto& sut = serverPortWithOfferOnCreate; constexpr uint64_t INVALID_USER_PAYLOAD_SIZE{23U}; - constexpr uint64_t INVALID_USER_PAYLOAD_ALIGNMENT{15U}; + constexpr uint32_t INVALID_USER_PAYLOAD_ALIGNMENT{15U}; constexpr uint64_t NUMBER_OF_REQUESTS{1U}; pushRequests(sut.requestQueuePusher, NUMBER_OF_REQUESTS); diff --git a/iceoryx_posh/test/moduletests/test_popo_untyped_client.cpp b/iceoryx_posh/test/moduletests/test_popo_untyped_client.cpp index 734813cb1e..299b283de4 100644 --- a/iceoryx_posh/test/moduletests/test_popo_untyped_client.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_untyped_client.cpp @@ -63,7 +63,7 @@ TEST_F(UntypedClient_test, LoanCallsUnderlyingPortWithSuccessResult) ::testing::Test::RecordProperty("TEST_ID", "acb900fd-288f-4ef3-96b9-6843cd869893"); constexpr uint64_t PAYLOAD_SIZE{8U}; - constexpr uint64_t PAYLOAD_ALIGNMENT{32U}; + constexpr uint32_t PAYLOAD_ALIGNMENT{32U}; const iox::expected allocateRequestResult = iox::ok(requestMock.userHeader()); @@ -79,7 +79,7 @@ TEST_F(UntypedClient_test, LoanCallsUnderlyingPortWithErrorResult) ::testing::Test::RecordProperty("TEST_ID", "905d8a67-1fde-4960-a95d-51c5ca4b6ed9"); constexpr uint64_t PAYLOAD_SIZE{8U}; - constexpr uint64_t PAYLOAD_ALIGNMENT{32U}; + constexpr uint32_t PAYLOAD_ALIGNMENT{32U}; constexpr AllocationError ALLOCATION_ERROR{AllocationError::RUNNING_OUT_OF_CHUNKS}; const iox::expected allocateRequestResult = iox::err(ALLOCATION_ERROR); diff --git a/iceoryx_posh/test/moduletests/test_popo_untyped_publisher.cpp b/iceoryx_posh/test/moduletests/test_popo_untyped_publisher.cpp index ee6877e30c..d50d84bc17 100644 --- a/iceoryx_posh/test/moduletests/test_popo_untyped_publisher.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_untyped_publisher.cpp @@ -58,7 +58,7 @@ class UntypedPublisherTest : public Test TEST_F(UntypedPublisherTest, LoansChunkWithRequestedSizeWorks) { ::testing::Test::RecordProperty("TEST_ID", "ddf997c8-ef8e-4f89-802e-66f1c4bf4980"); - constexpr uint32_t USER_PAYLOAD_SIZE = 7U; + constexpr uint64_t USER_PAYLOAD_SIZE = 7U; constexpr uint32_t USER_PAYLOAD_ALIGNMENT = 128U; EXPECT_CALL(portMock, tryAllocateChunk(USER_PAYLOAD_SIZE, @@ -79,7 +79,7 @@ TEST_F(UntypedPublisherTest, LoansChunkWithRequestedSizeAndUserHeaderWorks) TestUntypedPublisher sutWithUserHeader{{"", "", ""}}; MockPublisherPortUser& portMockWithUserHeader{sutWithUserHeader.mockPort()}; - constexpr uint32_t USER_PAYLOAD_SIZE = 42U; + constexpr uint64_t USER_PAYLOAD_SIZE = 42U; constexpr uint32_t USER_PAYLOAD_ALIGNMENT = 512U; constexpr uint32_t USER_HEADER_SIZE = sizeof(TestUserHeader); constexpr uint32_t USER_HEADER_ALIGNMENT = alignof(TestUserHeader); @@ -97,7 +97,7 @@ TEST_F(UntypedPublisherTest, LoansChunkWithRequestedSizeAndUserHeaderWorks) TEST_F(UntypedPublisherTest, LoanFailsIfPortCannotSatisfyAllocationRequest) { ::testing::Test::RecordProperty("TEST_ID", "b609f96e-ea08-46b2-9b72-d162a8273cb5"); - constexpr uint32_t ALLOCATION_SIZE = 17U; + constexpr uint64_t ALLOCATION_SIZE = 17U; EXPECT_CALL(portMock, tryAllocateChunk(ALLOCATION_SIZE, _, _, _)) .WillOnce(Return(ByMove(iox::err(iox::popo::AllocationError::RUNNING_OUT_OF_CHUNKS)))); // ===== Test ===== // @@ -111,7 +111,7 @@ TEST_F(UntypedPublisherTest, LoanFailsIfPortCannotSatisfyAllocationRequest) TEST_F(UntypedPublisherTest, ReleaseDelegatesCallToPort) { ::testing::Test::RecordProperty("TEST_ID", "e114b083-10c7-403e-a841-a04487a5f1e0"); - constexpr uint32_t ALLOCATION_SIZE = 7U; + constexpr uint64_t ALLOCATION_SIZE = 7U; EXPECT_CALL(portMock, tryAllocateChunk(ALLOCATION_SIZE, _, _, _)) .WillOnce(Return(ByMove(iox::ok(chunkMock.chunkHeader())))); diff --git a/iceoryx_posh/test/moduletests/test_popo_untyped_server.cpp b/iceoryx_posh/test/moduletests/test_popo_untyped_server.cpp index 8590e212f5..2a55682e2f 100644 --- a/iceoryx_posh/test/moduletests/test_popo_untyped_server.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_untyped_server.cpp @@ -109,7 +109,7 @@ TEST_F(UntypedServer_test, LoanCallsUnderlyingPortWithSuccessResult) ::testing::Test::RecordProperty("TEST_ID", "f39d58f3-b25e-4515-852d-c3afa5519e5a"); constexpr uint64_t PAYLOAD_SIZE{8U}; - constexpr uint64_t PAYLOAD_ALIGNMENT{32U}; + constexpr uint32_t PAYLOAD_ALIGNMENT{32U}; const iox::expected allocateResponseResult = iox::ok(responseMock.userHeader()); @@ -126,7 +126,7 @@ TEST_F(UntypedServer_test, LoanCallsUnderlyingPortWithErrorResult) ::testing::Test::RecordProperty("TEST_ID", "d813b550-64b2-490f-a9f4-bafc9ddc7696"); constexpr uint64_t PAYLOAD_SIZE{8U}; - constexpr uint64_t PAYLOAD_ALIGNMENT{32U}; + constexpr uint32_t PAYLOAD_ALIGNMENT{32U}; constexpr AllocationError ALLOCATION_ERROR{AllocationError::RUNNING_OUT_OF_CHUNKS}; const iox::expected allocateResponseResult = iox::err(ALLOCATION_ERROR); 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 c9f5ced98a..4d5141c9c8 100644 --- a/iceoryx_posh/test/moduletests/test_popo_used_chunk_list.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_used_chunk_list.cpp @@ -34,7 +34,7 @@ class UsedChunkList_test : public Test void SetUp() override { static constexpr uint32_t NUM_CHUNKS_IN_POOL = 100U; - static constexpr uint32_t CHUNK_SIZE = 128U; + static constexpr uint64_t CHUNK_SIZE = 128U; MePooConfig mempoolconf; mempoolconf.addMemPool({CHUNK_SIZE, NUM_CHUNKS_IN_POOL}); @@ -46,7 +46,7 @@ class UsedChunkList_test : public Test SharedChunk getChunkFromMemoryManager() { - constexpr uint32_t USER_PAYLOAD_SIZE{32U}; + 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()); diff --git a/iceoryx_posh/testing/CMakeLists.txt b/iceoryx_posh/testing/CMakeLists.txt index 2e50caf9c3..28a32f5820 100644 --- a/iceoryx_posh/testing/CMakeLists.txt +++ b/iceoryx_posh/testing/CMakeLists.txt @@ -37,3 +37,7 @@ iox_add_library( FILES source/roudi_gtest.cpp ) + +if(TEST_WITH_HUGE_PAYLOAD) + target_compile_definitions(iceoryx_posh_testing PUBLIC -DTEST_WITH_HUGE_PAYLOAD) +endif(TEST_WITH_HUGE_PAYLOAD) \ No newline at end of file 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 3da3338306..67e11182b2 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 @@ -34,7 +34,7 @@ class ChunkMock public: ChunkMock() { - const uint32_t userPayloadSize = sizeof(Topic); + const uint64_t userPayloadSize = sizeof(Topic); const uint32_t userPayloadAlignment = alignof(Topic); const uint32_t userHeaderSize = std::is_same::value ? 0U : sizeof(UserHeader); diff --git a/tools/iceoryx_build_test.sh b/tools/iceoryx_build_test.sh index 6e063935ad..17432fefc3 100755 --- a/tools/iceoryx_build_test.sh +++ b/tools/iceoryx_build_test.sh @@ -47,6 +47,7 @@ ADDRESS_SANITIZER_FLAG="OFF" THREAD_SANITIZER_FLAG="OFF" ROUDI_ENV_FLAG="OFF" TEST_ADD_USER="OFF" +TEST_HUGE_PAYLOAD="OFF" OUT_OF_TREE_FLAG="OFF" EXAMPLE_FLAG="OFF" BUILD_ALL_FLAG="OFF" @@ -124,6 +125,10 @@ while (( "$#" )); do "$WORKSPACE"/tools/scripts/add_test_users.sh check shift 1 ;; + "test-huge-payload") + TEST_HUGE_PAYLOAD="ON" + shift 1 + ;; "binding-c") echo " [i] Including C binding in build" BINDING_C_FLAG="ON" @@ -311,6 +316,7 @@ if [ "$NO_BUILD" == false ]; then -DADDRESS_SANITIZER=$ADDRESS_SANITIZER_FLAG \ -DTHREAD_SANITIZER=$THREAD_SANITIZER_FLAG \ -DTEST_WITH_ADDITIONAL_USER=$TEST_ADD_USER $TOOLCHAIN_FILE \ + -DTEST_WITH_HUGE_PAYLOAD=$TEST_HUGE_PAYLOAD \ -DCMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS \ "$WORKSPACE"/iceoryx_meta diff --git a/tools/introspection/source/introspection_app.cpp b/tools/introspection/source/introspection_app.cpp index 4622009f99..ef77811579 100644 --- a/tools/introspection/source/introspection_app.cpp +++ b/tools/introspection/source/introspection_app.cpp @@ -293,8 +293,8 @@ void IntrospectionApp::printMemPoolInfo(const MemPoolIntrospectionInfo& introspe wprintw(pad, "%*d |", usedchunksWidth, info.m_usedChunks); wprintw(pad, "%*d |", numchunksWidth, info.m_numChunks); wprintw(pad, "%*d |", minFreechunksWidth, info.m_minFreeChunks); - wprintw(pad, "%*d |", chunkSizeWidth, info.m_chunkSize); - wprintw(pad, "%*d\n", chunkPayloadSizeWidth, info.m_chunkPayloadSize); + wprintw(pad, "%*ld |", chunkSizeWidth, info.m_chunkSize); + wprintw(pad, "%*ld\n", chunkPayloadSizeWidth, info.m_chunkPayloadSize); } } wprintw(pad, "\n");