Skip to content

Commit d2c3c07

Browse files
committed
Fix log category name macro collision in MacOS (#5585) (#5595)
* Fix log category name macro collision in `MacOS` (#5585) * Refs #22657: BB test Signed-off-by: Mario Domínguez López <mariodominguez@eprosima.com> * Refs #22657: Fix Signed-off-by: Mario Domínguez López <mariodominguez@eprosima.com> * Refs #22657: Make test available in all platforms Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #22657: Apply missing Miguels suggestion Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> --------- Signed-off-by: Mario Domínguez López <mariodominguez@eprosima.com> Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> (cherry picked from commit a59d32f) # Conflicts: # src/cpp/rtps/RTPSDomain.cpp * Fix conflicts Signed-off-by: Miguel Company <miguelcompany@eprosima.com> --------- Signed-off-by: Miguel Company <miguelcompany@eprosima.com> Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com> Co-authored-by: Miguel Company <miguelcompany@eprosima.com> (cherry picked from commit 55cf7b2) # Conflicts: # src/cpp/fastdds/domain/DomainParticipantFactory.cpp
1 parent 1d15b46 commit d2c3c07

3 files changed

Lines changed: 157 additions & 6 deletions

File tree

‎src/cpp/fastdds/domain/DomainParticipantFactory.cpp‎

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,61 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_profile(
341341
return RETCODE_BAD_PARAMETER;
342342
}
343343

344+
<<<<<<< HEAD
345+
=======
346+
ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml(
347+
const std::string& xml,
348+
DomainParticipantQos& qos) const
349+
{
350+
ParticipantAttributes attr;
351+
if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, false))
352+
{
353+
qos = default_participant_qos_;
354+
utils::set_qos_from_attributes(qos, attr.rtps);
355+
return RETCODE_OK;
356+
}
357+
358+
return RETCODE_BAD_PARAMETER;
359+
}
360+
361+
ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml(
362+
const std::string& xml,
363+
DomainParticipantQos& qos,
364+
const std::string& profile_name) const
365+
{
366+
if (profile_name.empty())
367+
{
368+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Provided profile name must be non-empty");
369+
return RETCODE_BAD_PARAMETER;
370+
}
371+
372+
ParticipantAttributes attr;
373+
if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, true, profile_name))
374+
{
375+
qos = default_participant_qos_;
376+
utils::set_qos_from_attributes(qos, attr.rtps);
377+
return RETCODE_OK;
378+
}
379+
380+
return RETCODE_BAD_PARAMETER;
381+
}
382+
383+
ReturnCode_t DomainParticipantFactory::get_default_participant_qos_from_xml(
384+
const std::string& xml,
385+
DomainParticipantQos& qos) const
386+
{
387+
ParticipantAttributes attr;
388+
if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_participant_attributes_from_xml(xml, attr, true))
389+
{
390+
qos = default_participant_qos_;
391+
utils::set_qos_from_attributes(qos, attr.rtps);
392+
return RETCODE_OK;
393+
}
394+
395+
return RETCODE_BAD_PARAMETER;
396+
}
397+
398+
>>>>>>> 55cf7b2a (Fix log category name macro collision in `MacOS` (#5585) (#5595))
344399
ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile(
345400
const std::string& profile_name,
346401
DomainParticipantExtendedQos& extended_qos) const
@@ -349,6 +404,62 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile
349404
ParticipantAttributes attr;
350405
if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr, false))
351406
{
407+
<<<<<<< HEAD
408+
=======
409+
extended_qos = default_participant_qos_;
410+
utils::set_extended_qos_from_attributes(extended_qos, attr);
411+
return RETCODE_OK;
412+
}
413+
414+
return RETCODE_BAD_PARAMETER;
415+
}
416+
417+
ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml(
418+
const std::string& xml,
419+
DomainParticipantExtendedQos& extended_qos) const
420+
{
421+
ParticipantAttributes attr;
422+
if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, false))
423+
{
424+
extended_qos = default_participant_qos_;
425+
utils::set_extended_qos_from_attributes(extended_qos, attr);
426+
return RETCODE_OK;
427+
}
428+
429+
return RETCODE_BAD_PARAMETER;
430+
}
431+
432+
ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml(
433+
const std::string& xml,
434+
DomainParticipantExtendedQos& extended_qos,
435+
const std::string& profile_name) const
436+
{
437+
if (profile_name.empty())
438+
{
439+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Provided profile name must be non-empty");
440+
return RETCODE_BAD_PARAMETER;
441+
}
442+
443+
ParticipantAttributes attr;
444+
if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, true, profile_name))
445+
{
446+
extended_qos = default_participant_qos_;
447+
utils::set_extended_qos_from_attributes(extended_qos, attr);
448+
return RETCODE_OK;
449+
}
450+
451+
return RETCODE_BAD_PARAMETER;
452+
}
453+
454+
ReturnCode_t DomainParticipantFactory::get_default_participant_extended_qos_from_xml(
455+
const std::string& xml,
456+
DomainParticipantExtendedQos& extended_qos) const
457+
{
458+
ParticipantAttributes attr;
459+
if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_participant_attributes_from_xml(xml, attr, true))
460+
{
461+
extended_qos = default_participant_qos_;
462+
>>>>>>> 55cf7b2a (Fix log category name macro collision in `MacOS` (#5585) (#5595))
352463
utils::set_extended_qos_from_attributes(extended_qos, attr);
353464
return RETCODE_OK;
354465
}
@@ -407,7 +518,7 @@ ReturnCode_t DomainParticipantFactory::load_XML_profiles_file(
407518
{
408519
if (XMLP_ret::XML_ERROR == XMLProfileManager::loadXMLFile(xml_profile_file))
409520
{
410-
EPROSIMA_LOG_ERROR(DOMAIN, "Problem loading XML file '" << xml_profile_file << "'");
521+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Problem loading XML file '" << xml_profile_file << "'");
411522
return RETCODE_ERROR;
412523
}
413524
return RETCODE_OK;
@@ -419,7 +530,7 @@ ReturnCode_t DomainParticipantFactory::load_XML_profiles_string(
419530
{
420531
if (XMLP_ret::XML_ERROR == XMLProfileManager::loadXMLString(data, length))
421532
{
422-
EPROSIMA_LOG_ERROR(DOMAIN, "Problem loading XML string");
533+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Problem loading XML string");
423534
return RETCODE_ERROR;
424535
}
425536
return RETCODE_OK;
@@ -431,7 +542,7 @@ ReturnCode_t DomainParticipantFactory::check_xml_static_discovery(
431542
xmlparser::XMLEndpointParser parser;
432543
if (XMLP_ret::XML_OK != parser.loadXMLFile(xml_file))
433544
{
434-
EPROSIMA_LOG_ERROR(DOMAIN, "Error parsing xml file");
545+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Error parsing xml file");
435546
return RETCODE_ERROR;
436547
}
437548
return RETCODE_OK;

‎src/cpp/rtps/RTPSDomain.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride(
509509
// Check the specified discovery protocol: if other than simple it has priority over ros environment variable
510510
if (att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SIMPLE)
511511
{
512-
EPROSIMA_LOG_INFO(DOMAIN, "Detected non simple discovery protocol attributes."
512+
EPROSIMA_LOG_INFO(RTPS_DOMAIN, "Detected non simple discovery protocol attributes."
513513
<< " Ignoring auto default client-server setup.");
514514
return nullptr;
515515
}
@@ -577,13 +577,13 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride(
577577
if (nullptr != part)
578578
{
579579
// Client successfully created
580-
EPROSIMA_LOG_INFO(DOMAIN, "Auto default server-client setup. Default client created.");
580+
EPROSIMA_LOG_INFO(RTPS_DOMAIN, "Auto default server-client setup. Default client created.");
581581
part->mp_impl->client_override(true);
582582
return part;
583583
}
584584

585585
// Unable to create auto server-client default participants
586-
EPROSIMA_LOG_ERROR(DOMAIN, "Auto default server-client setup. Unable to create the client.");
586+
EPROSIMA_LOG_ERROR(RTPS_DOMAIN, "Auto default server-client setup. Unable to create the client.");
587587
return nullptr;
588588
}
589589

‎test/blackbox/common/DDSBlackboxTestsBasic.cpp‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,46 @@ TEST(DDSBasic, reliable_volatile_writer_secure_builtin_no_potential_deadlock)
10521052
writer.destroy();
10531053
}
10541054

1055+
TEST(DDSBasic, participant_factory_output_log_error_no_macro_collision)
1056+
{
1057+
using Log = eprosima::fastdds::dds::Log;
1058+
using LogConsumer = eprosima::fastdds::dds::LogConsumer;
1059+
1060+
// A LogConsumer that just counts the number of entries consumed
1061+
struct TestConsumer : public LogConsumer
1062+
{
1063+
TestConsumer(
1064+
std::atomic_size_t& n_logs_ref)
1065+
: n_logs_(n_logs_ref)
1066+
{
1067+
}
1068+
1069+
void Consume(
1070+
const Log::Entry&) override
1071+
{
1072+
++n_logs_;
1073+
}
1074+
1075+
private:
1076+
1077+
std::atomic_size_t& n_logs_;
1078+
};
1079+
1080+
// Counter for log entries
1081+
std::atomic<size_t>n_logs{};
1082+
1083+
// Prepare Log module to check that no SECURITY errors are produced
1084+
Log::SetCategoryFilter(std::regex("DOMAIN"));
1085+
Log::SetVerbosity(Log::Kind::Error);
1086+
Log::RegisterConsumer(std::unique_ptr<LogConsumer>(new TestConsumer(n_logs)));
1087+
1088+
auto dpf = DomainParticipantFactory::get_shared_instance();
1089+
DomainParticipantQos qos;
1090+
dpf->get_participant_qos_from_xml("", qos, "");
1091+
Log::Flush();
1092+
ASSERT_GE(n_logs.load(), 1u);
1093+
}
1094+
10551095
} // namespace dds
10561096
} // namespace fastdds
10571097
} // namespace eprosima

0 commit comments

Comments
 (0)