From 8b13ed6656a62c46c7b592e3433fc1ae59471788 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 26 Jun 2024 11:21:08 +0200 Subject: [PATCH] Improve test. Signed-off-by: Miguel Company --- .../common/DDSBlackboxTestsListeners.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index 112bf41442d..f4c981880dc 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -677,11 +677,22 @@ TEST_P(DDSStatus, DataAvailableConditions) subscriber_reader.wait_waitset_timeout(); } +// We want to ensure that samples are only lost due to the custom filter we have set in sample_lost_test_dw_init. +// Since we are going to send 300KB samples in the test for fragments, let's increase the buffer size to avoid any +// other possible loss. +static constexpr uint32_t SAMPLE_LOST_TEST_BUFFER_SIZE = + 300ul * 1024ul // sample size + * 13ul // number of samples + * 2ul; // 2x to avoid any possible loss + template void sample_lost_test_dw_init( PubSubWriter& writer) { auto testTransport = std::make_shared(); + testTransport->sendBufferSize = SAMPLE_LOST_TEST_BUFFER_SIZE; + testTransport->receiveBufferSize = SAMPLE_LOST_TEST_BUFFER_SIZE; + testTransport->drop_data_messages_filter_ = [](eprosima::fastrtps::rtps::CDRMessage_t& msg)-> bool { uint32_t old_pos = msg.pos; @@ -780,15 +791,8 @@ void sample_lost_test_init( PubSubWriter& writer, std::function functor) { - // We want to ensure that samples are only lost due to the custom filter we have set in sample_lost_test_dw_init. - // Since we are going to send 300KB samples in the test for fragments, let's increase the buffer size to avoid any - // other possible loss. - constexpr uint32_t BUFFER_SIZE = - 300ul * 1024ul // sample size - * 13ul // number of samples - * 2ul; // 2x to avoid any possible loss - reader.socket_buffer_size(BUFFER_SIZE); - writer.socket_buffer_size(BUFFER_SIZE); + reader.socket_buffer_size(SAMPLE_LOST_TEST_BUFFER_SIZE); + writer.socket_buffer_size(SAMPLE_LOST_TEST_BUFFER_SIZE); sample_lost_test_dw_init(writer); sample_lost_test_dr_init(reader, functor);