diff --git a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp index 55b73daec1d..a01f0ca2a1a 100644 --- a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp @@ -1183,6 +1183,64 @@ TEST(RTPS, participant_ignore_local_endpoints_two_participants) eprosima::fastrtps::rtps::RTPSDomain::removeRTPSParticipant(participant_reader); } +/* Maximum number of bytes allowed for an RTPS datagram generated by this participant. */ +TEST(RTPS, Check_max_output_message_size_participant) +{ + /* Set up */ + // Create the RTPSParticipants with the appropriate value for the property + auto testTransport = std::make_shared(); + std::string segment_size_str = "1470"; + const uint32_t segment_size = std::stoul(segment_size_str); + testTransport->messages_filter_ = [segment_size](eprosima::fastrtps::rtps::CDRMessage_t& datagram) + { + bool result = datagram.length > segment_size; + EXPECT_FALSE(result); + return result; + }; + + eprosima::fastrtps::rtps::RTPSParticipantAttributes patt; + eprosima::fastrtps::rtps::RTPSParticipant* participant_reader = + eprosima::fastrtps::rtps::RTPSDomain::createParticipant(static_cast(GET_PID()) % 230, patt); + ASSERT_NE(participant_reader, nullptr); + patt.useBuiltinTransports = false; + patt.userTransports.push_back(testTransport); + patt.properties.properties().emplace_back("fastdds.max_message_size", segment_size_str); + eprosima::fastrtps::rtps::RTPSParticipant* participant_writer = + eprosima::fastrtps::rtps::RTPSDomain::createParticipant(static_cast(GET_PID()) % 230, patt); + ASSERT_NE(participant_writer, nullptr); + + // Create the RTPSWriter + RTPSWithRegistrationWriter writer(TEST_TOPIC_NAME, participant_writer); + writer.init(); + EXPECT_TRUE(writer.isInitialized()); + + // Create the RTPSReader + RTPSWithRegistrationReader reader(TEST_TOPIC_NAME, participant_reader); + reader.init(); + EXPECT_TRUE(reader.isInitialized()); + + // Wait for discovery + writer.wait_discovery(1, std::chrono::seconds(2)); + reader.wait_discovery(1, std::chrono::seconds(2)); + EXPECT_EQ(writer.get_matched(), 1u); + EXPECT_EQ(reader.get_matched(), 1u); + + // Send samples + auto samples = default_large_helloworld_data_generator(1); + reader.expected_data(samples); + reader.startReception(); + writer.send(samples); + EXPECT_TRUE(samples.empty()); + + // Wait for reception + reader.block_for_all(std::chrono::seconds(1)); + EXPECT_EQ(reader.getReceivedCount(), 1u); + + /* Tear-down */ + eprosima::fastrtps::rtps::RTPSDomain::removeRTPSParticipant(participant_writer); + eprosima::fastrtps::rtps::RTPSDomain::removeRTPSParticipant(participant_reader); +} + /* Maximum number of bytes allowed for an RTPS datagram generated by this writer. */ TEST(RTPS, Check_max_output_message_size_writer) {