diff --git a/include/fastdds/dds/core/policy/QosPolicies.hpp b/include/fastdds/dds/core/policy/QosPolicies.hpp index 964cfaae070..fcdb9d5a4bf 100644 --- a/include/fastdds/dds/core/policy/QosPolicies.hpp +++ b/include/fastdds/dds/core/policy/QosPolicies.hpp @@ -2951,6 +2951,7 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy max_domains_ : b.domain_ids().size()); domain_ids_ = b.domain_ids(); + data_sharing_listener_thread_ = b.data_sharing_listener_thread(); return *this; } @@ -2961,6 +2962,7 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy return kind_ == b.kind_ && shm_directory_ == b.shm_directory_ && domain_ids_ == b.domain_ids_ && + data_sharing_listener_thread_ == b.data_sharing_listener_thread_ && Parameter_t::operator ==(b) && QosPolicy::operator ==(b); } @@ -3137,6 +3139,37 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy } } + /** + * Getter for DataSharing listener thread ThreadSettings + * + * @return rtps::ThreadSettings reference + */ + rtps::ThreadSettings& data_sharing_listener_thread() + { + return data_sharing_listener_thread_; + } + + /** + * Getter for DataSharing listener thread ThreadSettings + * + * @return rtps::ThreadSettings reference + */ + const rtps::ThreadSettings& data_sharing_listener_thread() const + { + return data_sharing_listener_thread_; + } + + /** + * Setter for the DataSharing listener thread ThreadSettings + * + * @param value New ThreadSettings to be set + */ + void data_sharing_listener_thread( + const rtps::ThreadSettings& value) + { + data_sharing_listener_thread_ = value; + } + private: void setup( @@ -3165,6 +3198,9 @@ class DataSharingQosPolicy : public Parameter_t, public QosPolicy //! Only endpoints with matching domain IDs are DataSharing compatible std::vector domain_ids_; + + //! Thread settings for the DataSharing listener thread + rtps::ThreadSettings data_sharing_listener_thread_; }; diff --git a/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp b/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp index 046babaf8b7..6dc01c45f34 100644 --- a/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp +++ b/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -208,8 +207,7 @@ class DataReaderQos (properties_ == b.properties()) && (endpoint_ == b.endpoint()) && (reader_resource_limits_ == b.reader_resource_limits()) && - (data_sharing_ == b.data_sharing()) && - (data_sharing_listener_thread_ == b.data_sharing_listener_thread()); + (data_sharing_ == b.data_sharing()); } RTPS_DllAPI ReaderQos get_readerqos( @@ -856,37 +854,6 @@ class DataReaderQos data_sharing_ = data_sharing; } - /** - * Getter for data sharing listener ThreadSettings - * - * @return rtps::ThreadSettings reference - */ - RTPS_DllAPI rtps::ThreadSettings& data_sharing_listener_thread() - { - return data_sharing_listener_thread_; - } - - /** - * Getter for data sharing listener ThreadSettings - * - * @return rtps::ThreadSettings reference - */ - RTPS_DllAPI const rtps::ThreadSettings& data_sharing_listener_thread() const - { - return data_sharing_listener_thread_; - } - - /** - * Setter for data sharing listener ThreadSettings - * - * @param data_sharing_listener_thread new value for the rtps::ThreadSettings - */ - RTPS_DllAPI void data_sharing_listener_thread( - const rtps::ThreadSettings& data_sharing_listener_thread) - { - data_sharing_listener_thread_ = data_sharing_listener_thread; - } - private: //!Durability Qos, implemented in the library. @@ -951,9 +918,6 @@ class DataReaderQos //!DataSharing configuration (Extension) DataSharingQosPolicy data_sharing_; - - //! Thread settings for the data-sharing listener thread - rtps::ThreadSettings data_sharing_listener_thread_; }; RTPS_DllAPI extern const DataReaderQos DATAREADER_QOS_DEFAULT; diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index ea73277ca7a..78d74be6690 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -487,7 +487,14 @@ class RTPSParticipantAttributes (this->properties == b.properties) && (this->prefix == b.prefix) && (this->flow_controllers == b.flow_controllers) && - (this->builtin_controllers_sender_thread == b.builtin_controllers_sender_thread); + (this->builtin_controllers_sender_thread == b.builtin_controllers_sender_thread) && + (this->timed_events_thread == b.timed_events_thread) && +#if HAVE_SECURITY + (this->security_log_thread == b.security_log_thread) && +#endif // if HAVE_SECURITY + (this->discovery_server_thread == b.discovery_server_thread) && + (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); + } /** @@ -588,6 +595,9 @@ class RTPSParticipantAttributes //! Thread settings for the discovery server thread fastdds::rtps::ThreadSettings discovery_server_thread; + //! Thread settings for the builtin transports reception threads + fastdds::rtps::ThreadSettings builtin_transports_reception_threads; + #if HAVE_SECURITY //! Thread settings for the security log thread fastdds::rtps::ThreadSettings security_log_thread; diff --git a/include/fastrtps/xmlparser/XMLParser.h b/include/fastrtps/xmlparser/XMLParser.h index 980d24a7641..9799280d5a0 100644 --- a/include/fastrtps/xmlparser/XMLParser.h +++ b/include/fastrtps/xmlparser/XMLParser.h @@ -15,19 +15,26 @@ #ifndef XML_PARSER_H_ #define XML_PARSER_H_ -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #include #include -#include -#include #include -#include +#include +#include +#include #include -#include - -#include -#include +#include namespace tinyxml2 { class XMLElement; @@ -52,6 +59,11 @@ typedef std::map sp_transport_map_t; typedef types::DynamicTypeBuilder* p_dynamictypebuilder_t; typedef std::map p_dynamictype_map_t; +typedef std::unique_ptr up_participantfactory_t; +typedef DataNode node_participantfactory_t; +typedef node_participantfactory_t* p_node_participantfactory_t; +typedef std::unique_ptr up_node_participantfactory_t; + typedef std::unique_ptr up_participant_t; typedef DataNode node_participant_t; typedef node_participant_t* p_node_participant_t; @@ -177,6 +189,10 @@ class XMLParser RTPS_DllAPI static XMLP_ret parseXMLTransportsProf( tinyxml2::XMLElement* p_root); + RTPS_DllAPI static XMLP_ret parseXMLDomainParticipantFactoryProf( + tinyxml2::XMLElement* p_root, + BaseNode& rootNode); + RTPS_DllAPI static XMLP_ret parseXMLParticipantProf( tinyxml2::XMLElement* p_root, BaseNode& rootNode); @@ -204,10 +220,21 @@ class XMLParser RTPS_DllAPI static XMLP_ret parseXMLTransportData( tinyxml2::XMLElement* p_root); + RTPS_DllAPI static XMLP_ret validateXMLTransportElements( + tinyxml2::XMLElement& p_root); + RTPS_DllAPI static XMLP_ret parseXMLCommonTransportData( tinyxml2::XMLElement* p_root, sp_transport_t p_transport); + RTPS_DllAPI static XMLP_ret parseXMLPortBasedTransportData( + tinyxml2::XMLElement* p_root, + std::shared_ptr p_transport); + + RTPS_DllAPI static XMLP_ret parseXMLSocketTransportData( + tinyxml2::XMLElement* p_root, + std::shared_ptr p_transport); + RTPS_DllAPI static XMLP_ret parseXMLCommonTCPTransportData( tinyxml2::XMLElement* p_root, sp_transport_t p_transport); @@ -220,6 +247,10 @@ class XMLParser tinyxml2::XMLElement* p_root, sp_transport_t tcp_transport); + RTPS_DllAPI static XMLP_ret parseXMLReceptionThreads( + tinyxml2::XMLElement& p_root, + fastdds::rtps::PortBasedTransportDescriptor::ReceptionThreadsConfigMap& reception_threads); + /** * Load a XML consumer node and parses it. Adds the parsed consumer to Log directly. * @param consumer Node to be loaded. @@ -280,6 +311,10 @@ class XMLParser types::MemberId mId, const std::string& values); + RTPS_DllAPI static XMLP_ret fillDataNode( + tinyxml2::XMLElement* p_profile, + DataNode& factory_node); + RTPS_DllAPI static XMLP_ret fillDataNode( tinyxml2::XMLElement* p_profile, DataNode& participant_node); @@ -549,6 +584,11 @@ class XMLParser uint16_t* ui16, uint8_t ident); + RTPS_DllAPI static XMLP_ret getXMLUint( + tinyxml2::XMLElement* elem, + uint64_t* ui64, + uint8_t ident); + RTPS_DllAPI static XMLP_ret getXMLBool( tinyxml2::XMLElement* elem, bool* b, @@ -599,6 +639,10 @@ class XMLParser rtps::GuidPrefix_t& prefix, uint8_t ident); + RTPS_DllAPI static XMLP_ret getXMLDomainParticipantFactoryQos( + tinyxml2::XMLElement& elem, + fastdds::dds::DomainParticipantFactoryQos& qos); + RTPS_DllAPI static XMLP_ret getXMLPublisherAttributes( tinyxml2::XMLElement* elem, PublisherAttributes& publisher, @@ -608,6 +652,23 @@ class XMLParser tinyxml2::XMLElement* elem, SubscriberAttributes& subscriber, uint8_t ident); + + RTPS_DllAPI static XMLP_ret getXMLThreadSettings( + tinyxml2::XMLElement& elem, + fastdds::rtps::ThreadSettings& thread_setting); + + /* + Return XMLP_ret::XML_OK when OK, XMLP_ret::XML_NOK when port attribute is not present, and + XMLP_ret::XML_ERROR if error + */ + RTPS_DllAPI static XMLP_ret getXMLThreadSettingsWithPort( + tinyxml2::XMLElement& elem, + fastdds::rtps::ThreadSettings& thread_setting, + uint32_t& port); + + RTPS_DllAPI static XMLP_ret getXMLEntityFactoryQos( + tinyxml2::XMLElement& elem, + fastdds::dds::EntityFactoryQosPolicy& entity_factory); }; } // namespace xmlparser diff --git a/include/fastrtps/xmlparser/XMLParserCommon.h b/include/fastrtps/xmlparser/XMLParserCommon.h index 227f58cde6e..ac16431ec0d 100644 --- a/include/fastrtps/xmlparser/XMLParserCommon.h +++ b/include/fastrtps/xmlparser/XMLParserCommon.h @@ -42,6 +42,7 @@ extern const char* LIBRARY_SETTINGS; extern const char* TRANSPORT_DESCRIPTORS; extern const char* PROFILE_NAME; extern const char* DEFAULT_PROF; +extern const char* DOMAINPARTICIPANT_FACTORY; extern const char* PARTICIPANT; extern const char* PUBLISHER; extern const char* SUBSCRIBER; @@ -80,8 +81,17 @@ extern const char* HEALTHY_CHECK_TIMEOUT_MS; extern const char* DISCARD; extern const char* FAIL; extern const char* RTPS_DUMP_FILE; +extern const char* DEFAULT_RECEPTION_THREADS; +extern const char* RECEPTION_THREADS; +extern const char* RECEPTION_THREAD; +extern const char* DUMP_THREAD; extern const char* ON; extern const char* AUTO; +extern const char* THREAD_SETTINGS; +extern const char* SCHEDULING_POLICY; +extern const char* PRIORITY; +extern const char* AFFINITY; +extern const char* STACK_SIZE; // IntraprocessDeliveryType extern const char* OFF; @@ -98,6 +108,12 @@ extern const char* DATA_READER; /// LibrarySettings attributes extern const char* INTRAPROCESS_DELIVERY; +/// DomainParticipantFactory Qos +extern const char* ENTITY_FACTORY; +extern const char* AUTOENABLE_CREATED_ENTITIES; +extern const char* SHM_WATCHDOG_THREAD; +extern const char* FILE_WATCH_THREADS; + /// RTPS Participant attributes extern const char* ALLOCATION; extern const char* PREFIX; @@ -132,6 +148,11 @@ extern const char* DYNAMIC_LC; extern const char* MAX_PROPERTIES; extern const char* MAX_USER_DATA; extern const char* MAX_PARTITIONS; +extern const char* TIMED_EVENTS_THREAD; +extern const char* DISCOVERY_SERVER_THREAD; +extern const char* SECURITY_LOG_THREAD; +extern const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS; +extern const char* BUILTIN_CONTROLLERS_SENDER_THREAD; /// Publisher-subscriber attributes extern const char* TOPIC; @@ -149,6 +170,7 @@ extern const char* USER_DEF_ID; extern const char* ENTITY_ID; extern const char* MATCHED_SUBSCRIBERS_ALLOCATION; extern const char* MATCHED_PUBLISHERS_ALLOCATION; +extern const char* DATA_SHARING_LISTENER_THREAD; /// extern const char* IGN_NON_MATCHING_LOCS; diff --git a/include/fastrtps/xmlparser/XMLProfileManager.h b/include/fastrtps/xmlparser/XMLProfileManager.h index bb934e3b978..d94996a7451 100644 --- a/include/fastrtps/xmlparser/XMLProfileManager.h +++ b/include/fastrtps/xmlparser/XMLProfileManager.h @@ -15,23 +15,26 @@ #ifndef XML_PROFILE_MANAGER_H_ #define XML_PROFILE_MANAGER_H_ +#include +#include +#include + +#include #include #include #include -#include -#include -#include -#include #include - -#include -#include -#include +#include +#include +#include +#include namespace eprosima { namespace fastrtps { namespace xmlparser { +using participant_factory_map_t = std::map; +using part_factory_map_iterator_t = participant_factory_map_t::iterator; using participant_map_t = std::map; using part_map_iterator_t = participant_map_t::iterator; using publisher_map_t = std::map; @@ -135,6 +138,25 @@ class XMLProfileManager RTPS_DllAPI static void getDefaultParticipantAttributes( ParticipantAttributes& participant_attributes); + /** + * Search for the profile specified and fill the structure. + * @param profile_name Name for the profile to be used to fill the structure. + * @param qos Structure to be filled. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + RTPS_DllAPI static XMLP_ret fillDomainParticipantFactoryQos( + const std::string& profile_name, + fastdds::dds::DomainParticipantFactoryQos& qos, + bool log_error = true); + + /** + * Fills input domain participant factory qos with the default values. + * @param qos Structure to be filled. + */ + RTPS_DllAPI static void getDefaultDomainParticipantFactoryQos( + fastdds::dds::DomainParticipantFactoryQos& qos); + /** * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. @@ -227,6 +249,7 @@ class XMLProfileManager */ RTPS_DllAPI static void DeleteInstance() { + participant_factory_profiles_.clear(); participant_profiles_.clear(); publisher_profiles_.clear(); subscriber_profiles_.clear(); @@ -268,6 +291,10 @@ class XMLProfileManager up_base_node_t properties, const std::string& filename); + RTPS_DllAPI static XMLP_ret extractDomainParticipantFactoryProfile( + up_base_node_t& profile, + const std::string& filename); + RTPS_DllAPI static XMLP_ret extractParticipantProfile( up_base_node_t& profile, const std::string& filename); @@ -296,6 +323,8 @@ class XMLProfileManager static LibrarySettingsAttributes library_settings_; + static participant_factory_map_t participant_factory_profiles_; + static participant_map_t participant_profiles_; static publisher_map_t publisher_profiles_; diff --git a/include/fastrtps/xmlparser/XMLTree.h b/include/fastrtps/xmlparser/XMLTree.h index 8ef44c8867e..2c69442f739 100644 --- a/include/fastrtps/xmlparser/XMLTree.h +++ b/include/fastrtps/xmlparser/XMLTree.h @@ -28,7 +28,8 @@ enum class NodeType LOG, REQUESTER, REPLIER, - LIBRARY_SETTINGS + LIBRARY_SETTINGS, + DOMAINPARTICIPANT_FACTORY }; class BaseNode diff --git a/resources/xsd/fastRTPS_profiles.xsd b/resources/xsd/fastRTPS_profiles.xsd index e03a2237b77..1a7c1310596 100644 --- a/resources/xsd/fastRTPS_profiles.xsd +++ b/resources/xsd/fastRTPS_profiles.xsd @@ -35,14 +35,16 @@ + ├ domainparticipant_factory [0~*], + ├ participant [0~*], + ├ data_writer [0~*], + ├ data_reader [0~*], + ├ transport_descriptors [0~1], + └ topic [0~*] --> + @@ -61,13 +63,15 @@ + ├ use_default [bool], + ├ consumer [1~*], + └ thread_settings [threadSettingsType],--> + @@ -93,29 +97,47 @@ + + + + + + + + + + ├ name [string], + ├ defaultUnicastLocatorList [0~1], + ├ defaultMulticastLocatorList [0~1], + ├ default_external_unicast_locators [0~1], + ├ ignore_non_matching_locators [bool], + ├ sendSocketBufferSize [uint32], + ├ listenSocketBufferSize [uint32], + ├ builtin [0~1], + ├ port [0~1], + ├ participantID [int32], + ├ userTransports [0~1], + | └ transport_id [1~*] [string], + ├ useBuiltinTransports [bool], + ├ propertiesPolicy [0~1], + ├ allocation [0~1], + ├ userData [0~1], + ├ prefix [0~1], + ├ builtin_controllers_sender_thread [threadSettingsType], + ├ timed_events_thread [threadSettingsType], + ├ discovery_server_thread [threadSettingsType], + ├ builtin_transports_reception_threads [threadSettingsType], + └ security_log_thread [threadSettingsType]--> @@ -145,6 +167,11 @@ + + + + + @@ -805,33 +832,36 @@ + ├ transport_id [string], + ├ type [string] ("UDPv4", "UDPv6", "TCPv4", "TCPv6", "SHM"), + ├ sendBufferSize [uint32], + ├ receiveBufferSize [uint32], + ├ maxMessageSize [uint32], + ├ maxInitialPeersRange [uint32], + ├ interfaceWhiteList [0~*], (NOT available for SHM type) + | └ address [ipv4Address|ipv6Address] + ├ TTL [uint8], (ONLY available for UDP type) + ├ non_blocking_send [boolean], (ONLY available for UDP type) + ├ output_port [uint16], (ONLY available for UDP type) + ├ wan_addr [ipv4AddressFormat], (ONLY available for TCPv4 type) + ├ keep_alive_frequency_ms [uint32], (ONLY available for TCP type) + ├ keep_alive_timeout_ms [uint32], (ONLY available for TCP type) + ├ max_logical_port [uint16], (ONLY available for TCP type) + ├ logical_port_range [uint16], (ONLY available for TCP type) + ├ logical_port_increment [uint16], (ONLY available for TCP type) + ├ listening_ports [0~*], (ONLY available for TCP type) + | └ port [uint16] (ONLY available for TCP type) + ├ tls [0~1], (ONLY available for TCP type) + ├ calculate_crc [bool], (ONLY available for TCP type) + ├ check_crc [bool], (ONLY available for TCP type) + ├ enable_tcp_nodelay [bool], (ONLY available for TCP type) + ├ segment_size [uint32], (ONLY available for SHM type) + ├ port_queue_capacity [uint32], (ONLY available for SHM type) + ├ healthy_check_timeout_ms [uint32], (ONLY available for SHM type) + ├ rtps_dump_file [string] (ONLY available for SHM type) + ├ default_reception_threads [threadSettingsType] + ├ reception_threads [receptionThreadsListType] (ONLY available for SHM type) + └ dump_thread [threadSettingsType] (ONLY available for SHM type) --> @@ -886,6 +916,9 @@ + + + @@ -1078,6 +1111,18 @@ + + + + + + + + + @@ -1153,7 +1197,6 @@ - @@ -1331,11 +1374,12 @@ + ├ kind [string] ("AUTOMATIC", "ON", "OFF"), + ├ shared_dir [string], + ├ domain_ids [0~*], + | └ domainID [uint32] + ├ max_domains [uint32] + └ data_sharing_listener_thread [0~1]--> @@ -1351,11 +1395,12 @@ - + + @@ -1429,13 +1474,11 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -1818,6 +1899,16 @@ + + + + + + + + + + diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index f21d339f7c2..377e40012d1 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -159,7 +159,7 @@ ReturnCode_t DataReaderImpl::enable() att.matched_writers_allocation = qos_.reader_resource_limits().matched_publisher_allocation; att.expectsInlineQos = qos_.expects_inline_qos(); att.disable_positive_acks = qos_.reliable_reader_qos().disable_positive_ACKs.enabled; - att.data_sharing_listener_thread = qos_.data_sharing_listener_thread(); + att.data_sharing_listener_thread = qos_.data_sharing().data_sharing_listener_thread(); // TODO(Ricardo) Remove in future // Insert topic_name and partitions @@ -1565,7 +1565,7 @@ bool DataReaderImpl::can_qos_be_updated( EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Positive ACKs QoS cannot be changed after the creation of a DataReader."); } - if (!(to.data_sharing_listener_thread() == from.data_sharing_listener_thread())) + if (!(to.data_sharing().data_sharing_listener_thread() == from.data_sharing().data_sharing_listener_thread())) { updatable = false; EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index ed8a32a0ee4..e0d469d6251 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -161,6 +161,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( UDPv4TransportDescriptor descriptor; descriptor.sendBufferSize = m_att.sendSocketBufferSize; descriptor.receiveBufferSize = m_att.listenSocketBufferSize; + descriptor.default_reception_threads(m_att.builtin_transports_reception_threads); if (is_intraprocess_only()) { // Avoid multicast leaving the host for intraprocess-only participants @@ -179,6 +180,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( shm_transport.segment_size(segment_size_udp_equivalent); // Use same default max_message_size on both UDP and SHM shm_transport.max_message_size(descriptor.max_message_size()); + shm_transport.default_reception_threads(m_att.builtin_transports_reception_threads); has_shm_transport_ |= m_network_Factory.RegisterTransport(&shm_transport); } #endif // ifdef SHM_TRANSPORT_BUILTIN diff --git a/src/cpp/rtps/xmlparser/XMLElementParser.cpp b/src/cpp/rtps/xmlparser/XMLElementParser.cpp index b8743d08487..405cdb36162 100644 --- a/src/cpp/rtps/xmlparser/XMLElementParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLElementParser.cpp @@ -14,8 +14,11 @@ // #include +#include +#include #include #include +#include #include #include @@ -2109,10 +2112,25 @@ XMLP_ret XMLParser::getXMLDataSharingQos( /* - - - - + + + + + + + + + + + + + + + + + + + */ @@ -2216,6 +2234,14 @@ XMLP_ret XMLParser::getXMLDataSharingQos( return XMLP_ret::XML_ERROR; } } + else if (strcmp(name, DATA_SHARING_LISTENER_THREAD) == 0) + { + // data_sharing_listener_thread + if (XMLP_ret::XML_OK != getXMLThreadSettings(*p_aux0, data_sharing.data_sharing_listener_thread())) + { + return XMLP_ret::XML_ERROR; + } + } else { EPROSIMA_LOG_ERROR(XMLPARSER, "Invalid element found in 'data_sharing'. Name: " << name); @@ -3718,6 +3744,56 @@ XMLP_ret XMLParser::getXMLUint( return XMLP_ret::XML_OK; } +XMLP_ret XMLParser::getXMLUint( + tinyxml2::XMLElement* elem, + uint64_t* ui64, + uint8_t /*ident*/) +{ + unsigned long int ui = 0u; + if (nullptr == elem || nullptr == ui64) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "nullptr when getXMLUint XML_ERROR!"); + return XMLP_ret::XML_ERROR; + } + + auto to_uint64 = [](const char* str, unsigned long int* value) -> bool + { + // Look for a '-' sign + bool ret = false; + const char minus = '-'; + const char* minus_result = str; + if (nullptr == std::strchr(minus_result, minus)) + { + // Minus not found + ret = true; + } + + if (ret) + { + ret = false; +#ifdef _WIN32 + if (sscanf_s(str, "%lu", value) == 1) +#else + if (sscanf(str, "%lu", value) == 1) +#endif // ifdef _WIN32 + { + // Number found + ret = true; + } + } + return ret; + }; + + std::string text = get_element_text(elem); + if (text.empty() || !to_uint64(text.c_str(), &ui)) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "<" << elem->Value() << "> getXMLUint XML_ERROR!"); + return XMLP_ret::XML_ERROR; + } + *ui64 = static_cast(ui); + return XMLP_ret::XML_OK; +} + XMLP_ret XMLParser::getXMLBool( tinyxml2::XMLElement* elem, bool* b, @@ -4033,6 +4109,65 @@ XMLP_ret XMLParser::getXMLguidPrefix( } +XMLP_ret XMLParser::getXMLDomainParticipantFactoryQos( + tinyxml2::XMLElement& elem, + fastdds::dds::DomainParticipantFactoryQos& qos) +{ + /* + + + + + + + + */ + + std::set tags_present; + + for (tinyxml2::XMLElement* element = elem.FirstChildElement(); element != nullptr; + element = element->NextSiblingElement()) + { + const char* name = element->Name(); + if (tags_present.count(name) != 0) + { + EPROSIMA_LOG_ERROR(XMLPARSER, + "Duplicated element found in 'domainParticipantFactoryQosPoliciesType'. Name: " << name); + return XMLP_ret::XML_ERROR; + } + tags_present.emplace(name); + + if (strcmp(name, ENTITY_FACTORY) == 0) + { + if (XMLP_ret::XML_OK != getXMLEntityFactoryQos(*element, qos.entity_factory())) + { + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, SHM_WATCHDOG_THREAD) == 0) + { + if (XMLP_ret::XML_OK != getXMLThreadSettings(*element, qos.shm_watchdog_thread())) + { + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, FILE_WATCH_THREADS) == 0) + { + if (XMLP_ret::XML_OK != getXMLThreadSettings(*element, qos.file_watch_threads())) + { + return XMLP_ret::XML_ERROR; + } + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, + "Invalid element found into 'domainParticipantFactoryQosPoliciesType'. Name: " << name); + return XMLP_ret::XML_ERROR; + } + } + return XMLP_ret::XML_OK; +} + XMLP_ret XMLParser::getXMLPublisherAttributes( tinyxml2::XMLElement* elem, PublisherAttributes& publisher, @@ -4372,6 +4507,197 @@ XMLP_ret XMLParser::getXMLSubscriberAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLParser::getXMLThreadSettings( + tinyxml2::XMLElement& elem, + fastdds::rtps::ThreadSettings& thread_setting) +{ + /* + + + + + + + + + */ + uint32_t port = 0; + return getXMLThreadSettingsWithPort(elem, thread_setting, + port) != XMLP_ret::XML_ERROR ? XMLP_ret::XML_OK : XMLP_ret::XML_ERROR; +} + +XMLP_ret XMLParser::getXMLThreadSettingsWithPort( + tinyxml2::XMLElement& elem, + fastdds::rtps::ThreadSettings& thread_setting, + uint32_t& port) +{ + /* + + + + + + + + */ + + /* + * The are 4 allowed elements, all their min occurrences are 0, and their max are 1. + * In case port is not present, return NOK instead of ERROR + */ + XMLP_ret ret = XMLP_ret::XML_OK; + bool port_found = false; + for (const tinyxml2::XMLAttribute* attrib = elem.FirstAttribute(); attrib != nullptr; attrib = attrib->Next()) + { + if (strcmp(attrib->Name(), PORT) == 0) + { + try + { + std::string temp = attrib->Value(); + temp.erase(std::remove_if(temp.begin(), temp.end(), [](unsigned char c) + { + return std::isspace(c); + }), temp.end()); + if (attrib->Value()[0] == '-') + { + throw std::invalid_argument("Negative value detected"); + } + port = static_cast(std::stoul(attrib->Value())); + port_found = true; + } + catch (std::invalid_argument& except) + { + EPROSIMA_LOG_ERROR(XMLPARSER, + "Found wrong value " << attrib->Value() << " for port attribute. " << + except.what()); + ret = XMLP_ret::XML_ERROR; + break; + } + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Found wrong attribute " << attrib->Name() << " in 'thread_settings"); + ret = XMLP_ret::XML_ERROR; + break; + } + } + + // Set ret to NOK is port attribute was not present + if (ret == XMLP_ret::XML_OK && !port_found) + { + ret = XMLP_ret::XML_NOK; + } + + const uint8_t ident = 1; + std::set tags_present; + + for (tinyxml2::XMLElement* current_elem = elem.FirstChildElement(); + current_elem != nullptr && ret != XMLP_ret::XML_ERROR; + current_elem = current_elem->NextSiblingElement()) + { + const char* name = current_elem->Name(); + if (tags_present.count(name) != 0) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Duplicated element found in 'thread_settings'. Tag: " << name); + ret = XMLP_ret::XML_ERROR; + break; + } + tags_present.emplace(name); + + if (strcmp(current_elem->Name(), SCHEDULING_POLICY) == 0) + { + // scheduling_policy - int32Type + if (XMLP_ret::XML_OK != getXMLInt(current_elem, &thread_setting.scheduling_policy, ident) || + thread_setting.scheduling_policy < -1) + { + ret = XMLP_ret::XML_ERROR; + break; + } + } + else if (strcmp(current_elem->Name(), PRIORITY) == 0) + { + // priority - int32Type + if (XMLP_ret::XML_OK != getXMLInt(current_elem, &thread_setting.priority, ident)) + { + ret = XMLP_ret::XML_ERROR; + break; + } + } + else if (strcmp(current_elem->Name(), AFFINITY) == 0) + { + // affinity - uint64Type + if (XMLP_ret::XML_OK != getXMLUint(current_elem, &thread_setting.affinity, ident)) + { + ret = XMLP_ret::XML_ERROR; + break; + } + } + else if (strcmp(current_elem->Name(), STACK_SIZE) == 0) + { + // stack_size - int32Type + if (XMLP_ret::XML_OK != getXMLInt(current_elem, &thread_setting.stack_size, ident) || + thread_setting.stack_size < -1) + { + ret = XMLP_ret::XML_ERROR; + break; + } + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Found incorrect tag '" << current_elem->Name() << "'"); + ret = XMLP_ret::XML_ERROR; + break; + } + } + return ret; +} + +XMLP_ret XMLParser::getXMLEntityFactoryQos( + tinyxml2::XMLElement& elem, + fastdds::dds::EntityFactoryQosPolicy& entity_factory) +{ + /* + + + + + + */ + + /* + * The only allowed element is autoenable_created_entities, its min occurrences is 0, and its max is 1. + */ + const uint8_t ident = 1; + std::set tags_present; + + for (tinyxml2::XMLElement* current_elem = elem.FirstChildElement(); current_elem != nullptr; + current_elem = current_elem->NextSiblingElement()) + { + const char* name = current_elem->Name(); + if (tags_present.count(name) != 0) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Duplicated element found in 'entityFactoryQosPolicyType'. Tag: " << name); + return XMLP_ret::XML_ERROR; + } + tags_present.emplace(name); + + if (strcmp(current_elem->Name(), AUTOENABLE_CREATED_ENTITIES) == 0) + { + // autoenable_created_entities - boolean + if (XMLP_ret::XML_OK != getXMLBool(current_elem, &entity_factory.autoenable_created_entities, ident)) + { + return XMLP_ret::XML_ERROR; + } + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Found incorrect tag '" << current_elem->Name() << "'"); + return XMLP_ret::XML_ERROR; + } + } + return XMLP_ret::XML_OK; +} + } // namespace xmlparser } // namespace fastrtps } // namespace eprosima diff --git a/src/cpp/rtps/xmlparser/XMLParser.cpp b/src/cpp/rtps/xmlparser/XMLParser.cpp index 6dd3d7af836..1cab55ce91b 100644 --- a/src/cpp/rtps/xmlparser/XMLParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLParser.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +123,10 @@ XMLP_ret XMLParser::parseXML( root->addChild(std::move(library_node)); } } + else if (strcmp(tag, DOMAINPARTICIPANT_FACTORY) == 0) + { + ret = parseXMLDomainParticipantFactoryProf(node, *root); + } else if (strcmp(tag, PARTICIPANT) == 0) { ret = parseXMLParticipantProf(node, *root); @@ -249,6 +254,11 @@ XMLP_ret XMLParser::parseXMLTransportData( */ + if (XMLP_ret::XML_OK != validateXMLTransportElements(*p_root)) + { + return XMLP_ret::XML_ERROR; + } + tinyxml2::XMLElement* p_aux0 = nullptr; p_aux0 = p_root->FirstChildElement(TRANSPORT_ID); if (nullptr == p_aux0) @@ -361,9 +371,25 @@ XMLP_ret XMLParser::parseXMLTransportData( return XMLP_ret::XML_ERROR; } + ret = parseXMLCommonTransportData(p_root, pDescriptor); + if (ret != XMLP_ret::XML_OK) + { + return ret; + } + + std::shared_ptr temp_1 = + std::dynamic_pointer_cast(pDescriptor); + ret = parseXMLPortBasedTransportData(p_root, temp_1); + if (ret != XMLP_ret::XML_OK) + { + return ret; + } + if (sType != SHM) { - ret = parseXMLCommonTransportData(p_root, pDescriptor); + std::shared_ptr temp_2 = + std::dynamic_pointer_cast(pDescriptor); + ret = parseXMLSocketTransportData(p_root, temp_2); if (ret != XMLP_ret::XML_OK) { return ret; @@ -374,6 +400,53 @@ XMLP_ret XMLParser::parseXMLTransportData( return ret; } +XMLP_ret XMLParser::validateXMLTransportElements( + tinyxml2::XMLElement& p_root) +{ + XMLP_ret ret = XMLP_ret::XML_OK; + for (tinyxml2::XMLElement* p_aux0 = p_root.FirstChildElement(); p_aux0 != nullptr; + p_aux0 = p_aux0->NextSiblingElement()) + { + const char* name = p_aux0->Name(); + if (!(strcmp(name, TRANSPORT_ID) == 0 || + strcmp(name, TYPE) == 0 || + strcmp(name, SEND_BUFFER_SIZE) == 0 || + strcmp(name, RECEIVE_BUFFER_SIZE) == 0 || + strcmp(name, MAX_MESSAGE_SIZE) == 0 || + strcmp(name, MAX_INITIAL_PEERS_RANGE) == 0 || + strcmp(name, WHITE_LIST) == 0 || + strcmp(name, TTL) == 0 || + strcmp(name, NON_BLOCKING_SEND) == 0 || + strcmp(name, UDP_OUTPUT_PORT) == 0 || + strcmp(name, TCP_WAN_ADDR) == 0 || + strcmp(name, KEEP_ALIVE_FREQUENCY) == 0 || + strcmp(name, KEEP_ALIVE_TIMEOUT) == 0 || + strcmp(name, MAX_LOGICAL_PORT) == 0 || + strcmp(name, LOGICAL_PORT_RANGE) == 0 || + strcmp(name, LOGICAL_PORT_INCREMENT) == 0 || + strcmp(name, LISTENING_PORTS) == 0 || + strcmp(name, CALCULATE_CRC) == 0 || + strcmp(name, CHECK_CRC) == 0 || + strcmp(name, ENABLE_TCP_NODELAY) == 0 || + strcmp(name, TLS) == 0 || + strcmp(name, SEGMENT_SIZE) == 0 || + strcmp(name, PORT_QUEUE_CAPACITY) == 0 || + strcmp(name, HEALTHY_CHECK_TIMEOUT_MS) == 0 || + strcmp(name, RTPS_DUMP_FILE) == 0 || + strcmp(name, DEFAULT_RECEPTION_THREADS) == 0 || + strcmp(name, RECEPTION_THREADS) == 0 || + strcmp(name, DUMP_THREAD) == 0 || + strcmp(name, PORT_OVERFLOW_POLICY) == 0 || + strcmp(name, SEGMENT_OVERFLOW_POLICY) == 0)) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Invalid element found into 'transportDescriptorType'. Name: " << name); + ret = XMLP_ret::XML_ERROR; + } + } + + return ret; +} + XMLP_ret XMLParser::parseXMLCommonTransportData( tinyxml2::XMLElement* p_root, sp_transport_t p_transport) @@ -383,28 +456,101 @@ XMLP_ret XMLParser::parseXMLCommonTransportData( - - - - - - - - - - - - - */ + tinyxml2::XMLElement* p_aux0 = nullptr; + const char* name = nullptr; + for (p_aux0 = p_root->FirstChildElement(); p_aux0 != nullptr; p_aux0 = p_aux0->NextSiblingElement()) + { + name = p_aux0->Name(); + if (strcmp(name, MAX_MESSAGE_SIZE) == 0) + { + // maxMessageSize - uint32Type + uint32_t uSize = 0; + if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &uSize, 0)) + { + return XMLP_ret::XML_ERROR; + } + p_transport->maxMessageSize = uSize; + } + else if (strcmp(name, MAX_INITIAL_PEERS_RANGE) == 0) + { + // maxInitialPeersRange - uint32Type + uint32_t uRange = 0; + if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &uRange, 0)) + { + return XMLP_ret::XML_ERROR; + } + p_transport->maxInitialPeersRange = uRange; + } + } + return XMLP_ret::XML_OK; +} - std::shared_ptr pDesc = - std::dynamic_pointer_cast(p_transport); +XMLP_ret XMLParser::parseXMLPortBasedTransportData( + tinyxml2::XMLElement* p_root, + std::shared_ptr p_transport) +{ + /* + + + + + + + */ + tinyxml2::XMLElement* p_aux0 = nullptr; + const char* name = nullptr; + for (p_aux0 = p_root->FirstChildElement(); p_aux0 != nullptr; p_aux0 = p_aux0->NextSiblingElement()) + { + name = p_aux0->Name(); + if (strcmp(name, DEFAULT_RECEPTION_THREADS) == 0) + { + fastdds::rtps::ThreadSettings thread_settings; + if (getXMLThreadSettings(*p_aux0, thread_settings) == XMLP_ret::XML_OK) + { + p_transport->default_reception_threads(thread_settings); + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Incorrect thread settings"); + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, RECEPTION_THREADS) == 0) + { + fastdds::rtps::PortBasedTransportDescriptor::ReceptionThreadsConfigMap reception_threads; + if (parseXMLReceptionThreads(*p_aux0, reception_threads) == XMLP_ret::XML_OK) + { + p_transport->reception_threads(reception_threads); + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Incorrect thread settings"); + return XMLP_ret::XML_ERROR; + } + } + } + return XMLP_ret::XML_OK; +} +XMLP_ret XMLParser::parseXMLSocketTransportData( + tinyxml2::XMLElement* p_root, + std::shared_ptr p_transport) +{ + /* + + + + + + + + + */ tinyxml2::XMLElement* p_aux0 = nullptr; const char* name = nullptr; for (p_aux0 = p_root->FirstChildElement(); p_aux0 != nullptr; p_aux0 = p_aux0->NextSiblingElement()) @@ -418,7 +564,7 @@ XMLP_ret XMLParser::parseXMLCommonTransportData( { return XMLP_ret::XML_ERROR; } - pDesc->sendBufferSize = iSize; + p_transport->sendBufferSize = iSize; } else if (strcmp(name, RECEIVE_BUFFER_SIZE) == 0) { @@ -428,7 +574,7 @@ XMLP_ret XMLParser::parseXMLCommonTransportData( { return XMLP_ret::XML_ERROR; } - pDesc->receiveBufferSize = iSize; + p_transport->receiveBufferSize = iSize; } else if (strcmp(name, TTL) == 0) { @@ -438,27 +584,7 @@ XMLP_ret XMLParser::parseXMLCommonTransportData( { return XMLP_ret::XML_ERROR; } - pDesc->TTL = static_cast(iTTL); - } - else if (strcmp(name, MAX_MESSAGE_SIZE) == 0) - { - // maxMessageSize - uint32Type - uint32_t uSize = 0; - if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &uSize, 0)) - { - return XMLP_ret::XML_ERROR; - } - std::dynamic_pointer_cast(p_transport)->maxMessageSize = uSize; - } - else if (strcmp(name, MAX_INITIAL_PEERS_RANGE) == 0) - { - // maxInitialPeersRange - uint32Type - uint32_t uRange = 0; - if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &uRange, 0)) - { - return XMLP_ret::XML_ERROR; - } - pDesc->maxInitialPeersRange = uRange; + p_transport->TTL = static_cast(iTTL); } else if (strcmp(name, WHITE_LIST) == 0) { @@ -473,7 +599,7 @@ XMLP_ret XMLParser::parseXMLCommonTransportData( std::string text = get_element_text(p_aux1); if (!text.empty()) { - pDesc->interfaceWhiteList.emplace_back(text); + p_transport->interfaceWhiteList.emplace_back(text); } } else @@ -483,26 +609,6 @@ XMLP_ret XMLParser::parseXMLCommonTransportData( } } } - else if (strcmp(name, TCP_WAN_ADDR) == 0 || strcmp(name, UDP_OUTPUT_PORT) == 0 || - strcmp(name, TRANSPORT_ID) == 0 || strcmp(name, TYPE) == 0 || - strcmp(name, KEEP_ALIVE_FREQUENCY) == 0 || strcmp(name, KEEP_ALIVE_TIMEOUT) == 0 || - strcmp(name, MAX_LOGICAL_PORT) == 0 || strcmp(name, LOGICAL_PORT_RANGE) == 0 || - strcmp(name, LOGICAL_PORT_INCREMENT) == 0 || strcmp(name, LISTENING_PORTS) == 0 || - strcmp(name, CALCULATE_CRC) == 0 || strcmp(name, CHECK_CRC) == 0 || - strcmp(name, ENABLE_TCP_NODELAY) == 0 || strcmp(name, TLS) == 0 || - strcmp(name, NON_BLOCKING_SEND) == 0 || - strcmp(name, SEGMENT_SIZE) == 0 || strcmp(name, PORT_QUEUE_CAPACITY) == 0 || - strcmp(name, PORT_OVERFLOW_POLICY) == 0 || strcmp(name, SEGMENT_OVERFLOW_POLICY) == 0 || - strcmp(name, HEALTHY_CHECK_TIMEOUT_MS) == 0 || strcmp(name, HEALTHY_CHECK_TIMEOUT_MS) == 0 || - strcmp(name, RTPS_DUMP_FILE) == 0) - { - // Parsed outside of this method - } - else - { - EPROSIMA_LOG_ERROR(XMLPARSER, "Invalid element found into 'rtpsTransportDescriptorType'. Name: " << name); - return XMLP_ret::XML_ERROR; - } } return XMLP_ret::XML_OK; } @@ -637,20 +743,6 @@ XMLP_ret XMLParser::parseXMLCommonTCPTransportData( return XMLP_ret::XML_ERROR; } } - else if (strcmp(name, TCP_WAN_ADDR) == 0 || strcmp(name, TRANSPORT_ID) == 0 || - strcmp(name, TYPE) == 0 || strcmp(name, SEND_BUFFER_SIZE) == 0 || - strcmp(name, RECEIVE_BUFFER_SIZE) == 0 || strcmp(name, TTL) == 0 || - strcmp(name, MAX_MESSAGE_SIZE) == 0 || strcmp(name, MAX_INITIAL_PEERS_RANGE) == 0 || - strcmp(name, WHITE_LIST) == 0) - { - // Parsed Outside of this method - } - else - { - EPROSIMA_LOG_ERROR(XMLPARSER, - "Invalid element found into 'rtpsTransportDescriptorType'. Name: " << name); - return XMLP_ret::XML_ERROR; - } } } else @@ -675,7 +767,8 @@ XMLP_ret XMLParser::parseXMLCommonSharedMemTransportData( - + + */ @@ -723,36 +816,17 @@ XMLP_ret XMLParser::parseXMLCommonSharedMemTransportData( } transport_descriptor->rtps_dump_file(str); } - else if (strcmp(name, MAX_MESSAGE_SIZE) == 0) + else if (strcmp(name, DUMP_THREAD) == 0) { - // maxMessageSize - uint32Type - uint32_t uSize = 0; - if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &uSize, 0)) + fastdds::rtps::ThreadSettings thread_settings; + if (getXMLThreadSettings(*p_aux0, thread_settings) != XMLP_ret::XML_OK) { + EPROSIMA_LOG_ERROR(XMLPARSER, "Incorrect thread settings"); return XMLP_ret::XML_ERROR; } - transport_descriptor->max_message_size(uSize); - } - else if (strcmp(name, MAX_INITIAL_PEERS_RANGE) == 0) - { - // maxInitialPeersRange - uint32Type - uint32_t uRange = 0; - if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &uRange, 0)) - { - return XMLP_ret::XML_ERROR; - } - transport_descriptor->maxInitialPeersRange = uRange; - } - else if (strcmp(name, TRANSPORT_ID) == 0 || strcmp(name, TYPE) == 0) - { - // Parsed Outside of this method - } - else - { - EPROSIMA_LOG_ERROR(XMLPARSER, - "Invalid element found into 'rtpsTransportDescriptorType'. Name: " << name); - return XMLP_ret::XML_ERROR; + transport_descriptor->dump_thread(thread_settings); } + // Do not parse nor fail on unkown tags; these may be parsed elsewhere } } else @@ -1130,6 +1204,48 @@ XMLP_ret XMLParser::parse_tls_config( return ret; } +XMLP_ret XMLParser::parseXMLReceptionThreads( + tinyxml2::XMLElement& p_root, + fastdds::rtps::PortBasedTransportDescriptor::ReceptionThreadsConfigMap& reception_threads) +{ + /* + + + + + + */ + + /* + * The only allowed element is + */ + XMLP_ret ret = XMLP_ret::XML_OK; + for (tinyxml2::XMLElement* p_element = p_root.FirstChildElement(); p_element != nullptr; + p_element = p_element->NextSiblingElement()) + { + if (strcmp(p_element->Name(), RECEPTION_THREAD) == 0) + { + uint32_t port = 0; + fastdds::rtps::ThreadSettings thread_settings; + ret = getXMLThreadSettingsWithPort(*p_element, thread_settings, port); + if (XMLP_ret::XML_OK != ret || reception_threads.count(port) != 0) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing reception_threads thread settings. Port: " << port); + ret = XMLP_ret::XML_ERROR; + break; + } + reception_threads[port] = thread_settings; + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing reception_threads. Wrong tag: " << p_element->Name()); + ret = XMLP_ret::XML_ERROR; + break; + } + } + return ret; +} + XMLP_ret XMLParser::parseXMLLibrarySettings( tinyxml2::XMLElement* p_root) { @@ -1166,6 +1282,27 @@ XMLP_ret XMLParser::parseXMLLibrarySettings( return ret; } +XMLP_ret XMLParser::parseXMLDomainParticipantFactoryProf( + tinyxml2::XMLElement* p_root, + BaseNode& rootNode) +{ + XMLP_ret ret = XMLP_ret::XML_OK; + up_participantfactory_t factory_qos{new fastdds::dds::DomainParticipantFactoryQos}; + up_node_participantfactory_t factory_node{new node_participantfactory_t{NodeType::DOMAINPARTICIPANT_FACTORY, + std::move(factory_qos)}}; + if (XMLP_ret::XML_OK == fillDataNode(p_root, *factory_node)) + { + rootNode.addChild(std::move(factory_node)); + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing participant profile"); + ret = XMLP_ret::XML_ERROR; + } + + return ret; +} + XMLP_ret XMLParser::parseXMLParticipantProf( tinyxml2::XMLElement* p_root, BaseNode& rootNode) @@ -1317,6 +1454,10 @@ XMLP_ret XMLParser::parseProfiles( { parseOk &= parseXMLLibrarySettings(p_profile) == XMLP_ret::XML_OK; } + else if (strcmp(tag, DOMAINPARTICIPANT_FACTORY) == 0) + { + parseOk &= parseXMLDomainParticipantFactoryProf(p_profile, profilesNode) == XMLP_ret::XML_OK; + } else if (strcmp(tag, PARTICIPANT) == 0) { parseOk &= parseXMLParticipantProf(p_profile, profilesNode) == XMLP_ret::XML_OK; @@ -1384,6 +1525,7 @@ XMLP_ret XMLParser::parseLogConfig( + @@ -1406,11 +1548,24 @@ XMLP_ret XMLParser::parseLogConfig( p_aux0 = p_root; } + std::set tags_present; tinyxml2::XMLElement* p_element = p_aux0->FirstChildElement(); + fastdds::rtps::ThreadSettings thread_settings; + bool set_thread_settings = false; while (ret == XMLP_ret::XML_OK && nullptr != p_element) { + const char* name = p_element->Name(); const char* tag = p_element->Value(); + + // Fail on duplicated not allowed elements + if (strcmp(tag, CONSUMER) != 0 && tags_present.count(name) != 0) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Duplicated element found in 'log'. Tag: " << name); + return XMLP_ret::XML_ERROR; + } + tags_present.emplace(name); + if (nullptr != tag) { if (strcmp(tag, USE_DEFAULT) == 0) @@ -1439,6 +1594,18 @@ XMLP_ret XMLParser::parseLogConfig( { ret = parseXMLConsumer(*p_element); } + else if (strcmp(tag, THREAD_SETTINGS) == 0) + { + ret = getXMLThreadSettings(*p_element, thread_settings); + if (ret == XMLP_ret::XML_OK) + { + set_thread_settings = true; + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Incorrect thread settings"); + } + } else { EPROSIMA_LOG_ERROR(XMLPARSER, "Not expected tag: '" << tag << "'"); @@ -1448,10 +1615,15 @@ XMLP_ret XMLParser::parseLogConfig( if (ret == XMLP_ret::XML_OK) { - p_element = p_element->NextSiblingElement(CONSUMER); + p_element = p_element->NextSiblingElement(); } } + if (ret == XMLP_ret::XML_OK && set_thread_settings) + { + fastdds::dds::Log::SetThreadConfig(thread_settings); + } + return ret; } @@ -1717,6 +1889,54 @@ XMLP_ret XMLParser::fillDataNode( return XMLP_ret::XML_OK; } +XMLP_ret XMLParser::fillDataNode( + tinyxml2::XMLElement* p_profile, + DataNode& factory_node) +{ + /* + + + + + + + + */ + + if (nullptr == p_profile) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Bad parameters!"); + return XMLP_ret::XML_ERROR; + } + + addAllAttributes(p_profile, factory_node); + + /* + * The only allowed element , and its max is 1; look for it. + */ + std::set tags_present; + for (tinyxml2::XMLElement* p_element = p_profile->FirstChildElement(); p_element != nullptr; + p_element = p_element->NextSiblingElement()) + { + const char* name = p_element->Name(); + if (tags_present.count(name) != 0) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Duplicated element found in 'participant'. Tag: " << name); + return XMLP_ret::XML_ERROR; + } + tags_present.emplace(name); + + if (strcmp(p_element->Name(), QOS) == 0) + { + if (XMLP_ret::XML_OK != getXMLDomainParticipantFactoryQos(*p_element, *factory_node.get())) + { + return XMLP_ret::XML_ERROR; + } + } + } + return XMLP_ret::XML_OK; +} + XMLP_ret XMLParser::fillDataNode( tinyxml2::XMLElement* p_profile, DataNode& participant_node) @@ -1961,6 +2181,49 @@ XMLP_ret XMLParser::fillDataNode( } participant_node.get()->rtps.setName(s.c_str()); } + else if (strcmp(name, BUILTIN_CONTROLLERS_SENDER_THREAD) == 0) + { + if (XMLP_ret::XML_OK != + getXMLThreadSettings(*p_aux0, + participant_node.get()->rtps.builtin_controllers_sender_thread)) + { + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, TIMED_EVENTS_THREAD) == 0) + { + if (XMLP_ret::XML_OK != getXMLThreadSettings(*p_aux0, participant_node.get()->rtps.timed_events_thread)) + { + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, DISCOVERY_SERVER_THREAD) == 0) + { + if (XMLP_ret::XML_OK != getXMLThreadSettings(*p_aux0, participant_node.get()->rtps.discovery_server_thread)) + { + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, BUILTIN_TRANSPORTS_RECEPTION_THREADS) == 0) + { + if (XMLP_ret::XML_OK != + getXMLThreadSettings(*p_aux0, + participant_node.get()->rtps.builtin_transports_reception_threads)) + { + return XMLP_ret::XML_ERROR; + } + } + else if (strcmp(name, SECURITY_LOG_THREAD) == 0) + { +#if HAVE_SECURITY + if (XMLP_ret::XML_OK != getXMLThreadSettings(*p_aux0, participant_node.get()->rtps.security_log_thread)) + { + return XMLP_ret::XML_ERROR; + } +#else + EPROSIMA_LOG_WARNING(XMLPARSER, "Ignoring '" << SECURITY_LOG_THREAD << "' since security is disabled"); +#endif // if HAVE_SECURITY + } else { EPROSIMA_LOG_ERROR(XMLPARSER, "Invalid element found into 'rtpsParticipantAttributesType'. Name: " << name); diff --git a/src/cpp/rtps/xmlparser/XMLParserCommon.cpp b/src/cpp/rtps/xmlparser/XMLParserCommon.cpp index 0c4e39bad0a..6baf830e963 100644 --- a/src/cpp/rtps/xmlparser/XMLParserCommon.cpp +++ b/src/cpp/rtps/xmlparser/XMLParserCommon.cpp @@ -29,6 +29,7 @@ const char* LIBRARY_SETTINGS = "library_settings"; const char* TRANSPORT_DESCRIPTORS = "transport_descriptors"; const char* PROFILE_NAME = "profile_name"; const char* DEFAULT_PROF = "is_default_profile"; +const char* DOMAINPARTICIPANT_FACTORY = "domainparticipant_factory"; const char* PARTICIPANT = "participant"; const char* PUBLISHER = "publisher"; const char* SUBSCRIBER = "subscriber"; @@ -67,8 +68,17 @@ const char* HEALTHY_CHECK_TIMEOUT_MS = "healthy_check_timeout_ms"; const char* DISCARD = "DISCARD"; const char* FAIL = "FAIL"; const char* RTPS_DUMP_FILE = "rtps_dump_file"; +const char* DEFAULT_RECEPTION_THREADS = "default_reception_threads"; +const char* RECEPTION_THREADS = "reception_threads"; +const char* RECEPTION_THREAD = "reception_thread"; +const char* DUMP_THREAD = "dump_thread"; const char* ON = "ON"; const char* AUTO = "AUTO"; +const char* THREAD_SETTINGS = "thread_settings"; +const char* SCHEDULING_POLICY = "scheduling_policy"; +const char* PRIORITY = "priority"; +const char* AFFINITY = "affinity"; +const char* STACK_SIZE = "stack_size"; const char* OFF = "OFF"; const char* USER_DATA_ONLY = "USER_DATA_ONLY"; @@ -81,6 +91,12 @@ const char* TYPE = "type"; const char* DATA_WRITER = "data_writer"; const char* DATA_READER = "data_reader"; +/// DomainParticipantFactory Qos +const char* ENTITY_FACTORY = "entity_factory"; +const char* AUTOENABLE_CREATED_ENTITIES = "autoenable_created_entities"; +const char* SHM_WATCHDOG_THREAD = "shm_watchdog_thread"; +const char* FILE_WATCH_THREADS = "file_watch_threads"; + /// RTPS Domain attributes const char* INTRAPROCESS_DELIVERY = "intraprocess_delivery"; @@ -116,6 +132,11 @@ const char* DYNAMIC_LC = "dynamic"; const char* MAX_PROPERTIES = "max_properties"; const char* MAX_USER_DATA = "max_user_data"; const char* MAX_PARTITIONS = "max_partitions"; +const char* TIMED_EVENTS_THREAD = "timed_events_thread"; +const char* DISCOVERY_SERVER_THREAD = "discovery_server_thread"; +const char* SECURITY_LOG_THREAD = "security_log_thread"; +const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS = "builtin_transports_reception_threads"; +const char* BUILTIN_CONTROLLERS_SENDER_THREAD = "builtin_controllers_sender_thread"; /// Publisher-subscriber attributes const char* TOPIC = "topic"; @@ -133,6 +154,7 @@ const char* USER_DEF_ID = "userDefinedID"; const char* ENTITY_ID = "entityID"; const char* MATCHED_SUBSCRIBERS_ALLOCATION = "matchedSubscribersAllocation"; const char* MATCHED_PUBLISHERS_ALLOCATION = "matchedPublishersAllocation"; +const char* DATA_SHARING_LISTENER_THREAD = "data_sharing_listener_thread"; /// const char* IGN_NON_MATCHING_LOCS = "ignore_non_matching_locators"; diff --git a/src/cpp/rtps/xmlparser/XMLProfileManager.cpp b/src/cpp/rtps/xmlparser/XMLProfileManager.cpp index 63b82d858d6..f14c23b0cdf 100644 --- a/src/cpp/rtps/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/rtps/xmlparser/XMLProfileManager.cpp @@ -12,20 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include #include -#include -#include #include #ifdef _WIN32 #include #endif // ifdef _WIN32 +#include + +#include +#include +#include + using namespace eprosima::fastrtps; +using namespace eprosima::fastdds; using namespace ::xmlparser; LibrarySettingsAttributes XMLProfileManager::library_settings_; +std::map XMLProfileManager::participant_factory_profiles_; +dds::DomainParticipantFactoryQos default_participant_factory_qos; std::map XMLProfileManager::participant_profiles_; ParticipantAttributes default_participant_attributes; std::map XMLProfileManager::publisher_profiles_; @@ -149,6 +155,30 @@ void XMLProfileManager::getDefaultPublisherAttributes( publisher_attributes = default_publisher_attributes; } +XMLP_ret XMLProfileManager::fillDomainParticipantFactoryQos( + const std::string& profile_name, + dds::DomainParticipantFactoryQos& qos, + bool log_error) +{ + part_factory_map_iterator_t it = participant_factory_profiles_.find(profile_name); + if (it == participant_factory_profiles_.end()) + { + if (log_error) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); + } + return XMLP_ret::XML_ERROR; + } + qos = *(it->second); + return XMLP_ret::XML_OK; +} + +void XMLProfileManager::getDefaultDomainParticipantFactoryQos( + dds::DomainParticipantFactoryQos& qos) +{ + qos = default_participant_factory_qos; +} + void XMLProfileManager::getDefaultSubscriberAttributes( SubscriberAttributes& subscriber_attributes) { @@ -368,7 +398,18 @@ XMLP_ret XMLProfileManager::extractProfiles( XMLP_ret ret = XMLP_ret::XML_OK; for (auto&& profile: profiles->getChildren()) { - if (NodeType::PARTICIPANT == profile->getType()) + if (NodeType::DOMAINPARTICIPANT_FACTORY == profile->getType()) + { + if (XMLP_ret::XML_OK == extractDomainParticipantFactoryProfile(profile, filename)) + { + ++profile_count; + } + else + { + ret = XMLP_ret::XML_NOK; + } + } + else if (NodeType::PARTICIPANT == profile->getType()) { if (XMLP_ret::XML_OK == extractParticipantProfile(profile, filename)) { @@ -449,6 +490,39 @@ XMLP_ret XMLProfileManager::extractProfiles( return ret; } +XMLP_ret XMLProfileManager::extractDomainParticipantFactoryProfile( + up_base_node_t& profile, + const std::string& filename) +{ + static_cast(filename); + std::string profile_name = ""; + + p_node_participantfactory_t node_factory = dynamic_cast(profile.get()); + node_att_map_cit_t it = node_factory->getAttributes().find(PROFILE_NAME); + if (it == node_factory->getAttributes().end() || it->second.empty()) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); + return XMLP_ret::XML_ERROR; + } + + profile_name = it->second; + + std::pair emplace = participant_factory_profiles_.emplace(profile_name, + node_factory->getData()); + if (false == emplace.second) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); + return XMLP_ret::XML_ERROR; + } + + it = node_factory->getAttributes().find(DEFAULT_PROF); + if (it != node_factory->getAttributes().end() && it->second == "true") // Set as default profile + { + default_participant_factory_qos = *(emplace.first->second.get()); + } + return XMLP_ret::XML_OK; +} + XMLP_ret XMLProfileManager::extractParticipantProfile( up_base_node_t& profile, const std::string& filename) diff --git a/src/cpp/utils/threading/threading_osx.ipp b/src/cpp/utils/threading/threading_osx.ipp index 3131d3642a7..70c7cf817f2 100644 --- a/src/cpp/utils/threading/threading_osx.ipp +++ b/src/cpp/utils/threading/threading_osx.ipp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -76,23 +77,19 @@ static void configure_current_thread_scheduler( // Set Scheduler Class and Priority // - if((sched_class == SCHED_OTHER) || - (sched_class == SCHED_BATCH) || - (sched_class == SCHED_IDLE)) + if(sched_class == SCHED_OTHER) { - // - // BATCH and IDLE do not have explicit priority values. - // - Requires priorty value to be zero (0). - result = pthread_setschedparam(self_tid, sched_class, ¶m); - // // Sched OTHER has a nice value, that we pull from the priority parameter. + // - Requires priorty value to be zero (0). // - - if(sched_class == SCHED_OTHER && change_priority) - { - result = setpriority(PRIO_PROCESS, gettid(), sched_priority); + result = pthread_setschedparam(self_tid, sched_class, ¶m); + if(0 == result && change_priority) + { + uint64_t tid; + pthread_threadid_np(NULL, &tid); + result = setpriority(PRIO_PROCESS, tid, sched_priority); } } else if((sched_class == SCHED_FIFO) || diff --git a/src/cpp/utils/threading/threading_pthread.ipp b/src/cpp/utils/threading/threading_pthread.ipp index 5803c3464e1..e9f1e96b852 100644 --- a/src/cpp/utils/threading/threading_pthread.ipp +++ b/src/cpp/utils/threading/threading_pthread.ipp @@ -95,7 +95,7 @@ static void configure_current_thread_scheduler( // Sched OTHER has a nice value, that we pull from the priority parameter. // - if(sched_class == SCHED_OTHER && change_priority) + if(0 == result && sched_class == SCHED_OTHER && change_priority) { result = setpriority(PRIO_PROCESS, gettid(), sched_priority); } diff --git a/test/mock/rtps/Log/fastdds/dds/log/Log.hpp b/test/mock/rtps/Log/fastdds/dds/log/Log.hpp index 2f9c7dac846..5f84e08fa69 100644 --- a/test/mock/rtps/Log/fastdds/dds/log/Log.hpp +++ b/test/mock/rtps/Log/fastdds/dds/log/Log.hpp @@ -18,8 +18,11 @@ #include #include + #include +#include + /** * eProsima log mock. */ @@ -82,6 +85,13 @@ class Log ClearConsumersFunc(); } + static std::function SetThreadConfigFunc; + static void SetThreadConfig( + rtps::ThreadSettings&) + { + SetThreadConfigFunc(); + } + }; using ::testing::_; @@ -100,6 +110,8 @@ class LogMock MOCK_METHOD1(RegisterConsumer, void(std::unique_ptr&)); MOCK_METHOD0(ClearConsumers, void()); + + MOCK_METHOD(void, SetThreadConfig, ()); }; } // namespace dds diff --git a/test/mock/rtps/SharedMemTransportDescriptor/fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h b/test/mock/rtps/SharedMemTransportDescriptor/fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h index 1f0a7312c9f..21795787fff 100644 --- a/test/mock/rtps/SharedMemTransportDescriptor/fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h +++ b/test/mock/rtps/SharedMemTransportDescriptor/fastdds/rtps/transport/shared_mem/SharedMemTransportDescriptor.h @@ -15,6 +15,10 @@ #ifndef _FASTDDS_SHAREDMEM_TRANSPORT_DESCRIPTOR_ #define _FASTDDS_SHAREDMEM_TRANSPORT_DESCRIPTOR_ +#include +#include + +#include #include namespace eprosima { @@ -106,12 +110,26 @@ typedef struct SharedMemTransportDescriptor : public PortBasedTransportDescripto rtps_dump_file_ = rtps_dump_file; } + //! Return the thread settings for the transport dump thread + RTPS_DllAPI ThreadSettings dump_thread() const + { + return dump_thread_; + } + + //! Set the thread settings for the transport dump thread + RTPS_DllAPI void dump_thread( + const ThreadSettings& dump_thread) + { + dump_thread_ = dump_thread; + } + private: uint32_t segment_size_; uint32_t port_queue_capacity_; uint32_t healthy_check_timeout_ms_; std::string rtps_dump_file_; + ThreadSettings dump_thread_; }SharedMemTransportDescriptor; diff --git a/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml b/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml index c559ea5af1c..9fcda9e5a55 100644 --- a/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml +++ b/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml @@ -749,6 +749,13 @@ TRUE + + + 12 + 12 + 12 + 12 + diff --git a/test/system/tools/xmlvalidation/all_profile.xml b/test/system/tools/xmlvalidation/all_profile.xml index 69fd2a97892..f90f3907d81 100644 --- a/test/system/tools/xmlvalidation/all_profile.xml +++ b/test/system/tools/xmlvalidation/all_profile.xml @@ -1008,6 +1008,13 @@ true + + + -1 + 0 + 0 + -1 + diff --git a/test/unittest/dds/profiles/test_xml_for_string_profile.xml b/test/unittest/dds/profiles/test_xml_for_string_profile.xml index 29d35118097..b5b33707d20 100644 --- a/test/unittest/dds/profiles/test_xml_for_string_profile.xml +++ b/test/unittest/dds/profiles/test_xml_for_string_profile.xml @@ -126,6 +126,36 @@ 66 true test_name + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + @@ -251,6 +281,36 @@ 99 true default_name + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + diff --git a/test/unittest/dds/profiles/test_xml_profile.xml b/test/unittest/dds/profiles/test_xml_profile.xml index 02b00ad4426..a0c59ac24d7 100644 --- a/test/unittest/dds/profiles/test_xml_profile.xml +++ b/test/unittest/dds/profiles/test_xml_profile.xml @@ -123,6 +123,36 @@ 66 true test_name + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + @@ -248,6 +278,36 @@ 99 true default_name + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 0cf8b1a1273..ea56aa958a3 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -3632,14 +3632,14 @@ TEST_F(DataReaderTests, UpdateInmutableQos) reader_qos.data_sharing().add_domain_id(static_cast(12)); ASSERT_EQ(ReturnCode_t::RETCODE_IMMUTABLE_POLICY, data_reader->set_qos(reader_qos)); - // Unique network flows reader_qos = DATAREADER_QOS_DEFAULT; - reader_qos.properties().properties().push_back({"fastdds.unique_network_flows", "true"}); + reader_qos.data_sharing().data_sharing_listener_thread().priority = + reader_qos.data_sharing().data_sharing_listener_thread().priority + 1; ASSERT_EQ(ReturnCode_t::RETCODE_IMMUTABLE_POLICY, data_reader->set_qos(reader_qos)); - // Datasharing listener thread + // Unique network flows reader_qos = DATAREADER_QOS_DEFAULT; - reader_qos.data_sharing_listener_thread().priority = reader_qos.data_sharing_listener_thread().priority + 1; + reader_qos.properties().properties().push_back({"fastdds.unique_network_flows", "true"}); ASSERT_EQ(ReturnCode_t::RETCODE_IMMUTABLE_POLICY, data_reader->set_qos(reader_qos)); /* Cleanup */ diff --git a/test/unittest/rtps/builtin/CMakeLists.txt b/test/unittest/rtps/builtin/CMakeLists.txt index abaef6fe2af..3876d83c195 100644 --- a/test/unittest/rtps/builtin/CMakeLists.txt +++ b/test/unittest/rtps/builtin/CMakeLists.txt @@ -13,53 +13,51 @@ # limitations under the License. set(BUILTIN_DATA_SERIALIZATION_TESTS_SOURCE BuiltinDataSerializationTests.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp - - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ReaderProxyData.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/WriterProxyData.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp - - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicData.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicDataFactory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicType.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicPubSubType.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypePtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicDataPtr.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicPubSubType.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilder.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderPtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderPtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeMember.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypePtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/MemberDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeIdentifier.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeIdentifierTypes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeNamesGenerator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObject.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObjectFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObjectHashId.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeNamesGenerator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypesBase.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp - + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ReaderProxyData.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/WriterProxyData.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/resources/ResourceEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.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/TimedConditionVariable.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) + ) if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 240e9f0223d..08f9df15cbb 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -13,42 +13,43 @@ # limitations under the License. set(EDPTESTS_SOURCE EdpTests.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicData.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicDataFactory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicType.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicPubSubType.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypePtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicDataPtr.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicPubSubType.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilder.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderPtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderPtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeMember.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypePtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/MemberDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeIdentifier.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeIdentifierTypes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeNamesGenerator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObject.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObjectFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObjectHashId.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeNamesGenerator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypesBase.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDP.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/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/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ) diff --git a/test/unittest/rtps/network/CMakeLists.txt b/test/unittest/rtps/network/CMakeLists.txt index baaac1b52a9..8dcbf6f8688 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/CMakeLists.txt @@ -97,46 +97,42 @@ if(QNX) endif() add_executable(ExternalLocatorsProcessorTests ExternalLocatorsProcessorTests.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicData.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicDataFactory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicType.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicPubSubType.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypePtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicDataPtr.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicPubSubType.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilder.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderPtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeBuilderPtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypeMember.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/DynamicTypePtr.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/MemberDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeIdentifier.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeIdentifierTypes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeNamesGenerator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObject.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObjectFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeObjectHashId.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypeNamesGenerator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/TypesBase.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp - + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.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/network/ExternalLocatorsProcessor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp - - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ) target_compile_definitions(ExternalLocatorsProcessorTests PRIVATE BOOST_ASIO_STANDALONE diff --git a/test/unittest/xmlparser/SHM_transport_descriptors_config_profile.xml b/test/unittest/xmlparser/SHM_transport_descriptors_config_profile.xml index c73fda0779d..a079f97229b 100644 --- a/test/unittest/xmlparser/SHM_transport_descriptors_config_profile.xml +++ b/test/unittest/xmlparser/SHM_transport_descriptors_config_profile.xml @@ -10,6 +10,32 @@ 4294967295 test_file.dump 128000 + + -1 + 0 + 0 + -1 + + + + -1 + 0 + 0 + -1 + + + -1 + 0 + 0 + -1 + + + + -1 + 0 + 0 + -1 + diff --git a/test/unittest/xmlparser/UDP_transport_descriptors_config_profile.xml b/test/unittest/xmlparser/UDP_transport_descriptors_config_profile.xml index 0b58e2a1a0f..e76c68ca781 100644 --- a/test/unittest/xmlparser/UDP_transport_descriptors_config_profile.xml +++ b/test/unittest/xmlparser/UDP_transport_descriptors_config_profile.xml @@ -1,22 +1,42 @@ - - - Test - UDPv4 - 8192 - 8192 - 250 - true - 16384 - 100 - -
192.168.1.41
-
127.0.0.1
-
- 5101 -
-
+ + + Test + UDPv4 + 8192 + 8192 + 250 + true + 16384 + 100 + +
192.168.1.41
+
127.0.0.1
+
+ 5101 + + -1 + 0 + 0 + -1 + + + + -1 + 0 + 0 + -1 + + + -1 + 0 + 0 + -1 + + +
+
diff --git a/test/unittest/xmlparser/XMLElementParserTests.cpp b/test/unittest/xmlparser/XMLElementParserTests.cpp index 693f52a6c9b..f28768dfdf6 100644 --- a/test/unittest/xmlparser/XMLElementParserTests.cpp +++ b/test/unittest/xmlparser/XMLElementParserTests.cpp @@ -16,11 +16,16 @@ #include #include #include +#include +#include #include +#include +#include #include #include +#include #include #include #include @@ -1279,6 +1284,7 @@ TEST_F(XMLParserTests, getXMLUint_NegativeClauses) uint8_t ident = 1; unsigned int ui; uint16_t ui16; + uint64_t ui64; tinyxml2::XMLDocument xml_doc; tinyxml2::XMLElement* titleElement; @@ -1293,6 +1299,12 @@ TEST_F(XMLParserTests, getXMLUint_NegativeClauses) ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse("not_an_uint")); titleElement = xml_doc.RootElement(); EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLUint_wrapper(titleElement, &ui16, ident)); + + EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLUint_wrapper(nullptr, &ui64, ident)); + + ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse("not_an_uint")); + titleElement = xml_doc.RootElement(); + EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::getXMLUint_wrapper(titleElement, &ui64, ident)); } /* @@ -4112,3 +4124,206 @@ TEST_F(XMLParserTests, env_var_substitution) clear_environment_variable(env_var_1); clear_environment_variable(env_var_2); } + +/* + * This test checks parsing of thread_settings elements. + */ +TEST_F(XMLParserTests, getXMLThreadSettings) +{ + /* Define the test cases */ + std::vector, XMLP_ret>> test_cases = + { + {{"12", "12", "12", "12", ""}, XMLP_ret::XML_OK}, + {{"-1", "12", "12", "12", ""}, XMLP_ret::XML_OK}, + {{"12", "-1", "12", "12", ""}, XMLP_ret::XML_OK}, + {{"12", "12", "12", "-1", ""}, XMLP_ret::XML_OK}, + {{"-2", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12", "12", "-2", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "-2", ""}, XMLP_ret::XML_ERROR}, + {{"a", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12", "a", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12", "12", "a", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "a", ""}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + {{"12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + }; + + /* Run the tests */ + for (auto test_case : test_cases) + { + std::vector& params = test_case.first; + XMLP_ret& expectation = test_case.second; + + using namespace eprosima::fastdds::rtps; + ThreadSettings thread_settings; + tinyxml2::XMLDocument xml_doc; + tinyxml2::XMLElement* titleElement; + + // Create XML snippet + std::string xml = + "" + " " + params[0] + "" + " " + params[1] + "" + " " + params[2] + "" + " " + params[3] + "" + + params[4] + + ""; + + // Parse the XML snippet + ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml.c_str())) << xml; + + // Extract ThreadSetting + titleElement = xml_doc.RootElement(); + ASSERT_EQ(expectation, XMLParserTest::getXMLThreadSettings_wrapper(titleElement, thread_settings)); + + // Validate in the OK cases + if (expectation == XMLP_ret::XML_OK) + { + ASSERT_EQ(thread_settings.scheduling_policy, static_cast(std::stoi(params[0]))); + ASSERT_EQ(thread_settings.priority, static_cast(std::stoi(params[1]))); + ASSERT_EQ(thread_settings.affinity, static_cast(std::stoi(params[2]))); + ASSERT_EQ(thread_settings.stack_size, static_cast(std::stoi(params[3]))); + } + } +} + +/* + * This test checks parsing of thread_settings with port elements. + */ +TEST_F(XMLParserTests, getXMLThreadSettingsWithPort) +{ + /* Define the test cases */ + std::vector, XMLP_ret>> test_cases = + { + {{"12345", "", "12", "12", "12", "12", ""}, XMLP_ret::XML_OK}, + {{"12345", "", "-1", "12", "12", "12", ""}, XMLP_ret::XML_OK}, + {{"12345", "", "12", "-1", "12", "12", ""}, XMLP_ret::XML_OK}, + {{"12345", "", "12", "12", "12", "-1", ""}, XMLP_ret::XML_OK}, + {{"12345", "", "-2", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"-1", "", "12", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"a", "", "12", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"a", "wrong_attr=\"12\"", "12", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12345", "", "12", "12", "12", "-2", ""}, XMLP_ret::XML_ERROR}, + {{"12345", "", "a", "12", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12345", "", "12", "a", "12", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12345", "", "12", "12", "a", "12", ""}, XMLP_ret::XML_ERROR}, + {{"12345", "", "12", "12", "12", "a", ""}, XMLP_ret::XML_ERROR}, + {{"12345", "", "12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + {{"12345", "", "12", "12", "12", "12", "12"}, XMLP_ret::XML_ERROR}, + }; + + /* Run the tests */ + for (auto test_case : test_cases) + { + std::vector& params = test_case.first; + XMLP_ret& expectation = test_case.second; + + using namespace eprosima::fastdds::rtps; + ThreadSettings thread_settings; + tinyxml2::XMLDocument xml_doc; + tinyxml2::XMLElement* titleElement; + + // Create XML snippet + std::string xml = + "" + " " + params[2] + "" + " " + params[3] + "" + " " + params[4] + "" + " " + params[5] + "" + + params[6] + + ""; + + // Parse the XML snippet + ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml.c_str())) << xml; + + // Extract ThreadSetting + titleElement = xml_doc.RootElement(); + uint32_t port; + ASSERT_EQ(expectation, + XMLParserTest::getXMLThreadSettingsWithPort_wrapper(titleElement, thread_settings, port)); + + // Validate in the OK cases + if (expectation == XMLP_ret::XML_OK) + { + ASSERT_EQ(port, static_cast(std::stoi(params[0]))); + ASSERT_EQ(thread_settings.scheduling_policy, static_cast(std::stoi(params[2]))); + ASSERT_EQ(thread_settings.priority, static_cast(std::stoi(params[3]))); + ASSERT_EQ(thread_settings.affinity, static_cast(std::stoi(params[4]))); + ASSERT_EQ(thread_settings.stack_size, static_cast(std::stoi(params[5]))); + } + } +} + +/* + * This test checks parsing of entity factory qos elements. + */ +TEST_F(XMLParserTests, getXMLEntityFactoryQos) +{ + /* Define the test cases */ + std::vector, XMLP_ret>> test_cases = + { + {{"true", ""}, XMLP_ret::XML_OK}, + {{"false", ""}, XMLP_ret::XML_OK}, + {{"0", ""}, XMLP_ret::XML_OK}, + {{"1", ""}, XMLP_ret::XML_OK}, + {{"20", ""}, XMLP_ret::XML_OK}, + {{"wrong_value", ""}, XMLP_ret::XML_ERROR} + }; + + /* Run the tests */ + for (auto test_case : test_cases) + { + std::vector& params = test_case.first; + XMLP_ret& expectation = test_case.second; + + using namespace eprosima::fastdds::dds; + EntityFactoryQosPolicy entity_factory_qos; + tinyxml2::XMLDocument xml_doc; + tinyxml2::XMLElement* titleElement; + + // Create XML snippet + std::string xml = + "" + " " + params[0] + "" + + params[1] + + ""; + + std::cout << xml << std::endl; + + // Parse the XML snippet + ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml.c_str())); + + // Extract ThreadSetting + titleElement = xml_doc.RootElement(); + ASSERT_EQ(expectation, XMLParserTest::getXMLEntityFactoryQos_wrapper(titleElement, entity_factory_qos)); + + // Validate in the OK cases + if (expectation == XMLP_ret::XML_OK) + { + bool expected_value; + if (params[0] == "true") + { + expected_value = true; + } + else if (params[0] == "false") + { + expected_value = false; + } + else + { + try + { + expected_value = static_cast(std::stoi(params[0])); + } + catch (std::invalid_argument&) + { + expected_value = false; + } + } + ASSERT_EQ(entity_factory_qos.autoenable_created_entities, expected_value); + } + } +} diff --git a/test/unittest/xmlparser/XMLParserTests.cpp b/test/unittest/xmlparser/XMLParserTests.cpp index dfe1eba3b12..c0de0941cce 100644 --- a/test/unittest/xmlparser/XMLParserTests.cpp +++ b/test/unittest/xmlparser/XMLParserTests.cpp @@ -12,30 +12,34 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "XMLParserTests.hpp" + +#include +#include + +#include #include #include -#include #include #include -#include "../logging/mock/MockConsumer.h" -#include "XMLParserTests.hpp" -#include "wrapper/XMLParserTest.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include + #include -#include -#include +#include "../logging/mock/MockConsumer.h" +#include "wrapper/XMLParserTest.hpp" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -860,6 +864,12 @@ TEST_F(XMLParserTests, loadXMLProfiles) */ TEST_F(XMLParserTests, parseXMLTransportData) { + eprosima::fastdds::rtps::ThreadSettings modified_thread_settings; + modified_thread_settings.scheduling_policy = 12; + modified_thread_settings.priority = 12; + modified_thread_settings.affinity = 12; + modified_thread_settings.stack_size = 12; + // Test UDPv4 and UDPv6 { tinyxml2::XMLDocument xml_doc; @@ -899,9 +909,29 @@ TEST_F(XMLParserTests, parseXMLTransportData) 512\ 1000\ rtsp_messages.log\ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ \ "; - constexpr size_t xml_len {2000}; + constexpr size_t xml_len {3000}; char xml[xml_len]; // UDPv4 @@ -921,6 +951,9 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pUDPv4Desc->interfaceWhiteList[0], "192.168.1.41"); EXPECT_EQ(pUDPv4Desc->interfaceWhiteList[1], "127.0.0.1"); EXPECT_EQ(pUDPv4Desc->m_output_udp_socket, 5101u); + EXPECT_EQ(pUDPv4Desc->default_reception_threads(), modified_thread_settings); + EXPECT_EQ(pUDPv4Desc->get_thread_config_for_port(12345), modified_thread_settings); + EXPECT_EQ(pUDPv4Desc->get_thread_config_for_port(12346), modified_thread_settings); xmlparser::XMLProfileManager::DeleteInstance(); @@ -941,6 +974,9 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pUDPv6Desc->interfaceWhiteList[0], "192.168.1.41"); EXPECT_EQ(pUDPv6Desc->interfaceWhiteList[1], "127.0.0.1"); EXPECT_EQ(pUDPv6Desc->m_output_udp_socket, 5101u); + EXPECT_EQ(pUDPv6Desc->default_reception_threads(), modified_thread_settings); + EXPECT_EQ(pUDPv6Desc->get_thread_config_for_port(12345), modified_thread_settings); + EXPECT_EQ(pUDPv6Desc->get_thread_config_for_port(12346), modified_thread_settings); xmlparser::XMLProfileManager::DeleteInstance(); } @@ -977,9 +1013,29 @@ TEST_F(XMLParserTests, parseXMLTransportData) false\ false\ \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ \ "; - constexpr size_t xml_len {2000}; + constexpr size_t xml_len {3000}; char xml[xml_len]; // TCPv4 @@ -1009,6 +1065,9 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pTCPv4Desc->logical_port_increment, 2u); EXPECT_EQ(pTCPv4Desc->listening_ports[0], 5100u); EXPECT_EQ(pTCPv4Desc->listening_ports[1], 5200u); + EXPECT_EQ(pTCPv4Desc->default_reception_threads(), modified_thread_settings); + EXPECT_EQ(pTCPv4Desc->get_thread_config_for_port(12345), modified_thread_settings); + EXPECT_EQ(pTCPv4Desc->get_thread_config_for_port(12346), modified_thread_settings); xmlparser::XMLProfileManager::DeleteInstance(); // TCPv6 @@ -1034,6 +1093,9 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pTCPv6Desc->logical_port_increment, 2u); EXPECT_EQ(pTCPv6Desc->listening_ports[0], 5100u); EXPECT_EQ(pTCPv6Desc->listening_ports[1], 5200u); + EXPECT_EQ(pTCPv6Desc->default_reception_threads(), modified_thread_settings); + EXPECT_EQ(pTCPv6Desc->get_thread_config_for_port(12345), modified_thread_settings); + EXPECT_EQ(pTCPv6Desc->get_thread_config_for_port(12346), modified_thread_settings); xmlparser::XMLProfileManager::DeleteInstance(); } @@ -1053,6 +1115,32 @@ TEST_F(XMLParserTests, parseXMLTransportData) rtsp_messages.log\ 16384\ 100\ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ + \ + \ + 12\ + 12\ + 12\ + 12\ + \ \ "; @@ -1068,6 +1156,10 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pSHMDesc->rtps_dump_file(), "rtsp_messages.log"); EXPECT_EQ(pSHMDesc->max_message_size(), 16384u); EXPECT_EQ(pSHMDesc->max_initial_peers_range(), 100u); + EXPECT_EQ(pSHMDesc->default_reception_threads(), modified_thread_settings); + EXPECT_EQ(pSHMDesc->get_thread_config_for_port(12345), modified_thread_settings); + EXPECT_EQ(pSHMDesc->get_thread_config_for_port(12346), modified_thread_settings); + EXPECT_EQ(pSHMDesc->dump_thread(), modified_thread_settings); xmlparser::XMLProfileManager::DeleteInstance(); } @@ -1098,6 +1190,8 @@ TEST_F(XMLParserTests, parseXMLTransportData_NegativeClauses) "non_blocking_send", "interfaceWhiteList", "output_port", + "default_reception_threads", + "reception_threads", "bad_element" }; @@ -1108,9 +1202,7 @@ TEST_F(XMLParserTests, parseXMLTransportData_NegativeClauses) "sendBufferSize", "receiveBufferSize", "TTL", - "non_blocking_send", "interfaceWhiteList", - "output_port", "keep_alive_frequency_ms", "keep_alive_timeout_ms", "max_logical_port", @@ -1120,6 +1212,8 @@ TEST_F(XMLParserTests, parseXMLTransportData_NegativeClauses) "check_crc", "enable_tcp_nodelay", "tls", + "default_reception_threads", + "reception_threads", "bad_element" }; @@ -1131,6 +1225,9 @@ TEST_F(XMLParserTests, parseXMLTransportData_NegativeClauses) "port_queue_capacity", "healthy_check_timeout_ms", "rtps_dump_file", + "default_reception_threads", + "reception_threads", + "dump_thread", "bad_element" }; @@ -1558,7 +1655,7 @@ TEST_F(XMLParserTests, parseXMLConsumerNegativeClauses) /* * This test checks the return of the parseLogConfig method. - * 1. Check a consummer with a wrong class + * 1. Check a consumer with a wrong class * 2. Check the use_default tag without TRUE and TRUE * 3. Check a wrong tag */ @@ -2878,6 +2975,146 @@ TEST_F(XMLParserTests, parseXMLTopicDataNegativeClauses) EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParserTest::parseXMLTopicData_wrapper(nullptr, *topic_node)); } +/* + * This test checks the behaviour of the parseXMLReceptionThreads function. + */ +TEST_F(XMLParserTests, parseXMLReceptionThreads) +{ + using namespace eprosima::fastdds::rtps; + + struct TestCase + { + std::string title; + std::string xml; + xmlparser::XMLP_ret result; + PortBasedTransportDescriptor::ReceptionThreadsConfigMap threads_config; + }; + + ThreadSettings modified_thread_settings; + modified_thread_settings.scheduling_policy = 12; + modified_thread_settings.priority = 12; + modified_thread_settings.affinity = 12; + modified_thread_settings.stack_size = 12; + + + std::vector test_cases = + { + { + "reception_threads_empty", + "", + xmlparser::XMLP_ret::XML_OK, + {} + }, + { + "reception_threads_ok", + R"( + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + )", + xmlparser::XMLP_ret::XML_OK, + { + {12345, {modified_thread_settings}}, + {12346, {modified_thread_settings}} + } + }, + { + "reception_threads_duplicated", + R"( + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + )", + xmlparser::XMLP_ret::XML_ERROR, + {} + }, + { + "reception_threads_wrong_tags", + R"( + + + 12 + 12 + 12 + 12 + + )", + xmlparser::XMLP_ret::XML_ERROR, + {} + }, + { + "reception_threads_wrong_attribute", + R"( + + + 12 + 12 + 12 + 12 + + )", + xmlparser::XMLP_ret::XML_ERROR, + {} + }, + { + "reception_threads_no_attribute", + R"( + + + 12 + 12 + 12 + 12 + + )", + xmlparser::XMLP_ret::XML_ERROR, + {} + }, + }; + + for (auto test_case : test_cases) + { + tinyxml2::XMLDocument xml_doc; + std::unique_ptr root; + tinyxml2::XMLElement* titleElement; + PortBasedTransportDescriptor::ReceptionThreadsConfigMap reception_threads; + + ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, + xml_doc.Parse(test_case.xml.c_str())) << "test_case = [" << test_case.title << "]"; + + titleElement = xml_doc.RootElement(); + EXPECT_EQ(test_case.result, XMLParserTest::parseXMLReceptionThreads_wrapper(*titleElement, reception_threads)); + + if (test_case.result == xmlparser::XMLP_ret::XML_OK) + { + for (auto entry : test_case.threads_config) + { + EXPECT_EQ(entry.second, reception_threads[entry.first]); + } + } + } +} + int main( int argc, char** argv) diff --git a/test/unittest/xmlparser/XMLProfileParserTests.cpp b/test/unittest/xmlparser/XMLProfileParserTests.cpp index 39e617a6fa0..5947a466e5f 100644 --- a/test/unittest/xmlparser/XMLProfileParserTests.cpp +++ b/test/unittest/xmlparser/XMLProfileParserTests.cpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -57,8 +59,14 @@ void TestClearConsumersFunc() log_mock->ClearConsumers(); } +void TestSetThreadConfigFunc() +{ + log_mock->SetThreadConfig(); +} + std::function&&)> Log::RegisterConsumerFunc = TestRegisterConsumerFunc; std::function Log::ClearConsumersFunc = TestClearConsumersFunc; +std::function Log::SetThreadConfigFunc = TestSetThreadConfigFunc; class XMLProfileParserBasicTests : public ::testing::Test { @@ -122,7 +130,7 @@ class XMLProfileParserTests : public XMLProfileParserBasicTests, public testing: std::string xml_filename_ = "test_xml_profile.xml"; - const std::pair c_environment_values_[156] + const std::pair c_environment_values_[161] { {"XML_PROFILES_ENV_VAR_1", "123"}, {"XML_PROFILES_ENV_VAR_2", "4"}, @@ -279,7 +287,12 @@ class XMLProfileParserTests : public XMLProfileParserBasicTests, public testing: {"XML_PROFILES_ENV_VAR_153", "0"}, {"XML_PROFILES_ENV_VAR_154", "KEEP_ALL"}, {"XML_PROFILES_ENV_VAR_155", "1001"}, - {"XML_PROFILES_ENV_VAR_156", "FULL"} + {"XML_PROFILES_ENV_VAR_156", "FULL"}, + {"XML_PROFILES_ENV_VAR_157", "true"}, + {"XML_PROFILES_ENV_VAR_158", "-1"}, + {"XML_PROFILES_ENV_VAR_159", "0"}, + {"XML_PROFILES_ENV_VAR_160", "0"}, + {"XML_PROFILES_ENV_VAR_161", "-1"} }; }; @@ -1638,6 +1651,7 @@ TEST_F(XMLProfileParserBasicTests, file_and_default) using namespace eprosima::fastdds::dds; EXPECT_CALL(*log_mock, RegisterConsumer(IsFileConsumer())).Times(1); + EXPECT_CALL(*log_mock, SetThreadConfig()).Times(1); xmlparser::XMLProfileManager::loadXMLFile("log_def_file_profile.xml"); } @@ -3188,6 +3202,905 @@ TEST_F(XMLProfileParserBasicTests, external_locators_feature) } } +/** + * This test checks positive and negative cases for parsing of ThreadSettings in Log + */ +TEST_F(XMLProfileParserBasicTests, log_thread_settings_qos) +{ + struct TestCase + { + std::string title; + std::string xml; + xmlparser::XMLP_ret result; + }; + + std::vector test_cases = + { + /* Log test cases */ + { + "log_thread_settings_ok", + R"( + + + + + -1 + 0 + 0 + -1 + + + )", + xmlparser::XMLP_ret::XML_OK + }, + { + "log_thread_settings_duplicate", + R"( + + + + + -1 + 0 + 0 + -1 + + + -1 + 0 + 0 + -1 + + + )", + xmlparser::XMLP_ret::XML_ERROR + }, + { + "log_thread_settings_wrong", + R"( + + + + + -1 + 0 + 0 + -1 + 0 + + + )", + xmlparser::XMLP_ret::XML_ERROR + }, + }; + + EXPECT_CALL(*log_mock, SetThreadConfig()).Times(1); + for (const TestCase& test : test_cases) + { + EXPECT_EQ(test.result, xmlparser::XMLProfileManager::loadXMLString(test.xml.c_str(), test.xml.length())) << + " test_case = [" << test.title << "]"; + xmlparser::XMLProfileManager::DeleteInstance(); + } +} + +/** + * This test checks positive and negative cases for parsing of DomainParticipantFactory Qos + */ +TEST_F(XMLProfileParserBasicTests, domainparticipantfactory) +{ + using namespace eprosima::fastdds::dds; + using namespace eprosima::fastdds::rtps; + struct TestCase + { + std::string title; + std::string xml; + xmlparser::XMLP_ret result; + EntityFactoryQosPolicy entity_factory; + ThreadSettings shm_watchdog_thread; + ThreadSettings file_watch_threads; + }; + + ThreadSettings default_thread_settings; + ThreadSettings modified_thread_settings; + modified_thread_settings.scheduling_policy = 12; + modified_thread_settings.priority = 12; + modified_thread_settings.affinity = 12; + modified_thread_settings.stack_size = 12; + + std::vector test_cases = + { + /* DomainParticipantFactory cases */ + { + "entity_factory_ok", + R"( + + + + + + + false + + + + + )", + xmlparser::XMLP_ret::XML_OK, + EntityFactoryQosPolicy(false), + default_thread_settings, + default_thread_settings + }, + { + "shm_watchdog_thread_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + EntityFactoryQosPolicy(true), + modified_thread_settings, + default_thread_settings + }, + { + "file_watch_threads_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + EntityFactoryQosPolicy(true), + default_thread_settings, + modified_thread_settings + }, + { + "all_present_ok", + R"( + + + + + + + false + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + EntityFactoryQosPolicy(false), + modified_thread_settings, + modified_thread_settings + }, + { + "qos_duplicated", + R"( + + + + + + + false + + + + + false + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + default_thread_settings, + default_thread_settings + }, + { + "entity_factory_wrong_tag", + R"( + + + + + + + false + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + default_thread_settings, + default_thread_settings + }, + { + "entity_factory_duplicated_autoenable_created_entities_tag", + R"( + + + + + + + false + false + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + default_thread_settings, + default_thread_settings + }, + { + "entity_factory_duplicated_autoenable_created_entities_and_wrong_tag", + R"( + + + + + + + false + false + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + default_thread_settings, + default_thread_settings + }, + { + "entity_factory_duplicated", + R"( + + + + + + + false + + + false + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + modified_thread_settings, + modified_thread_settings + }, + { + "shm_watchdog_thread_duplicated", + R"( + + + + + + + false + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + modified_thread_settings, + modified_thread_settings + }, + { + "file_watch_threads_duplicated", + R"( + + + + + + + false + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + EntityFactoryQosPolicy(true), + modified_thread_settings, + modified_thread_settings + } + }; + + for (const TestCase& test : test_cases) + { + EXPECT_EQ(test.result, xmlparser::XMLProfileManager::loadXMLString(test.xml.c_str(), test.xml.length())) << + " test_case = [" << test.title << "]"; + if (test.result == xmlparser::XMLP_ret::XML_OK) + { + using namespace eprosima::fastdds::dds; + + DomainParticipantFactoryQos profile_qos; + ASSERT_EQ(xmlparser::XMLP_ret::XML_OK, + xmlparser::XMLProfileManager::fillDomainParticipantFactoryQos("factory", profile_qos)); + + DomainParticipantFactoryQos default_qos; + xmlparser::XMLProfileManager::getDefaultDomainParticipantFactoryQos(default_qos); + + ASSERT_EQ(profile_qos, default_qos); + ASSERT_EQ(profile_qos.entity_factory(), test.entity_factory); + ASSERT_EQ(profile_qos.shm_watchdog_thread(), test.shm_watchdog_thread); + ASSERT_EQ(profile_qos.file_watch_threads(), test.file_watch_threads); + } + xmlparser::XMLProfileManager::DeleteInstance(); + } +} + +/** + * This test checks positive and negative cases for parsing of DomainParticipant ThreadSettings + */ +TEST_F(XMLProfileParserBasicTests, participant_thread_settings) +{ + using namespace eprosima::fastdds::dds; + using namespace eprosima::fastdds::rtps; + struct TestCase + { + std::string title; + std::string xml; + xmlparser::XMLP_ret result; + ThreadSettings builtin_controllers_sender_thread; + ThreadSettings timed_events_thread; + ThreadSettings discovery_server_thread; + ThreadSettings builtin_transports_reception_threads; +#if HAVE_SECURITY + ThreadSettings security_log_thread; +#endif // if HAVE_SECURITY + }; + + ThreadSettings default_thread_settings; + ThreadSettings modified_thread_settings; + modified_thread_settings.scheduling_policy = 12; + modified_thread_settings.priority = 12; + modified_thread_settings.affinity = 12; + modified_thread_settings.stack_size = 12; + + std::vector test_cases = + { + { + "builtin_controllers_sender_thread_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + modified_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings + }, + { + "builtin_controllers_sender_thread_nok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + modified_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings + }, + { + "timed_events_thread_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + default_thread_settings, + modified_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings + }, + { + "timed_events_thread_nok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + default_thread_settings, + modified_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings + }, + { + "discovery_server_thread_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + default_thread_settings, + default_thread_settings, + modified_thread_settings, + default_thread_settings, + default_thread_settings + }, + { + "discovery_server_thread_nok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + default_thread_settings, + default_thread_settings, + modified_thread_settings, + default_thread_settings, + default_thread_settings + }, + { + "builtin_transports_reception_threads_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + default_thread_settings, + default_thread_settings, + default_thread_settings, + modified_thread_settings, + default_thread_settings + }, + { + "builtin_transports_reception_threads_nok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + default_thread_settings, + default_thread_settings, + default_thread_settings, + modified_thread_settings, + default_thread_settings + }, +#if HAVE_SECURITY + { + "security_log_thread_ok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_OK, + default_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings, + modified_thread_settings + }, + { + "security_log_thread_nok", + R"( + + + + + + + 12 + 12 + 12 + 12 + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + default_thread_settings, + default_thread_settings, + default_thread_settings, + default_thread_settings, + modified_thread_settings + }, +#endif // if HAVE_SECURITY + }; + + for (const TestCase& test : test_cases) + { + EXPECT_EQ(test.result, xmlparser::XMLProfileManager::loadXMLString(test.xml.c_str(), test.xml.length())) << + " test_case = [" << test.title << "]"; + if (test.result == xmlparser::XMLP_ret::XML_OK) + { + using namespace eprosima::fastdds::dds; + + ParticipantAttributes profile_attr; + ASSERT_EQ(xmlparser::XMLP_ret::XML_OK, + xmlparser::XMLProfileManager::fillParticipantAttributes("participant", profile_attr)); + + ParticipantAttributes default_attr; + xmlparser::XMLProfileManager::getDefaultParticipantAttributes(default_attr); + + ASSERT_EQ(profile_attr, default_attr); + ASSERT_EQ(profile_attr.rtps.builtin_controllers_sender_thread, test.builtin_controllers_sender_thread); + ASSERT_EQ(profile_attr.rtps.timed_events_thread, test.timed_events_thread); + ASSERT_EQ(profile_attr.rtps.discovery_server_thread, test.discovery_server_thread); + ASSERT_EQ(profile_attr.rtps.builtin_transports_reception_threads, + test.builtin_transports_reception_threads); +#if HAVE_SECURITY + ASSERT_EQ(profile_attr.rtps.security_log_thread, test.security_log_thread); +#endif // if HAVE_SECURITY + } + xmlparser::XMLProfileManager::DeleteInstance(); + } +} + +/** + * This test checks positive and negative cases for parsing of DataReader ThreadSettings + */ +TEST_F(XMLProfileParserBasicTests, datareader_thread_settings) +{ + using namespace eprosima::fastdds::dds; + using namespace eprosima::fastdds::rtps; + struct TestCase + { + std::string title; + std::string xml; + xmlparser::XMLP_ret result; + ThreadSettings data_sharing_listener_thread; + }; + + ThreadSettings default_thread_settings; + ThreadSettings modified_thread_settings; + modified_thread_settings.scheduling_policy = 12; + modified_thread_settings.priority = 12; + modified_thread_settings.affinity = 12; + modified_thread_settings.stack_size = 12; + + std::vector test_cases = + { + { + "data_sharing_listener_thread_ok", + R"( + + + + + + + AUTOMATIC + + 12 + 12 + 12 + 12 + + + + + + )", + xmlparser::XMLP_ret::XML_OK, + modified_thread_settings + }, + { + "data_sharing_listener_thread_empty", + R"( + + + + + + + AUTOMATIC + + + + + + + )", + xmlparser::XMLP_ret::XML_OK, + default_thread_settings, + }, + { + "no_data_sharing_listener_thread", + R"( + + + + + + + AUTOMATIC + + + + + )", + xmlparser::XMLP_ret::XML_OK, + default_thread_settings, + }, + { + "data_sharing_listener_thread_wrong_value", + R"( + + + + + + + AUTOMATIC + + aa + 0 + 0 + 0 + + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + default_thread_settings, + }, + { + "data_sharing_listener_thread_wrong_tag", + R"( + + + + + + + AUTOMATIC + + -1 + 0 + 0 + 0 + + + + + + )", + xmlparser::XMLP_ret::XML_ERROR, + default_thread_settings, + }, + }; + + for (const TestCase& test : test_cases) + { + EXPECT_EQ(test.result, xmlparser::XMLProfileManager::loadXMLString(test.xml.c_str(), test.xml.length())) << + " test_case = [" << test.title << "]"; + if (test.result == xmlparser::XMLP_ret::XML_OK) + { + SubscriberAttributes profile_attr; + ASSERT_EQ(xmlparser::XMLP_ret::XML_OK, + xmlparser::XMLProfileManager::fillSubscriberAttributes("datareader", profile_attr)); + + SubscriberAttributes default_attr; + xmlparser::XMLProfileManager::getDefaultSubscriberAttributes(default_attr); + + ASSERT_EQ(profile_attr, default_attr); + ASSERT_EQ(profile_attr.qos.data_sharing.data_sharing_listener_thread(), test.data_sharing_listener_thread); + } + xmlparser::XMLProfileManager::DeleteInstance(); + } +} + INSTANTIATE_TEST_SUITE_P(XMLProfileParserTests, XMLProfileParserTests, testing::Values(false)); INSTANTIATE_TEST_SUITE_P(XMLProfileParserEnvVarTests, XMLProfileParserTests, testing::Values(true)); diff --git a/test/unittest/xmlparser/log_def_file_profile.xml b/test/unittest/xmlparser/log_def_file_profile.xml index fc803ed3fe6..38b052a081c 100644 --- a/test/unittest/xmlparser/log_def_file_profile.xml +++ b/test/unittest/xmlparser/log_def_file_profile.xml @@ -5,5 +5,11 @@ FileConsumer + + -1 + 0 + 0 + -1 + diff --git a/test/unittest/xmlparser/test_xml_deprecated.xml b/test/unittest/xmlparser/test_xml_deprecated.xml index 2d38fdb4fdc..99ead8f8282 100644 --- a/test/unittest/xmlparser/test_xml_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_deprecated.xml @@ -151,6 +151,36 @@ 56.30.0.CE + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + diff --git a/test/unittest/xmlparser/test_xml_profile.xml b/test/unittest/xmlparser/test_xml_profile.xml index 39f8b8e284c..f97ae1328ce 100644 --- a/test/unittest/xmlparser/test_xml_profile.xml +++ b/test/unittest/xmlparser/test_xml_profile.xml @@ -1,6 +1,25 @@ + + + + true + + + -1 + 0 + 0 + -1 + + + -1 + 0 + 0 + -1 + + + 123 @@ -147,6 +166,36 @@ 56.30.0.ce + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + diff --git a/test/unittest/xmlparser/test_xml_profile_env_var.xml b/test/unittest/xmlparser/test_xml_profile_env_var.xml index a5abd2143f0..91b238eb638 100644 --- a/test/unittest/xmlparser/test_xml_profile_env_var.xml +++ b/test/unittest/xmlparser/test_xml_profile_env_var.xml @@ -147,6 +147,36 @@ ${XML_PROFILES_ENV_VAR_66} + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + @@ -388,4 +418,23 @@ ${XML_PROFILES_ENV_VAR_156} + + + + ${XML_PROFILES_ENV_VAR_157} + + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + + + diff --git a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml index 2225fe2c134..79d773dfba8 100644 --- a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml @@ -126,6 +126,36 @@ true test_name + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + diff --git a/test/unittest/xmlparser/test_xml_rooted_profile.xml b/test/unittest/xmlparser/test_xml_rooted_profile.xml index 9a28be1f38b..b6e95e1751e 100644 --- a/test/unittest/xmlparser/test_xml_rooted_profile.xml +++ b/test/unittest/xmlparser/test_xml_rooted_profile.xml @@ -1,6 +1,25 @@ + + + + true + + + -1 + 0 + 0 + -1 + + + -1 + 0 + 0 + -1 + + + 123 @@ -122,6 +141,36 @@ 9898 true test_name + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + + + 12 + 12 + 12 + 12 + diff --git a/test/unittest/xmlparser/wrapper/XMLParserTest.hpp b/test/unittest/xmlparser/wrapper/XMLParserTest.hpp index 9c4fe763afd..c78524bb6bf 100644 --- a/test/unittest/xmlparser/wrapper/XMLParserTest.hpp +++ b/test/unittest/xmlparser/wrapper/XMLParserTest.hpp @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include #include using namespace eprosima::fastrtps; @@ -214,6 +217,14 @@ class XMLParserTest : public XMLParser return getXMLUint(elem, ui16, ident); } + static XMLP_ret getXMLUint_wrapper( + tinyxml2::XMLElement* elem, + uint64_t* ui64, + uint8_t ident) + { + return getXMLUint(elem, ui64, ident); + } + static XMLP_ret getXMLBuiltinAttributes_wrapper( tinyxml2::XMLElement* elem, BuiltinAttributes& builtin, @@ -494,6 +505,13 @@ class XMLParserTest : public XMLParser return parse_tls_config(p_root, tcp_transport); } + static XMLP_ret parseXMLReceptionThreads_wrapper( + tinyxml2::XMLElement& p_root, + eprosima::fastdds::rtps::PortBasedTransportDescriptor::ReceptionThreadsConfigMap& reception_threads) + { + return parseXMLReceptionThreads(p_root, reception_threads); + } + static XMLP_ret parseXMLLibrarySettings_wrapper( tinyxml2::XMLElement* p_root) { @@ -577,4 +595,26 @@ class XMLParserTest : public XMLParser return parseXMLTopicData(p_root, rootNode); } + static XMLP_ret getXMLThreadSettings_wrapper( + tinyxml2::XMLElement* p_root, + eprosima::fastdds::rtps::ThreadSettings& thread_settings) + { + return getXMLThreadSettings(*p_root, thread_settings); + } + + static XMLP_ret getXMLThreadSettingsWithPort_wrapper( + tinyxml2::XMLElement* p_root, + eprosima::fastdds::rtps::ThreadSettings& thread_settings, + uint32_t& port) + { + return getXMLThreadSettingsWithPort(*p_root, thread_settings, port); + } + + static XMLP_ret getXMLEntityFactoryQos_wrapper( + tinyxml2::XMLElement* p_root, + eprosima::fastdds::dds::EntityFactoryQosPolicy& entity_factory) + { + return getXMLEntityFactoryQos(*p_root, entity_factory); + } + };