Skip to content

Commit 0a01cb6

Browse files
committed
Refs #23183: Tests
Signed-off-by: cferreiragonz <[email protected]>
1 parent 2d6a707 commit 0a01cb6

File tree

1 file changed

+283
-0
lines changed

1 file changed

+283
-0
lines changed

test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp

Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,181 @@ TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds)
21862186
}
21872187
}
21882188

2189+
/*!
2190+
* This test checks that Fast DDS can properly serialize ResourceLimitsQos in DATA(w) when it has more fields than
2191+
* max_samples, max_instances and max_samples_per_instance. It also checks that those fields are not serialized
2192+
* into the allocated_samples and extra samples fields.
2193+
*/
2194+
TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds_writer_resource_limits)
2195+
{
2196+
const VendorId_t intercom_vendor_id = { 1, 5 };
2197+
// DATA(w)
2198+
{
2199+
// This was captured with wireshark from intercom_dds-3.16.2.0_shape_main_linux taken from
2200+
// https://github.com/omg-dds/dds-rtps/releases/tag/v1.2.2024
2201+
octet data_w_buffer[] =
2202+
{
2203+
// Encapsulation
2204+
0x00, 0x03, 0x00, 0x00,
2205+
// Writer GUID
2206+
0x5a, 0x00, 0x10, 0x00,
2207+
0x01, 0x05, 0xfa, 0xd5, 0x7a, 0x09, 0x6a, 0x22, 0x84, 0xfb, 0x23, 0xa2, 0x00, 0x00, 0x01, 0x02,
2208+
// Participant GUID
2209+
0x50, 0x00, 0x10, 0x00,
2210+
0x01, 0x05, 0xfa, 0xd5, 0x7a, 0x09, 0x6a, 0x22, 0x84, 0xfb, 0x23, 0xa2, 0x00, 0x00, 0x01, 0xc1,
2211+
// Topic name
2212+
0x05, 0x00, 0x0c, 0x00,
2213+
0x07, 0x00, 0x00, 0x00, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x00, 0x00,
2214+
// Type name
2215+
0x07, 0x00, 0x10, 0x00,
2216+
0x0a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x70, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00,
2217+
// Type information
2218+
0x75, 0x00, 0x5c, 0x00,
2219+
0x58, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
2220+
0xf1, 0xa5, 0x12, 0xf3, 0x95, 0xe2, 0xba, 0xb0, 0xb9, 0xfc, 0x83, 0x8e, 0x08, 0x6e, 0x2c, 0x00,
2221+
0x57, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2222+
0x02, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x77, 0x32, 0x07,
2223+
0xfb, 0x72, 0x38, 0x6e, 0x0d, 0xdb, 0x0e, 0x1a, 0x2b, 0x4f, 0xbe, 0x00, 0x84, 0x00, 0x00, 0x00,
2224+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2225+
// Topic data
2226+
0x2e, 0x00, 0x04, 0x00,
2227+
0x00, 0x00, 0x00, 0x00,
2228+
// Data representation
2229+
0x73, 0x00, 0x08, 0x00,
2230+
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2231+
// Property list
2232+
0x59, 0x00, 0x08, 0x00,
2233+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2234+
// Data tags
2235+
0x03, 0x10, 0x04, 0x00,
2236+
0x00, 0x00, 0x00, 0x00,
2237+
// Service instance name
2238+
0x80, 0x00, 0x04, 0x00,
2239+
0x00, 0x00, 0x00, 0x00,
2240+
// Related entity GUID
2241+
0x81, 0x00, 0x10, 0x00,
2242+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2243+
// History
2244+
0x40, 0x00, 0x08, 0x00,
2245+
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2246+
// Resource limits
2247+
0x41, 0x00, 0x14, 0x00,
2248+
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2249+
0x05, 0x00, 0x00, 0x00,
2250+
// Custom (0x8030)
2251+
0x30, 0x80, 0x04, 0x00,
2252+
0x00, 0x00, 0x00, 0x00,
2253+
// Sentinel
2254+
0x01, 0x00, 0x00, 0x00
2255+
};
2256+
2257+
CDRMessage_t msg(0);
2258+
msg.init(data_w_buffer, static_cast<uint32_t>(sizeof(data_w_buffer)));
2259+
msg.length = msg.max_size;
2260+
2261+
WriterProxyData wpd(max_unicast_locators, max_multicast_locators);
2262+
EXPECT_NO_THROW(EXPECT_TRUE(wpd.read_from_cdr_message(&msg, intercom_vendor_id)));
2263+
2264+
ASSERT_TRUE(wpd.resource_limits);
2265+
ASSERT_EQ(wpd.resource_limits->max_samples, 1);
2266+
ASSERT_EQ(wpd.resource_limits->max_instances, 2);
2267+
ASSERT_EQ(wpd.resource_limits->max_samples_per_instance, 3);
2268+
// Allocated samples and extra samples should have default values as they should not be read because
2269+
// they come from another vendor
2270+
ASSERT_EQ(wpd.resource_limits->allocated_samples, 100);
2271+
ASSERT_EQ(wpd.resource_limits->extra_samples, 1);
2272+
}
2273+
}
2274+
2275+
/*!
2276+
* This test checks that Fast DDS can properly serialize ResourceLimitsQos in DATA(r) when it has more fields than
2277+
* max_samples, max_instances and max_samples_per_instance. It also checks that those fields are not serialized
2278+
* into the allocated_samples and extra samples fields.
2279+
*/
2280+
TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds_reader_resource_limits)
2281+
{
2282+
const VendorId_t intercom_vendor_id = { 1, 5 };
2283+
// DATA(r)
2284+
{
2285+
// This was captured with wireshark from intercom_dds-3.16.2.0_shape_main_linux taken from
2286+
// https://github.com/omg-dds/dds-rtps/releases/tag/v1.2.2024
2287+
uint8_t data_r_buffer[] =
2288+
{
2289+
// Encapsulation
2290+
0x00, 0x03, 0x00, 0x00,
2291+
// Reader GUID
2292+
0x5a, 0x00, 0x10, 0x00,
2293+
0x01, 0x05, 0x0f, 0xda, 0x14, 0xdd, 0x32, 0x62, 0x74, 0xef, 0x08, 0xeb, 0x00, 0x00, 0x01, 0x07,
2294+
// Participant GUID
2295+
0x50, 0x00, 0x10, 0x00,
2296+
0x01, 0x05, 0x0f, 0xda, 0x14, 0xdd, 0x32, 0x62, 0x74, 0xef, 0x08, 0xeb, 0x00, 0x00, 0x01, 0xc1,
2297+
// Topic name
2298+
0x05, 0x00, 0x0c, 0x00,
2299+
0x07, 0x00, 0x00, 0x00, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x00, 0x00,
2300+
// Type name
2301+
0x07, 0x00, 0x10, 0x00,
2302+
0x0a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x70, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00,
2303+
// Type information
2304+
0x75, 0x00, 0x5c, 0x00,
2305+
0x58, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
2306+
0xf1, 0xa5, 0x12, 0xf3, 0x95, 0xe2, 0xba, 0xb0, 0xb9, 0xfc, 0x83, 0x8e, 0x08, 0x6e, 0x2c, 0x00,
2307+
0x57, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2308+
0x02, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x77, 0x32, 0x07,
2309+
0xfb, 0x72, 0x38, 0x6e, 0x0d, 0xdb, 0x0e, 0x1a, 0x2b, 0x4f, 0xbe, 0x00, 0x84, 0x00, 0x00, 0x00,
2310+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2311+
// Reliability
2312+
0x1a, 0x00, 0x10, 0x00,
2313+
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0x99, 0x99, 0x19, 0x00, 0x00, 0x00, 0x00,
2314+
// Topic data
2315+
0x2e, 0x00, 0x04, 0x00,
2316+
0x00, 0x00, 0x00, 0x00,
2317+
// Data representation
2318+
0x73, 0x00, 0x08, 0x00,
2319+
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2320+
// Type consistency
2321+
0x74, 0x00, 0x08, 0x00,
2322+
0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
2323+
// Property list
2324+
0x59, 0x00, 0x08, 0x00,
2325+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2326+
// Data tags
2327+
0x03, 0x10, 0x04, 0x00,
2328+
0x00, 0x00, 0x00, 0x00,
2329+
// Service instance name
2330+
0x80, 0x00, 0x04, 0x00,
2331+
0x00, 0x00, 0x00, 0x00,
2332+
// Related entity GUID
2333+
0x81, 0x00, 0x10, 0x00,
2334+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2335+
// History
2336+
0x40, 0x00, 0x08, 0x00,
2337+
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2338+
// Resource limits
2339+
0x41, 0x00, 0x14, 0x00,
2340+
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2341+
0x05, 0x00, 0x00, 0x00,
2342+
// Sentinel
2343+
0x01, 0x00, 0x00, 0x00
2344+
};
2345+
2346+
CDRMessage_t msg(0);
2347+
msg.init(data_r_buffer, static_cast<uint32_t>(sizeof(data_r_buffer)));
2348+
msg.length = msg.max_size;
2349+
2350+
ReaderProxyData rpd(max_unicast_locators, max_multicast_locators);
2351+
EXPECT_NO_THROW(EXPECT_TRUE(rpd.read_from_cdr_message(&msg, intercom_vendor_id)));
2352+
2353+
ASSERT_TRUE(rpd.resource_limits);
2354+
ASSERT_EQ(rpd.resource_limits->max_samples, 1);
2355+
ASSERT_EQ(rpd.resource_limits->max_instances, 2);
2356+
ASSERT_EQ(rpd.resource_limits->max_samples_per_instance, 3);
2357+
// Allocated samples and extra samples should have default values as they should not be read because
2358+
// they come from another vendor
2359+
ASSERT_EQ(rpd.resource_limits->allocated_samples, 100);
2360+
ASSERT_EQ(rpd.resource_limits->extra_samples, 1);
2361+
}
2362+
}
2363+
21892364
/*!
21902365
* This is a regression test for redmine issue #21537
21912366
*
@@ -2654,6 +2829,60 @@ TEST(BuiltinDataSerializationTests, optional_qos_extensions_reader)
26542829
ASSERT_EQ(rpd.reader_resource_limits->max_samples_per_read, 16);
26552830
}
26562831

2832+
/*!
2833+
* This test checks that a correct ReaderProxyData is obtained when sending only max_samples, max_instances
2834+
* and max_samples_per_instance in the ResourceLimits QoS policy
2835+
*/
2836+
TEST(BuiltinDataSerializationTests, optional_qos_extensions_reader_resource_limits)
2837+
{
2838+
// DATA(r)
2839+
uint8_t data_r_buffer[] =
2840+
{
2841+
// Encapsulation
2842+
0x00, 0x03, 0x00, 0x00,
2843+
// Reader GUID
2844+
0x5a, 0x00, 0x10, 0x00,
2845+
0x01, 0x05, 0x0f, 0xda, 0x14, 0xdd, 0x32, 0x62, 0x74, 0xef, 0x08, 0xeb, 0x00, 0x00, 0x01, 0x07,
2846+
// Participant GUID
2847+
0x50, 0x00, 0x10, 0x00,
2848+
0x01, 0x05, 0x0f, 0xda, 0x14, 0xdd, 0x32, 0x62, 0x74, 0xef, 0x08, 0xeb, 0x00, 0x00, 0x01, 0xc1,
2849+
// Topic name
2850+
0x05, 0x00, 0x0c, 0x00,
2851+
0x07, 0x00, 0x00, 0x00, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x00, 0x00,
2852+
// Type name
2853+
0x07, 0x00, 0x10, 0x00,
2854+
0x0a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x70, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00,
2855+
// Type information
2856+
0x75, 0x00, 0x5c, 0x00,
2857+
0x58, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
2858+
0xf1, 0xa5, 0x12, 0xf3, 0x95, 0xe2, 0xba, 0xb0, 0xb9, 0xfc, 0x83, 0x8e, 0x08, 0x6e, 0x2c, 0x00,
2859+
0x57, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2860+
0x02, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x77, 0x32, 0x07,
2861+
0xfb, 0x72, 0x38, 0x6e, 0x0d, 0xdb, 0x0e, 0x1a, 0x2b, 0x4f, 0xbe, 0x00, 0x84, 0x00, 0x00, 0x00,
2862+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2863+
// Resource limits (without allocated samples nor extra samples)
2864+
0x41, 0x00, 0x0c, 0x00,
2865+
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2866+
// Sentinel
2867+
0x01, 0x00, 0x00, 0x00
2868+
};
2869+
2870+
CDRMessage_t msg(0);
2871+
msg.init(data_r_buffer, static_cast<uint32_t>(sizeof(data_r_buffer)));
2872+
msg.length = msg.max_size;
2873+
2874+
ReaderProxyData rpd(max_unicast_locators, max_multicast_locators);
2875+
EXPECT_NO_THROW(EXPECT_TRUE(rpd.read_from_cdr_message(&msg, c_VendorId_eProsima)));
2876+
2877+
ASSERT_TRUE(rpd.resource_limits);
2878+
ASSERT_EQ(rpd.resource_limits->max_samples, 1);
2879+
ASSERT_EQ(rpd.resource_limits->max_instances, 2);
2880+
ASSERT_EQ(rpd.resource_limits->max_samples_per_instance, 3);
2881+
// Allocated samples and extra samples should have default values as they are not present in the data
2882+
ASSERT_EQ(rpd.resource_limits->allocated_samples, 100);
2883+
ASSERT_EQ(rpd.resource_limits->extra_samples, 1);
2884+
}
2885+
26572886
/*!
26582887
* This test checks that a correct WriterProxyData is obtained
26592888
* from eProsima's optional qos extensions in PublicationBuiltinTopicData
@@ -2773,6 +3002,60 @@ TEST(BuiltinDataSerializationTests, optional_qos_extensions_writer)
27733002
ASSERT_EQ(wpd.writer_resource_limits->reader_filters_allocation.increment, 6u);
27743003
}
27753004

3005+
/*!
3006+
* This test checks that a correct WriterProxyData is obtained when sending only max_samples, max_instances
3007+
* and max_samples_per_instance in the ResourceLimits QoS policy
3008+
*/
3009+
TEST(BuiltinDataSerializationTests, optional_qos_extensions_writer_resource_limits)
3010+
{
3011+
// DATA(w)
3012+
octet data_w_buffer[] =
3013+
{
3014+
// Encapsulation
3015+
0x00, 0x03, 0x00, 0x00,
3016+
// Writer GUID
3017+
0x5a, 0x00, 0x10, 0x00,
3018+
0x01, 0x05, 0xfa, 0xd5, 0x7a, 0x09, 0x6a, 0x22, 0x84, 0xfb, 0x23, 0xa2, 0x00, 0x00, 0x01, 0x02,
3019+
// Participant GUID
3020+
0x50, 0x00, 0x10, 0x00,
3021+
0x01, 0x05, 0xfa, 0xd5, 0x7a, 0x09, 0x6a, 0x22, 0x84, 0xfb, 0x23, 0xa2, 0x00, 0x00, 0x01, 0xc1,
3022+
// Topic name
3023+
0x05, 0x00, 0x0c, 0x00,
3024+
0x07, 0x00, 0x00, 0x00, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x00, 0x00,
3025+
// Type name
3026+
0x07, 0x00, 0x10, 0x00,
3027+
0x0a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x70, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00,
3028+
// Type information
3029+
0x75, 0x00, 0x5c, 0x00,
3030+
0x58, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
3031+
0xf1, 0xa5, 0x12, 0xf3, 0x95, 0xe2, 0xba, 0xb0, 0xb9, 0xfc, 0x83, 0x8e, 0x08, 0x6e, 0x2c, 0x00,
3032+
0x57, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3033+
0x02, 0x10, 0x00, 0x50, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x77, 0x32, 0x07,
3034+
0xfb, 0x72, 0x38, 0x6e, 0x0d, 0xdb, 0x0e, 0x1a, 0x2b, 0x4f, 0xbe, 0x00, 0x84, 0x00, 0x00, 0x00,
3035+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3036+
// Resource limits (without allocated samples nor extra samples)
3037+
0x41, 0x00, 0x0c, 0x00,
3038+
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3039+
// Sentinel
3040+
0x01, 0x00, 0x00, 0x00
3041+
};
3042+
3043+
CDRMessage_t msg(0);
3044+
msg.init(data_w_buffer, static_cast<uint32_t>(sizeof(data_w_buffer)));
3045+
msg.length = msg.max_size;
3046+
3047+
WriterProxyData wpd(max_unicast_locators, max_multicast_locators);
3048+
EXPECT_NO_THROW(EXPECT_TRUE(wpd.read_from_cdr_message(&msg, c_VendorId_eProsima)));
3049+
3050+
ASSERT_TRUE(wpd.resource_limits);
3051+
ASSERT_EQ(wpd.resource_limits->max_samples, 1);
3052+
ASSERT_EQ(wpd.resource_limits->max_instances, 2);
3053+
ASSERT_EQ(wpd.resource_limits->max_samples_per_instance, 3);
3054+
// Allocated samples and extra samples should have default values as they are not present in the data
3055+
ASSERT_EQ(wpd.resource_limits->allocated_samples, 100);
3056+
ASSERT_EQ(wpd.resource_limits->extra_samples, 1);
3057+
}
3058+
27763059
/**
27773060
* This test checks that a correct serialization is obtained
27783061
* when non-default eProsima's optional qos extensions are used in ReaderProxyData.

0 commit comments

Comments
 (0)