Skip to content

Commit 55cf7b2

Browse files
mergify[bot]Mario-DLMiguelCompany
authored
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 <[email protected]> * Refs #22657: Fix Signed-off-by: Mario Domínguez López <[email protected]> * Refs #22657: Make test available in all platforms Signed-off-by: Mario Dominguez <[email protected]> * Refs #22657: Apply missing Miguels suggestion Signed-off-by: Mario Dominguez <[email protected]> --------- Signed-off-by: Mario Domínguez López <[email protected]> Signed-off-by: Mario Dominguez <[email protected]> (cherry picked from commit a59d32f) # Conflicts: # src/cpp/rtps/RTPSDomain.cpp * Fix conflicts Signed-off-by: Miguel Company <[email protected]> --------- Signed-off-by: Miguel Company <[email protected]> Co-authored-by: Mario Domínguez López <[email protected]> Co-authored-by: Miguel Company <[email protected]>
1 parent 00586a2 commit 55cf7b2

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

src/cpp/fastdds/domain/DomainParticipantFactory.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml(
363363
{
364364
if (profile_name.empty())
365365
{
366-
EPROSIMA_LOG_ERROR(DOMAIN, "Provided profile name must be non-empty");
366+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Provided profile name must be non-empty");
367367
return RETCODE_BAD_PARAMETER;
368368
}
369369

@@ -430,7 +430,7 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml(
430430
{
431431
if (profile_name.empty())
432432
{
433-
EPROSIMA_LOG_ERROR(DOMAIN, "Provided profile name must be non-empty");
433+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Provided profile name must be non-empty");
434434
return RETCODE_BAD_PARAMETER;
435435
}
436436

@@ -511,7 +511,7 @@ ReturnCode_t DomainParticipantFactory::load_XML_profiles_file(
511511
{
512512
if (XMLP_ret::XML_ERROR == XMLProfileManager::loadXMLFile(xml_profile_file))
513513
{
514-
EPROSIMA_LOG_ERROR(DOMAIN, "Problem loading XML file '" << xml_profile_file << "'");
514+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Problem loading XML file '" << xml_profile_file << "'");
515515
return RETCODE_ERROR;
516516
}
517517
return RETCODE_OK;
@@ -523,7 +523,7 @@ ReturnCode_t DomainParticipantFactory::load_XML_profiles_string(
523523
{
524524
if (XMLP_ret::XML_ERROR == XMLProfileManager::loadXMLString(data, length))
525525
{
526-
EPROSIMA_LOG_ERROR(DOMAIN, "Problem loading XML string");
526+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Problem loading XML string");
527527
return RETCODE_ERROR;
528528
}
529529
return RETCODE_OK;
@@ -535,7 +535,7 @@ ReturnCode_t DomainParticipantFactory::check_xml_static_discovery(
535535
xmlparser::XMLEndpointParser parser;
536536
if (XMLP_ret::XML_OK != parser.loadXMLFile(xml_file))
537537
{
538-
EPROSIMA_LOG_ERROR(DOMAIN, "Error parsing xml file");
538+
EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Error parsing xml file");
539539
return RETCODE_ERROR;
540540
}
541541
return RETCODE_OK;

src/cpp/rtps/RTPSDomain.cpp

+3-3
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

+40
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)