@@ -208,7 +208,7 @@ void test_local_communication(
208208
209209template <class MsgStruct , class MsgStructType >
210210void test_original_writer_forwarding (
211- DdsRouterConfiguration ddsrouter_configuration)
211+ DdsRouterConfiguration ddsrouter_configuration, int case_number )
212212{
213213 INSTANTIATE_LOG_TESTER (eprosima::utils::Log::Kind::Error, 0 , 0 );
214214
@@ -234,36 +234,45 @@ void test_original_writer_forwarding(
234234 router.start ();
235235
236236 // CASE 1: Send message without original_writer_param, should be set to writers guid
237- sent_msg.index (++samples_sent);
238- ASSERT_EQ (publisher.publish (sent_msg), eprosima::fastdds::dds::RETCODE_OK);
239- // Watiting for the message to be received
240- while (samples_received.load () < 1 )
237+ if (case_number == 1 )
241238 {
239+ sent_msg.index (++samples_sent);
240+ ASSERT_EQ (publisher.publish (sent_msg), eprosima::fastdds::dds::RETCODE_OK);
241+ // Watiting for the message to be received
242+ while (samples_received.load () < 1 )
243+ {
244+ }
245+ ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
242246 }
243- ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
244247
245248 // CASE 2: Send message with original_writer_param set to some value, value must be kept
246- sent_msg.index (++samples_sent);
247- eprosima::fastdds::rtps::WriteParams params_with_og_writer;
248- eprosima::fastdds::rtps::GUID_t guid ({}, 0x12345678 );
249- params_with_og_writer.original_writer_info ().original_writer_guid (guid);
250- ASSERT_EQ (publisher.publish_with_params (sent_msg, params_with_og_writer), eprosima::fastdds::dds::RETCODE_OK);
251- // Waiting for the message to be received
252- while (samples_received.load () < 2 )
249+ if (case_number == 2 )
253250 {
251+ sent_msg.index (++samples_sent);
252+ eprosima::fastdds::rtps::WriteParams params_with_og_writer;
253+ eprosima::fastdds::rtps::GUID_t guid ({}, 0x12345678 );
254+ params_with_og_writer.original_writer_info ().original_writer_guid (guid);
255+ ASSERT_EQ (publisher.publish_with_params (sent_msg, params_with_og_writer), eprosima::fastdds::dds::RETCODE_OK);
256+ // Waiting for the message to be received
257+ while (samples_received.load () < 1 )
258+ {
259+ }
260+ ASSERT_EQ (subscriber.original_writer_guid (), guid);
254261 }
255- ASSERT_EQ (subscriber.original_writer_guid (), guid);
256262
257263 // CASE 3: Send message with original_writer_param set to unknown, should be set to other value
258- sent_msg.index (++samples_sent);
259- eprosima::fastdds::rtps::WriteParams params;
260- params.original_writer_info (eprosima::fastdds::rtps::OriginalWriterInfo::unknown ());
261- ASSERT_EQ (publisher.publish_with_params (sent_msg, params), eprosima::fastdds::dds::RETCODE_OK);
262- // Waiting for the message to be received
263- while (samples_received.load () < 3 )
264+ if (case_number == 3 )
264265 {
266+ sent_msg.index (++samples_sent);
267+ eprosima::fastdds::rtps::WriteParams params;
268+ params.original_writer_info (eprosima::fastdds::rtps::OriginalWriterInfo::unknown ());
269+ ASSERT_EQ (publisher.publish_with_params (sent_msg, params), eprosima::fastdds::dds::RETCODE_OK);
270+ // Waiting for the message to be received
271+ while (samples_received.load () < 1 )
272+ {
273+ }
274+ ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
265275 }
266- ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
267276
268277 router.stop ();
269278}
@@ -391,7 +400,11 @@ TEST(DDSTestLocal, end_to_end_local_communication_transient_local_disable_dynami
391400TEST (DDSTestLocal, end_to_end_local_communication_original_writer_forwarding)
392401{
393402 test::test_original_writer_forwarding<HelloWorld, HelloWorldPubSubType>(
394- test::dds_test_simple_configuration ());
403+ test::dds_test_simple_configuration (), 1 );
404+ test::test_original_writer_forwarding<HelloWorld, HelloWorldPubSubType>(
405+ test::dds_test_simple_configuration (), 2 );
406+ test::test_original_writer_forwarding<HelloWorld, HelloWorldPubSubType>(
407+ test::dds_test_simple_configuration (), 3 );
395408}
396409
397410int main (
0 commit comments