From ce3ae97b6a8a96a6872bb2578859a35e56ee9f40 Mon Sep 17 00:00:00 2001 From: Irene Bandera Moreno Date: Thu, 22 Jun 2023 07:06:31 +0200 Subject: [PATCH] Fast DDS Spy tool tests (#21) * Add tool tests Signed-off-by: Irene Bandera * Update Signed-off-by: Irene Bandera * Fix python linter Signed-off-by: Irene Bandera * AApply changes Signed-off-by: Irene Bandera * Fail test Signed-off-by: Irene Bandera * Without one shot Signed-off-by: Irene Bandera * Fix tsan Signed-off-by: Irene Bandera * add commands Signed-off-by: Irene Bandera * Update structure Signed-off-by: Irene Bandera * Change structure Signed-off-by: Irene Bandera * Add one shot test without dds Signed-off-by: Irene Bandera * Update Signed-off-by: Irene Bandera * Working without fast Signed-off-by: Irene Bandera * Add one shot with dds tests Signed-off-by: Irene Bandera * Add dds publisher Signed-off-by: Irene Bandera * Get output commands Signed-off-by: Irene Bandera * Rename function Signed-off-by: Irene Bandera * Test output without dds working Signed-off-by: Irene Bandera * Everything working except for tool with dds Signed-off-by: Irene Bandera * Add xtsan flag to dds tests Signed-off-by: Irene Bandera * Update Signed-off-by: Irene Bandera * Rate with regexp Signed-off-by: Irene Bandera * Everything working Signed-off-by: Irene Bandera * Add signal windows Signed-off-by: Irene Bandera * More coverage Signed-off-by: Irene Bandera * Fix tests Signed-off-by: Irene Bandera * Long lines Signed-off-by: Irene Bandera * Long lines Signed-off-by: Irene Bandera * Some style fixes Signed-off-by: Irene Bandera * Some fixes windows Signed-off-by: Irene Bandera * Some fixes windows Signed-off-by: Irene Bandera * Signal windows Signed-off-by: Irene Bandera * Fix local path dds Signed-off-by: Irene Bandera * Fix one shot Signed-off-by: Irene Bandera * Some fixes Signed-off-by: Irene Bandera * Fix return Signed-off-by: Irene Bandera * Some fixes Signed-off-by: Irene Bandera * Some fixes Signed-off-by: Irene Bandera * Without return code Signed-off-by: Irene Bandera * Update Signed-off-by: Irene Bandera * Some fixes Signed-off-by: Irene Bandera * Time changes Signed-off-by: Irene Bandera * Fix time, uncrustify and python linter Signed-off-by: Irene Bandera * Uncrustify and more timeout Signed-off-by: Irene Bandera * add lease_duration Signed-off-by: Irene Bandera * More timeout Signed-off-by: Irene Bandera * add stop when fail Signed-off-by: Irene Bandera * Add Release path Signed-off-by: Irene Bandera * Fix stop tool when wrong output and sys.exit(0) Signed-off-by: Irene Bandera * Fix exit and give time to stop Signed-off-by: Irene Bandera * Less timeout Signed-off-by: Irene Bandera * timeout=15 Signed-off-by: Irene Bandera * Fix python linter Signed-off-by: Irene Bandera * Give more time to stop Signed-off-by: Irene Bandera * change kill publisher Signed-off-by: Irene Bandera * kill publisher Signed-off-by: Irene Bandera * Apply changes Signed-off-by: Irene Bandera * Testing Signed-off-by: Irene Bandera * Add docu code Signed-off-by: Irene Bandera * Debug Signed-off-by: Irene Bandera * Apply changes Signed-off-by: Irene Bandera * Apply changes Signed-off-by: Irene Bandera * Apply changes Signed-off-by: Irene Bandera --------- Signed-off-by: Irene Bandera --- .../visualization/ModelParser.hpp | 26 +- .../src/cpp/visualization/ModelParser.cpp | 40 +- fastddsspy_tool/package.xml | 2 + fastddsspy_tool/test/CMakeLists.txt | 4 + .../test/application/CMakeLists.txt | 160 ++++++++ fastddsspy_tool/test/application/README.md | 60 +++ .../configuration/configuration_basic.yaml | 11 + .../configuration_discovery_time.yaml | 4 + .../configuration_wrong_empty_arg.yaml | 11 + .../configuration_wrong_type.yaml | 11 + .../AdvancedConfigurationPublisher.cpp | 360 ++++++++++++++++++ .../AdvancedConfigurationPublisher.h | 150 ++++++++ .../AdvancedConfigurationSubscriber.cpp | 314 +++++++++++++++ .../AdvancedConfigurationSubscriber.h | 136 +++++++ .../AdvancedConfiguration_main.cpp | 267 +++++++++++++ .../CMakeLists.txt | 53 +++ .../HelloWorld.cxx | 239 ++++++++++++ .../AdvancedConfigurationExample/HelloWorld.h | 234 ++++++++++++ .../HelloWorld.idl | 5 + .../HelloWorldPubSubTypes.cxx | 170 +++++++++ .../HelloWorldPubSubTypes.h | 101 +++++ .../AdvancedConfigurationExample/README.md | 85 +++++ .../arg_configuration.h | 249 ++++++++++++ .../AdvancedConfigurationExample/types.hpp | 31 ++ fastddsspy_tool/test/application/launcher.ps1 | 60 +++ fastddsspy_tool/test/application/test.py | 176 +++++++++ .../test_cases/one_shot__config.py | 43 +++ .../one_shot__config_fail_empty_arg.py | 62 +++ .../test_cases/one_shot__config_fail_file.py | 76 ++++ .../test_cases/one_shot__config_fail_type.py | 60 +++ .../application/test_cases/one_shot__debug.py | 40 ++ .../application/test_cases/one_shot__help.py | 90 +++++ .../test_cases/one_shot__log_filter.py | 40 ++ .../test_cases/one_shot__log_filter_fail.py | 76 ++++ .../test_cases/one_shot__log_verb_error.py | 40 ++ .../test_cases/one_shot__log_verb_fail.py | 76 ++++ .../test_cases/one_shot__log_verb_info.py | 40 ++ .../test_cases/one_shot__log_verb_warning.py | 40 ++ .../application/test_cases/one_shot__null.py | 76 ++++ .../test_cases/one_shot__reload_time.py | 40 ++ .../test_cases/one_shot__reload_time_fail.py | 76 ++++ .../test_cases/one_shot__version.py | 51 +++ .../test_cases/one_shot_datareader.py | 40 ++ .../test_cases/one_shot_datareader_dds.py | 43 +++ .../one_shot_datareader_guid_dds.py | 46 +++ .../test_cases/one_shot_datareader_verbose.py | 40 ++ .../one_shot_datareader_verbose_dds.py | 43 +++ .../test_cases/one_shot_datawriter.py | 40 ++ .../test_cases/one_shot_datawriter_dds.py | 45 +++ .../one_shot_datawriter_guid_dds_fail.py | 46 +++ .../test_cases/one_shot_datawriter_verbose.py | 40 ++ .../one_shot_datawriter_verbose_dds.py | 50 +++ .../one_shot_datawriter_verbose_dds_qos.py | 50 +++ .../application/test_cases/one_shot_help.py | 70 ++++ .../test_cases/one_shot_help_dds.py | 73 ++++ .../application/test_cases/one_shot_null.py | 41 ++ .../test_cases/one_shot_participants.py | 40 ++ .../test_cases/one_shot_participants_dds.py | 44 +++ .../one_shot_participants_guid_dds.py | 46 +++ .../one_shot_participants_verbose.py | 40 ++ .../one_shot_participants_verbose_dds.py | 46 +++ .../application/test_cases/one_shot_quit.py | 40 ++ .../test_cases/one_shot_quit_dds.py | 43 +++ .../test_cases/one_shot_show_all.py | 40 ++ .../test_cases/one_shot_show_fail.py | 41 ++ .../test_cases/one_shot_show_topic.py | 40 ++ .../test_cases/one_shot_show_topic_verbose.py | 40 ++ .../application/test_cases/one_shot_topics.py | 40 ++ .../test_cases/one_shot_topics_dds.py | 47 +++ .../test_cases/one_shot_topics_name.py | 41 ++ .../test_cases/one_shot_topics_name_dds.py | 48 +++ .../test_cases/one_shot_topics_verbose.py | 40 ++ .../test_cases/one_shot_topics_verbose_dds.py | 48 +++ .../application/test_cases/tool_datareader.py | 41 ++ .../test_cases/tool_datareader_dds.py | 44 +++ .../application/test_cases/tool_datawriter.py | 41 ++ .../test_cases/tool_datawriter_dds.py | 48 +++ .../test/application/test_cases/tool_help.py | 73 ++++ .../application/test_cases/tool_help_dds.py | 76 ++++ .../test/application/test_cases/tool_null.py | 42 ++ .../test_cases/tool_participants.py | 41 ++ .../test_cases/tool_participants_dds.py | 46 +++ .../application/test_cases/tool_show_all.py | 41 ++ .../application/test_cases/tool_show_topic.py | 42 ++ .../test_cases/tool_show_topic_dds.py | 45 +++ .../application/test_cases/tool_topics.py | 41 ++ .../application/test_cases/tool_topics_dds.py | 52 +++ .../application/test_cases/tool_version.py | 52 +++ .../test/application/test_class.py | 280 ++++++++++++++ fastddsspy_tool/test/labels/CMakeLists.txt | 16 + fastddsspy_tool/test/labels/XTSAN.list | 62 +++ fastddsspy_yaml/src/cpp/YamlReader.cpp | 40 -- 92 files changed, 6326 insertions(+), 73 deletions(-) create mode 100644 fastddsspy_tool/test/application/CMakeLists.txt create mode 100644 fastddsspy_tool/test/application/README.md create mode 100644 fastddsspy_tool/test/application/configuration/configuration_basic.yaml create mode 100644 fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml create mode 100644 fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml create mode 100644 fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfiguration_main.cpp create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.idl create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types.hpp create mode 100644 fastddsspy_tool/test/application/launcher.ps1 create mode 100644 fastddsspy_tool/test/application/test.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__config.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__debug.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__help.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__log_filter.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__log_verb_error.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__log_verb_info.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__log_verb_warning.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__null.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__reload_time.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot__version.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datareader.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datareader_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datawriter.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_help.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_help_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_null.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_participants.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_quit.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_quit_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_show_all.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_topics.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_topics_name.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose.py create mode 100644 fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_datareader.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_datareader_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_datawriter.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_help.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_help_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_null.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_participants.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_participants_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_show_all.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_show_topic.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_topics.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_topics_dds.py create mode 100644 fastddsspy_tool/test/application/test_cases/tool_version.py create mode 100644 fastddsspy_tool/test/application/test_class.py create mode 100644 fastddsspy_tool/test/labels/CMakeLists.txt create mode 100644 fastddsspy_tool/test/labels/XTSAN.list delete mode 100644 fastddsspy_yaml/src/cpp/YamlReader.cpp diff --git a/fastddsspy_participants/include/fastddsspy_participants/visualization/ModelParser.hpp b/fastddsspy_participants/include/fastddsspy_participants/visualization/ModelParser.hpp index 1f6f26ca..597239ec 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/visualization/ModelParser.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/visualization/ModelParser.hpp @@ -29,52 +29,52 @@ struct ModelParser { FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector participants( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector participants_verbose( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static ComplexParticipantData participants( const SpyModel& model, - const ddspipe::core::types::Guid& guid); + const ddspipe::core::types::Guid& guid) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector writers( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector writers_verbose( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static ComplexEndpointData writers( const SpyModel& model, - const ddspipe::core::types::Guid& guid); + const ddspipe::core::types::Guid& guid) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector readers( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector readers_verbose( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static ComplexEndpointData readers( const SpyModel& model, - const ddspipe::core::types::Guid& guid); + const ddspipe::core::types::Guid& guid) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static ddspipe::core::types::DdsTopic get_topic( const SpyModel& model, - std::string topic_name); + std::string topic_name) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector topics( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static std::vector topics_verbose( - const SpyModel& model); + const SpyModel& model) noexcept; FASTDDSSPY_PARTICIPANTS_DllAPI static ComplexTopicData topics( const SpyModel& model, - const std::string& topic_name); + const std::string& topic_name) noexcept; }; } /* namespace participants */ diff --git a/fastddsspy_participants/src/cpp/visualization/ModelParser.cpp b/fastddsspy_participants/src/cpp/visualization/ModelParser.cpp index f10e92e9..329efa3e 100644 --- a/fastddsspy_participants/src/cpp/visualization/ModelParser.cpp +++ b/fastddsspy_participants/src/cpp/visualization/ModelParser.cpp @@ -21,7 +21,7 @@ namespace spy { namespace participants { std::vector ModelParser::participants( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; for (const auto& it : model.participant_database_) @@ -36,7 +36,7 @@ std::vector ModelParser::participants( } std::vector ModelParser::participants_verbose( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -56,7 +56,7 @@ void add_endpoint_to_vector( std::map& already_endpoints_index, std::vector& endpoints, const std::pair& endpoint) + eprosima::spy::participants::EndpointInfo>& endpoint) noexcept { // Check if this topic has already endpoints added auto it = already_endpoints_index.find(endpoint.second.topic.m_topic_name); @@ -79,7 +79,7 @@ void add_endpoint_to_vector( ComplexParticipantData ModelParser::participants( const SpyModel& model, - const ddspipe::core::types::Guid& guid) + const ddspipe::core::types::Guid& guid) noexcept { ComplexParticipantData result; @@ -126,7 +126,7 @@ ComplexParticipantData ModelParser::participants( std::string get_participant_name( const SpyModel& model, - const ddspipe::core::types::Guid guid) + const ddspipe::core::types::Guid guid) noexcept { // Look for participant name for (const auto& participant : model.participant_database_) @@ -142,7 +142,7 @@ std::string get_participant_name( SimpleEndpointData fill_simple_endpoint( const SpyModel& model, - const spy::participants::EndpointInfo& endpoint) + const spy::participants::EndpointInfo& endpoint) noexcept { std::string participant_name = get_participant_name(model, endpoint.guid); @@ -159,7 +159,7 @@ SimpleEndpointData fill_simple_endpoint( void fill_complex_endpoint( const SpyModel& model, ComplexEndpointData& result, - const spy::participants::EndpointInfo& endpoint) + const spy::participants::EndpointInfo& endpoint) noexcept { result.participant_name = get_participant_name(model, endpoint.guid); @@ -173,7 +173,7 @@ void fill_complex_endpoint( void set_endpoint_simple_information( const SpyModel& model, std::vector& result, - const ddspipe::core::types::EndpointKind kind) + const ddspipe::core::types::EndpointKind kind) noexcept { for (const auto& endpoint : model.endpoint_database_) { @@ -188,7 +188,7 @@ void set_endpoint_complex_information( const SpyModel& model, ComplexEndpointData& result, const ddspipe::core::types::EndpointKind kind, - const eprosima::ddspipe::core::types::Guid guid) + const eprosima::ddspipe::core::types::Guid guid) noexcept { for (const auto& endpoint : model.endpoint_database_) { @@ -202,7 +202,7 @@ void set_endpoint_complex_information( } std::vector ModelParser::writers( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -212,7 +212,7 @@ std::vector ModelParser::writers( } std::vector ModelParser::writers_verbose( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -229,7 +229,7 @@ std::vector ModelParser::writers_verbose( ComplexEndpointData ModelParser::writers( const SpyModel& model, - const ddspipe::core::types::Guid& guid) + const ddspipe::core::types::Guid& guid) noexcept { ComplexEndpointData result; @@ -239,7 +239,7 @@ ComplexEndpointData ModelParser::writers( } std::vector ModelParser::readers( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -249,7 +249,7 @@ std::vector ModelParser::readers( } std::vector ModelParser::readers_verbose( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -266,7 +266,7 @@ std::vector ModelParser::readers_verbose( ComplexEndpointData ModelParser::readers( const SpyModel& model, - const ddspipe::core::types::Guid& guid) + const ddspipe::core::types::Guid& guid) noexcept { ComplexEndpointData result; @@ -279,7 +279,7 @@ ComplexEndpointData ModelParser::readers( * This is an auxiliary function that is used to get topics endpoint database */ std::set get_topics( - const SpyModel& model) + const SpyModel& model) noexcept { std::set result; for (const auto& endpoint : model.endpoint_database_) @@ -294,7 +294,7 @@ std::set get_topics( ddspipe::core::types::DdsTopic ModelParser::get_topic( const SpyModel& model, - std::string topic_name) + std::string topic_name) noexcept { for (const auto& endpoint : model.endpoint_database_) @@ -309,7 +309,7 @@ ddspipe::core::types::DdsTopic ModelParser::get_topic( } std::vector ModelParser::topics( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -348,7 +348,7 @@ std::vector ModelParser::topics( } std::vector ModelParser::topics_verbose( - const SpyModel& model) + const SpyModel& model) noexcept { std::vector result; @@ -363,7 +363,7 @@ std::vector ModelParser::topics_verbose( ComplexTopicData ModelParser::topics( const SpyModel& model, - const std::string& topic_name) + const std::string& topic_name) noexcept { ComplexTopicData result; diff --git a/fastddsspy_tool/package.xml b/fastddsspy_tool/package.xml index da346f7f..96b5512e 100644 --- a/fastddsspy_tool/package.xml +++ b/fastddsspy_tool/package.xml @@ -17,7 +17,9 @@ cmake + cmake_utils cpp_utils + py_utils ddspipe_core ddspipe_participants ddspipe_yaml diff --git a/fastddsspy_tool/test/CMakeLists.txt b/fastddsspy_tool/test/CMakeLists.txt index 7122e5ff..5889a285 100644 --- a/fastddsspy_tool/test/CMakeLists.txt +++ b/fastddsspy_tool/test/CMakeLists.txt @@ -12,4 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Add subdirectory with labels for tests +add_subdirectory(labels) + # Add subdirectory with tests +add_subdirectory(application) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt new file mode 100644 index 00000000..b08f0adb --- /dev/null +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -0,0 +1,160 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +########################################################################### +# Create tests # +########################################################################### + +find_package(PythonInterp 3 REQUIRED) + +# Name of files to test + +function(get_filenames_without_parent PATH_LIST RESULT_VARIABLE) + set(FILENAMES "") + + foreach(PATH ${${PATH_LIST}}) + get_filename_component(FILENAME ${PATH} NAME) + string(REGEX REPLACE "\\.[^.]*$" "" FILE_NAME_WITHOUT_EXTENSION ${FILENAME}) + list(APPEND FILENAMES ${FILE_NAME_WITHOUT_EXTENSION}) + endforeach() + + set(${RESULT_VARIABLE} ${FILENAMES} PARENT_SCOPE) +endfunction() + +file( + GLOB_RECURSE TEST_PATH + "test_cases/*.py" +) + +get_filenames_without_parent(TEST_PATH TEST_FILENAMES) + +message(STATUS "TEST FILES NAME: ${TEST_FILENAMES}") + +set(PWS_LAUNCHER + ${CMAKE_CURRENT_SOURCE_DIR}/launcher.ps1 +) + +# Calculate environment +set(TEST_ENVIRONMENT + "PATH=$ENV{PATH};$") + +foreach(PROJECT_DEPENDENCY ${MODULE_DEPENDENCIES}) + + message(STATUS "Finding target for libraries for ${PROJECT_DEPENDENCY}") + + if(TARGET ${PROJECT_DEPENDENCY} OR TARGET eprosima::${PROJECT_DEPENDENCY} OR TARGET ${PROJECT_DEPENDENCY}::${PROJECT_DEPENDENCY}) + set(TEST_ENVIRONMENT + "${TEST_ENVIRONMENT};$") + + elseif(EXISTS ${PROJECT_DEPENDENCY}_LIBRARY) + get_filename_component( + ${PROJECT_DEPENDENCY}_LIBRARY_DIR ${${PROJECT_DEPENDENCY}_LIBRARY} DIRECTORY) + set(TEST_ENVIRONMENT + "${TEST_ENVIRONMENT};${${PROJECT_DEPENDENCY}_LIBRARY_DIR}") + unset(${PROJECT_DEPENDENCY}_LIBRARY_DIR) + + else() + + message(STATUS "${PROJECT_DEPENDENCY} could not be added to TEST_ENVIRONMENT") + + endif() + +endforeach() + +if(WIN32) + + if(TARGET tinyxml2 OR TARGET tinyxml2::tinyxml2) + set(TEST_ENVIRONMENT + "${TEST_ENVIRONMENT};$") + elseif(EXISTS TINYXML2_LIBRARY) + get_filename_component( + TINYXML2_LIBRARY_DIR ${TINYXML2_LIBRARY} DIRECTORY) + set(TEST_ENVIRONMENT + "${TEST_ENVIRONMENT};${TINYXML2_LIBRARY_DIR}") + unset(TINYXML2_LIBRARY_DIR) + endif() + + if(TARGET yamlcpp OR TARGET yamlcpp::yamlcpp) + set(TEST_ENVIRONMENT + "${TEST_ENVIRONMENT};$") + elseif(EXISTS YAMLCPP_LIBRARY) + get_filename_component( + YAMLCPP_LIBRARY_DIR ${YAMLCPP_LIBRARY} DIRECTORY) + set(TEST_ENVIRONMENT + "${TEST_ENVIRONMENT};${YAMLCPP_LIBRARY_DIR}") + unset(YAMLCPP_LIBRARY_DIR) + endif() + + string(REPLACE ";" "\\;" TEST_ENVIRONMENT "${TEST_ENVIRONMENT}") + +endif(WIN32) + +# compile AdvanceConfigurationExample needed for tests +add_subdirectory(dds/AdvancedConfigurationExample) + +set(TEST_NEEDED_SOURCES + configuration/configuration_basic.yaml + configuration/configuration_wrong_empty_arg.yaml + configuration/configuration_wrong_type.yaml + configuration/configuration_discovery_time.yaml + ) + +foreach(NEEDED_SOURCE ${TEST_NEEDED_SOURCES}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${NEEDED_SOURCE} + ${CMAKE_CURRENT_BINARY_DIR}/${NEEDED_SOURCE} + COPYONLY) +endforeach() + +# populate the tests +foreach(TEST IN LISTS TEST_FILENAMES) + set(TEST_NAME "tool.application.fastddsspy.test.test_cases.${TEST}") + + if(WIN32) + add_test( + NAME ${TEST_NAME} + COMMAND powershell "-File" ${PWS_LAUNCHER} + ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/test.py + $ + $ + ${TEST} + ) + + else() + + add_test( + NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/test.py + "--exe" $ + "--pub" $ + "--test" ${TEST} + ) + + endif() + + # Add labels to tests + # TODO use cmake_utils + set_test_labels(${TEST_NAME}) + + # Set test properties + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + ) + +endforeach() + +unset(TEST_ENVIRONMENT) diff --git a/fastddsspy_tool/test/application/README.md b/fastddsspy_tool/test/application/README.md new file mode 100644 index 00000000..5bd72969 --- /dev/null +++ b/fastddsspy_tool/test/application/README.md @@ -0,0 +1,60 @@ +# Fast-DDS-spy tool tests + +This module builds a test suite for the Fast DDS Spy. + +## Executable [test.py](test.py) + +The executable is responsible for running all the tests and verify that the system behaves correctly under the different conditions. + +## Executable [test_class.py](test_class.py) + +Is the base class that provides the foundation for creating test cases. +Encapsulates various methods and functionalities that enable the definition and execution of individual test cases. +By inheriting from `test_class.TestCase`, you can create custom test case classes that inherit the features and capabilities of the base class. +This inheritance allows you to leverage the provided methods and utilities within your test cases. +However, you also have the flexibility to reimplement or override those methods to tailor them to your specific test cases. + +## Add a new test case file + +To add a new test case file and define specific conditions to test, follow these steps: + +1. Create a new python file inside [test_cases](test_cases/) directory. +2. In the newly created file, create a child class that inherits from `test_class.TestCase`. +3. Customize the class by setting the desired parameters to define the conditions you want to test. + +For example, if you want to test: + + ```bash + fastddsspy --config-path fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml participants verbose + ``` + +With a DDS Publisher running: + + ```bash + AdvancedConfigurationExample publisher + ``` + +You need a class like [this](test_cases/one_shot_participants_verbose_dds.py): + + ```yaml + name='TopicsVerboseDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'topics', 'verbose'], + commands_spy=[], + output="""- name: HelloWorldTopic\n\ + type: HelloWorld\n\ + datawriters:\n\ + - %%guid%%\n\ + rate: %%rate%%\n\ + dynamic_type_discovered: false\n""" + ``` + +If you need to override a specific method for a particular test case, you can do so by providing an implementation within that specific test case class like [here](test_cases/one_shot__help.py) with `valid_output()`. + +## TODO + +Add a test scenario with a DataReader. diff --git a/fastddsspy_tool/test/application/configuration/configuration_basic.yaml b/fastddsspy_tool/test/application/configuration/configuration_basic.yaml new file mode 100644 index 00000000..2c080729 --- /dev/null +++ b/fastddsspy_tool/test/application/configuration/configuration_basic.yaml @@ -0,0 +1,11 @@ +version: 1.0 + +dds: + domain: 33 + allowlist: + - name: "*" + +specs: + threads: 12 + max-history-depth: 5000 + discovery-time: 2000 diff --git a/fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml b/fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml new file mode 100644 index 00000000..1e57e3d3 --- /dev/null +++ b/fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml @@ -0,0 +1,4 @@ +version: 1.0 + +specs: + discovery-time: 2000 diff --git a/fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml b/fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml new file mode 100644 index 00000000..4ccf8518 --- /dev/null +++ b/fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml @@ -0,0 +1,11 @@ +version: 1.0 + +dds: + domain: + allowlist: + - name: "*" + +specs: + threads: 12 + max-history-depth: 5000 + discovery-time: 2000 diff --git a/fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml b/fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml new file mode 100644 index 00000000..b080469d --- /dev/null +++ b/fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml @@ -0,0 +1,11 @@ +version: 1.0 + +dds: + domain: "hello" + allowlist: + - name: "*" + +specs: + threads: 12 + max-history-depth: 5000 + discovery-time: 2000 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp new file mode 100644 index 00000000..6f4299dd --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp @@ -0,0 +1,360 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AdvancedConfigurationPublisher.cpp + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AdvancedConfigurationPublisher.h" + +using namespace eprosima::fastdds::dds; +using namespace eprosima::fastdds::rtps; + +std::atomic HelloWorldPublisher::stop_(false); +std::mutex HelloWorldPublisher::PubListener::wait_matched_cv_mtx_; +std::condition_variable HelloWorldPublisher::PubListener::wait_matched_cv_; + +HelloWorldPublisher::HelloWorldPublisher() + : participant_(nullptr) + , publisher_(nullptr) + , topic_(nullptr) + , writer_(nullptr) + , type_(new HelloWorldPubSubType()) +{ +} + +bool HelloWorldPublisher::is_stopped() +{ + return stop_; +} + +void HelloWorldPublisher::stop() +{ + stop_ = true; + PubListener::awake(); +} + +bool HelloWorldPublisher::init( + const std::string& topic_name, + uint32_t domain, + uint32_t num_wait_matched, + bool async, + TransportType transport, + bool reliable, + bool transient, + int hops, + const std::string& partitions, + bool use_ownership, + unsigned int ownership_strength /* = 0 */) +{ + hello_.index(0); + memcpy(hello_.message().data(), "HelloWorld ", strlen("HelloWorld") + 1); + + DomainParticipantQos pqos; + pqos.name("Participant_pub"); + listener_.set_num_wait_matched(num_wait_matched); + + // TRANSPORT CONFIG + // If it is set, not use default and set the transport + if (transport != DEFAULT || hops > 0 ) + { + pqos.transport().use_builtin_transports = false; + + switch ( transport ) + { + case SHM: + { + auto shm_transport = std::make_shared(); + pqos.transport().user_transports.push_back(shm_transport); + } + break; + case UDPv4: + { + auto udp_transport = std::make_shared(); + pqos.transport().user_transports.push_back(udp_transport); + } + break; + case UDPv6: + { + auto udp_transport = std::make_shared(); + pqos.transport().user_transports.push_back(udp_transport); + } + break; + case DEFAULT: + default: + { + // mimick default transport selection + auto udp_transport = std::make_shared(); + pqos.transport().user_transports.push_back(udp_transport); +#ifdef SHM_TRANSPORT_BUILTIN + auto shm_transport = std::make_shared(); + pqos.transport().user_transports.push_back(shm_transport); +#endif // SHM_TRANSPORT_BUILTIN + } + } + + if ( hops > 0 ) + { + for (auto& transportDescriptor : pqos.transport().user_transports) + { + SocketTransportDescriptor* pT = dynamic_cast(transportDescriptor.get()); + if (pT) + { + pT->TTL = (uint8_t)std::min(hops, 255); + } + } + } + } + + // CREATE THE PARTICIPANT + participant_ = DomainParticipantFactory::get_instance()->create_participant(domain, pqos); + + if (participant_ == nullptr) + { + return false; + } + + // REGISTER THE TYPE + type_.register_type(participant_); + + // CREATE THE PUBLISHER + PublisherQos pbqos; + + if (!partitions.empty()) + { + // Divide in partitions by ; + std::stringstream spartitions(partitions); + std::string partition_cut; + while (std::getline(spartitions, partition_cut, ';')) + { + pbqos.partition().push_back(partition_cut.c_str()); + } + } + + // Create publisher + publisher_ = participant_->create_publisher(pbqos, nullptr); + + if (publisher_ == nullptr) + { + return false; + } + + // CREATE THE TOPIC + topic_ = participant_->create_topic(topic_name, "HelloWorld", TOPIC_QOS_DEFAULT); + + if (topic_ == nullptr) + { + return false; + } + + // CREATE THE WRITER + DataWriterQos wqos = DATAWRITER_QOS_DEFAULT; + + // Data sharing set in endpoint. If it is not default, set it to off + if (transport != DEFAULT) + { + wqos.data_sharing().off(); + } + else + { + wqos.data_sharing().automatic(); // default + } + + if (async) + { + wqos.publish_mode().kind = ASYNCHRONOUS_PUBLISH_MODE; + } + else + { + wqos.publish_mode().kind = SYNCHRONOUS_PUBLISH_MODE; // default + } + + if (reliable) + { + wqos.reliability().kind = RELIABLE_RELIABILITY_QOS; + wqos.history().kind = KEEP_ALL_HISTORY_QOS; + } + else + { + wqos.reliability().kind = BEST_EFFORT_RELIABILITY_QOS; // default in this example (although default value for + // writters' qos actually is RELIABLE) + } + + if (transient) + { + wqos.durability().kind = TRANSIENT_LOCAL_DURABILITY_QOS; + wqos.history().kind = KEEP_ALL_HISTORY_QOS; // store previously sent samples so they can be resent to newly + // matched DataReaders + } + else + { + wqos.durability().kind = VOLATILE_DURABILITY_QOS; // default in this example (although default value for + // writters' qos actually is TRANSIENT_LOCAL) + } + + // Set ownership + if (use_ownership) + { + wqos.ownership().kind = OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS; + wqos.ownership_strength().value = ownership_strength; + } + + wqos.liveliness().lease_duration = eprosima::fastrtps::Duration_t(2, 0); + wqos.liveliness().announcement_period = eprosima::fastrtps::Duration_t(1, 0); + + writer_ = publisher_->create_datawriter(topic_, wqos, &listener_); + + if (writer_ == nullptr) + { + return false; + } + + std::cout << "Publisher Participant created with DataWriter Guid [ " << writer_->guid() << " ]." << std::endl; + return true; +} + +HelloWorldPublisher::~HelloWorldPublisher() +{ + if (participant_ != nullptr) + { + if (publisher_ != nullptr) + { + if (writer_ != nullptr) + { + publisher_->delete_datawriter(writer_); + } + participant_->delete_publisher(publisher_); + } + if (topic_ != nullptr) + { + participant_->delete_topic(topic_); + } + DomainParticipantFactory::get_instance()->delete_participant(participant_); + } +} + +void HelloWorldPublisher::PubListener::on_publication_matched( + eprosima::fastdds::dds::DataWriter*, + const eprosima::fastdds::dds::PublicationMatchedStatus& info) +{ + if (info.current_count_change == 1) + { + matched_ = info.current_count; + std::cout << "Publisher matched [ " << iHandle2GUID(info.last_subscription_handle) << " ]." << std::endl; + if (enough_matched()) + { + awake(); + } + } + else if (info.current_count_change == -1) + { + matched_ = info.current_count; + std::cout << "Publisher unmatched [ " << iHandle2GUID(info.last_subscription_handle) << " ]." << std::endl; + } + else + { + std::cout << info.current_count_change + << " is not a valid value for PublicationMatchedStatus current count change" << std::endl; + } +} + +void HelloWorldPublisher::PubListener::set_num_wait_matched( + uint32_t num_wait_matched) +{ + num_wait_matched_ = num_wait_matched; +} + +bool HelloWorldPublisher::PubListener::enough_matched() +{ + return matched_ >= num_wait_matched_; +} + +void HelloWorldPublisher::PubListener::wait() +{ + std::unique_lock lck(wait_matched_cv_mtx_); + wait_matched_cv_.wait(lck, [this] + { + return enough_matched() || is_stopped(); + }); +} + +void HelloWorldPublisher::PubListener::awake() +{ + wait_matched_cv_.notify_all(); +} + +void HelloWorldPublisher::runThread( + uint32_t samples, + uint32_t sleep) +{ + while (!is_stopped() && (samples == 0 || hello_.index() < samples)) + { + if (listener_.enough_matched()) + { + publish(); + std::cout << "Message: " << hello_.message().data() << " with index: " << hello_.index() + << " SENT" << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(sleep)); + } + else + { + listener_.wait(); + } + } +} + +void HelloWorldPublisher::run( + uint32_t samples, + uint32_t sleep) +{ + stop_ = false; + std::thread thread(&HelloWorldPublisher::runThread, this, samples, sleep); + if (samples == 0) + { + std::cout << "Publisher running. Please press CTRL+C to stop the Publisher at any time." << std::endl; + } + else + { + std::cout << "Publisher running " << samples << + " samples. Please press CTRL+C to stop the Publisher at any time." << std::endl; + } + signal(SIGINT, [](int signum) + { + std::cout << "SIGINT received, stopping Publisher execution." << std::endl; + static_cast(signum); HelloWorldPublisher::stop(); + }); + thread.join(); +} + +void HelloWorldPublisher::publish() +{ + hello_.index(hello_.index() + 1); + writer_->write(&hello_); +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h new file mode 100644 index 00000000..8ce952a1 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h @@ -0,0 +1,150 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AdvancedConfigurationPublisher.h + * + */ + +#ifndef _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ADVANCEDCONFIGURATIONPUBLISHER_H_ +#define _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ADVANCEDCONFIGURATIONPUBLISHER_H_ + +#include +#include +#include + +#include +#include +#include + +#include "HelloWorldPubSubTypes.h" +#include "types.hpp" + +/** + * Class used to group into a single working unit a Publisher with a DataWriter, its listener, and a TypeSupport member + * corresponding to the HelloWorld datatype + */ +class HelloWorldPublisher +{ +public: + + HelloWorldPublisher(); + + virtual ~HelloWorldPublisher(); + + //! Initialize the publisher + bool init( + const std::string& topic_name, + uint32_t domain, + uint32_t num_wait_matched, + bool async, + TransportType transport, + bool reliable, + bool transient, + int hops, + const std::string& partitions, + bool use_ownership, + unsigned int ownership_strength); + + //! Publish a sample + void publish(); + + //! Run for number samples, publish every sleep seconds + void run( + uint32_t number, + uint32_t sleep); + + //! Return the current state of execution + static bool is_stopped(); + + //! Trigger the end of execution + static void stop(); + +private: + + HelloWorld hello_; + + eprosima::fastdds::dds::DomainParticipant* participant_; + + eprosima::fastdds::dds::Publisher* publisher_; + + eprosima::fastdds::dds::Topic* topic_; + + eprosima::fastdds::dds::DataWriter* writer_; + + eprosima::fastdds::dds::TypeSupport type_; + + /** + * Class handling discovery events and dataflow + */ + class PubListener : public eprosima::fastdds::dds::DataWriterListener + { + public: + + PubListener() + : matched_(0) + , num_wait_matched_(0) + { + } + + ~PubListener() override + { + } + + //! Callback executed when a DataReader is matched or unmatched + void on_publication_matched( + eprosima::fastdds::dds::DataWriter* writer, + const eprosima::fastdds::dds::PublicationMatchedStatus& info) override; + + //! Set the number of matched DataReaders required for publishing + void set_num_wait_matched( + uint32_t num_wait_matched); + + //! Return true if there are at least num_wait_matched_ matched DataReaders + bool enough_matched(); + + //! Block the thread until enough DataReaders are matched + void wait(); + + //! Unblock the thread so publication of samples begins/resumes + static void awake(); + + private: + + //! Number of DataReaders matched to the associated DataWriter + std::atomic matched_; + + //! Number of matched DataReaders required for publishing + uint32_t num_wait_matched_; + + //! Protects wait_matched condition variable + static std::mutex wait_matched_cv_mtx_; + + //! Waits until enough DataReaders are matched + static std::condition_variable wait_matched_cv_; + } + listener_; + + //! Run thread for number samples, publish every sleep seconds + void runThread( + uint32_t number, + uint32_t sleep); + + //! Member used for control flow purposes + static std::atomic stop_; +}; + + + +#endif /* _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ADVANCEDCONFIGURATIONPUBLISHER_H_ */ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp new file mode 100644 index 00000000..b15c3b63 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp @@ -0,0 +1,314 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AdvancedConfigurationSubscriber.cpp + * + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AdvancedConfigurationSubscriber.h" + +using namespace eprosima::fastdds::dds; +using namespace eprosima::fastdds::rtps; + +std::atomic HelloWorldSubscriber::stop_(false); +std::mutex HelloWorldSubscriber::terminate_cv_mtx_; +std::condition_variable HelloWorldSubscriber::terminate_cv_; + +HelloWorldSubscriber::HelloWorldSubscriber() + : participant_(nullptr) + , subscriber_(nullptr) + , topic_(nullptr) + , reader_(nullptr) + , type_(new HelloWorldPubSubType()) +{ +} + +bool HelloWorldSubscriber::is_stopped() +{ + return stop_; +} + +void HelloWorldSubscriber::stop() +{ + stop_ = true; + terminate_cv_.notify_all(); +} + +bool HelloWorldSubscriber::init( + const std::string& topic_name, + uint32_t max_messages, + uint32_t domain, + TransportType transport, + bool reliable, + bool transient, + int hops, + const std::string& partitions, + bool use_ownership) +{ + DomainParticipantQos pqos; + pqos.name("Participant_sub"); + + // TRANSPORT CONFIG + // If it is set, not use default and set the transport + if (transport != DEFAULT || hops > 0 ) + { + pqos.transport().use_builtin_transports = false; + + switch ( transport ) + { + case SHM: + { + auto shm_transport = std::make_shared(); + pqos.transport().user_transports.push_back(shm_transport); + } + break; + case UDPv4: + { + auto udp_transport = std::make_shared(); + pqos.transport().user_transports.push_back(udp_transport); + } + break; + case UDPv6: + { + auto udp_transport = std::make_shared(); + pqos.transport().user_transports.push_back(udp_transport); + } + break; + case DEFAULT: + default: + { + // mimick default transport selection + auto udp_transport = std::make_shared(); + pqos.transport().user_transports.push_back(udp_transport); +#ifdef SHM_TRANSPORT_BUILTIN + auto shm_transport = std::make_shared(); + pqos.transport().user_transports.push_back(shm_transport); +#endif // SHM_TRANSPORT_BUILTIN + } + } + + if ( hops > 0 ) + { + for (auto& transportDescriptor : pqos.transport().user_transports) + { + SocketTransportDescriptor* pT = dynamic_cast(transportDescriptor.get()); + if (pT) + { + pT->TTL = (uint8_t)std::min(hops, 255); + } + } + } + } + + // CREATE THE PARTICIPANT + participant_ = DomainParticipantFactory::get_instance()->create_participant(domain, pqos); + + if (participant_ == nullptr) + { + return false; + } + + // REGISTER THE TYPE + type_.register_type(participant_); + + // CREATE THE SUBSCRIBER + SubscriberQos sqos; + + if (!partitions.empty()) + { + // Divide in partitions by ; + std::stringstream spartitions(partitions); + std::string partition_cut; + while (std::getline(spartitions, partition_cut, ';')) + { + sqos.partition().push_back(partition_cut.c_str()); + } + } + + subscriber_ = participant_->create_subscriber(sqos, nullptr); + + if (subscriber_ == nullptr) + { + return false; + } + + // CREATE THE TOPIC + topic_ = participant_->create_topic( + topic_name, + "HelloWorld", + TOPIC_QOS_DEFAULT); + + if (topic_ == nullptr) + { + return false; + } + + // CREATE THE READER + if (max_messages > 0) + { + listener_.set_max_messages(max_messages); + } + DataReaderQos rqos = DATAREADER_QOS_DEFAULT; + + // Data sharing set in endpoint. If it is not default, set it to off + if (transport != DEFAULT) + { + rqos.data_sharing().off(); + } + else + { + rqos.data_sharing().automatic(); // default + } + + if (reliable) + { + rqos.reliability().kind = RELIABLE_RELIABILITY_QOS; + rqos.history().kind = KEEP_ALL_HISTORY_QOS; + } + else + { + rqos.reliability().kind = BEST_EFFORT_RELIABILITY_QOS; // default + } + + if (transient) + { + rqos.durability().kind = TRANSIENT_LOCAL_DURABILITY_QOS; + } + else + { + rqos.durability().kind = VOLATILE_DURABILITY_QOS; // default + } + + // Set ownership + if (use_ownership) + { + rqos.ownership().kind = OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS; + } + + reader_ = subscriber_->create_datareader(topic_, rqos, &listener_); + + if (reader_ == nullptr) + { + return false; + } + + std::cout << "Subscriber Participant created with DataReader Guid [ " << reader_->guid() << " ]." << std::endl; + + return true; +} + +HelloWorldSubscriber::~HelloWorldSubscriber() +{ + if (participant_ != nullptr) + { + if (subscriber_ != nullptr) + { + if (reader_ != nullptr) + { + subscriber_->delete_datareader(reader_); + } + participant_->delete_subscriber(subscriber_); + } + if (topic_ != nullptr) + { + participant_->delete_topic(topic_); + } + DomainParticipantFactory::get_instance()->delete_participant(participant_); + } +} + +void HelloWorldSubscriber::SubListener::set_max_messages( + uint32_t max_messages) +{ + max_messages_ = max_messages; +} + +void HelloWorldSubscriber::SubListener::on_subscription_matched( + DataReader*, + const SubscriptionMatchedStatus& info) +{ + if (info.current_count_change == 1) + { + matched_ = info.current_count; + std::cout << "Subscriber matched [ " << iHandle2GUID(info.last_publication_handle) << " ]." << std::endl; + } + else if (info.current_count_change == -1) + { + matched_ = info.current_count; + std::cout << "Subscriber unmatched [ " << iHandle2GUID(info.last_publication_handle) << " ]." << std::endl; + } + else + { + std::cout << info.current_count_change + << " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl; + } +} + +void HelloWorldSubscriber::SubListener::on_data_available( + DataReader* reader) +{ + SampleInfo info; + while ((reader->take_next_sample(&hello_, &info) == ReturnCode_t::RETCODE_OK) && !is_stopped()) + { + if (info.instance_state == ALIVE_INSTANCE_STATE) + { + samples_++; + // Print your structure data here. + std::cout << "Message " << hello_.message().data() << " " << hello_.index() << " RECEIVED" << std::endl; + if (max_messages_ > 0 && (samples_ >= max_messages_)) + { + stop(); + } + } + } +} + +void HelloWorldSubscriber::run( + uint32_t samples) +{ + stop_ = false; + if (samples > 0) + { + std::cout << "Subscriber running until " << samples << + " samples have been received. Please press CTRL+C to stop the Subscriber at any time." << std::endl; + } + else + { + std::cout << "Subscriber running. Please press CTRL+C to stop the Subscriber." << std::endl; + } + signal(SIGINT, [](int signum) + { + std::cout << "SIGINT received, stopping Subscriber execution." << std::endl; + static_cast(signum); HelloWorldSubscriber::stop(); + }); + std::unique_lock lck(terminate_cv_mtx_); + terminate_cv_.wait(lck, [] + { + return is_stopped(); + }); +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h new file mode 100644 index 00000000..37596a04 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h @@ -0,0 +1,136 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AdvancedConfigurationSubscriber.h + * + */ + +#ifndef _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ADVANCEDCONFIGURATIONSUBSCRIBER_H_ +#define _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ADVANCEDCONFIGURATIONSUBSCRIBER_H_ + +#include +#include +#include + +#include +#include +#include + +#include "HelloWorldPubSubTypes.h" +#include "types.hpp" + +/** + * Class used to group into a single working unit a Subscriber with a DataReader, its listener, and a TypeSupport member + * corresponding to the HelloWorld datatype + */ +class HelloWorldSubscriber +{ +public: + + HelloWorldSubscriber(); + + virtual ~HelloWorldSubscriber(); + + //! Initialize the subscriber + bool init( + const std::string& topic_name, + uint32_t max_messages, + uint32_t domain, + TransportType transport, + bool reliable, + bool transient, + int hops, + const std::string& partitions, + bool use_ownership); + + //! RUN the subscriber until number samples are received + void run( + uint32_t number); + + //! Return the current state of execution + static bool is_stopped(); + + //! Trigger the end of execution + static void stop(); + +private: + + eprosima::fastdds::dds::DomainParticipant* participant_; + + eprosima::fastdds::dds::Subscriber* subscriber_; + + eprosima::fastdds::dds::Topic* topic_; + + eprosima::fastdds::dds::DataReader* reader_; + + eprosima::fastdds::dds::TypeSupport type_; + + /** + * Class handling discovery and dataflow events + */ + class SubListener : public eprosima::fastdds::dds::DataReaderListener + { + public: + + SubListener() + : matched_(0) + , samples_(0) + , max_messages_(0) + { + } + + ~SubListener() override + { + } + + //! Set the maximum number of messages to receive before exiting + void set_max_messages( + uint32_t max_messages); + + //! Callback executed when a new sample is received + void on_data_available( + eprosima::fastdds::dds::DataReader* reader) override; + + //! Callback executed when a DataWriter is matched or unmatched + void on_subscription_matched( + eprosima::fastdds::dds::DataReader* reader, + const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; + + private: + + HelloWorld hello_; + + //! Number of DataWriters matched to the associated DataReader + int matched_; + + //! Number of samples received + uint32_t samples_; + + //! Number of messages to be received before triggering termination of execution + uint32_t max_messages_; + } + listener_; + + //! Member used for control flow purposes + static std::atomic stop_; + + //! Protects terminate condition variable + static std::mutex terminate_cv_mtx_; + + //! Waits during execution until SIGINT or max_messages_ samples are received + static std::condition_variable terminate_cv_; +}; + +#endif /* _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ADVANCEDCONFIGURATIONSUBSCRIBER_H_ */ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfiguration_main.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfiguration_main.cpp new file mode 100644 index 00000000..ce6e7b43 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfiguration_main.cpp @@ -0,0 +1,267 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AdvancedConfiguration_main.cpp + * + */ + +#include + +#include "arg_configuration.h" +#include "AdvancedConfigurationPublisher.h" +#include "AdvancedConfigurationSubscriber.h" +#include "types.hpp" + +enum EntityType +{ + PUBLISHER, + SUBSCRIBER +}; + +int main( + int argc, + char** argv) +{ + int columns; + +#if defined(_WIN32) + char* buf = nullptr; + size_t sz = 0; + if (_dupenv_s(&buf, &sz, "COLUMNS") == 0 && buf != nullptr) + { + columns = strtol(buf, nullptr, 10); + free(buf); + } + else + { + columns = 80; + } +#else + columns = getenv("COLUMNS") ? atoi(getenv("COLUMNS")) : 80; +#endif // if defined(_WIN32) + + EntityType type = PUBLISHER; + std::string topic_name = "HelloWorldTopic"; + int count = 0; + long sleep = 100; + int num_wait_matched = 0; + int domain = 0; + bool async = false; + TransportType transport = DEFAULT; + int hops = -1; + bool reliable = false; + bool transient = false; // transient local + std::string partitions = ""; + bool use_ownership = false; + unsigned int ownership_strength = 0; + // + argc -= (argc > 0); + argv += (argc > 0); // skip program name argv[0] if present + option::Stats stats(true, usage, argc, argv); + std::vector options(stats.options_max); + std::vector buffer(stats.buffer_max); + option::Parser parse(true, usage, argc, argv, &options[0], &buffer[0]); + + if (parse.error()) + { + option::printUsage(fwrite, stdout, usage, columns); + return 1; + } + + if (options[optionIndex::HELP]) + { + option::printUsage(fwrite, stdout, usage, columns); + return 0; + } + + // Decide between publisher or subscriber + try + { + if (parse.nonOptionsCount() != 1) + { + throw 1; + } + + const char* type_name = parse.nonOption(0); + + // make sure is the first option + if (parse.optionsCount() && type_name >= buffer[0].name) + { + throw 1; + } + + if (strcmp(type_name, "publisher") == 0) + { + type = PUBLISHER; + } + else if (strcmp(type_name, "subscriber") == 0) + { + type = SUBSCRIBER; + } + else + { + throw 1; + } + } + catch (int error) + { + std::cerr << "ERROR: first argument must be followed by - or -- options" << std::endl; + option::printUsage(fwrite, stdout, usage, columns); + return error; + } + + for (int i = 0; i < parse.optionsCount(); ++i) + { + option::Option& opt = buffer[i]; + switch (opt.index()) + { + case optionIndex::HELP: + // not possible, because handled further above and exits the program + break; + + case optionIndex::TOPIC: + topic_name = std::string(opt.arg); + break; + + case optionIndex::DOMAIN_ID: + domain = strtol(opt.arg, nullptr, 10); + break; + + case optionIndex::SAMPLES: + count = strtol(opt.arg, nullptr, 10); + break; + + case optionIndex::INTERVAL: + if (type == PUBLISHER) + { + sleep = strtol(opt.arg, nullptr, 10); + } + else + { + print_warning("publisher", opt.name); + } + break; + + case optionIndex::WAIT: + if (type == PUBLISHER) + { + num_wait_matched = strtol(opt.arg, nullptr, 10); + } + else + { + print_warning("publisher", opt.name); + } + break; + + case optionIndex::ASYNC: + if (type == PUBLISHER) + { + async = true; + } + else + { + print_warning("publisher", opt.name); + } + break; + + case optionIndex::TRANSPORT: + if (strcmp(opt.arg, "shm") == 0) + { + transport = SHM; + } + else if (strcmp(opt.arg, "udp") == 0 || (strcmp(opt.arg, "udpv4") == 0)) + { + transport = UDPv4; + } + else if (strcmp(opt.arg, "udpv6") == 0) + { + transport = UDPv6; + } + break; + + case optionIndex::RELIABLE: + reliable = true; + break; + + case optionIndex::TRANSIENT_LOCAL: + transient = true; + break; + + case optionIndex::TTL: + hops = strtol(opt.arg, nullptr, 10); + break; + + case optionIndex::PARTITIONS: + partitions = std::string(opt.arg); + break; + + case optionIndex::OWNERSHIP: + use_ownership = true; + break; + + case optionIndex::OWNERSHIP_STRENGTH: + if (type == PUBLISHER) + { + use_ownership = true; + ownership_strength = strtol(opt.arg, nullptr, 10); + } + else + { + print_warning("publisher", opt.name); + } + break; + + case optionIndex::UNKNOWN_OPT: + std::cerr << "ERROR: " << opt.name << " is not a valid argument." << std::endl; + option::printUsage(fwrite, stdout, usage, columns); + return 1; + break; + } + } + if (transient && !reliable) + { + std::cerr << "WARNING: --transient will take no effect since not reliable." << std::endl; + } + + if (transport == SHM && hops > 0 ) + { + std::cerr << "WARNING: --ttl will take no effect since not using UDP transport." << std::endl; + } + + switch (type) + { + case PUBLISHER: + { + HelloWorldPublisher mypub; + if (mypub.init(topic_name, static_cast(domain), static_cast(num_wait_matched), async, + transport, reliable, transient, hops, partitions, use_ownership, ownership_strength)) + { + mypub.run(static_cast(count), static_cast(sleep)); + } + break; + } + case SUBSCRIBER: + { + HelloWorldSubscriber mysub; + if (mysub.init(topic_name, static_cast(count), static_cast(domain), transport, + reliable, transient, hops, partitions, use_ownership)) + { + mysub.run(static_cast(count)); + } + break; + } + } + return 0; +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt new file mode 100644 index 00000000..acdbe3c8 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.16.3) + +project(AdvancedConfigurationExample_FastDDSSpy_tool_tests VERSION 1 LANGUAGES CXX) + +set(EXECUTABLE_NAME "AdvancedConfigurationExample") + +# Find requirements +if(NOT fastcdr_FOUND) + find_package(fastcdr REQUIRED) +endif() + +if(NOT fastrtps_FOUND) + find_package(fastrtps REQUIRED) +endif() + +#Check C++11 +include(CheckCXXCompilerFlag) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) + check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) + if(NOT SUPPORTS_CXX11) + message(FATAL_ERROR "Compiler doesn't support C++11") + endif() +endif() + +message(STATUS "Configuring AdvancedConfiguration example...") +file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX "*.cxx") +file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP "*.cpp") + +add_executable(${EXECUTABLE_NAME} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP}) +target_compile_definitions(${EXECUTABLE_NAME} PRIVATE + $<$>,$>:__DEBUG> + $<$:__INTERNALDEBUG> # Internal debug activated. + $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport +) + +target_link_libraries(${EXECUTABLE_NAME} fastrtps fastcdr fastdds::optionparser) +install(TARGETS ${EXECUTABLE_NAME} + RUNTIME DESTINATION examples/cpp/dds/${EXECUTABLE_NAME}/${BIN_INSTALL_DIR}) diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx new file mode 100644 index 00000000..775eb649 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx @@ -0,0 +1,239 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "HelloWorld.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +HelloWorld::HelloWorld() +{ + // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@2b552920 + m_index = 0; + // m_message com.eprosima.idl.parser.typecode.ArrayTypeCode@1f36e637 + memset(&m_message, 0, (20) * 1); + +} + +HelloWorld::~HelloWorld() +{ + + +} + +HelloWorld::HelloWorld( + const HelloWorld& x) +{ + m_index = x.m_index; + m_message = x.m_message; +} + +HelloWorld::HelloWorld( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + m_message = std::move(x.m_message); +} + +HelloWorld& HelloWorld::operator =( + const HelloWorld& x) +{ + + m_index = x.m_index; + m_message = x.m_message; + + return *this; +} + +HelloWorld& HelloWorld::operator =( + HelloWorld&& x) noexcept +{ + + m_index = x.m_index; + m_message = std::move(x.m_message); + + return *this; +} + +bool HelloWorld::operator ==( + const HelloWorld& x) const +{ + + return (m_index == x.m_index && m_message == x.m_message); +} + +bool HelloWorld::operator !=( + const HelloWorld& x) const +{ + return !(*this == x); +} + +size_t HelloWorld::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += ((20) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + + return current_alignment - initial_alignment; +} + +size_t HelloWorld::getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += ((20) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + return current_alignment - initial_alignment; +} + +void HelloWorld::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_index; + scdr << m_message; + + +} + +void HelloWorld::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_index; + dcdr >> m_message; + +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void HelloWorld::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t HelloWorld::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& HelloWorld::index() +{ + return m_index; +} + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void HelloWorld::message( + const std::array& _message) +{ + m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void HelloWorld::message( + std::array&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::array& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::array& HelloWorld::message() +{ + return m_message; +} + +size_t HelloWorld::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h new file mode 100644 index 00000000..d714752b --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h @@ -0,0 +1,234 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HelloWorld_SOURCE) +#define HelloWorld_DllAPI __declspec( dllexport ) +#else +#define HelloWorld_DllAPI __declspec( dllimport ) +#endif // HelloWorld_SOURCE +#else +#define HelloWorld_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define HelloWorld_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HELLOWORLD + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + const HelloWorld& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + HelloWorld&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + const HelloWorld& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + HelloWorld&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator ==( + const HelloWorld& x) const; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator !=( + const HelloWorld& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::array& _message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::array&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::array& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::array& message(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + uint32_t m_index; + std::array m_message; +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ \ No newline at end of file diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.idl b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.idl new file mode 100644 index 00000000..9750fbe1 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.idl @@ -0,0 +1,5 @@ +struct HelloWorld +{ + unsigned long index; + char message[20]; +}; diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx new file mode 100644 index 00000000..237fb758 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx @@ -0,0 +1,170 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "HelloWorldPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +HelloWorldPubSubType::HelloWorldPubSubType() +{ + setName("HelloWorld"); + auto type_size = HelloWorld::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = HelloWorld::isKeyDefined(); + size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize() > 16 ? + HelloWorld::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +HelloWorldPubSubType::~HelloWorldPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool HelloWorldPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool HelloWorldPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function HelloWorldPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* HelloWorldPubSubType::createData() +{ + return reinterpret_cast(new HelloWorld()); +} + +void HelloWorldPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool HelloWorldPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + HelloWorld::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || HelloWorld::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h new file mode 100644 index 00000000..af8725f1 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ + +#include +#include + +#include "HelloWorld.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. + * @ingroup HELLOWORLD + */ +class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport virtual ~HelloWorldPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) HelloWorld(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ \ No newline at end of file diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md new file mode 100644 index 00000000..4d3d6137 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md @@ -0,0 +1,85 @@ +# Advanced Configuration Example + +This example extends the configuration options of a trivial HelloWorld by letting the user specify properties of +entities such as durability, reliability or specify the transport protocol to be used, among other possibilities. This +could be useful, for example, to quickly test whether two endpoints are compatible and hence would match. + +## Execution instructions + +To launch this test open two different consoles: + +In the first one launch: ./AdvancedConfigurationExample publisher (or AdvancedConfigurationExample.exe publisher on windows). +In the second one: ./AdvancedConfigurationExample subscriber (or AdvancedConfigurationExample.exe subscriber on windows). + +## Arguments + +First argument is `publisher` or `subscriber` and then the rest of arguments are read unordered + +```sh +Usage: AdvancedConfigurationExample + +General options: + -h --help + Produce help message. + +Publisher options: + -t --topic= + Topic name (Default: HelloWorldTopic). + -d --domain= + DDS domain ID (Default: 0). + -w --wait= + Number of matched subscribers required to publish (Default: + 0 => does not wait). + -s --samples= + Number of samples to send (Default: 0 => infinite samples). + -i --interval= + Time between samples in milliseconds (Default: 100). + -a --async + Asynchronous publish mode (synchronous by default). + --transport= + Use only shared-memory, UDPv4, or UDPv6 transport.If not + set, use Fast DDS default transports (depending on the + scenario it will use the most efficient one: data-sharing + delivery mechanism > shared-memory > UDP). + -o --ownership + Use Topic with EXCLUSIVE_OWNERSHIP (SHARED_OWNERSHIP by + default). + --strength= + Set this Publisher strength. Set Topic with + EXCLUSIVE_OWNERSHIP. Default: 0 + +Subscriber options: + -t --topic= + Topic name (Default: HelloWorldTopic). + -d --domain= + DDS domain ID (Default: 0). + -s --samples= + Number of samples to wait for (Default: 0 => infinite + samples). + --transport= + Use only shared-memory, UDPv4, or UDPv6 transport.If not + set, use Fast DDS default transports (depending on the + scenario it will use the most efficient one: data-sharing + delivery mechanism > shared-memory > UDP). + -o --ownership + Use Topic with EXCLUSIVE_OWNERSHIP (SHARED_OWNERSHIP by + default). + +QoS options: + -r --reliable + Set reliability to reliable (best-effort by default). + --transient + Set durability to transient local (volatile by default, + ineffective when not reliable). + -p --partitions= + Partitions to match separated by ';'. Single or double + quotes required with multiple partitions. With empty string + ('') no partitions used. (Default: ''). + +Discovery options: + --ttl + Set multicast discovery Time To Live on IPv4 or Hop Limit + for IPv6. If not set, uses Fast-DDS default (1 hop). + Increase it to avoid discovery issues on scenarios with + several routers. Maximum: 255. +``` diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h new file mode 100644 index 00000000..c53a98f7 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h @@ -0,0 +1,249 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file arg_configuration.h + * + */ + +#ifndef _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ARG_CONFIGURATION_H_ +#define _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ARG_CONFIGURATION_H_ + +#include +#include +#include +#include + +#include + +namespace option = eprosima::option; + +struct Arg : public option::Arg +{ + static void print_error( + const char* msg1, + const option::Option& opt, + const char* msg2) + { + fprintf(stderr, "%s", msg1); + fwrite(opt.name, opt.namelen, 1, stderr); + fprintf(stderr, "%s", msg2); + } + + static option::ArgStatus Unknown( + const option::Option& option, + bool msg) + { + if (msg) + { + print_error("Unknown option '", option, "'\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Required( + const option::Option& option, + bool msg) + { + if (option.arg != 0 && option.arg[0] != 0) + { + return option::ARG_OK; + } + + if (msg) + { + print_error("Option '", option, "' requires an argument\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Numeric( + const option::Option& option, + bool msg) + { + char* endptr = 0; + if ( option.arg != nullptr ) + { + strtol(option.arg, &endptr, 10); + if (endptr != option.arg && *endptr == 0) + { + return option::ARG_OK; + } + } + + if (msg) + { + print_error("Option '", option, "' requires a numeric argument\n"); + } + return option::ARG_ILLEGAL; + } + + template::max()> + static option::ArgStatus NumericRange( + const option::Option& option, + bool msg) + { + static_assert(min <= max, "NumericRange: invalid range provided."); + + char* endptr = 0; + if ( option.arg != nullptr ) + { + long value = strtol(option.arg, &endptr, 10); + if ( endptr != option.arg && *endptr == 0 && + value >= min && value <= max) + { + return option::ARG_OK; + } + } + + if (msg) + { + std::ostringstream os; + os << "' requires a numeric argument in range [" + << min << ", " << max << "]" << std::endl; + print_error("Option '", option, os.str().c_str()); + } + + return option::ARG_ILLEGAL; + } + + static option::ArgStatus String( + const option::Option& option, + bool msg) + { + if (option.arg != 0) + { + return option::ARG_OK; + } + if (msg) + { + print_error("Option '", option, "' requires a string argument\n"); + } + return option::ARG_ILLEGAL; + } + + static option::ArgStatus Transport( + const option::Option& option, + bool msg) + { + if (option.arg != 0) + { + std::string transport = std::string(option.arg); + if (transport != "shm" && transport != "udp" && transport != "udpv4" && transport != "udpv6") + { + if (msg) + { + print_error("Option '", option, "' only accepts values\n"); + } + return option::ARG_ILLEGAL; + } + return option::ARG_OK; + } + if (msg) + { + print_error("Option '", option, "' requires a string argument\n"); + } + return option::ARG_ILLEGAL; + } + +}; + +enum optionIndex +{ + UNKNOWN_OPT, + HELP, + TOPIC, + WAIT, + SAMPLES, + INTERVAL, + ASYNC, + DOMAIN_ID, + TRANSPORT, + RELIABLE, + TRANSIENT_LOCAL, + TTL, + PARTITIONS, + OWNERSHIP_STRENGTH, + OWNERSHIP +}; + +const option::Descriptor usage[] = { + { UNKNOWN_OPT, 0, "", "", Arg::None, + "Usage: AdvancedConfigurationExample \n\nGeneral options:" }, + { HELP, 0, "h", "help", Arg::None, " -h \t--help \tProduce help message." }, + + { UNKNOWN_OPT, 0, "", "", Arg::None, "\nPublisher options:"}, + { TOPIC, 0, "t", "topic", Arg::String, + " -t \t--topic= \tTopic name (Default: HelloWorldTopic)." }, + { DOMAIN_ID, 0, "d", "domain", Arg::NumericRange<0, 230>, + " -d \t--domain= \tDDS domain ID (Default: 0)." }, + { WAIT, 0, "w", "wait", Arg::NumericRange<>, + " -w \t--wait= \tNumber of matched subscribers required to publish" + " (Default: 0 => does not wait)." }, + { SAMPLES, 0, "s", "samples", Arg::NumericRange<>, + " -s \t--samples= \tNumber of samples to send (Default: 0 => infinite samples)." }, + { INTERVAL, 0, "i", "interval", Arg::NumericRange<>, + " -i \t--interval= \tTime between samples in milliseconds (Default: 100)." }, + { ASYNC, 0, "a", "async", Arg::None, + " -a \t--async \tAsynchronous publish mode (synchronous by default)." }, + { TRANSPORT, 0, "", "transport", Arg::Transport, + " \t--transport= \tUse only shared-memory, UDPv4, or UDPv6 transport." + "If not set, use Fast DDS default transports (depending on the scenario it will use the most efficient one:" + " data-sharing delivery mechanism > shared-memory > UDP)." }, + { OWNERSHIP, 0, "o", "ownership", Arg::None, + " -o \t--ownership \tUse Topic with EXCLUSIVE_OWNERSHIP (SHARED_OWNERSHIP by default)."}, + { OWNERSHIP_STRENGTH, 0, "", "strength", Arg::NumericRange<>, + " \t--strength= \tSet this Publisher strength. Set Topic with EXCLUSIVE_OWNERSHIP. Default: 0"}, + + { UNKNOWN_OPT, 0, "", "", Arg::None, "\nSubscriber options:"}, + { TOPIC, 0, "t", "topic", Arg::String, + " -t \t--topic= \tTopic name (Default: HelloWorldTopic)." }, + { DOMAIN_ID, 0, "d", "domain", Arg::NumericRange<0, 230>, + " -d \t--domain= \tDDS domain ID (Default: 0)." }, + { SAMPLES, 0, "s", "samples", Arg::NumericRange<>, + " -s \t--samples= \tNumber of samples to wait for (Default: 0 => infinite samples)." }, + { TRANSPORT, 0, "", "transport", Arg::Transport, + " \t--transport= \tUse only shared-memory, UDPv4, or UDPv6 transport." + "If not set, use Fast DDS default transports (depending on the scenario it will use the most efficient one:" + " data-sharing delivery mechanism > shared-memory > UDP)." }, + { OWNERSHIP, 0, "o", "ownership", Arg::None, + " -o \t--ownership \tUse Topic with EXCLUSIVE_OWNERSHIP (SHARED_OWNERSHIP by default)."}, + + { UNKNOWN_OPT, 0, "", "", Arg::None, "\nQoS options:"}, + { RELIABLE, 0, "r", "reliable", Arg::None, + " -r \t--reliable \tSet reliability to reliable (best-effort by default)." }, + { TRANSIENT_LOCAL, 0, "", "transient", Arg::None, + " \t--transient \tSet durability to transient local (volatile by default, ineffective when not reliable)." }, + { PARTITIONS, 0, "p", "partitions", Arg::String, + " -p \t--partitions= \tPartitions to match separated by ';'." + " Single or double quotes required with multiple partitions." + " With empty string ('') no partitions used. (Default: '')." }, + + { UNKNOWN_OPT, 0, "", "", Arg::None, "\nDiscovery options:"}, + { TTL, 0, "", "ttl", Arg::NumericRange<1, 255>, + "\t--ttl \tSet multicast discovery Time To Live on IPv4 or Hop Limit for IPv6." + " If not set, uses Fast-DDS default (1 hop). Increase it to avoid discovery issues" + " on scenarios with several routers. Maximum: 255."}, + + { 0, 0, 0, 0, 0, 0 } +}; + +void print_warning( + std::string type, + const char* opt) +{ + std::cerr << "WARNING: " << opt << " is a " << type << " option, ignoring argument." << std::endl; +} + +#endif /* _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_ARG_CONFIGURATION_H_ */ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types.hpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types.hpp new file mode 100644 index 00000000..b323d8e0 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types.hpp @@ -0,0 +1,31 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AdvancedConfigurationPublisher.h + * + */ + +#ifndef _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_TYPES_HPP_ +#define _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_TYPES_HPP_ + +enum TransportType +{ + DEFAULT, + SHM, + UDPv4, + UDPv6, +}; + +#endif /* _EPROSIMA_FASTDDS_EXAMPLES_CPP_DDS_ADVANCEDCONFIGURATIONEXAMPLE_TYPES_HPP_ */ diff --git a/fastddsspy_tool/test/application/launcher.ps1 b/fastddsspy_tool/test/application/launcher.ps1 new file mode 100644 index 00000000..8a49a7cd --- /dev/null +++ b/fastddsspy_tool/test/application/launcher.ps1 @@ -0,0 +1,60 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Param( + [Parameter(Position=0, Mandatory=$true)] + [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] + [String] + # python3 binary + $python_path, + + [Parameter(Position=1, Mandatory=$true)] + [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] + [String] + # python script that keeps the testing + $test_script, + + [Parameter(Position=2, Mandatory=$true)] + [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] + [String] + # fastddsspy creation binary full qualified path + $tool_path, + + [Parameter(Position=3, Mandatory=$true)] + [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] + [String] + # fastdds publisher creation binary full qualified path + $pub_path, + + [Parameter(Position=4, Mandatory=$true)] + [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] + [String] + # fastddsspy test + $test_path +) + +$test = Start-Process -Passthru -Wait ` + -FilePath $python_path ` + -ArgumentList ( + $test_script, + "--exe", $tool_path, + "--pub", $pub_path, + "--test", $test_path) ` + -WindowStyle Hidden + +if( $test.ExitCode -ne 0 ) +{ + $error_message = "Test: $test_path failed with exit code $($test.ExitCode)." + throw $error_message +} diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py new file mode 100644 index 00000000..37a9aaa2 --- /dev/null +++ b/fastddsspy_tool/test/application/test.py @@ -0,0 +1,176 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Tests for the fastddsspy executable. + +Contains a package of system test for fastddsspy tool + +Usage: test.py --exe --pub --test + +Arguments: + Fast DDS Spy binary path : -e | --exe binary_path + Fast DDS publisher path : -p | --pub publisher_path + Test name : -t | --test +""" +import argparse +import importlib +import os +import sys + + +DESCRIPTION = """Script to execute Fast DDS Spy executable test""" +USAGE = ('python3 tests.py -e ' + ' [-d]') + + +def is_linux() -> bool: + """ + @brief Check if the script is running in a Linux environment. + + @return: True if the script is running in a Linux environment, False otherwise. + """ + return os.name == 'posix' + + +def executable_permission_value(): + """ + @brief Return the executable permission value depending on the operating system. + + @return: The executable permission value. + """ + if os.name == 'nt': + return os.X_OK # windows + else: + return os.EX_OK + + +def file_exist_and_have_permissions(file_path): + """ + @brief Check if a file exists and has executable permissions. + + @param file_path: The path of the file to check. + @return: The file path if it exists and has executable permissions, otherwise None. + """ + if os.access(file_path, executable_permission_value()): + return file_path + else: + return None + + +def parse_options(): + """ + @brief Parse command-line arguments. + + @return: The parsed arguments. + """ + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + add_help=True, + description=(DESCRIPTION), + usage=(USAGE) + ) + required_args = parser.add_argument_group('required arguments') + required_args.add_argument( + '-e', + '--exe', + type=file_exist_and_have_permissions, + required=True, + help='Path to DDS Spy executable.' + ) + required_args.add_argument( + '-p', + '--pub', + type=file_exist_and_have_permissions, + required=True, + help='Path to DDS Publisher executable.' + ) + required_args.add_argument( + '-t', + '--test', + type=str, + required=True, + help='Test to run.' + ) + + return parser.parse_args() + + +def get_config_path_spy(arguments_spy, exec_spy, config): + """ + @brief Get the path of the configuration of the Spy + + @param arguments_spy: List of arguments for the DDS Spy. + @param exec_spy: Fast DDS Spy executable file path. + @param config: Name of the configuration file. + """ + index = arguments_spy.index('configuration') + if is_linux(): + arguments_spy[index] = \ + exec_spy.replace('fastddsspy_tool/fastddsspy', + config) + else: + if 'Debug' in exec_spy: + build_type = 'Debug' + else: + build_type = 'Release' + arguments_spy[index] = \ + exec_spy.replace('fastddsspy_tool/' + build_type + '/fastddsspy.exe', + config) + return arguments_spy + + +def main(): + """@brief The main entry point of the program.""" + args = parse_options() + + module = importlib.import_module('test_cases.'+args.test) + test_class = module.TestCase_instance() + test_class.exec_spy = args.exe + test_class.exec_dds = args.pub + + if test_class.config != '': + test_class.arguments_spy = get_config_path_spy( + test_class.arguments_spy, + test_class.exec_spy, + test_class.config) + + dds = test_class.run_dds() + spy = test_class.run_tool() + + if spy is None: + print('ERROR: Wrong output') + test_class.stop_dds(dds) + sys.exit(1) + + if not test_class.one_shot: + + output = test_class.send_command_tool(spy) + + if not test_class.valid_output(output): + test_class.stop_tool(spy) + test_class.stop_dds(dds) + print('ERROR: Output command not valid') + sys.exit(1) + + if not test_class.stop_dds(dds): + sys.exit(1) + + if not test_class.one_shot: + test_class.stop_tool(spy) + + sys.exit(0) + + +if __name__ == '__main__': + main() diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__config.py b/fastddsspy_tool/test/application/test_cases/one_shot__config.py new file mode 100644 index 00000000..96e43659 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config.py @@ -0,0 +1,43 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_basic.yaml datareaders + AdvancedConfigurationExample publisher + """ + super().__init__( + name='--configCommand', + one_shot=True, + command=[], + dds=False, + config='fastddsspy_tool/test/application/configuration/\ +configuration_basic.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datareaders'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py new file mode 100644 index 00000000..cd6a261c --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py @@ -0,0 +1,62 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_wrong_empty_arg.yaml datareaders + """ + super().__init__( + name='--configFailArgCommand', + one_shot=True, + command=[], + dds=False, + config='fastddsspy_tool/test/application/configuration/\ +configuration_wrong_empty_arg.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datareaders'], + commands_spy=[], + output="""\x1b[37;1m2023-04-13 11:52:11.327 \ +\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Error] \ +\x1b[37mError Loading Fast DDS Spy Configuration from file \ +/home/user/DDS-Spy/build/fastddsspy_tool\ +/test/application/configuration/configuration_wrong_empty_arg.yaml. \ +Error message:\n\ + Error loading DDS Router configuration from yaml:\n\ + Error getting required value of type in\ + tag :\n Trying to read a primitive value of type from\ + a non scalar yaml.\ +\x1b[34;1m -> Function \x1b[36mmain\x1b[m\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py new file mode 100644 index 00000000..c8ae0071 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py @@ -0,0 +1,76 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path hello + """ + super().__init__( + name='--configFailCommand', + one_shot=True, + command=[], + dds=False, + config='hello', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=[], + output="""Usage: Fast DDS Spy \n\ +Start an interactive CLI to introspect a DDS network.\n\ +General options:\n\ +\n\ +Application help and information.\n\ + -h --help Print this help message.\n\ + -v --version Print version, branch and commit hash.\n\ +\n\ +Application parameters\n\ + -c --config-path Path to the Configuration File (yaml format) \ +[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\ + -r --reload-time Time period in seconds to reload configuration file. \ +This is needed when FileWatcher functionality is not available \ +(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\ +\n\ +Debug parameters\n\ + -d --debug Set log verbosity to Info \ + \n\ + (Using this option with \ +--log-filter and/or --log-verbosity will head to undefined behaviour).\n\ + --log-filter Set a Regex Filter to filter by category the info and warning \ +log entries. [Default = "FASTDDSSPY"]. \n\ + --log-verbosity Set a Log Verbosity Level higher or equal the one given. \ +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\ +\n\ +\x1b[37;1m2023-04-12 14:29:23.337 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \ +\x1b[37mOption '--config-path' requires an existing readable file as argument.\ +\x1b[34;1m -> Function \x1b[36mReadable_File\x1b[m\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py new file mode 100644 index 00000000..3ca1d863 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py @@ -0,0 +1,60 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_wrong_type.yaml datareaders + """ + super().__init__( + name='--configFailTypeCommand', + one_shot=True, + command=[], + dds=False, + config='fastddsspy_tool/test/application/configuration/\ +configuration_wrong_type.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datareaders'], + commands_spy=[], + output="""\x1b[37;1m2023-04-13 11:36:09.453 \ +\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Error] \ +\x1b[37mError Loading Fast DDS Spy Configuration from file \ +/home/user/DDS-Spy/build/fastddsspy_tool\ +/test/application/configuration/configuration_wrong_type.yaml. \ +Error message:\n Error loading DDS Router configuration from yaml:\n \ +Error getting required value of type in tag :\n Incorrect format for primitive value, \ +expected :\n yaml-cpp: error at line 4, column 11: bad conversion\ +\x1b[34;1m -> Function \x1b[36mmain\x1b[m\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__debug.py b/fastddsspy_tool/test/application/test_cases/one_shot__debug.py new file mode 100644 index 00000000..65de554f --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__debug.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --debug exit + """ + super().__init__( + name='--DebugCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--debug', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__help.py b/fastddsspy_tool/test/application/test_cases/one_shot__help.py new file mode 100644 index 00000000..d4568681 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__help.py @@ -0,0 +1,90 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import os + +import test_class + + +def is_windows() -> bool: + """ + @brief Check if the script is running in a Windows environment. + + @return: True if the script is running in a Windows environment, False otherwise. + """ + return os.name == 'nt' + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --help + """ + super().__init__( + name='--HelpCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--help'], + commands_spy=[], + output="""Usage: Fast DDS Spy \n\ +Start an interactive CLI to introspect a DDS network.\n\ +General options:\n\ + +Application help and information.\n\ + -h --help Print this help message.\n\ + -v --version Print version, branch and commit hash.\n\ +\n\ +Application parameters\n\ + -c --config-path Path to the Configuration File (yaml format) \ +[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\ + -r --reload-time Time period in seconds to reload configuration file. \ +This is needed when FileWatcher functionality is not available \ +(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\ +\n\ +Debug parameters\n\ + -d --debug Set log verbosity to Info \ + \n\ + (Using this option with \ +--log-filter and/or --log-verbosity will head to undefined behaviour).\n\ + --log-filter Set a Regex Filter to filter by category the info and warning \ +log entries. [Default = "FASTDDSSPY"]. \n\ + --log-verbosity Set a Log Verbosity Level higher or equal the one given. \ +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\n +""" + ) + + def valid_output(self, output): + """ + @brief Validate the output against the expected output or delegate \ + the validation to the parent class. + + @param output: The actual output obtained from executing a command. + @return True if the output is considered valid, either because the \ + system is running on Windows or the parent class validates the output, \ + False otherwise. + """ + if (is_windows()): + return True + else: + return super().valid_output(output) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__log_filter.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter.py new file mode 100644 index 00000000..804c5726 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-filter (FASTDDSSPY) exit + """ + super().__init__( + name='--log-filterCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--log-filter', '(FASTDDSSPY)', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py new file mode 100644 index 00000000..ecd61b2a --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py @@ -0,0 +1,76 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-filter + """ + super().__init__( + name='--log-filterFailCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--log-filter'], + commands_spy=[], + output="""Usage: Fast DDS Spy \n\ +Start an interactive CLI to introspect a DDS network.\n\ +General options:\n\ + +Application help and information.\n\ + -h --help Print this help message.\n\ + -v --version Print version, branch and commit hash.\n\ +\n\ +Application parameters\n\ + -c --config-path Path to the Configuration File (yaml format) \ +[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\ + -r --reload-time Time period in seconds to reload configuration file. \ +This is needed when FileWatcher functionality is not available \ +(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\ +\n\ +Debug parameters\n\ + -d --debug Set log verbosity to Info \ + \n\ + (Using this option with \ +--log-filter and/or --log-verbosity will head to undefined behaviour).\n\ + --log-filter Set a Regex Filter to filter by category the info and warning \ +log entries. [Default = "(DDSPIPE|FASTDDSSPY)"]. \n\ + --log-verbosity Set a Log Verbosity Level higher or equal the one given. \ +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\ +\n\ +\x1b[37;1m2023-04-13 12:08:51.556 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \ +\x1b[37mOption \'--log-filter\' requires a text argument.\x1b[34;1m -> Function \ +\x1b[36mString\x1b[m\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_error.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_error.py new file mode 100644 index 00000000..428fbd27 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_error.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity error exit + """ + super().__init__( + name='--log-verbosityCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'error', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py new file mode 100644 index 00000000..b68647a2 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py @@ -0,0 +1,76 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity hello exit + """ + super().__init__( + name='--log-verbosityFailCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'hello', 'exit'], + commands_spy=[], + output="""Usage: Fast DDS Spy \n\ +Start an interactive CLI to introspect a DDS network.\n\ +General options:\n\ + +Application help and information.\n\ + -h --help Print this help message.\n\ + -v --version Print version, branch and commit hash.\n\ +\n\ +Application parameters\n\ + -c --config-path Path to the Configuration File (yaml format) \ +[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\ + -r --reload-time Time period in seconds to reload configuration file. \ +This is needed when FileWatcher functionality is not available \ +(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\ +\n\ +Debug parameters\n\ + -d --debug Set log verbosity to Info \ + \n\ + (Using this option with \ +--log-filter and/or --log-verbosity will head to undefined behaviour).\n\ + --log-filter Set a Regex Filter to filter by category the info and warning \ +log entries. [Default = "(DDSPIPE|FASTDDSSPY)"]. \n\ + --log-verbosity Set a Log Verbosity Level higher or equal the one given. \ +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\ +\n\ +\x1b[37;1m2023-04-12 14:29:23.337 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \ +\x1b[37mOption '--log-verbosity' requires a one of this values: {"error";"warning";"info";}.\ +\x1b[34;1m -> Function \x1b[36mValid_Options\x1b[m\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_info.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_info.py new file mode 100644 index 00000000..acfd5420 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_info.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity info exit + """ + super().__init__( + name='--log-verbosityCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'info', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_warning.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_warning.py new file mode 100644 index 00000000..43203a88 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_warning.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity warning exit + """ + super().__init__( + name='--log-verbosityCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'warning', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__null.py b/fastddsspy_tool/test/application/test_cases/one_shot__null.py new file mode 100644 index 00000000..beba48a9 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__null.py @@ -0,0 +1,76 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --nullarg + """ + super().__init__( + name='--FailCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--nullarg'], + commands_spy=[], + output="""Usage: Fast DDS Spy \n\ +Start an interactive CLI to introspect a DDS network.\n\ +General options:\n\ + +Application help and information.\n\ + -h --help Print this help message.\n\ + -v --version Print version, branch and commit hash.\n\ +\n\ +Application parameters\n\ + -c --config-path Path to the Configuration File (yaml format) \ +[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\ + -r --reload-time Time period in seconds to reload configuration file. \ +This is needed when FileWatcher functionality is not available \ +(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\ +\n\ +Debug parameters\n\ + -d --debug Set log verbosity to Info \ + \n\ + (Using this option with \ +--log-filter and/or --log-verbosity will head to undefined behaviour).\n\ + --log-filter Set a Regex Filter to filter by category the info and warning \ +log entries. [Default = "FASTDDSSPY"]. \n\ + --log-verbosity Set a Log Verbosity Level higher or equal the one given. \ +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\ +\n\ +\x1b[37;1m2023-04-12 14:29:23.337 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \ +\x1b[37m--nullarg is not a valid argument.\ +\x1b[34;1m -> Function \x1b[36mparse_arguments\x1b[m\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__reload_time.py b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time.py new file mode 100644 index 00000000..2e233bb8 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --reload-time 2 exit + """ + super().__init__( + name='--reloadCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--reload-time', '2', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py new file mode 100644 index 00000000..0affd588 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py @@ -0,0 +1,76 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --reload-time hello exit + """ + super().__init__( + name='--reloadFailCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--reload-time', 'hello', 'exit'], + commands_spy=[], + output="""Usage: Fast DDS Spy \n\ +Start an interactive CLI to introspect a DDS network.\n\ +General options:\n\ + +Application help and information.\n\ + -h --help Print this help message.\n\ + -v --version Print version, branch and commit hash.\n\ +\n\ +Application parameters\n\ + -c --config-path Path to the Configuration File (yaml format) \ +[Default: ./FASTDDSSPY_CONFIGURATION.yaml].\n\ + -r --reload-time Time period in seconds to reload configuration file. \ +This is needed when FileWatcher functionality is not available \ +(e.g. config file is a symbolic link). Value 0 does not reload file. [Default: 0].\n\ +\n\ +Debug parameters\n\ + -d --debug Set log verbosity to Info \ + \n\ + (Using this option with \ +--log-filter and/or --log-verbosity will head to undefined behaviour).\n\ + --log-filter Set a Regex Filter to filter by category the info and warning \ +log entries. [Default = "FASTDDSSPY"]. \n\ + --log-verbosity Set a Log Verbosity Level higher or equal the one given. \ +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\ +\n\ +\x1b[37;1m2023-04-12 14:29:23.337 \x1b[31;1m[\x1b[37;1mFOXGLOVEWS_ARGS\x1b[31;1m Error] \ +\x1b[37mOption '--reload-time' requires a numeric argument.\ +\x1b[34;1m -> Function \x1b[36mValid_Options\x1b[m""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__version.py b/fastddsspy_tool/test/application/test_cases/one_shot__version.py new file mode 100644 index 00000000..08f81d9d --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot__version.py @@ -0,0 +1,51 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --version + """ + super().__init__( + name='--VersionCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['--version'], + commands_spy=[], + output="""Fast DDS Spy v0.1.0\ +commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @todo Parse the output + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datareader.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader.py new file mode 100644 index 00000000..689e7251 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datareader.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datareader + """ + super().__init__( + name='DatareaderCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['datareader'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_dds.py new file mode 100644 index 00000000..48ba49de --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_dds.py @@ -0,0 +1,43 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datareader + AdvancedConfigurationExample publisher + """ + super().__init__( + name='DatareaderDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datareader'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py new file mode 100644 index 00000000..550aba80 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py @@ -0,0 +1,46 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datareader \ + 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 + AdvancedConfigurationExample publisher + """ + super().__init__( + name='DataReaderGuidDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datareader', + '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + commands_spy=[], + output="""\x1b[1;31m01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \ +does not match with any known reader.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose.py new file mode 100644 index 00000000..bf7dad7e --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datareader verbose + """ + super().__init__( + name='DatareaderVerboseCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['datareader', 'verbose'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose_dds.py new file mode 100644 index 00000000..fbbe50a3 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose_dds.py @@ -0,0 +1,43 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datareader verbose + AdvancedConfigurationExample publisher + """ + super().__init__( + name='DatareaderVerboseDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datareader', 'verbose'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datawriter.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter.py new file mode 100644 index 00000000..f0be4040 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datawriter + """ + super().__init__( + name='DatawriterCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['datawriter'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py new file mode 100644 index 00000000..2906a159 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py @@ -0,0 +1,45 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datawriter + AdvancedConfigurationExample publisher + """ + super().__init__( + name='DatawriterDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datawriter'], + commands_spy=[], + output="""- guid: %%guid%%\n\ + participant: Participant_pub\n\ + topic: HelloWorldTopic [HelloWorld]\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py new file mode 100644 index 00000000..dd8636e6 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py @@ -0,0 +1,46 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datawriter \ + 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 + AdvancedConfigurationExample publisher + """ + super().__init__( + name='DatawriterGuidDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datawriter', + '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + commands_spy=[], + output="""\x1b[1;31m01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \ +does not match with any known writer.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose.py new file mode 100644 index 00000000..50836d67 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datawriter verbose + """ + super().__init__( + name='DatawriterVerboseCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['datawriter', 'verbose'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py new file mode 100644 index 00000000..8772fa0c --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py @@ -0,0 +1,50 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datawriter verbose + AdvancedConfigurationExample publisher + """ + super().__init__( + name='DatawriterVerboseDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'datawriter', 'verbose'], + commands_spy=[], + output="""- guid: %%guid%%\n\ + participant: Participant_pub\n\ + topic:\n\ + name: HelloWorldTopic\n\ + type: HelloWorld\n\ + qos:\n\ + durability: volatile\n\ + reliability: best-effort\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py new file mode 100644 index 00000000..8d6da491 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py @@ -0,0 +1,50 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml datawriter verbose + AdvancedConfigurationExample publisher --reliable --transient + """ + super().__init__( + name='DatawriterVerboseDDSQosCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=['--reliable', '--transient'], + arguments_spy=['--config-path', 'configuration', 'datawriter', 'verbose'], + commands_spy=[], + output="""- guid: %%guid%%\n\ + participant: Participant_pub\n\ + topic:\n\ + name: HelloWorldTopic\n\ + type: HelloWorld\n\ + qos:\n\ + durability: transient-local\n\ + reliability: reliable\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_help.py b/fastddsspy_tool/test/application/test_cases/one_shot_help.py new file mode 100644 index 00000000..02ac8248 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_help.py @@ -0,0 +1,70 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datawriter + """ + super().__init__( + name='HelpCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['help'], + commands_spy=[], + output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks.\n\ +Each command shows data related with the network in Yaml format.\n\ +Commands available and the information they show:\n\ +\thelp : this help.\n\ +\tversion : tool version.\n\ +\tquit : exit interactive CLI and close program.\n\ +\tparticipants : DomainParticipants discovered in the network.\n\ +\tparticipants verbose : verbose information about DomainParticipants discovered in the \ +network.\n\ +\tparticipants : verbose information related with a specific DomainParticipant.\n\ +\twriters : DataWriters discovered in the network.\n\ +\twriters verbose : verbose information about DataWriters discovered in the network.\n\ +\twriters : verbose information related with a specific DataWriter.\n\ +\treader : DataReaders discovered in the network.\n\ +\treader verbose : verbose information about DataReaders discovered in the network.\n\ +\treader : verbose information related with a specific DataReader.\n\ +\ttopics : Topics discovered in the network.\n\ +\ttopics verbose : verbose information about Topics discovered in the network.\n\ +\ttopics : verbose information related with a specific Topic.\n\ +\tshow : data of a specific Topic (Data Type must be discovered).\n\ +\tshow verbose : data with additional source info of a specific Topic.\n\ +\tshow all : verbose data of all topics (only those whose Data Type is \ +discovered).\n\ +\n\ +Notes and comments:\n\ +\tTo exit from data printing, press enter.\n\ +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s).\n\ +\n\ +For more information about these commands and formats, please refer to the documentation:\n\ +https://fast-dds-spy.readthedocs.io/en/latest/\n +""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_help_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_help_dds.py new file mode 100644 index 00000000..e6cab040 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_help_dds.py @@ -0,0 +1,73 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml help + AdvancedConfigurationExample publisher + """ + super().__init__( + name='HelpDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'help'], + commands_spy=[], + output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks.\n\ +Each command shows data related with the network in Yaml format.\n\ +Commands available and the information they show:\n\ +\thelp : this help.\n\ +\tversion : tool version.\n\ +\tquit : exit interactive CLI and close program.\n\ +\tparticipants : DomainParticipants discovered in the network.\n\ +\tparticipants verbose : verbose information about DomainParticipants discovered in the \ +network.\n\ +\tparticipants : verbose information related with a specific DomainParticipant.\n\ +\twriters : DataWriters discovered in the network.\n\ +\twriters verbose : verbose information about DataWriters discovered in the network.\n\ +\twriters : verbose information related with a specific DataWriter.\n\ +\treader : DataReaders discovered in the network.\n\ +\treader verbose : verbose information about DataReaders discovered in the network.\n\ +\treader : verbose information related with a specific DataReader.\n\ +\ttopics : Topics discovered in the network.\n\ +\ttopics verbose : verbose information about Topics discovered in the network.\n\ +\ttopics : verbose information related with a specific Topic.\n\ +\tshow : data of a specific Topic (Data Type must be discovered).\n\ +\tshow verbose : data with additional source info of a specific Topic.\n\ +\tshow all : verbose data of all topics (only those whose Data Type is \ +discovered).\n\ +\n\ +Notes and comments:\n\ +\tTo exit from data printing, press enter.\n\ +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s).\n\ +\n\ +For more information about these commands and formats, please refer to the documentation:\n\ +https://fast-dds-spy.readthedocs.io/en/latest/\n +""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_null.py b/fastddsspy_tool/test/application/test_cases/one_shot_null.py new file mode 100644 index 00000000..7ad3479f --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_null.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy nullarg + """ + super().__init__( + name='NullCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['nullarg'], + commands_spy=[], + output="""\x1b[1;31m is not a known command. \ +Use command to see valid commands and arguments.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_participants.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants.py new file mode 100644 index 00000000..dc7ea582 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy participants + """ + super().__init__( + name='ParticipantsCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['participants'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py new file mode 100644 index 00000000..1ccc8595 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py @@ -0,0 +1,44 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml participants + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ParticipantsDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'participants'], + commands_spy=[], + output="""- name: Participant_pub\n\ + guid: %%guid%%\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py new file mode 100644 index 00000000..57ac625b --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py @@ -0,0 +1,46 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml participant \ + 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ParticipantsGuidDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'participant', + '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + commands_spy=[], + output="""\x1b[1;31m01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 \ +does not match with any known participant.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose.py new file mode 100644 index 00000000..c3dfd0e9 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy participants verbose + """ + super().__init__( + name='ParticipantsVerboseCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['participants', 'verbose'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py new file mode 100644 index 00000000..b4ef2911 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py @@ -0,0 +1,46 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml participants verbose + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ParticipantsVerboseCommandDDS', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'participants', 'verbose'], + commands_spy=[], + output="""- name: Participant_pub\n\ + guid: %%guid%%\n\ + datawriters:\n\ + - HelloWorldTopic [HelloWorld] (1)\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_quit.py b/fastddsspy_tool/test/application/test_cases/one_shot_quit.py new file mode 100644 index 00000000..88662f97 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_quit.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy exit + """ + super().__init__( + name='QuitCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_quit_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_quit_dds.py new file mode 100644 index 00000000..0c148d33 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_quit_dds.py @@ -0,0 +1,43 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml exit + AdvancedConfigurationExample publisher + """ + super().__init__( + name='QuitDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'exit'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_show_all.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_all.py new file mode 100644 index 00000000..c8b76cb1 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_show_all.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + r""" + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show all \n + """ + super().__init__( + name='ShowAllCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['show', 'all', '\n'], + commands_spy=[], + output='' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py new file mode 100644 index 00000000..641b0d1d --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show + """ + super().__init__( + name='ShowCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['show'], + commands_spy=[], + output="""\x1b[1;31mCommand requires at least \ +one argument.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py new file mode 100644 index 00000000..74f02678 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show hello + """ + super().__init__( + name='ShowTopicCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['show', 'hello'], + commands_spy=[], + output="""\x1b[1;31mTopic does not exist.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py new file mode 100644 index 00000000..86d3af40 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show hello verbose + """ + super().__init__( + name='ShowTopicCommandVerbose', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['show', 'hello', 'verbose'], + commands_spy=[], + output="""\x1b[1;31mTopic does not exist.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics.py new file mode 100644 index 00000000..88b4506f --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy topics + """ + super().__init__( + name='TopicsCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['topics'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py new file mode 100644 index 00000000..2506c715 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py @@ -0,0 +1,47 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml topics + AdvancedConfigurationExample publisher + """ + super().__init__( + name='TopicsDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'topics'], + commands_spy=[], + output="""- name: HelloWorldTopic\n\ + type: HelloWorld\n\ + datawriters: 1\n\ + datareaders: 0\n\ + rate: %%rate%%\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_name.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name.py new file mode 100644 index 00000000..c2c43680 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy topics hello + """ + super().__init__( + name='TopicsNameCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['topics', 'hello'], + commands_spy=[], + output="""\x1b[1;31m topic does not exist \ +in the DDS network.\x1b[0m\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py new file mode 100644 index 00000000..a019c48a --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py @@ -0,0 +1,48 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml topics HelloWorldTopic + AdvancedConfigurationExample publisher + """ + super().__init__( + name='TopicsNameDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'topics', 'HelloWorldTopic'], + commands_spy=[], + output="""name: HelloWorldTopic\n\ +type: HelloWorld\n\ +datawriters:\n\ + - %%guid%%\n\ +rate: %%rate%%\n\ +dynamic_type_discovered: false\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose.py new file mode 100644 index 00000000..6eaff7a1 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose.py @@ -0,0 +1,40 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy topics verbose + """ + super().__init__( + name='TopicsVerboseCommand', + one_shot=True, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=['topics', 'verbose'], + commands_spy=[], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py new file mode 100644 index 00000000..b3af2276 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py @@ -0,0 +1,48 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml topics verbose + AdvancedConfigurationExample publisher + """ + super().__init__( + name='TopicsVerboseDDSCommand', + one_shot=True, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'topics', 'verbose'], + commands_spy=[], + output="""- name: HelloWorldTopic\n\ + type: HelloWorld\n\ + datawriters:\n\ + - %%guid%%\n\ + rate: %%rate%%\n\ + dynamic_type_discovered: false\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_datareader.py b/fastddsspy_tool/test/application/test_cases/tool_datareader.py new file mode 100644 index 00000000..a8008e22 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_datareader.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> datareader + """ + super().__init__( + name='ToolDatareaderCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['datareader'], + output=""">> \x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_datareader_dds.py b/fastddsspy_tool/test/application/test_cases/tool_datareader_dds.py new file mode 100644 index 00000000..2ffd014a --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_datareader_dds.py @@ -0,0 +1,44 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml + >> datareader + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ToolDatareaderDDSCommand', + one_shot=False, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['datareader'], + output=""">> \x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_datawriter.py b/fastddsspy_tool/test/application/test_cases/tool_datawriter.py new file mode 100644 index 00000000..1bbea412 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_datawriter.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> datawriter + """ + super().__init__( + name='ToolDatawriterCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['datawriter'], + output=""">> \x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py b/fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py new file mode 100644 index 00000000..1dbc6821 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py @@ -0,0 +1,48 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml + >> datawriter + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ToolDatawriterDDSCommand', + one_shot=False, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['datawriter'], + output=""">> \x1b[0m- guid: %%guid%%\n\ +\n\ + participant: Participant_pub\n\ +\n\ + topic: HelloWorldTopic [HelloWorld]\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_help.py b/fastddsspy_tool/test/application/test_cases/tool_help.py new file mode 100644 index 00000000..d96787ce --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_help.py @@ -0,0 +1,73 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> help + """ + super().__init__( + name='ToolHelpCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['help'], + output=""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect\ + DDS networks.\n\n\ +Each command shows data related with the network in Yaml format.\n\n\ +Commands available and the information they show:\n\n\ +\thelp : this help.\n\n\ +\tversion : tool version.\n\n\ +\tquit : exit interactive CLI and close program.\n\n\ +\tparticipants : DomainParticipants discovered in the network.\n\n\ +\tparticipants verbose : verbose information about DomainParticipants discovered in \ +the network.\n\n\ +\tparticipants : verbose information related with a specific DomainParticipant.\n\n\ +\twriters : DataWriters discovered in the network.\n\n\ +\twriters verbose : verbose information about DataWriters discovered in the network.\n\n\ +\twriters : verbose information related with a specific DataWriter.\n\n\ +\treader : DataReaders discovered in the network.\n\n\ +\treader verbose : verbose information about DataReaders discovered in the network.\n\n\ +\treader : verbose information related with a specific DataReader.\n\n\ +\ttopics : Topics discovered in the network.\n\n\ +\ttopics verbose : verbose information about Topics discovered in the network.\n\n\ +\ttopics : verbose information related with a specific Topic.\n\n\ +\tshow : data of a specific Topic (Data Type must be discovered).\n\n\ +\tshow verbose : data with additional source info of a specific Topic.\n\n\ +\tshow all : verbose data of all topics (only those whose Data Type is\ + discovered).\n\n\ +\n\ +\n\ +Notes and comments:\n\n\ +\tTo exit from data printing, press enter.\n\n\ +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s).\n\n\ +\n\ +\n\ +For more information about these commands and formats, please refer to the documentation:\n\n\ +https://fast-dds-spy.readthedocs.io/en/latest/\n\n\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_help_dds.py b/fastddsspy_tool/test/application/test_cases/tool_help_dds.py new file mode 100644 index 00000000..6f9acdd2 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_help_dds.py @@ -0,0 +1,76 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml + >> help + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ToolHelpDDSCommand', + one_shot=False, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['help'], + output=""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect\ + DDS networks.\n\n\ +Each command shows data related with the network in Yaml format.\n\n\ +Commands available and the information they show:\n\n\ +\thelp : this help.\n\n\ +\tversion : tool version.\n\n\ +\tquit : exit interactive CLI and close program.\n\n\ +\tparticipants : DomainParticipants discovered in the network.\n\n\ +\tparticipants verbose : verbose information about DomainParticipants discovered in \ +the network.\n\n\ +\tparticipants : verbose information related with a specific DomainParticipant.\n\n\ +\twriters : DataWriters discovered in the network.\n\n\ +\twriters verbose : verbose information about DataWriters discovered in the network.\n\n\ +\twriters : verbose information related with a specific DataWriter.\n\n\ +\treader : DataReaders discovered in the network.\n\n\ +\treader verbose : verbose information about DataReaders discovered in the network.\n\n\ +\treader : verbose information related with a specific DataReader.\n\n\ +\ttopics : Topics discovered in the network.\n\n\ +\ttopics verbose : verbose information about Topics discovered in the network.\n\n\ +\ttopics : verbose information related with a specific Topic.\n\n\ +\tshow : data of a specific Topic (Data Type must be discovered).\n\n\ +\tshow verbose : data with additional source info of a specific Topic.\n\n\ +\tshow all : verbose data of all topics (only those whose Data Type is\ + discovered).\n\n\ +\n\ +\n\ +Notes and comments:\n\n\ +\tTo exit from data printing, press enter.\n\n\ +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s).\n\n\ +\n\ +\n\ +For more information about these commands and formats, please refer to the documentation:\n\n\ +https://fast-dds-spy.readthedocs.io/en/latest/\n\n\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_null.py b/fastddsspy_tool/test/application/test_cases/tool_null.py new file mode 100644 index 00000000..7f536a3a --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_null.py @@ -0,0 +1,42 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> null + """ + super().__init__( + name='ToolNull', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['null'], + output=""">> \x1b[0m\x1b[1;31m is not a known command. \ +Use command to see valid commands and arguments.\x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_participants.py b/fastddsspy_tool/test/application/test_cases/tool_participants.py new file mode 100644 index 00000000..821db2e5 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_participants.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> participants + """ + super().__init__( + name='ToolParticipantsCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['participants'], + output=""">> \x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_participants_dds.py b/fastddsspy_tool/test/application/test_cases/tool_participants_dds.py new file mode 100644 index 00000000..a8c48f66 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_participants_dds.py @@ -0,0 +1,46 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml + >> participants + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ToolParticipantsDDSCommand', + one_shot=False, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['participants'], + output=""">> \x1b[0m- name: Participant_pub\n\ +\n\ + guid: %%guid%%\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_show_all.py b/fastddsspy_tool/test/application/test_cases/tool_show_all.py new file mode 100644 index 00000000..d4fec727 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_show_all.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + r""" + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> show all \n + """ + super().__init__( + name='ToolShowAllCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['show all \n'], + output=""">> \x1b[0m\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_show_topic.py b/fastddsspy_tool/test/application/test_cases/tool_show_topic.py new file mode 100644 index 00000000..b188fe26 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_show_topic.py @@ -0,0 +1,42 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> show topic + """ + super().__init__( + name='ToolShowTopicCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['show topic'], + output=""">> \x1b[0m\x1b[1;31mTopic \ +does not exist.\x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py b/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py new file mode 100644 index 00000000..02b46779 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py @@ -0,0 +1,45 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml + >> show HelloWorldTopic + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ToolShowTopicDDSCommand', + one_shot=False, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['show HelloWorldTopic'], + output=""">> \x1b[0m\x1b[1;31mTopic Type has not \ +been discovered, and thus cannot print its data.\x1b[0m\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_topics.py b/fastddsspy_tool/test/application/test_cases/tool_topics.py new file mode 100644 index 00000000..6d048f82 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_topics.py @@ -0,0 +1,41 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> topics + """ + super().__init__( + name='ToolTopicsCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['topics'], + output=""">> \x1b[0m\n\n\n\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_topics_dds.py b/fastddsspy_tool/test/application/test_cases/tool_topics_dds.py new file mode 100644 index 00000000..4fdc3dda --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_topics_dds.py @@ -0,0 +1,52 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ + configuration_discovery_time.yaml + >> topics + AdvancedConfigurationExample publisher + """ + super().__init__( + name='ToolTopicsDDSCommand', + one_shot=False, + command=[], + dds=True, + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['topics'], + output=""">> \x1b[0m- name: HelloWorldTopic\n\ +\n\ + type: HelloWorld\n\ +\n\ + datawriters: 1\n\ +\n\ + datareaders: 0\n\ +\n\ + rate: %%rate%%\n""" + ) diff --git a/fastddsspy_tool/test/application/test_cases/tool_version.py b/fastddsspy_tool/test/application/test_cases/tool_version.py new file mode 100644 index 00000000..a5ad6a69 --- /dev/null +++ b/fastddsspy_tool/test/application/test_cases/tool_version.py @@ -0,0 +1,52 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for the fastddsspy executable.""" + +import test_class + + +class TestCase_instance (test_class.TestCase): + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" + + def __init__(self): + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> version + """ + super().__init__( + name='ToolVersionCommand', + one_shot=False, + command=[], + dds=False, + config='', + arguments_dds=[], + arguments_spy=[], + commands_spy=['version'], + output=""">> \x1b[0mFast DDS Spy v0.1.0\n\ +\n\ +commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451\n\n""" + ) + + def valid_output(self, output): + """ + @brief Validate the output. + + @param output: The actual output obtained from executing a command. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py new file mode 100644 index 00000000..636dcfc2 --- /dev/null +++ b/fastddsspy_tool/test/application/test_class.py @@ -0,0 +1,280 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Contains a test class for fastddsspy tool tests.""" + +import re +import subprocess +import time + + +SLEEP_TIME = 0.2 + + +class TestCase(): + """Test class.""" + + def __init__(self, name, one_shot, command, dds, config, + arguments_dds, arguments_spy, commands_spy, output): + """ + @brief Initialize the object. + + @param name: The name of the test. + @param one_shot: A boolean indicating if the object runs in one-shot mode. + @param command: The command associated with the object. + @param dds: A boolean indicating if the object launch a DDS Publisher. + @param config: The configuration of the DDS Spy. + @param arguments_dds: A list of arguments for the DDS Publisher. + @param arguments_spy: A list of arguments for the DDS Spy. + @param commands_spy: A list of commands for the DDS Spy interactive application. + @param output: The expected output associated with the object. + """ + self.name = name + self.one_shot = one_shot + self.command = command + self.dds = dds + self.config = config + self.arguments_dds = arguments_dds + self.arguments_spy = arguments_spy + self.commands_spy = commands_spy + self.output = output + self.exec_spy = '' + self.exec_dds = '' + + def run_dds(self): + """ + @brief Run the DDS publisher tool with the arguments set in the parameter \ + 'arguments_dds' of the class. + + @return Returns a subprocess object representing the running DDS publisher. + """ + if self.dds: + self.command = [self.exec_dds, 'publisher'] + self.arguments_dds + + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + return proc + + def run_tool(self): + """ + @brief Run Fast DDS Spy as one_shot if the one_shot parameter is set to true, \ + otherwise. as an interactive application with the arguments specified in the \ + parameter 'arguments_spy' of the class. + + @return Returns the subprocess object representing the running Spy. + """ + self.command = [self.exec_spy] + self.arguments_spy + + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding='utf8') + + if (self.one_shot): + output = '' + try: + output = proc.communicate(timeout=10)[0] + except subprocess.TimeoutExpired: + proc.kill() + if not self.valid_output(output): + return None + + else: + self.read_command_output(proc) + return proc + + def send_command_tool(self, proc): + """ + @brief Send a command to the running Spy. + + @param proc: The subprocess object representing the running Spy. + @return Returns the output received after sending the command. + """ + time.sleep(SLEEP_TIME) + proc.stdin.write((self.commands_spy[0]+'\n')) + proc.stdin.flush() + + output = self.read_command_output(proc) + return (output) + + def read_command_output(self, proc): + """ + @brief Read the output from the subprocess. + + @param proc: The subprocess object representing the running process. + @return Returns the accumulated output read from the subprocess. + """ + output = '' + count = 0 + # max number of loops while can take to avoid waiting forever if something goes wrong + max_count = 250 + + while True: + count += 1 + + if count > max_count: + break + + line = proc.stdout.readline() + + if ('Insert a command for Fast DDS Spy:' in line): + break + + output = output + f'{line}\n' + return output + + def output_command(self): + """ + @brief Get the expected output. + + @return Returns the expected output. + """ + return (self.output) + + def valid_guid(self, guid) -> bool: + """ + @brief Check if a GUID has the correct pattern. + + @param guid: The GUID to check. + @return Returns True if the GUID is valid, False otherwise. + """ + pattern = r'^(([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' + if not re.match(pattern, guid): + print('Not valid guid: ') + print(guid) + return False + return True + + def valid_rate(self, rate) -> bool: + """ + @brief Check if a rate is valid. + + @param rate: The rate to check. + @return Returns True if the rate is valid, False otherwise. + """ + pattern_1 = r'^(\d*\.?\d*\s(Hz))$' # rate: 10.5 Hz + pattern_2 = r'^((inf)\s(Hz))$' # rate: inf Hz + if re.match(pattern_1, rate): + return True + if re.match(pattern_2, rate): + return True + print('Not valid rate: ') + print(rate) + return False + + def valid_output(self, output) -> bool: + """ + @brief Check the validity of the output against the expected output. + + @param output: The actual output obtained from executing a command. + @return Returns True if the output matches the expected output or \ + satisfies specific conditions for lines containing '%%guid%%' or '%%rate%%', \ + False otherwise. + + The function compares the provided 'output' with the expected output. + It checks each line of the 'output' and 'expected_output' to determine their validity. + + If the entire 'output' matches the 'expected_output', the function returns True. + Otherwise, it iterates over each line and performs the following checks: + - If a line in 'expected_output' contains '%%guid%%', it calls the 'valid_guid()'. + - If a line in 'expected_output' contains '%%rate%%', it calls the 'valid_rate()'. + - If a line does not contain '%%guid%%' or '%%rate%%', it compares the corresponding \ + lines in 'output' and 'expected_output' for equality. + + If any line does not meet the expected conditions, the function returns False and prints \ + the 'output' and 'expected_output' for debugging purposes. + + """ + expected_output = self.output_command() + if expected_output == output: + return True + + lines_expected_output = expected_output.splitlines() + lines_output = output.splitlines() + guid = True + rate = True + for i in range(len(lines_expected_output)): + if '%%guid%%' in lines_expected_output[i]: + start_guid_position = lines_expected_output[i].find('%%guid%%') + guid = self.valid_guid(lines_output[i][start_guid_position:]) + elif '%%rate%%' in lines_expected_output[i]: + start_rate_position = lines_expected_output[i].find('%%rate%%') + rate = self.valid_rate(lines_output[i][start_rate_position:]) + elif lines_expected_output[i] != lines_output[i]: + print('Output: ') + print(output) + print('Expected output: ') + print(expected_output) + return False + return (guid and rate) + + def stop_tool(self, proc) -> bool: + """ + @brief Stop the running Spy. + + @param proc: The subprocess object representing the running Spy. + @return Returns True if the Spy is successfully stopped, False otherwise. + """ + try: + proc.communicate(input='exit\n', timeout=10)[0] + except subprocess.TimeoutExpired: + proc.kill() + + time.sleep(SLEEP_TIME) + + if not self.is_stop(proc): + print('ERROR: DDS Spy still running') + return False + + return True + + def stop_dds(self, proc) -> bool: + """ + @brief Stop the DDS publisher. + + @param proc: The subprocess object representing the running DDS publisher. + @return Returns True if the DDS publisher is successfully stopped, False otherwise. + """ + if self.dds: + try: + proc.terminate() + proc.communicate(timeout=13) + except subprocess.TimeoutExpired: + proc.kill() + + time.sleep(SLEEP_TIME) + + if not self.is_stop(proc): + print('ERROR: DDS Publisher still running') + return False + + return True + + def is_stop(self, proc) -> bool: + """ + @brief Check if the subprocess has stopped. + + @param proc: The subprocess to check. + @return Returns True if the subprocess has stopped, + False otherwise. + """ + return_code = proc.poll() + + if (return_code is None): + return False + return True diff --git a/fastddsspy_tool/test/labels/CMakeLists.txt b/fastddsspy_tool/test/labels/CMakeLists.txt new file mode 100644 index 00000000..d9a82ad5 --- /dev/null +++ b/fastddsspy_tool/test/labels/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Set list of tests that can fail using TSAN +set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/XTSAN.list "xtsan") diff --git a/fastddsspy_tool/test/labels/XTSAN.list b/fastddsspy_tool/test/labels/XTSAN.list new file mode 100644 index 00000000..5c73a4c8 --- /dev/null +++ b/fastddsspy_tool/test/labels/XTSAN.list @@ -0,0 +1,62 @@ +tool.application.fastddsspy.test.test_cases.one_shot_help_dds +tool.application.fastddsspy.test.test_cases.one_shot_datareader_dds +tool.application.fastddsspy.test.test_cases.one_shot_datareader_guid_dds +tool.application.fastddsspy.test.test_cases.one_shot_datareader_verbose_dds +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_dds +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose_dds_qos +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_guid_dds_fail +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose_dds +tool.application.fastddsspy.test.test_cases.one_shot_participants_dds +tool.application.fastddsspy.test.test_cases.one_shot_participants_guid_dds +tool.application.fastddsspy.test.test_cases.one_shot_participants_verbose_dds +tool.application.fastddsspy.test.test_cases.one_shot_quit_dds +tool.application.fastddsspy.test.test_cases.one_shot_topics_dds +tool.application.fastddsspy.test.test_cases.one_shot_topics_name_dds +tool.application.fastddsspy.test.test_cases.one_shot_topics_verbose_dds +tool.application.fastddsspy.test.test_cases.tool_datareader_dds +tool.application.fastddsspy.test.test_cases.tool_datawriter_dds +tool.application.fastddsspy.test.test_cases.tool_help_dds +tool.application.fastddsspy.test.test_cases.tool_participants_dds +tool.application.fastddsspy.test.test_cases.tool_show_topic_dds +tool.application.fastddsspy.test.test_cases.tool_topics_dds +tool.application.fastddsspy.test.test_cases.one_shot__config +tool.application.fastddsspy.test.test_cases.one_shot__config_fail_file +tool.application.fastddsspy.test.test_cases.one_shot__config_fail_type +tool.application.fastddsspy.test.test_cases.one_shot__config_fail_empty_arg +tool.application.fastddsspy.test.test_cases.one_shot__log_filter +tool.application.fastddsspy.test.test_cases.one_shot__log_filter_fail +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_fail +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_info +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_warning +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_error +tool.application.fastddsspy.test.test_cases.one_shot__reload_time +tool.application.fastddsspy.test.test_cases.one_shot__reload_time_fail +tool.application.fastddsspy.test.test_cases.one_shot__debug +tool.application.fastddsspy.test.test_cases.one_shot_help +tool.application.fastddsspy.test.test_cases.one_shot__help +tool.application.fastddsspy.test.test_cases.one_shot_null +tool.application.fastddsspy.test.test_cases.one_shot__null +tool.application.fastddsspy.test.test_cases.one_shot__version +tool.application.fastddsspy.test.test_cases.one_shot_datareader +tool.application.fastddsspy.test.test_cases.one_shot_datareader_verbose +tool.application.fastddsspy.test.test_cases.one_shot_datawriter +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose +tool.application.fastddsspy.test.test_cases.one_shot_participants +tool.application.fastddsspy.test.test_cases.one_shot_participants_verbose +tool.application.fastddsspy.test.test_cases.one_shot_quit +tool.application.fastddsspy.test.test_cases.one_shot_show_all +tool.application.fastddsspy.test.test_cases.one_shot_show_fail +tool.application.fastddsspy.test.test_cases.one_shot_show_topic +tool.application.fastddsspy.test.test_cases.one_shot_show_topic_verbose +tool.application.fastddsspy.test.test_cases.one_shot_topics +tool.application.fastddsspy.test.test_cases.one_shot_topics_name +tool.application.fastddsspy.test.test_cases.one_shot_topics_verbose +tool.application.fastddsspy.test.test_cases.tool_datareader +tool.application.fastddsspy.test.test_cases.tool_datawriter +tool.application.fastddsspy.test.test_cases.tool_help +tool.application.fastddsspy.test.test_cases.tool_null +tool.application.fastddsspy.test.test_cases.tool_participants +tool.application.fastddsspy.test.test_cases.tool_show_all +tool.application.fastddsspy.test.test_cases.tool_show_topic +tool.application.fastddsspy.test.test_cases.tool_topics +tool.application.fastddsspy.test.test_cases.tool_version diff --git a/fastddsspy_yaml/src/cpp/YamlReader.cpp b/fastddsspy_yaml/src/cpp/YamlReader.cpp deleted file mode 100644 index dcd6b543..00000000 --- a/fastddsspy_yaml/src/cpp/YamlReader.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include - -#include - -namespace eprosima { -namespace ddspipe { -namespace yaml { - -template <> -spy::participants::SpyParticipantConfiguration -YamlReader::get( - const Yaml& yml, - const YamlReaderVersion version) -{ - spy::participants::SpyParticipantConfiguration conf; - - YamlReader::fill(conf, yml, version); - - return conf; -} - -} /* namespace yaml */ -} /* namespace ddspipe */ -} /* namespace eprosima */