Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2157 Add TEST_WITH_HUGE_PAYLOAD cmake flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakusek committed Feb 1, 2024
1 parent 4a11974 commit f694aca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
2 changes: 2 additions & 0 deletions iceoryx_meta/build_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
40 changes: 17 additions & 23 deletions iceoryx_posh/test/integrationtests/test_client_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,16 @@ TEST_F(ClientServer_test, ClientTakesResponseUnblocksServerSendingResponse)
EXPECT_THAT(wasResponseSent.load(), Eq(true));
}

#ifdef RUN_BIG_PAYLOAD_TESTS
#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 START{1337};
constexpr uint64_t END{2137};
constexpr uint64_t FIRST{4095};
constexpr uint64_t LAST{BIG_PAYLOAD_SIZE - 1};
constexpr uint64_t STEP{4096};
constexpr uint8_t SHIFT{13U};

Client<BigPayloadStruct, BigPayloadStruct> client{sd};
Expand All @@ -502,9 +503,9 @@ TEST_F(BigPayloadClientServer_test, TypedApiWithBigPayloadWithMatchingOptionsWor
ASSERT_FALSE(loanResult.has_error());
auto& request = loanResult.value();
request.getRequestHeader().setSequenceId(SEQUENCE_ID);
for (uint64_t i = START; i < END; ++i)
for (uint64_t i = FIRST; i <= LAST; i += STEP)
{
request->bigPayload[i] = static_cast<uint8_t>(i % 256U);
request->bigPayload[i] = static_cast<uint8_t>((i / STEP) % 256U);
}
ASSERT_FALSE(client.send(std::move(request)).has_error());
}
Expand All @@ -518,7 +519,7 @@ TEST_F(BigPayloadClientServer_test, TypedApiWithBigPayloadWithMatchingOptionsWor
auto loanResult = server.loan(request);
ASSERT_FALSE(loanResult.has_error());
auto& response = loanResult.value();
for (uint64_t i = START; i < END; ++i)
for (uint64_t i = FIRST; i <= LAST; i += STEP)
{
response->bigPayload[i] = request->bigPayload[i] + SHIFT;
}
Expand All @@ -531,13 +532,9 @@ TEST_F(BigPayloadClientServer_test, TypedApiWithBigPayloadWithMatchingOptionsWor
ASSERT_FALSE(takeResult.has_error());
auto& response = takeResult.value();
EXPECT_THAT(response.getResponseHeader().getSequenceId(), Eq(SEQUENCE_ID));
for (uint64_t i = START; i < END; ++i)
for (uint64_t i = FIRST; i <= LAST; i += STEP)
{
if (response->bigPayload[i] != static_cast<uint8_t>((i % 256U) + SHIFT))
{
EXPECT_THAT(response->bigPayload[i], Eq(static_cast<uint8_t>((i % 256U) + SHIFT)));
break;
}
ASSERT_THAT(response->bigPayload[i], Eq(static_cast<uint8_t>(((i / STEP) % 256U) + SHIFT)));
}
}
}
Expand All @@ -547,8 +544,9 @@ TEST_F(BigPayloadClientServer_test, UntypedApiWithBigPayloadWithMatchingOptionsW
::testing::Test::RecordProperty("TEST_ID", "3c784d7f-6fe8-2137-b267-7f3e70a307f3");

constexpr int64_t SEQUENCE_ID{37};
constexpr uint64_t START{1337};
constexpr uint64_t END{2137};
constexpr uint64_t FIRST{4095};
constexpr uint64_t LAST{BIG_PAYLOAD_SIZE - 1};
constexpr uint64_t STEP{4096};
constexpr uint8_t SHIFT{13U};

UntypedClient client{sd};
Expand All @@ -560,9 +558,9 @@ TEST_F(BigPayloadClientServer_test, UntypedApiWithBigPayloadWithMatchingOptionsW
ASSERT_FALSE(loanResult.has_error());
auto request = static_cast<BigPayloadStruct*>(loanResult.value());
RequestHeader::fromPayload(request)->setSequenceId(SEQUENCE_ID);
for (uint64_t i = START; i < END; ++i)
for (uint64_t i = FIRST; i <= LAST; i += STEP)
{
request->bigPayload[i] = static_cast<uint8_t>(i % 256U);
request->bigPayload[i] = static_cast<uint8_t>((i / STEP) % 256U);
}
ASSERT_FALSE(client.send(request).has_error());
}
Expand All @@ -577,7 +575,7 @@ TEST_F(BigPayloadClientServer_test, UntypedApiWithBigPayloadWithMatchingOptionsW
server.loan(RequestHeader::fromPayload(request), sizeof(BigPayloadStruct), alignof(BigPayloadStruct));
ASSERT_FALSE(loanResult.has_error());
auto response = static_cast<BigPayloadStruct*>(loanResult.value());
for (uint64_t i = START; i < END; ++i)
for (uint64_t i = FIRST; i <= LAST; i += STEP)
{
response->bigPayload[i] = request->bigPayload[i] + SHIFT;
}
Expand All @@ -591,13 +589,9 @@ TEST_F(BigPayloadClientServer_test, UntypedApiWithBigPayloadWithMatchingOptionsW
ASSERT_FALSE(takeResult.has_error());
auto response = static_cast<const BigPayloadStruct*>(takeResult.value());
EXPECT_THAT(ResponseHeader::fromPayload(response)->getSequenceId(), Eq(SEQUENCE_ID));
for (uint64_t i = START; i < END; ++i)
for (uint64_t i = FIRST; i <= LAST; i += STEP)
{
if (response->bigPayload[i] != static_cast<uint8_t>((i % 256U) + SHIFT))
{
EXPECT_THAT(response->bigPayload[i], Eq(static_cast<uint8_t>((i % 256U) + SHIFT)));
break;
}
ASSERT_THAT(response->bigPayload[i], Eq(static_cast<uint8_t>(((i / STEP) % 256U) + SHIFT)));
}
client.releaseResponse(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ TEST_F(PublisherSubscriberCommunication_test, PublisherUniqueIdMatchesReceivedSa
}
}

#ifdef RUN_BIG_PAYLOAD_TESTS
#ifdef TEST_WITH_HUGE_PAYLOAD

TEST_F(PublisherSubscriberCommunicationWithBigPayload_test, SendingComplexDataType_BigPayloadStruct)
{
Expand All @@ -755,19 +755,20 @@ TEST_F(PublisherSubscriberCommunicationWithBigPayload_test, SendingComplexDataTy

ASSERT_FALSE(publisher->loan()
.and_then([](auto& sample) {
for (uint64_t i = 4242; i < 5353; ++i)
for (uint64_t i = 4095; i < BIG_PAYLOAD_SIZE; i += 4096)
{
sample->complexType.bigPayload[i] = static_cast<uint8_t>(i % 256U);
sample->complexType.bigPayload[i] = static_cast<uint8_t>((i / 4096) % 256U);
}
sample.publish();
})
.has_error());

EXPECT_FALSE(subscriber->take()
.and_then([](auto& sample) {
for (uint64_t i = 4242; i < 5353; ++i)
for (uint64_t i = 4095; i < BIG_PAYLOAD_SIZE; i += 4096)
{
EXPECT_THAT(sample->complexType.bigPayload[i], Eq(static_cast<uint8_t>(i % 256U)));
ASSERT_THAT(sample->complexType.bigPayload[i],
Eq(static_cast<uint8_t>((i / 4096) % 256U)));
}
})
.has_error());
Expand Down
4 changes: 4 additions & 0 deletions iceoryx_posh/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 6 additions & 0 deletions tools/iceoryx_build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f694aca

Please sign in to comment.