From 1a268c9d0830ac25fb282cb009614ee1a13dadc0 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Thu, 20 Jun 2024 10:15:27 +0200 Subject: [PATCH] Refs #20629: Review - Make ServerAttributes private Signed-off-by: cferreiragonz --- .../cpp/dds/DiscoveryServerExample/common.h | 15 +- .../attributes/RTPSParticipantAttributes.h | 16 +- .../rtps/participant/RTPSParticipant.h | 1 + .../dds/domain/DomainParticipant.hpp | 1 + src/cpp/CMakeLists.txt | 2 +- src/cpp/rtps/RTPSDomain.cpp | 1 + .../ServerAttributes.cpp | 2 +- .../cpp/rtps/attributes/ServerAttributes.hpp | 46 ++--- .../builtin/discovery/participant/PDPClient.h | 1 + .../discovery/participant/PDPServer.hpp | 2 +- .../rtps/participant/RTPSParticipantImpl.cpp | 2 +- src/cpp/xmlparser/XMLElementParser.cpp | 103 ----------- src/cpp/xmlparser/XMLParser.h | 10 -- .../common/BlackboxTestsDiscovery.cpp | 2 +- .../attributes/RTPSParticipantAttributes.h | 8 +- .../dds/participant/ParticipantTests.cpp | 2 +- test/unittest/dds/publisher/CMakeLists.txt | 2 +- test/unittest/rtps/reader/CMakeLists.txt | 2 +- test/unittest/statistics/dds/CMakeLists.txt | 4 +- test/unittest/utils/SystemInfoTests.cpp | 2 +- .../xmlparser/XMLElementParserTests.cpp | 169 ------------------ .../xmlparser/wrapper/XMLParserTest.hpp | 16 -- tools/fds/server.cpp | 2 +- 23 files changed, 55 insertions(+), 356 deletions(-) rename src/cpp/rtps/{builtin/discovery/participant => attributes}/ServerAttributes.cpp (95%) rename include/fastdds/rtps/attributes/ServerAttributes.h => src/cpp/rtps/attributes/ServerAttributes.hpp (81%) diff --git a/examples/cpp/dds/DiscoveryServerExample/common.h b/examples/cpp/dds/DiscoveryServerExample/common.h index c48cf35978f..edfe32bd6fd 100644 --- a/examples/cpp/dds/DiscoveryServerExample/common.h +++ b/examples/cpp/dds/DiscoveryServerExample/common.h @@ -20,7 +20,7 @@ #ifndef _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_DISCOVERYSERVEREXAMPLE_COMMON_H_ #define _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_DISCOVERYSERVEREXAMPLE_COMMON_H_ -#include +#include #include enum class TransportKind @@ -32,19 +32,6 @@ enum class TransportKind SHM, }; -inline eprosima::fastdds::rtps::GuidPrefix_t get_discovery_server_guid_from_id( - unsigned short id) -{ - eprosima::fastdds::rtps::GuidPrefix_t result; - - // Get default DS guid and modify the one value expected to be changed - std::istringstream(eprosima::fastdds::rtps::DEFAULT_ROS2_SERVER_GUIDPREFIX) >> result; - result.value[2] = - static_cast(id); // This is done like this in Fast - - return result; -} - inline bool is_ip( const std::string ip_str) { diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index 0142fa929cc..f8c3fe048bd 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -129,6 +128,21 @@ inline std::ostream& operator <<( return output; } +/** + * Returns the guidPrefix associated to the given server id + * @param[in] id of the default server whose guidPrefix we want to retrieve + * @param[out] guid reference to the guidPrefix to modify + * @return true if the server guid can be delivered + */ +FASTDDS_EXPORTED_API bool get_server_client_default_guidPrefix( + int id, + fastdds::rtps::GuidPrefix_t& guid); + +// Port used if the ros environment variable doesn't specify one +constexpr uint16_t DEFAULT_ROS2_SERVER_PORT = 11811; +// Port used by default for tcp transport +constexpr uint16_t DEFAULT_TCP_SERVER_PORT = 42100; + //! Filtering flags when discovering participants enum ParticipantFilteringFlags : uint32_t { diff --git a/include/fastdds/rtps/participant/RTPSParticipant.h b/include/fastdds/rtps/participant/RTPSParticipant.h index 91a179c747b..7d17bd82965 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.h +++ b/include/fastdds/rtps/participant/RTPSParticipant.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/fastdds/statistics/dds/domain/DomainParticipant.hpp b/include/fastdds/statistics/dds/domain/DomainParticipant.hpp index 05c829dc06b..265948aeae7 100644 --- a/include/fastdds/statistics/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/statistics/dds/domain/DomainParticipant.hpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace eprosima { namespace fastdds { diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index f66218305c8..b08f41e5d3f 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -110,6 +110,7 @@ set(${PROJECT_NAME}_source_files rtps/attributes/EndpointSecurityAttributes.cpp rtps/attributes/PropertyPolicy.cpp rtps/attributes/RTPSParticipantAttributes.cpp + rtps/attributes/ServerAttributes.cpp rtps/attributes/ThreadSettings.cpp rtps/attributes/TopicAttributes.cpp rtps/builtin/BuiltinProtocols.cpp @@ -136,7 +137,6 @@ set(${PROJECT_NAME}_source_files rtps/builtin/discovery/participant/PDPServer.cpp rtps/builtin/discovery/participant/PDPServerListener.cpp rtps/builtin/discovery/participant/PDPSimple.cpp - rtps/builtin/discovery/participant/ServerAttributes.cpp rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp rtps/builtin/liveliness/WLP.cpp diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 302e883aaaa..6bdb5806ea6 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp b/src/cpp/rtps/attributes/ServerAttributes.cpp similarity index 95% rename from src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp rename to src/cpp/rtps/attributes/ServerAttributes.cpp index 67ad154610c..bc51b94f92c 100644 --- a/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp +++ b/src/cpp/rtps/attributes/ServerAttributes.cpp @@ -17,7 +17,7 @@ * */ -#include +#include namespace eprosima { namespace fastdds { diff --git a/include/fastdds/rtps/attributes/ServerAttributes.h b/src/cpp/rtps/attributes/ServerAttributes.hpp similarity index 81% rename from include/fastdds/rtps/attributes/ServerAttributes.h rename to src/cpp/rtps/attributes/ServerAttributes.hpp index 38c890a6605..11740c01d39 100644 --- a/include/fastdds/rtps/attributes/ServerAttributes.h +++ b/src/cpp/rtps/attributes/ServerAttributes.hpp @@ -1,4 +1,4 @@ -// Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file ServerAttributes.h + * @file ServerAttributes.hpp * */ @@ -29,9 +29,9 @@ #include namespace eprosima { - namespace fastdds { namespace rtps { + class ParticipantProxyData; /** @@ -43,7 +43,7 @@ class RemoteServerAttributes { public: - FASTDDS_EXPORTED_API inline bool operator ==( + inline bool operator ==( const RemoteServerAttributes& r) const { return guidPrefix == r.guidPrefix @@ -51,19 +51,19 @@ class RemoteServerAttributes && metatrafficMulticastLocatorList == r.metatrafficMulticastLocatorList; } - FASTDDS_EXPORTED_API void clear() + void clear() { guidPrefix = fastdds::rtps::GuidPrefix_t::unknown(); metatrafficUnicastLocatorList.clear(); metatrafficMulticastLocatorList.clear(); } - FASTDDS_EXPORTED_API fastdds::rtps::GUID_t GetParticipant() const; + fastdds::rtps::GUID_t GetParticipant() const; - FASTDDS_EXPORTED_API fastdds::rtps::GUID_t GetPDPReader() const; - FASTDDS_EXPORTED_API fastdds::rtps::GUID_t GetPDPWriter() const; + fastdds::rtps::GUID_t GetPDPReader() const; + fastdds::rtps::GUID_t GetPDPWriter() const; - FASTDDS_EXPORTED_API inline bool ReadguidPrefix( + inline bool ReadguidPrefix( const char* pfx) { return bool(std::istringstream(pfx) >> guidPrefix); @@ -92,8 +92,8 @@ typedef std::list RemoteServerList_t; template struct server_ostream_separators { - FASTDDS_EXPORTED_API static const charT* list_separator; - FASTDDS_EXPORTED_API static const charT* locator_separator; + static const charT* list_separator; + static const charT* locator_separator; }; #ifndef _MSC_VER @@ -133,12 +133,8 @@ std::basic_ostream& operator <<( return output; } -// port used if the ros environment variable doesn't specify one -constexpr uint16_t DEFAULT_ROS2_SERVER_PORT = 11811; -// default server base guidPrefix +// Default server base guidPrefix const char* const DEFAULT_ROS2_SERVER_GUIDPREFIX = "44.53.00.5f.45.50.52.4f.53.49.4d.41"; -// port used by default for tcp transport -constexpr uint16_t DEFAULT_TCP_SERVER_PORT = 42100; /* Environment variable to specify a semicolon-separated list of locators ([transport]ip:port) that define remote server * locators. The [transport] specification is optional. The default transport is UDPv4. @@ -166,7 +162,7 @@ const char* const ROS_SUPER_CLIENT = "ROS_SUPER_CLIENT"; * @param[out] servers_list reference to a LocatorList_t to populate. * @return true if parsing succeeds, false otherwise (or if the list is empty) */ -FASTDDS_EXPORTED_API bool load_environment_server_info( +bool load_environment_server_info( const std::string& list, LocatorList& servers_list); @@ -181,30 +177,20 @@ FASTDDS_EXPORTED_API bool load_environment_server_info( * @param[out] servers_list reference to a LocatorList_t to populate. * @return true if parsing succeeds, false otherwise */ -FASTDDS_EXPORTED_API bool load_environment_server_info( +bool load_environment_server_info( LocatorList& servers_list); /** * Get the value of environment variable DEFAULT_ROS2_MASTER_URI * @return The value of environment variable DEFAULT_ROS2_MASTER_URI. Empty string if the variable is not defined. */ -FASTDDS_EXPORTED_API const std::string& ros_discovery_server_env(); +const std::string& ros_discovery_server_env(); /** * Get the value of environment variable ROS_SUPER_CLIENT * @return The value of environment variable ROS_SUPER_CLIENT. False if the variable is not defined. */ -FASTDDS_EXPORTED_API bool ros_super_client_env(); - -/** - * Returns the guidPrefix associated to the given server id - * @param[in] id of the default server whose guidPrefix we want to retrieve - * @param[out] guid reference to the guidPrefix to modify - * @return true if the server guid can be delivered - */ -FASTDDS_EXPORTED_API bool get_server_client_default_guidPrefix( - int id, - fastdds::rtps::GuidPrefix_t& guid); +bool ros_super_client_env(); } // rtps } // fastdds diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.h b/src/cpp/rtps/builtin/discovery/participant/PDPClient.h index d8953753306..40e590cdec0 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.h +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.h @@ -21,6 +21,7 @@ #define _FASTDDS_RTPS_PDPCLIENT_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#include #include #include #include diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp index 2a0b5518c30..e6b5e43aef5 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp @@ -28,8 +28,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 715adfb5713..1e2daf727e5 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/xmlparser/XMLElementParser.cpp b/src/cpp/xmlparser/XMLElementParser.cpp index b31100c61f7..e8191440ad7 100644 --- a/src/cpp/xmlparser/XMLElementParser.cpp +++ b/src/cpp/xmlparser/XMLElementParser.cpp @@ -4030,109 +4030,6 @@ XMLP_ret XMLParser::getXMLEnum( return XMLP_ret::XML_OK; } -XMLP_ret XMLParser::getXMLRemoteServer( - tinyxml2::XMLElement* elem, - eprosima::fastdds::rtps::RemoteServerAttributes& server, - uint8_t ident) -{ - /* - - - - - - - - */ - - const char* Prefix = nullptr; - tinyxml2::XMLElement* pLU = nullptr, * pLM = nullptr; - - if (nullptr == elem ) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "nullptr when getXMLRemoteServer XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - else if (nullptr == (Prefix = elem->Attribute(PREFIX))) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "nullptr when getXMLRemoteServer try to recover server's guidPrefix XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - else if (!server.ReadguidPrefix(Prefix)) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "getXMLRemoteServer found an invalid server's guidPrefix XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - - pLU = elem->FirstChildElement(META_UNI_LOC_LIST); - pLM = elem->FirstChildElement(META_MULTI_LOC_LIST); - - if ( pLU == nullptr && pLM == nullptr ) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "getXMLRemoteServer couldn't find any server's locator XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - - if (pLU && XMLP_ret::XML_OK != getXMLLocatorList(pLU, server.metatrafficUnicastLocatorList, ident)) - { - EPROSIMA_LOG_ERROR(XMLPARSER, - "getXMLRemoteServer was given a misformatted server's " << META_UNI_LOC_LIST << " XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - - if (pLM && XMLP_ret::XML_OK != getXMLLocatorList(pLM, server.metatrafficMulticastLocatorList, ident)) - { - EPROSIMA_LOG_ERROR(XMLPARSER, - "getXMLRemoteServer was given a misformatted server's " << META_MULTI_LOC_LIST << " XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - - return XMLP_ret::XML_OK; -} - -XMLP_ret XMLParser::getXMLList( - tinyxml2::XMLElement* elem, - eprosima::fastdds::rtps::RemoteServerList_t& list, - uint8_t ident) -{ - /* - - - - - - */ - - tinyxml2::XMLElement* pS = nullptr; - - if (nullptr == elem) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "nullptr when getXMLList XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - else if (nullptr == (pS = elem->FirstChildElement(RSERVER))) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "getXMLList couldn't find any RemoteServer XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - - while (pS) - { - eprosima::fastdds::rtps::RemoteServerAttributes server; - if (XMLP_ret::XML_OK != getXMLRemoteServer(pS, server, ident)) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "getXMLList was given a misformatted RemoteServer XML_ERROR!"); - return XMLP_ret::XML_ERROR; - } - list.push_back(std::move(server)); - - pS = pS->NextSiblingElement(RSERVER); - } - - return XMLP_ret::XML_OK; - -} - XMLP_ret XMLParser::getXMLString( tinyxml2::XMLElement* elem, std::string* s, diff --git a/src/cpp/xmlparser/XMLParser.h b/src/cpp/xmlparser/XMLParser.h index 27646091c10..ab1fd21a8f5 100644 --- a/src/cpp/xmlparser/XMLParser.h +++ b/src/cpp/xmlparser/XMLParser.h @@ -623,21 +623,11 @@ class XMLParser rtps::DiscoveryProtocol* e, uint8_t ident); - static XMLP_ret getXMLList( - tinyxml2::XMLElement* elem, - eprosima::fastdds::rtps::RemoteServerList_t& list, - uint8_t ident); - static XMLP_ret getXMLEnum( tinyxml2::XMLElement* elem, rtps::ParticipantFilteringFlags* e, uint8_t ident); - static XMLP_ret getXMLRemoteServer( - tinyxml2::XMLElement* elem, - eprosima::fastdds::rtps::RemoteServerAttributes& server, - uint8_t ident); - static XMLP_ret getXMLString( tinyxml2::XMLElement* elem, std::string* s, diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index 71ba42eb6f4..fea96f51487 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -27,10 +27,10 @@ #include #include // #include -#include #include #include +#include #include #include "BlackboxTests.hpp" diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index 96af3fe9eee..5d6a459ff79 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -41,6 +40,8 @@ #include #include +#include + namespace eprosima { namespace fastdds { namespace rtps { @@ -128,6 +129,11 @@ inline std::ostream& operator <<( return output; } +// Port used if the ros environment variable doesn't specify one +constexpr uint16_t DEFAULT_ROS2_SERVER_PORT = 11811; +// Port used by default for tcp transport +constexpr uint16_t DEFAULT_TCP_SERVER_PORT = 42100; + //! Filtering flags when discovering participants enum ParticipantFilteringFlags : uint32_t { diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index d2e9adfd85d..e190555411a 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -62,6 +61,7 @@ #include #include +#include #include #include #include diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 348eab958bf..7e6eb5bf810 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -78,6 +78,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/BuiltinProtocols.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -103,7 +104,6 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/liveliness/WLP.cpp diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index 1cd1a450b40..f97299fcc02 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -174,6 +174,7 @@ set(STATEFUL_READER_TESTS_SOURCE StatefulReaderTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/BuiltinProtocols.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -199,7 +200,6 @@ set(STATEFUL_READER_TESTS_SOURCE StatefulReaderTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/liveliness/WLP.cpp diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index b08d33f54ec..9fab90374cf 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -180,6 +180,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/BuiltinProtocols.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -205,7 +206,6 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -358,6 +358,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/QosConverters.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/BuiltinProtocols.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -383,7 +384,6 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/liveliness/WLP.cpp diff --git a/test/unittest/utils/SystemInfoTests.cpp b/test/unittest/utils/SystemInfoTests.cpp index 50da9759535..13216b1ca23 100644 --- a/test/unittest/utils/SystemInfoTests.cpp +++ b/test/unittest/utils/SystemInfoTests.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include #define SIZE 512 diff --git a/test/unittest/xmlparser/XMLElementParserTests.cpp b/test/unittest/xmlparser/XMLElementParserTests.cpp index e5c09f7523a..8bd5c780471 100644 --- a/test/unittest/xmlparser/XMLElementParserTests.cpp +++ b/test/unittest/xmlparser/XMLElementParserTests.cpp @@ -906,108 +906,6 @@ TEST_F(XMLParserTests, getXMLPropertiesPolicy) EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::propertiesPolicy_wrapper(titleElement, property_policy, ident)); } -/* - * This test checks the proper parsing of a xml element to a RemoteServerAttributes object, and negative - * cases. - * 1. Check nullptr as tinyxml2::XMLElement argument. - * 2. Check missing prefix in the tag. - * 3. Check wrongly formated in the tag. - * 5. Check an empty tag. - * 6. Check an empty tag. - * 6. Check a tag with no locators. - */ -TEST_F(XMLParserTests, getXMLRemoteServer) -{ - uint8_t ident = 1; - RemoteServerAttributes attr; - tinyxml2::XMLDocument xml_doc; - tinyxml2::XMLElement* titleElement; - - const std::vector valid_parameters { - "prefix=\"4D.49.47.55.45.4c.5f.42.41.52.52.4f\"", - "\ - \ - 8844\ -
::1
\ -
\ -
", - "\ - \ - 8844\ -
::1
\ -
\ -
", }; - std::vector parameters(valid_parameters); - - // Parametrized XML - const char* xml_p = - "\ - \ - %s\ - %s\ - \ - "; - constexpr size_t xml_len {1200}; - char xml[xml_len]; - - // Valid XML - snprintf(xml, xml_len, xml_p, valid_parameters[0].c_str(), valid_parameters[1].c_str(), - valid_parameters[2].c_str()); - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - ASSERT_EQ(XMLP_ret::XML_OK, XMLParserTest::getXMLRemoteServer_wrapper(titleElement, attr, ident)); - EXPECT_EQ(attr.guidPrefix.value[0], (octet)0x4d); - EXPECT_EQ(attr.guidPrefix.value[1], (octet)0x49); - EXPECT_EQ(attr.guidPrefix.value[2], (octet)0x47); - EXPECT_EQ(attr.guidPrefix.value[3], (octet)0x55); - EXPECT_EQ(attr.guidPrefix.value[4], (octet)0x45); - EXPECT_EQ(attr.guidPrefix.value[5], (octet)0x4c); - EXPECT_EQ(attr.guidPrefix.value[6], (octet)0x5f); - EXPECT_EQ(attr.guidPrefix.value[7], (octet)0x42); - EXPECT_EQ(attr.guidPrefix.value[8], (octet)0x41); - EXPECT_EQ(attr.guidPrefix.value[9], (octet)0x52); - EXPECT_EQ(attr.guidPrefix.value[10], (octet)0x52); - EXPECT_EQ(attr.guidPrefix.value[11], (octet)0x4f); - - EXPECT_EQ(attr.metatrafficUnicastLocatorList.begin()->port, 8844u); - EXPECT_EQ(attr.metatrafficUnicastLocatorList.begin()->address[15], 1); - EXPECT_EQ(attr.metatrafficMulticastLocatorList.begin()->port, 8844u); - EXPECT_EQ(attr.metatrafficMulticastLocatorList.begin()->address[15], 1); - - // nullptr element - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLRemoteServer_wrapper(nullptr, attr, ident)); - - // No prefix - snprintf(xml, xml_len, xml_p, "", valid_parameters[1].c_str(), valid_parameters[2].c_str()); - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLRemoteServer_wrapper(titleElement, attr, ident)); - - // Bad prefix value - snprintf(xml, xml_len, xml_p, "prefix=\"\"", valid_parameters[1].c_str(), valid_parameters[2].c_str()); - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLRemoteServer_wrapper(titleElement, attr, ident)); - - // Bad unicast - snprintf(xml, xml_len, xml_p, valid_parameters[0].c_str(), "", valid_parameters[2].c_str()); - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLRemoteServer_wrapper(titleElement, attr, ident)); - - // Bad multicast - snprintf(xml, xml_len, xml_p, valid_parameters[0].c_str(), valid_parameters[1].c_str(), ""); - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLRemoteServer_wrapper(titleElement, attr, ident)); - - // No locators - snprintf(xml, xml_len, "", valid_parameters[0].c_str()); - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLRemoteServer_wrapper(titleElement, attr, ident)); -} - /* * This test checks the negative cases of a xml element. * 1. Check a missing case of each of the child tags. @@ -1331,73 +1229,6 @@ TEST_F(XMLParserTests, getXMLString) EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLString_wrapper(titleElement, &s, ident)); } -/* - * This test checks the negative cases of the XMLParser::getXMLList method. - * 1. Check passing a nullptr as a tinyxml2::XMLElement argument. - * 2. Check passing an empty field. - * 3. Check passing a non valid value of descriptor as an element of . - */ -TEST_F(XMLParserTests, getXMLList_NegativeClauses) -{ - uint8_t ident = 1; - RemoteServerList_t list; - tinyxml2::XMLDocument xml_doc; - tinyxml2::XMLElement* titleElement; - - // empty element - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLList_wrapper(nullptr, list, ident)); - - // empty list - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse("")); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLList_wrapper(titleElement, list, ident)); - - // bad remote server element - const char* xml = "bad_remote_server"; - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLList_wrapper(titleElement, list, ident)); -} - -/* - * This test checks the positive case of the XMLParser::getXMLList method. - * 1. Check an valid return on the function. - * 2. Check the correct element has been placed on the list. - */ -TEST_F(XMLParserTests, getXMLList_positive) -{ - uint8_t ident = 1; - RemoteServerList_t list; - tinyxml2::XMLDocument xml_doc; - tinyxml2::XMLElement* titleElement; - - // bad remote server element - const char* xml = - "\ - \ - \ - \ - \ - 8844\ -
::1
\ -
\ -
\ -
\ -
\ -
"; - - ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); - titleElement = xml_doc.RootElement(); - EXPECT_EQ(XMLP_ret::XML_OK, XMLParserTest::getXMLList_wrapper(titleElement, list, ident)); - EXPECT_EQ(list.begin()->metatrafficUnicastLocatorList.begin()->port, 8844u); - EXPECT_EQ(list.begin()->metatrafficUnicastLocatorList.begin()->address[15], 1); - EXPECT_EQ(list.begin()->guidPrefix.value[0], 0x4d); - EXPECT_EQ(list.begin()->guidPrefix.value[1], 0x49); - EXPECT_EQ(list.begin()->guidPrefix.value[2], 0x47); - EXPECT_EQ(list.begin()->guidPrefix.value[3], 0x55); - EXPECT_EQ(list.begin()->guidPrefix.value[4], 0x45); -} - /* * This test checks the negative cases of the XMLParser::getXMLBool method. * 1. Check passing a nullptr as a tinyxml2::XMLElement argument. diff --git a/test/unittest/xmlparser/wrapper/XMLParserTest.hpp b/test/unittest/xmlparser/wrapper/XMLParserTest.hpp index 46b8499b72b..a0de6da9eb0 100644 --- a/test/unittest/xmlparser/wrapper/XMLParserTest.hpp +++ b/test/unittest/xmlparser/wrapper/XMLParserTest.hpp @@ -140,14 +140,6 @@ class XMLParserTest : public XMLParser return getXMLPropertiesPolicy(elem, propertiesPolicy, ident); } - static XMLP_ret getXMLRemoteServer_wrapper( - tinyxml2::XMLElement* elem, - RemoteServerAttributes& attr, - uint8_t ident) - { - return getXMLRemoteServer(elem, attr, ident); - } - static XMLP_ret getXMLTransports_wrapper( tinyxml2::XMLElement* elem, std::vector>& transports, @@ -189,14 +181,6 @@ class XMLParserTest : public XMLParser return getXMLString(elem, s, ident); } - static XMLP_ret getXMLList_wrapper( - tinyxml2::XMLElement* elem, - eprosima::fastdds::rtps::RemoteServerList_t& list, - uint8_t ident) - { - return getXMLList(elem, list, ident); - } - static XMLP_ret getXMLBool_wrapper( tinyxml2::XMLElement* elem, bool* b, diff --git a/tools/fds/server.cpp b/tools/fds/server.cpp index 5fe40ecfc05..59d5978851e 100644 --- a/tools/fds/server.cpp +++ b/tools/fds/server.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include