Skip to content

Commit

Permalink
Fix log category name macro collision in MacOS (backport #5585) (ba…
Browse files Browse the repository at this point in the history
…ckport #5595) (#5619)

* 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]>
(cherry picked from commit 55cf7b2)

# Conflicts:
#	src/cpp/fastdds/domain/DomainParticipantFactory.cpp

* Fix conflict

Signed-off-by: Javier Gil Aviles <[email protected]>

* Fix conflicts

Signed-off-by: Javier Gil Aviles <[email protected]>

---------

Signed-off-by: Javier Gil Aviles <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Javier Gil Aviles <[email protected]>
  • Loading branch information
mergify[bot] and Javgilavi authored Feb 7, 2025
1 parent 6d8c1b6 commit 5c8457d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/cpp/fastdds/domain/DomainParticipantFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,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;
Expand All @@ -419,7 +419,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;
Expand All @@ -431,7 +431,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;
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,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;
}
Expand Down Expand Up @@ -577,13 +577,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;
}

Expand Down
40 changes: 40 additions & 0 deletions test/blackbox/common/DDSBlackboxTestsBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::atomic<size_t>n_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<LogConsumer>(new TestConsumer(n_logs)));

auto dpf = DomainParticipantFactory::get_shared_instance();
DomainParticipantQos qos;
dpf->load_XML_profiles_file("");
Log::Flush();
ASSERT_GE(n_logs.load(), 1u);
}

} // namespace dds
} // namespace fastdds
} // namespace eprosima

0 comments on commit 5c8457d

Please sign in to comment.