From a59d32fca3788dc80471b677f9128c7491dae9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Dom=C3=ADnguez=20L=C3=B3pez?= <116071334+Mario-DL@users.noreply.github.com> Date: Fri, 24 Jan 2025 08:28:30 +0100 Subject: [PATCH] Fix log category name macro collision in `MacOS` (#5585) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #22657: BB test Signed-off-by: Mario Domínguez López * Refs #22657: Fix Signed-off-by: Mario Domínguez López * Refs #22657: Make test available in all platforms Signed-off-by: Mario Dominguez * Refs #22657: Apply missing Miguels suggestion Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Domínguez López Signed-off-by: Mario Dominguez --- .../domain/DomainParticipantFactory.cpp | 10 ++--- src/cpp/rtps/RTPSDomain.cpp | 8 ++-- .../blackbox/common/DDSBlackboxTestsBasic.cpp | 40 +++++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index a1000e7db93..e58a51d73bb 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -363,7 +363,7 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml( { if (profile_name.empty()) { - EPROSIMA_LOG_ERROR(DOMAIN, "Provided profile name must be non-empty"); + EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Provided profile name must be non-empty"); return RETCODE_BAD_PARAMETER; } @@ -430,7 +430,7 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml( { if (profile_name.empty()) { - EPROSIMA_LOG_ERROR(DOMAIN, "Provided profile name must be non-empty"); + EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Provided profile name must be non-empty"); return RETCODE_BAD_PARAMETER; } @@ -511,7 +511,7 @@ ReturnCode_t DomainParticipantFactory::load_XML_profiles_file( { if (XMLP_ret::XML_ERROR == XMLProfileManager::loadXMLFile(xml_profile_file)) { - EPROSIMA_LOG_ERROR(DOMAIN, "Problem loading XML file '" << xml_profile_file << "'"); + EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Problem loading XML file '" << xml_profile_file << "'"); return RETCODE_ERROR; } return RETCODE_OK; @@ -523,7 +523,7 @@ ReturnCode_t DomainParticipantFactory::load_XML_profiles_string( { if (XMLP_ret::XML_ERROR == XMLProfileManager::loadXMLString(data, length)) { - EPROSIMA_LOG_ERROR(DOMAIN, "Problem loading XML string"); + EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Problem loading XML string"); return RETCODE_ERROR; } return RETCODE_OK; @@ -535,7 +535,7 @@ ReturnCode_t DomainParticipantFactory::check_xml_static_discovery( xmlparser::XMLEndpointParser parser; if (XMLP_ret::XML_OK != parser.loadXMLFile(xml_file)) { - EPROSIMA_LOG_ERROR(DOMAIN, "Error parsing xml file"); + EPROSIMA_LOG_ERROR(DDS_DOMAIN, "Error parsing xml file"); return RETCODE_ERROR; } return RETCODE_OK; diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 0e04082d7f1..36dd3d8ecb3 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -510,7 +510,7 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride( // Check the specified discovery protocol: if other than simple it has priority over ros environment variable if (att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SIMPLE) { - EPROSIMA_LOG_INFO(DOMAIN, "Detected non simple discovery protocol attributes." + EPROSIMA_LOG_INFO(RTPS_DOMAIN, "Detected non simple discovery protocol attributes." << " Ignoring auto default client-server setup."); return nullptr; } @@ -566,7 +566,7 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride( client_att.userTransports.push_back(std::move(descriptor)); } - EPROSIMA_LOG_INFO(DOMAIN, "Detected auto client-server environment variable." + EPROSIMA_LOG_INFO(RTPS_DOMAIN, "Detected auto client-server environment variable." << "Trying to create client with the default server setup: " << client_att.builtin.discovery_config.m_DiscoveryServers); @@ -647,13 +647,13 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride( if (nullptr != part) { // Client successfully created - EPROSIMA_LOG_INFO(DOMAIN, "Auto default server-client setup. Default client created."); + EPROSIMA_LOG_INFO(RTPS_DOMAIN, "Auto default server-client setup. Default client created."); part->mp_impl->client_override(true); return part; } // Unable to create auto server-client default participants - EPROSIMA_LOG_ERROR(DOMAIN, "Auto default server-client setup. Unable to create the client."); + EPROSIMA_LOG_ERROR(RTPS_DOMAIN, "Auto default server-client setup. Unable to create the client."); return nullptr; } diff --git a/test/blackbox/common/DDSBlackboxTestsBasic.cpp b/test/blackbox/common/DDSBlackboxTestsBasic.cpp index 540281d62d5..24c9b8722ff 100644 --- a/test/blackbox/common/DDSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/DDSBlackboxTestsBasic.cpp @@ -1052,6 +1052,46 @@ TEST(DDSBasic, reliable_volatile_writer_secure_builtin_no_potential_deadlock) writer.destroy(); } +TEST(DDSBasic, participant_factory_output_log_error_no_macro_collision) +{ + using Log = eprosima::fastdds::dds::Log; + using LogConsumer = eprosima::fastdds::dds::LogConsumer; + + // A LogConsumer that just counts the number of entries consumed + struct TestConsumer : public LogConsumer + { + TestConsumer( + std::atomic_size_t& n_logs_ref) + : n_logs_(n_logs_ref) + { + } + + void Consume( + const Log::Entry&) override + { + ++n_logs_; + } + + private: + + std::atomic_size_t& n_logs_; + }; + + // Counter for log entries + std::atomicn_logs{}; + + // Prepare Log module to check that no SECURITY errors are produced + Log::SetCategoryFilter(std::regex("DOMAIN")); + Log::SetVerbosity(Log::Kind::Error); + Log::RegisterConsumer(std::unique_ptr(new TestConsumer(n_logs))); + + auto dpf = DomainParticipantFactory::get_shared_instance(); + DomainParticipantQos qos; + dpf->get_participant_qos_from_xml("", qos, ""); + Log::Flush(); + ASSERT_GE(n_logs.load(), 1u); +} + } // namespace dds } // namespace fastdds } // namespace eprosima