From 5ca4a1815a72b9aeebcd30f4da295072b7decddf Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Fri, 10 May 2024 09:14:48 +0200 Subject: [PATCH] Refs #20933: Add tests Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- .../builtin/BuiltinDataSerializationTests.cpp | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 76cd708b1bc..1c05bde657b 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -140,6 +140,90 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) } } +TEST(BuiltinDataSerializationTests, msg_without_datasharing) +{ + { + // This was captured with wireshark from OpenDDS iShapes 3.16 + 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); + } + + { + // This was captured with wireshark from OpenDDS iShapes 3.16 + 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) +{ + { + // This was captured with wireshark from OpenDDS iShapes 3.16 + 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); + } + + { + // This was captured with wireshark from OpenDDS iShapes 3.16 + 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. // Update against OpenDDS 3.27. With this version we can read the remote DATA(w). TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27)