From 0aa5a73fedda1463710653dcbc22af1af470613b Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Fri, 17 May 2024 13:55:36 +0200 Subject: [PATCH 1/2] Set DataSharing in Writer|ReaderProxyData (#4761) * Refs #20933: Set datasharing on when pid is found Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20933: Set datasharing off after the clear Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20933: Add tests Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20933: Fix other_vendor_parameter_list_with_custom_pids test Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20933: Change implementation to fix failing tests Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20933: Apply suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --------- Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> (cherry picked from commit 904c5230296cb64821b982419a870724b2ba12e8) --- .../core/policy/QosPoliciesSerializer.hpp | 2 +- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 2 + src/cpp/rtps/builtin/data/WriterProxyData.cpp | 1 + .../builtin/BuiltinDataSerializationTests.cpp | 80 +++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp index f068979c50a..3c7830c253b 100644 --- a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp +++ b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp @@ -855,7 +855,7 @@ inline bool QosPoliciesSerializer::read_content_from_cdr_m uint32_t pos_ref = cdr_message->pos; // If the parameter is sent, the remote endpoint is datasharing compatible - qos_policy.automatic(); + qos_policy.on("."); uint32_t num_domains = 0; bool valid = fastrtps::rtps::CDRMessage::readUInt32(cdr_message, &num_domains); diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index 896e2a875f8..097e152b670 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -994,6 +994,7 @@ bool ReaderProxyData::readFromCDRMessage( "Received with error."); return false; } + break; } @@ -1008,6 +1009,7 @@ bool ReaderProxyData::readFromCDRMessage( uint32_t qos_size; clear(); + m_qos.data_sharing.off(); try { if (ParameterList::readParameterListfromCDRMsg(*msg, param_process, true, qos_size)) diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index ebef33e3cd1..edb7f6e7ba1 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -986,6 +986,7 @@ bool WriterProxyData::readFromCDRMessage( uint32_t qos_size; clear(); + m_qos.data_sharing.off(); try { if (ParameterList::readParameterListfromCDRMsg(*msg, param_process, true, qos_size)) diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 930dbe2d03b..1654a6d8918 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -129,6 +129,86 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) } } +TEST(BuiltinDataSerializationTests, msg_without_datasharing) +{ + { + uint8_t data_r_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00 + }; + + CDRMessage_t msg(0); + msg.init(data_r_buffer, static_cast(sizeof(data_r_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), OFF); + } + + { + uint8_t data_w_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00 + + }; + + CDRMessage_t msg(0); + msg.init(data_w_buffer, static_cast(sizeof(data_w_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), OFF); + } +} + +TEST(BuiltinDataSerializationTests, msg_with_datasharing) +{ + { + uint8_t data_r_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00, + //Data Sharing + 0x06, 0x80, 0x0c, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x9b, 0xf9, 0xbe, 0x1c, 0xb8 + + }; + + CDRMessage_t msg(0); + msg.init(data_r_buffer, static_cast(sizeof(data_r_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), ON); + } + + { + uint8_t data_w_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00, + //Data Sharing + 0x06, 0x80, 0x0c, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x9b, 0xf9, 0xbe, 0x1c, 0xb8 + + }; + + CDRMessage_t msg(0); + msg.init(data_w_buffer, static_cast(sizeof(data_w_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), ON); + } +} + + // Regression test for redmine issue #10547 TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) { From fd19f4435181001ddd0edc1413efc9814b4a161b Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:10:32 +0200 Subject: [PATCH 2/2] Refs #20933: Applu suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- .../rtps/builtin/BuiltinDataSerializationTests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 1654a6d8918..22533b8cd24 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -143,7 +143,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, false); ASSERT_EQ(out.m_qos.data_sharing.kind(), OFF); } @@ -160,7 +160,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, false); ASSERT_EQ(out.m_qos.data_sharing.kind(), OFF); } } @@ -183,7 +183,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, false); ASSERT_EQ(out.m_qos.data_sharing.kind(), ON); } @@ -203,7 +203,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, false); ASSERT_EQ(out.m_qos.data_sharing.kind(), ON); } }