@@ -361,3 +361,78 @@ TEST(DSEasyMode, easy_discovery_mode_env_inconsistent_ip)
361
361
stop_background_servers ();
362
362
#endif // _WIN32
363
363
}
364
+
365
+ /* *
366
+ * Check that the environment variable ROS2_EASY_MODE is ignored if
367
+ * it does not have a valid IPv4 format.
368
+ */
369
+ TEST (DSEasyMode, easy_discovery_mode_env_invalid)
370
+ {
371
+ #ifndef _WIN32 // The feature is not supported on Windows yet
372
+ PubSubWriter<HelloWorldPubSubType> writer (TEST_TOPIC_NAME);
373
+ PubSubReader<HelloWorldPubSubType> reader (TEST_TOPIC_NAME);
374
+
375
+ // Set ROS2_EASY_MODE to an invalid string value
376
+ set_easy_discovery_mode_env (" Foo" );
377
+
378
+ std::atomic<bool > writer_background_ds_discovered (false );
379
+ std::atomic<bool > reader_background_ds_discovered (false );
380
+
381
+ writer.set_on_discovery_function (
382
+ [&writer_background_ds_discovered](
383
+ const eprosima::fastdds::rtps::ParticipantBuiltinTopicData& data,
384
+ eprosima::fastdds::rtps::ParticipantDiscoveryStatus)
385
+ {
386
+ if (data.participant_name == " DiscoveryServerAuto" )
387
+ {
388
+ writer_background_ds_discovered.store (true );
389
+ }
390
+ return true ;
391
+ });
392
+ writer.init ();
393
+
394
+ reader.set_on_discovery_function (
395
+ [&reader_background_ds_discovered](const eprosima::fastdds::rtps::ParticipantBuiltinTopicData& data,
396
+ eprosima::fastdds::rtps::ParticipantDiscoveryStatus)
397
+ {
398
+ if (data.participant_name == " DiscoveryServerAuto" )
399
+ {
400
+ reader_background_ds_discovered.store (true );
401
+ }
402
+ return true ;
403
+ });
404
+ reader.init ();
405
+
406
+ ASSERT_TRUE (writer.isInitialized ());
407
+ ASSERT_TRUE (reader.isInitialized ());
408
+
409
+ // Wait for endpoint discovery first
410
+ writer.wait_discovery ();
411
+ reader.wait_discovery ();
412
+
413
+ // Check that no Background DS was discovered,
414
+ // only the other reader or writer
415
+ ASSERT_GE (writer.get_participants_matched (), 1u );
416
+ ASSERT_GE (reader.get_participants_matched (), 1u );
417
+ ASSERT_FALSE (writer_background_ds_discovered.load ());
418
+ ASSERT_FALSE (reader_background_ds_discovered.load ());
419
+ #endif // _WIN32
420
+ }
421
+
422
+ /* *
423
+ * Check that easy mode configuration is ignored when setting it
424
+ * with code using WireProtocolConfigQos.
425
+ *
426
+ * Note: This test only checks that the configuration is ignored.
427
+ * Probably it should be extended similarly to easy_discovery_mode_env_invalid
428
+ * when Configuring Easy Mode via c++ and XML is implemented.
429
+ */
430
+ TEST (DSEasyMode, wire_protocol_qos_params_invalid)
431
+ {
432
+ eprosima::fastdds::dds::WireProtocolConfigQos wire_protocol_qos;
433
+
434
+ // Try to set easy mode IP using an invalid IP address
435
+ wire_protocol_qos.easy_mode (" Foo" );
436
+
437
+ ASSERT_TRUE (wire_protocol_qos.easy_mode ().empty ());
438
+ }
0 commit comments