Skip to content

Commit

Permalink
Refs #20301: fix memory leak
Browse files Browse the repository at this point in the history
Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
  • Loading branch information
JLBuenoLopez committed Mar 8, 2024
1 parent a7afe9d commit e77242f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
41 changes: 1 addition & 40 deletions test/unittest/rtps/domain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ set(RTPS_DOMAIN_TESTS_EXEC RTPSDomainTests)

file(GLOB RTPS_DOMAIN_TESTS_SOURCE
RTPSDomainTests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/*.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/*.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp
${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp
${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp
${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp
${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp
${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp
${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp
${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/*.cpp
)

# External sources
Expand Down Expand Up @@ -65,29 +48,6 @@ target_compile_definitions(${RTPS_DOMAIN_TESTS_EXEC} PRIVATE
target_include_directories(
${RTPS_DOMAIN_TESTS_EXEC}
PRIVATE
${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor
${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData
${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData
${PROJECT_SOURCE_DIR}/test/mock/rtps/ResourceEvent
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipant
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantAttributes
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter
${PROJECT_SOURCE_DIR}/test/mock/rtps/ServerAttributes
${PROJECT_SOURCE_DIR}/test/mock/rtps/SharedMemTransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader
${PROJECT_SOURCE_DIR}/test/mock/rtps/StatelessReader
${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulWriter
${PROJECT_SOURCE_DIR}/test/mock/rtps/StatelessWriter
${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPTransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv4TransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/TCPv6TransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/UDPTransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/UDPv4TransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/UDPv6TransportDescriptor
${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory
${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterProxyData
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include
${PROJECT_SOURCE_DIR}/src/cpp
Expand All @@ -99,6 +59,7 @@ target_link_libraries(
GTest::gmock
${CMAKE_DL_LIBS}
fastcdr
fastdds
$<$<BOOL:${LINK_SSL}>:OpenSSL::SSL$<SEMICOLON>OpenSSL::Crypto>
${TINYXML2_LIBRARY}
)
Expand Down
11 changes: 5 additions & 6 deletions test/unittest/rtps/domain/RTPSDomainTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

#include <gtest/gtest.h>

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/LibrarySettings.hpp>
#include <fastdds/rtps/RTPSDomain.h>

#include <xmlparser/XMLParserCommon.h>
#include <xmlparser/XMLProfileManager.h>

/**
* This test checks the getter and setter for the library settings in the RTPS layer.
*/
Expand Down Expand Up @@ -49,12 +47,13 @@ TEST(RTPSDomainTests, library_settings_test)
EXPECT_TRUE(eprosima::fastrtps::rtps::RTPSDomain::get_library_settings(library_settings));
EXPECT_EQ(eprosima::fastdds::INTRAPROCESS_USER_DATA_ONLY, library_settings.intraprocess_delivery);
// Remove RTPSParticipant
eprosima::fastrtps::rtps::RTPSDomain::stopAll();
EXPECT_TRUE(eprosima::fastrtps::rtps::RTPSDomain::removeRTPSParticipant(participant));
library_settings.intraprocess_delivery = eprosima::fastdds::INTRAPROCESS_OFF;
// Setting LibrarySettings with no participants shall suceed
EXPECT_TRUE(eprosima::fastrtps::rtps::RTPSDomain::set_library_settings(library_settings));
EXPECT_TRUE(eprosima::fastrtps::rtps::RTPSDomain::get_library_settings(library_settings));
EXPECT_EQ(eprosima::fastdds::INTRAPROCESS_OFF, library_settings.intraprocess_delivery);
eprosima::fastrtps::rtps::RTPSDomain::stopAll();
}

/**
Expand Down Expand Up @@ -85,8 +84,8 @@ TEST(RTPSDomainTests, get_topic_attributes_from_profile_test)
</topic>
</profiles>)";

EXPECT_EQ(eprosima::fastrtps::xmlparser::XMLP_ret::XML_OK,
eprosima::fastrtps::xmlparser::XMLProfileManager::loadXMLString(xml.c_str(), xml.length()));
EXPECT_EQ(eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->load_XML_profiles_string(xml.c_str(),
xml.length()), ReturnCode_t::RETCODE_OK);
EXPECT_TRUE(eprosima::fastrtps::rtps::RTPSDomain::get_topic_attributes_from_profile(profile_name, topic_att));
EXPECT_EQ(topic_att.topicName, "Test");
EXPECT_EQ(topic_att.topicDataType, "DataTest");
Expand Down

0 comments on commit e77242f

Please sign in to comment.