From e52e4011c4b45b11d12f2ec896a6db90ab5f161a Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 27 Mar 2023 08:40:09 +0200 Subject: [PATCH 01/63] Add tool tests Signed-off-by: Irene Bandera --- fastddsspy_tool/test/CMakeLists.txt | 2 +- .../test/application/CMakeLists.txt | 132 +++++++++ fastddsspy_tool/test/application/launcher.ps1 | 34 +++ fastddsspy_tool/test/application/tests.py | 268 ++++++++++++++++++ 4 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 fastddsspy_tool/test/application/CMakeLists.txt create mode 100644 fastddsspy_tool/test/application/launcher.ps1 create mode 100644 fastddsspy_tool/test/application/tests.py diff --git a/fastddsspy_tool/test/CMakeLists.txt b/fastddsspy_tool/test/CMakeLists.txt index 7122e5ff..923b16ac 100644 --- a/fastddsspy_tool/test/CMakeLists.txt +++ b/fastddsspy_tool/test/CMakeLists.txt @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -# 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..761620c5 --- /dev/null +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -0,0 +1,132 @@ +# 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) + +# Whether one or other signal in test +set(SIGNAL_TEST_ARGS + "sigint" + "sigterm" +) + +# windows auxiliary script to fork test execution +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) + +# populate the tests +set(TEST_NAME "tool.application.fastddsspy") + +# CTest has issues with signals on windows. We forked the test +# execution using an auxiliary powershell script and using only sigint +if(WIN32) + add_test( + NAME ${TEST_NAME} + COMMAND powershell "-File" ${PWS_LAUNCHER} + ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/tests.py + $ + ) + + # Set test properties + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + ) + +else() + + foreach(SIGNAL_ARG IN LISTS SIGNAL_TEST_ARGS) + + set(TEST_NAME "${TEST_NAME}.${SIGNAL_ARG}") + add_test( + NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/tests.py + "--exe" $ + "--debug" + "--signal" ${SIGNAL_ARG} + ) + + # Set test properties + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + ) + endforeach() +endif() + + +unset(TEST_ENVIRONMENT) diff --git a/fastddsspy_tool/test/application/launcher.ps1 b/fastddsspy_tool/test/application/launcher.ps1 new file mode 100644 index 00000000..f1b6bfbd --- /dev/null +++ b/fastddsspy_tool/test/application/launcher.ps1 @@ -0,0 +1,34 @@ +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 +) + +$test = Start-Process -Passthru -Wait ` + -FilePath $python_path ` + -ArgumentList ( + $test_script, + "--exe", $tool_path, + "--debug", + "--signal", "sigint") ` + -WindowStyle Hidden + +if( $test.ExitCode -ne 0 ) +{ + $error_message = "Test: $test_name failed with exit code $($test.ExitCode)." + throw $error_message +} diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py new file mode 100644 index 00000000..67b06e2d --- /dev/null +++ b/fastddsspy_tool/test/application/tests.py @@ -0,0 +1,268 @@ +# Copyright 2021 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 -e -c + +Arguments: + + DDS Router binary path : -e | --exe binary_path + + DDS Router binary path : -c | --config-file + + Run test in Debug mode : -d | --debug + + Use SIGINT or SIGTERM : -s | --signal sigint|sigterm +""" + +import argparse +import logging +import os +import signal +import subprocess +import sys +import time +from enum import Enum + +DESCRIPTION = """Script to execute Fast DDS Spy executable test""" +USAGE = ('python3 tests.py -e ' + ' --signal sigint [-d]') + +# Sleep time to let process init and finish +SLEEP_TIME = 1 +MAX_SIGNALS_SEND_ITERATIONS = 3 + + +def signal_handler(signum, frame): + """ + Ignore Signal handler. + + This method is required in Windows to not handle the signal that + is sent to the subprocess. + """ + pass + + +def executable_permission_value(): + """Return executable permissions value depending on the OS.""" + if os.name == 'nt': + return os.X_OK # windows + else: + return os.EX_OK + + +def file_exist_and_have_permissions(file_path): + """Check if a file exists and have executable permissions.""" + if os.access(file_path, executable_permission_value()): + return file_path + else: + return None + + +def is_linux(): + """Return whether the script is running in a Linux environment.""" + return os.name == 'posix' + + +def is_windows(): + """Return whether the script is running in a Windows environment.""" + return os.name == 'nt' + + +class KillingSignalType(Enum): + """Enumeration for signals used to kill subprocesses.""" + + KST_SIGINT = 2 + KST_SIGTERM = 15 + + +def check_terminate_signal(st): + """Return signal that must be used to kill process otherwise.""" + if st == 'sigterm': + return KillingSignalType.KST_SIGTERM + elif st == 'sigint': + return KillingSignalType.KST_SIGINT + else: + raise argparse.ArgumentTypeError( + f'Invalid value: {st}. It must be or ') + + +def parse_options(): + """ + Parse arguments. + + :return: The arguments parsed. + """ + 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 discovery-server executable.' + ) + parser.add_argument( + '-d', + '--debug', + action='store_true', + help='Print test debugging info.' + ) + parser.add_argument( + '-s', + '--signal', + type=check_terminate_signal, + required=True, + help='|: Use SIGINT or SIGTERM to kill process.' + ) + return parser.parse_args() + + +def test_fastddsspy_closure(fastddsspy, killing_signal): + """ + Test that fastddsspy command closes correctly. + + It creates a command line with the executable and the configuration + file, executes the process and send it a signal after SLEEP_TIME sec. + If the process has finished before the signal, test fails. + If the process does not end after sending MAX_SIGNALS_SEND_ITERATIONS + it is hard killed and the test fails. + + Parameters: + fastddsspy (path): Path to fastddsspy binary executable + use_sigint (KillingSignalType): Signal to kill subprocesses + + Returns: + 0 if okay, otherwise the return code of the command executed + """ + command = [fastddsspy] + + logger.info('Executing command: ' + str(command)) + + # this subprocess cannot be executed in shell=True or using bash + # because a background script will not broadcast the signals + # it receives + proc = subprocess.Popen(command, + stdout=subprocess.PIPE, + universal_newlines=True) + + # sleep to let the server run + time.sleep(SLEEP_TIME) + + # Check whether the process has terminated already + if not proc.poll() is None: + # If the process has already exit means something has gone wrong. + # Capture and print output for traceability and exit with code s1. + output, err = proc.communicate() + logger.debug('-----------------------------------------------------') + logger.error('Command ' + str(command) + ' failed before signal.') + logger.debug('Command output:') + logger.debug('Stdout: \n' + str(output)) + logger.debug('Stderr: \n' + str(err)) + logger.debug('-----------------------------------------------------') + return 1 + + # direct this script to ignore SIGINT in case of windows + if is_windows(): + signal.signal(signal.SIGINT, signal_handler) + + # send signal to process and wait for it to be killed + lease = 0 + while True: + + if killing_signal == KillingSignalType.KST_SIGTERM: + # Use SIGTERM instead + if is_linux(): + proc.send_signal(signal.SIGTERM) + elif is_windows(): + proc.send_signal(signal.CTRL_BREAK_EVENT) + else: + # Use SIGINT (use by default if not SIGTERM) + if is_linux(): + proc.send_signal(signal.SIGINT) + elif is_windows(): + proc.send_signal(signal.CTRL_C_EVENT) + + time.sleep(SLEEP_TIME) + lease += 1 + + # Break when signal kills the process or it hangs + if proc.poll() is None and lease < MAX_SIGNALS_SEND_ITERATIONS: + logger.debug('Sending signal again. Iterating...') + else: + break + + # Check whether SIGINT was able to terminate the process + if proc.poll() is None: + # SIGINT couldn't terminate the process. Kill it and exit with code 2 + proc.kill() + output, err = proc.communicate() + logger.debug('-----------------------------------------------------') + logger.debug('Internal Fast DDS Spy output:') + logger.debug('Stdout: \n' + str(output)) + logger.debug('Stderr: \n' + str(err)) + logger.error('Signal could not kill process') + logger.debug('-----------------------------------------------------') + return 1 + + output, err = proc.communicate() + logger.debug('-----------------------------------------------------') + logger.info( + 'Command ' + str(command) + ' finished correctly') + logger.debug('Command output:') + logger.debug('Stdout: \n' + str(output)) + logger.debug('Stderr: \n' + str(err)) + logger.debug('-----------------------------------------------------') + + return 0 + + +if __name__ == '__main__': + + args = parse_options() + + # Create a custom logger + logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + logger.addHandler(l_handler) + # Set log level + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + + if args.exe is None: + logger.error( + 'Executable binary file does not exist or has no ' + 'executable permissions.') + sys.exit(1) + + sys.exit( + test_fastddsspy_closure( + args.exe, # Path to executable + args.signal)) # Signal to kill subprocess From e869b7ff937d45b9994471a5d4862a90ff06455a Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 27 Mar 2023 08:45:03 +0200 Subject: [PATCH 02/63] Update Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/tests.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py index 67b06e2d..f8daf638 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/tests.py @@ -16,13 +16,11 @@ Contains a package of system test for fastddsspy tool -Usage: test.py -e -c +Usage: test.py -e Arguments: - DDS Router binary path : -e | --exe binary_path - - DDS Router binary path : -c | --config-file + Fast DDS Spy binary path : -e | --exe binary_path Run test in Debug mode : -d | --debug From 32477a3f3344b4d6f2c65e32fd16dba5fc0e0cf0 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 27 Mar 2023 09:11:12 +0200 Subject: [PATCH 03/63] Fix python linter Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py index f8daf638..03f815ad 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/tests.py @@ -135,7 +135,7 @@ def parse_options(): return parser.parse_args() -def test_fastddsspy_closure(fastddsspy, killing_signal): +def test_spy_closure(fastddsspy, killing_signal): """ Test that fastddsspy command closes correctly. @@ -261,6 +261,6 @@ def test_fastddsspy_closure(fastddsspy, killing_signal): sys.exit(1) sys.exit( - test_fastddsspy_closure( + test_spy_closure( args.exe, # Path to executable args.signal)) # Signal to kill subprocess From 528ec6a92d38dd0ec7186126666257b0918b2ebb Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 08:00:44 +0200 Subject: [PATCH 04/63] AApply changes Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 61 ++------ fastddsspy_tool/test/application/launcher.ps1 | 3 +- fastddsspy_tool/test/application/tests.py | 142 +----------------- 3 files changed, 22 insertions(+), 184 deletions(-) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 761620c5..40017132 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -18,12 +18,6 @@ find_package(PythonInterp 3 REQUIRED) -# Whether one or other signal in test -set(SIGNAL_TEST_ARGS - "sigint" - "sigterm" -) - # windows auxiliary script to fork test execution set(PWS_LAUNCHER ${CMAKE_CURRENT_SOURCE_DIR}/launcher.ps1 @@ -86,47 +80,18 @@ endif(WIN32) # populate the tests set(TEST_NAME "tool.application.fastddsspy") - -# CTest has issues with signals on windows. We forked the test -# execution using an auxiliary powershell script and using only sigint -if(WIN32) - add_test( - NAME ${TEST_NAME} - COMMAND powershell "-File" ${PWS_LAUNCHER} - ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/tests.py - $ - ) - - # Set test properties - set_tests_properties( - ${TEST_NAME} - PROPERTIES - ENVIRONMENT "${TEST_ENVIRONMENT}" - ) - -else() - - foreach(SIGNAL_ARG IN LISTS SIGNAL_TEST_ARGS) - - set(TEST_NAME "${TEST_NAME}.${SIGNAL_ARG}") - add_test( - NAME ${TEST_NAME} - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/tests.py - "--exe" $ - "--debug" - "--signal" ${SIGNAL_ARG} - ) - - # Set test properties - set_tests_properties( - ${TEST_NAME} - PROPERTIES - ENVIRONMENT "${TEST_ENVIRONMENT}" - ) - endforeach() -endif() - +add_test( + NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/tests.py + "--exe" $ + ) + +# Set test properties +set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + ) unset(TEST_ENVIRONMENT) diff --git a/fastddsspy_tool/test/application/launcher.ps1 b/fastddsspy_tool/test/application/launcher.ps1 index f1b6bfbd..f840eca6 100644 --- a/fastddsspy_tool/test/application/launcher.ps1 +++ b/fastddsspy_tool/test/application/launcher.ps1 @@ -23,8 +23,7 @@ $test = Start-Process -Passthru -Wait ` -ArgumentList ( $test_script, "--exe", $tool_path, - "--debug", - "--signal", "sigint") ` + "--debug") ` -WindowStyle Hidden if( $test.ExitCode -ne 0 ) diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py index 03f815ad..f99ccb05 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/tests.py @@ -24,35 +24,21 @@ Run test in Debug mode : -d | --debug - Use SIGINT or SIGTERM : -s | --signal sigint|sigterm """ import argparse import logging import os -import signal import subprocess import sys import time -from enum import Enum DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' - ' --signal sigint [-d]') + ' [-d]') # Sleep time to let process init and finish SLEEP_TIME = 1 -MAX_SIGNALS_SEND_ITERATIONS = 3 - - -def signal_handler(signum, frame): - """ - Ignore Signal handler. - - This method is required in Windows to not handle the signal that - is sent to the subprocess. - """ - pass def executable_permission_value(): @@ -70,35 +56,6 @@ def file_exist_and_have_permissions(file_path): else: return None - -def is_linux(): - """Return whether the script is running in a Linux environment.""" - return os.name == 'posix' - - -def is_windows(): - """Return whether the script is running in a Windows environment.""" - return os.name == 'nt' - - -class KillingSignalType(Enum): - """Enumeration for signals used to kill subprocesses.""" - - KST_SIGINT = 2 - KST_SIGTERM = 15 - - -def check_terminate_signal(st): - """Return signal that must be used to kill process otherwise.""" - if st == 'sigterm': - return KillingSignalType.KST_SIGTERM - elif st == 'sigint': - return KillingSignalType.KST_SIGINT - else: - raise argparse.ArgumentTypeError( - f'Invalid value: {st}. It must be or ') - - def parse_options(): """ Parse arguments. @@ -125,112 +82,30 @@ def parse_options(): action='store_true', help='Print test debugging info.' ) - parser.add_argument( - '-s', - '--signal', - type=check_terminate_signal, - required=True, - help='|: Use SIGINT or SIGTERM to kill process.' - ) return parser.parse_args() -def test_spy_closure(fastddsspy, killing_signal): - """ - Test that fastddsspy command closes correctly. - - It creates a command line with the executable and the configuration - file, executes the process and send it a signal after SLEEP_TIME sec. - If the process has finished before the signal, test fails. - If the process does not end after sending MAX_SIGNALS_SEND_ITERATIONS - it is hard killed and the test fails. - - Parameters: - fastddsspy (path): Path to fastddsspy binary executable - use_sigint (KillingSignalType): Signal to kill subprocesses - - Returns: - 0 if okay, otherwise the return code of the command executed - """ - command = [fastddsspy] +def test_spy_closure(fastddsspy): + command = [fastddsspy, "exit"] logger.info('Executing command: ' + str(command)) - # this subprocess cannot be executed in shell=True or using bash - # because a background script will not broadcast the signals - # it receives - proc = subprocess.Popen(command, - stdout=subprocess.PIPE, - universal_newlines=True) + proc = subprocess.run(command, capture_output=True, text=True) # sleep to let the server run time.sleep(SLEEP_TIME) # Check whether the process has terminated already - if not proc.poll() is None: - # If the process has already exit means something has gone wrong. - # Capture and print output for traceability and exit with code s1. + # Typically, an exit status of 0 indicates that it ran successfully. + if proc.returncode: output, err = proc.communicate() logger.debug('-----------------------------------------------------') - logger.error('Command ' + str(command) + ' failed before signal.') + logger.error('Command ' + str(command) + ' failed.') logger.debug('Command output:') logger.debug('Stdout: \n' + str(output)) logger.debug('Stderr: \n' + str(err)) logger.debug('-----------------------------------------------------') return 1 - - # direct this script to ignore SIGINT in case of windows - if is_windows(): - signal.signal(signal.SIGINT, signal_handler) - - # send signal to process and wait for it to be killed - lease = 0 - while True: - - if killing_signal == KillingSignalType.KST_SIGTERM: - # Use SIGTERM instead - if is_linux(): - proc.send_signal(signal.SIGTERM) - elif is_windows(): - proc.send_signal(signal.CTRL_BREAK_EVENT) - else: - # Use SIGINT (use by default if not SIGTERM) - if is_linux(): - proc.send_signal(signal.SIGINT) - elif is_windows(): - proc.send_signal(signal.CTRL_C_EVENT) - - time.sleep(SLEEP_TIME) - lease += 1 - - # Break when signal kills the process or it hangs - if proc.poll() is None and lease < MAX_SIGNALS_SEND_ITERATIONS: - logger.debug('Sending signal again. Iterating...') - else: - break - - # Check whether SIGINT was able to terminate the process - if proc.poll() is None: - # SIGINT couldn't terminate the process. Kill it and exit with code 2 - proc.kill() - output, err = proc.communicate() - logger.debug('-----------------------------------------------------') - logger.debug('Internal Fast DDS Spy output:') - logger.debug('Stdout: \n' + str(output)) - logger.debug('Stderr: \n' + str(err)) - logger.error('Signal could not kill process') - logger.debug('-----------------------------------------------------') - return 1 - - output, err = proc.communicate() - logger.debug('-----------------------------------------------------') - logger.info( - 'Command ' + str(command) + ' finished correctly') - logger.debug('Command output:') - logger.debug('Stdout: \n' + str(output)) - logger.debug('Stderr: \n' + str(err)) - logger.debug('-----------------------------------------------------') - return 0 @@ -262,5 +137,4 @@ def test_spy_closure(fastddsspy, killing_signal): sys.exit( test_spy_closure( - args.exe, # Path to executable - args.signal)) # Signal to kill subprocess + args.exe)) # Path to executable From 0e69b27d6085833189da29da858aafd7f31da4d9 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 08:21:57 +0200 Subject: [PATCH 05/63] Fail test Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/tests.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py index f99ccb05..d62be70d 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/tests.py @@ -56,6 +56,7 @@ def file_exist_and_have_permissions(file_path): else: return None + def parse_options(): """ Parse arguments. @@ -87,7 +88,7 @@ def parse_options(): def test_spy_closure(fastddsspy): - command = [fastddsspy, "exit"] + command = [fastddsspy, 'exit'] logger.info('Executing command: ' + str(command)) proc = subprocess.run(command, capture_output=True, text=True) @@ -98,12 +99,8 @@ def test_spy_closure(fastddsspy): # Check whether the process has terminated already # Typically, an exit status of 0 indicates that it ran successfully. if proc.returncode: - output, err = proc.communicate() logger.debug('-----------------------------------------------------') logger.error('Command ' + str(command) + ' failed.') - logger.debug('Command output:') - logger.debug('Stdout: \n' + str(output)) - logger.debug('Stderr: \n' + str(err)) logger.debug('-----------------------------------------------------') return 1 return 0 From 7c50a6cea6cc0a34c009305b1cc2c8aa7a1476ab Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 08:48:17 +0200 Subject: [PATCH 06/63] Without one shot Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/tests.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py index d62be70d..c0dbaafd 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/tests.py @@ -31,7 +31,6 @@ import os import subprocess import sys -import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -91,18 +90,21 @@ def test_spy_closure(fastddsspy): command = [fastddsspy, 'exit'] logger.info('Executing command: ' + str(command)) - proc = subprocess.run(command, capture_output=True, text=True) - - # sleep to let the server run - time.sleep(SLEEP_TIME) - - # Check whether the process has terminated already - # Typically, an exit status of 0 indicates that it ran successfully. - if proc.returncode: + proc = subprocess.Popen(command, + stdout=subprocess.PIPE, + universal_newlines=True) + try: + proc.communicate(input='exit', timeout=2) logger.debug('-----------------------------------------------------') - logger.error('Command ' + str(command) + ' failed.') + logger.debug('Command ' + str(command) + ' worked.') logger.debug('-----------------------------------------------------') + except subprocess.TimeoutExpired: + proc.kill() + logger.error('-----------------------------------------------------') + logger.error('Command ' + str(command) + ' failed.') + logger.error('-----------------------------------------------------') return 1 + return 0 From 0a9f145d8cf80111df70894f1d8977414659e2f7 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 08:56:28 +0200 Subject: [PATCH 07/63] Fix tsan Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/tests.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/tests.py index c0dbaafd..2ac7d114 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/tests.py @@ -31,6 +31,7 @@ import os import subprocess import sys +import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -87,14 +88,21 @@ def parse_options(): def test_spy_closure(fastddsspy): - command = [fastddsspy, 'exit'] + command = [fastddsspy] logger.info('Executing command: ' + str(command)) proc = subprocess.Popen(command, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, universal_newlines=True) + + # sleep to let the server run + time.sleep(SLEEP_TIME) + try: proc.communicate(input='exit', timeout=2) + proc.kill() logger.debug('-----------------------------------------------------') logger.debug('Command ' + str(command) + ' worked.') logger.debug('-----------------------------------------------------') From 27733c9c031f3b55225e9b63b3a5caf24ff68c3d Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 09:24:48 +0200 Subject: [PATCH 08/63] add commands Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 38 +++++++++------ .../test/application/datawriters.py | 48 +++++++++++++++++++ fastddsspy_tool/test/application/exit.py | 47 ++++++++++++++++++ .../test/application/participants.py | 48 +++++++++++++++++++ fastddsspy_tool/test/application/topics.py | 48 +++++++++++++++++++ .../test/application/{tests.py => utils.py} | 44 +++-------------- 6 files changed, 222 insertions(+), 51 deletions(-) create mode 100644 fastddsspy_tool/test/application/datawriters.py create mode 100644 fastddsspy_tool/test/application/exit.py create mode 100644 fastddsspy_tool/test/application/participants.py create mode 100644 fastddsspy_tool/test/application/topics.py rename fastddsspy_tool/test/application/{tests.py => utils.py} (74%) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 40017132..a8f81208 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -18,6 +18,14 @@ find_package(PythonInterp 3 REQUIRED) +# Name of files to test +set(TEST_LIST + exit + participants + topics + datawriters +) + # windows auxiliary script to fork test execution set(PWS_LAUNCHER ${CMAKE_CURRENT_SOURCE_DIR}/launcher.ps1 @@ -79,19 +87,21 @@ if(WIN32) endif(WIN32) # populate the tests -set(TEST_NAME "tool.application.fastddsspy") -add_test( - NAME ${TEST_NAME} - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/tests.py - "--exe" $ - ) - -# Set test properties -set_tests_properties( - ${TEST_NAME} - PROPERTIES - ENVIRONMENT "${TEST_ENVIRONMENT}" - ) +foreach(TEST IN LISTS TEST_LIST) + set(TEST_NAME "tool.application.fastddsspy.${TEST}") + add_test( + NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}.py + "--exe" $ + ) + + # Set test properties + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + ) +endforeach() unset(TEST_ENVIRONMENT) diff --git a/fastddsspy_tool/test/application/datawriters.py b/fastddsspy_tool/test/application/datawriters.py new file mode 100644 index 00000000..77c66f93 --- /dev/null +++ b/fastddsspy_tool/test/application/datawriters.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. + +from utils import * + + +if __name__ == '__main__': + + args = parse_options() + + # Create a custom logger + logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + logger.addHandler(l_handler) + # Set log level + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + + if args.exe is None: + logger.error( + 'Executable binary file does not exist or has no ' + 'executable permissions.') + sys.exit(1) + + spy = test_spy_start(args.exe, logger) + + sys.exit( + test_spy_command( + spy, 'datawriters', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/exit.py b/fastddsspy_tool/test/application/exit.py new file mode 100644 index 00000000..1aa4997a --- /dev/null +++ b/fastddsspy_tool/test/application/exit.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. + +from utils import * + +if __name__ == '__main__': + + args = parse_options() + + # Create a custom logger + logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + logger.addHandler(l_handler) + # Set log level + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + + if args.exe is None: + logger.error( + 'Executable binary file does not exist or has no ' + 'executable permissions.') + sys.exit(1) + + spy = test_spy_start(args.exe, logger) + + sys.exit( + test_spy_command( + spy, 'exit', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/participants.py b/fastddsspy_tool/test/application/participants.py new file mode 100644 index 00000000..7c7944d1 --- /dev/null +++ b/fastddsspy_tool/test/application/participants.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. + +from utils import * + + +if __name__ == '__main__': + + args = parse_options() + + # Create a custom logger + logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + logger.addHandler(l_handler) + # Set log level + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + + if args.exe is None: + logger.error( + 'Executable binary file does not exist or has no ' + 'executable permissions.') + sys.exit(1) + + spy = test_spy_start(args.exe, logger) + + sys.exit( + test_spy_command( + spy, 'participants', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/topics.py b/fastddsspy_tool/test/application/topics.py new file mode 100644 index 00000000..7160c688 --- /dev/null +++ b/fastddsspy_tool/test/application/topics.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. + +from utils import * + + +if __name__ == '__main__': + + args = parse_options() + + # Create a custom logger + logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + logger.addHandler(l_handler) + # Set log level + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + + if args.exe is None: + logger.error( + 'Executable binary file does not exist or has no ' + 'executable permissions.') + sys.exit(1) + + spy = test_spy_start(args.exe, logger) + + sys.exit( + test_spy_command( + spy, 'topics', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/tests.py b/fastddsspy_tool/test/application/utils.py similarity index 74% rename from fastddsspy_tool/test/application/tests.py rename to fastddsspy_tool/test/application/utils.py index 2ac7d114..f656ba68 100644 --- a/fastddsspy_tool/test/application/tests.py +++ b/fastddsspy_tool/test/application/utils.py @@ -1,4 +1,4 @@ -# Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# 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. @@ -38,7 +38,7 @@ ' [-d]') # Sleep time to let process init and finish -SLEEP_TIME = 1 +SLEEP_TIME = 2 def executable_permission_value(): @@ -86,7 +86,7 @@ def parse_options(): return parser.parse_args() -def test_spy_closure(fastddsspy): +def test_spy_start(fastddsspy, logger): command = [fastddsspy] logger.info('Executing command: ' + str(command)) @@ -96,12 +96,13 @@ def test_spy_closure(fastddsspy): stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + return proc - # sleep to let the server run - time.sleep(SLEEP_TIME) + +def test_spy_command(proc, command, logger): try: - proc.communicate(input='exit', timeout=2) + proc.communicate(input=command, timeout=5) proc.kill() logger.debug('-----------------------------------------------------') logger.debug('Command ' + str(command) + ' worked.') @@ -114,34 +115,3 @@ def test_spy_closure(fastddsspy): return 1 return 0 - - -if __name__ == '__main__': - - args = parse_options() - - # Create a custom logger - logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - logger.addHandler(l_handler) - # Set log level - if args.debug: - logger.setLevel(logging.DEBUG) - else: - logger.setLevel(logging.INFO) - - if args.exe is None: - logger.error( - 'Executable binary file does not exist or has no ' - 'executable permissions.') - sys.exit(1) - - sys.exit( - test_spy_closure( - args.exe)) # Path to executable From 762dae0cb777f132ff1f64873c97d8615fc48e7b Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 11:07:21 +0200 Subject: [PATCH 09/63] Update structure Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/datawriters.py | 9 +++++++++ fastddsspy_tool/test/application/exit.py | 10 ++++++++++ fastddsspy_tool/test/application/participants.py | 9 +++++++++ fastddsspy_tool/test/application/topics.py | 9 +++++++++ fastddsspy_tool/test/application/utils.py | 9 +-------- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/fastddsspy_tool/test/application/datawriters.py b/fastddsspy_tool/test/application/datawriters.py index 77c66f93..7e8ded31 100644 --- a/fastddsspy_tool/test/application/datawriters.py +++ b/fastddsspy_tool/test/application/datawriters.py @@ -12,8 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +import sys +import time from utils import * +# Sleep time to let process init and finish +SLEEP_TIME = 2 + if __name__ == '__main__': @@ -43,6 +49,9 @@ spy = test_spy_start(args.exe, logger) + # sleep to let the spy run + time.sleep(SLEEP_TIME) + sys.exit( test_spy_command( spy, 'datawriters', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/exit.py b/fastddsspy_tool/test/application/exit.py index 1aa4997a..6f1fd823 100644 --- a/fastddsspy_tool/test/application/exit.py +++ b/fastddsspy_tool/test/application/exit.py @@ -12,8 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +import sys +import time from utils import * +# Sleep time to let process init and finish +SLEEP_TIME = 2 + + if __name__ == '__main__': args = parse_options() @@ -42,6 +49,9 @@ spy = test_spy_start(args.exe, logger) + # sleep to let the spy run + time.sleep(SLEEP_TIME) + sys.exit( test_spy_command( spy, 'exit', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/participants.py b/fastddsspy_tool/test/application/participants.py index 7c7944d1..9932494f 100644 --- a/fastddsspy_tool/test/application/participants.py +++ b/fastddsspy_tool/test/application/participants.py @@ -12,8 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +import sys +import time from utils import * +# Sleep time to let process init and finish +SLEEP_TIME = 2 + if __name__ == '__main__': @@ -43,6 +49,9 @@ spy = test_spy_start(args.exe, logger) + # sleep to let the spy run + time.sleep(SLEEP_TIME) + sys.exit( test_spy_command( spy, 'participants', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/topics.py b/fastddsspy_tool/test/application/topics.py index 7160c688..4946aa79 100644 --- a/fastddsspy_tool/test/application/topics.py +++ b/fastddsspy_tool/test/application/topics.py @@ -12,8 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +import sys +import time from utils import * +# Sleep time to let process init and finish +SLEEP_TIME = 2 + if __name__ == '__main__': @@ -43,6 +49,9 @@ spy = test_spy_start(args.exe, logger) + # sleep to let the spy run + time.sleep(SLEEP_TIME) + sys.exit( test_spy_command( spy, 'topics', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/utils.py b/fastddsspy_tool/test/application/utils.py index f656ba68..8a90fa97 100644 --- a/fastddsspy_tool/test/application/utils.py +++ b/fastddsspy_tool/test/application/utils.py @@ -27,20 +27,13 @@ """ import argparse -import logging import os import subprocess -import sys -import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' ' [-d]') -# Sleep time to let process init and finish -SLEEP_TIME = 2 - - def executable_permission_value(): """Return executable permissions value depending on the OS.""" if os.name == 'nt': @@ -103,7 +96,7 @@ def test_spy_command(proc, command, logger): try: proc.communicate(input=command, timeout=5) - proc.kill() + # proc.kill() logger.debug('-----------------------------------------------------') logger.debug('Command ' + str(command) + ' worked.') logger.debug('-----------------------------------------------------') From 90af7a346cf2e311eb56be13257711646452e007 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 12:45:12 +0200 Subject: [PATCH 10/63] Change structure Signed-off-by: Irene Bandera --- .../test/application/one_shot_help.py | 31 ++++ fastddsspy_tool/test/application/test.py | 171 ++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 fastddsspy_tool/test/application/one_shot_help.py create mode 100644 fastddsspy_tool/test/application/test.py diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py new file mode 100644 index 00000000..92168965 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -0,0 +1,31 @@ +# 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. + +import test + +class TestCase_instance (test.TestCase): + + def __init__(self): + super().__init__( + name = "HelpCommand", + one_shot = True, + command = [], + dds = False, + arguments = "help", + exec_spy = "" + ) + + # @override + def valid_output_tool(stdout, stderr): + super().valid_output_tool(stdout, stderr) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py new file mode 100644 index 00000000..38f915bb --- /dev/null +++ b/fastddsspy_tool/test/application/test.py @@ -0,0 +1,171 @@ +# 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 -e + +Arguments: + + Fast DDS Spy binary path : -e | --exe binary_path + + Run test in Debug mode : -d | --debug + +""" + +import argparse +import logging +import os +import subprocess +import ast + +DESCRIPTION = """Script to execute Fast DDS Spy executable test""" +USAGE = ('python3 tests.py -e ' + ' [-d]') + +class TestCase(): + + def __init__(self, name, one_shot, command, dds, arguments): + self.name = name + self.one_shot = one_shot + self.command = command + self.dds = dds + self.arguments = arguments + self.exec_spy = "" + + # Create a custom logger + self.logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + self.logger.addHandler(l_handler) + + def run(self): + if (self.dds): + self.run_dds() + self.run_tool() + + def run_tool(self): + self.logger.info('Run tool') + if (self.one_shot): + self.command = [self.exec_spy + " " + self.arguments] + else: + self.command = [self.exec_spy] + + self.logger.info('Executing command: ' + str(self.command)) + + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True) + return proc + + # proc = Popen(f"fastddspy {self.arguments} {self.one_shot}") + # proc.communicate(self.command) + + def run_dds(self): + self.logger.info('Run dds') + # proc = Popen(f"example {self.dds}") + # proc.communicate(self.command) + + def valid_output_tool(stdout, stderr): + return stderr == "" + + +def executable_permission_value(): + """Return executable permissions value depending on the OS.""" + if os.name == 'nt': + return os.X_OK # windows + else: + return os.EX_OK + + +def file_exist_and_have_permissions(file_path): + """Check if a file exists and have executable permissions.""" + if os.access(file_path, executable_permission_value()): + return file_path + else: + return None + +def parse_options(): + """ + Parse arguments. + + :return: The arguments parsed. + """ + 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 discovery-server executable.' + ) + parser.add_argument( + '-d', + '--debug', + action='store_true', + help='Print test debugging info.' + ) + return parser.parse_args() + +from one_shot_help import TestCase_instance + +def main(): + + args = parse_options() + + with open("one_shot_help.py") as file: + test_file = ast.parse(file.read()) + + # test_case = test_file.body + # test_case = test_case.__class__ + for t in test_file.body: + if isinstance(t, ast.ClassDef): + test_function = t + break + + # test_case = TestCase_instance() + # test_case.args.args.exec_spy = "hello" + print(test_function) + print(test_function.name) + # print(test_function.body) + # print(test_function.arguments) + + result = test_function.run() + + if not result: + return 1 + + if not test_function.valid_output_tool(result.stdout, result.stderr): + return 1 + + return 0 + + +if __name__ == '__main__': + main() From 2963a76cbeaf2e3187616ee2f438a64c4800e0d5 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 28 Mar 2023 16:25:28 +0200 Subject: [PATCH 11/63] Add one shot test without dds Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 18 ++- .../test/application/datawriters.py | 57 --------- fastddsspy_tool/test/application/exit.py | 57 --------- .../test/application/one_shot_datareader.py | 30 +++++ .../test/application/one_shot_datawriter.py | 30 +++++ .../test/application/one_shot_help.py | 13 +-- .../test/application/one_shot_participants.py | 30 +++++ .../test/application/one_shot_quit.py | 30 +++++ .../test/application/one_shot_show.py | 30 +++++ .../test/application/one_shot_topics.py | 30 +++++ .../test/application/one_shot_trivial.py | 30 +++++ .../test/application/one_shot_version.py | 30 +++++ .../test/application/participants.py | 57 --------- fastddsspy_tool/test/application/test.py | 88 +++----------- .../test/application/test_class.py | 85 ++++++++++++++ fastddsspy_tool/test/application/topics.py | 57 --------- fastddsspy_tool/test/application/utils.py | 110 ------------------ 17 files changed, 356 insertions(+), 426 deletions(-) delete mode 100644 fastddsspy_tool/test/application/datawriters.py delete mode 100644 fastddsspy_tool/test/application/exit.py create mode 100644 fastddsspy_tool/test/application/one_shot_datareader.py create mode 100644 fastddsspy_tool/test/application/one_shot_datawriter.py create mode 100644 fastddsspy_tool/test/application/one_shot_participants.py create mode 100644 fastddsspy_tool/test/application/one_shot_quit.py create mode 100644 fastddsspy_tool/test/application/one_shot_show.py create mode 100644 fastddsspy_tool/test/application/one_shot_topics.py create mode 100644 fastddsspy_tool/test/application/one_shot_trivial.py create mode 100644 fastddsspy_tool/test/application/one_shot_version.py delete mode 100644 fastddsspy_tool/test/application/participants.py create mode 100644 fastddsspy_tool/test/application/test_class.py delete mode 100644 fastddsspy_tool/test/application/topics.py delete mode 100644 fastddsspy_tool/test/application/utils.py diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index a8f81208..e57bca6f 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -20,10 +20,15 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test set(TEST_LIST - exit - participants - topics - datawriters + one_shot_trivial + one_shot_help + one_shot_datareader + one_shot_datawriter + one_shot_participants + one_shot_quit + one_shot_show + one_shot_topics + one_shot_version ) # windows auxiliary script to fork test execution @@ -88,12 +93,13 @@ endif(WIN32) # populate the tests foreach(TEST IN LISTS TEST_LIST) - set(TEST_NAME "tool.application.fastddsspy.${TEST}") + set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") add_test( NAME ${TEST_NAME} COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}.py + ${CMAKE_CURRENT_SOURCE_DIR}/test.py "--exe" $ + "--test" ${TEST} ) # Set test properties diff --git a/fastddsspy_tool/test/application/datawriters.py b/fastddsspy_tool/test/application/datawriters.py deleted file mode 100644 index 7e8ded31..00000000 --- a/fastddsspy_tool/test/application/datawriters.py +++ /dev/null @@ -1,57 +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. - -import logging -import sys -import time -from utils import * - -# Sleep time to let process init and finish -SLEEP_TIME = 2 - - -if __name__ == '__main__': - - args = parse_options() - - # Create a custom logger - logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - logger.addHandler(l_handler) - # Set log level - if args.debug: - logger.setLevel(logging.DEBUG) - else: - logger.setLevel(logging.INFO) - - if args.exe is None: - logger.error( - 'Executable binary file does not exist or has no ' - 'executable permissions.') - sys.exit(1) - - spy = test_spy_start(args.exe, logger) - - # sleep to let the spy run - time.sleep(SLEEP_TIME) - - sys.exit( - test_spy_command( - spy, 'datawriters', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/exit.py b/fastddsspy_tool/test/application/exit.py deleted file mode 100644 index 6f1fd823..00000000 --- a/fastddsspy_tool/test/application/exit.py +++ /dev/null @@ -1,57 +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. - -import logging -import sys -import time -from utils import * - -# Sleep time to let process init and finish -SLEEP_TIME = 2 - - -if __name__ == '__main__': - - args = parse_options() - - # Create a custom logger - logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - logger.addHandler(l_handler) - # Set log level - if args.debug: - logger.setLevel(logging.DEBUG) - else: - logger.setLevel(logging.INFO) - - if args.exe is None: - logger.error( - 'Executable binary file does not exist or has no ' - 'executable permissions.') - sys.exit(1) - - spy = test_spy_start(args.exe, logger) - - # sleep to let the spy run - time.sleep(SLEEP_TIME) - - sys.exit( - test_spy_command( - spy, 'exit', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py new file mode 100644 index 00000000..45ea2968 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "DatareaderCommand", + one_shot = True, + command = [], + dds = False, + arguments = "datawriter" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py new file mode 100644 index 00000000..8e13db50 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "DatawriterCommand", + one_shot = True, + command = [], + dds = False, + arguments = "datawriter" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index 92168965..c95cb037 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import test +import test_class -class TestCase_instance (test.TestCase): +class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( @@ -22,10 +22,9 @@ def __init__(self): one_shot = True, command = [], dds = False, - arguments = "help", - exec_spy = "" + arguments = "help" ) - # @override - def valid_output_tool(stdout, stderr): - super().valid_output_tool(stdout, stderr) + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py new file mode 100644 index 00000000..2fa2e446 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "ParticipantsCommand", + one_shot = True, + command = [], + dds = False, + arguments = "participants" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py new file mode 100644 index 00000000..378871c2 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "QuitCommand", + one_shot = True, + command = [], + dds = False, + arguments = "exit" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_show.py b/fastddsspy_tool/test/application/one_shot_show.py new file mode 100644 index 00000000..67e08702 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_show.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "ShowCommand", + one_shot = True, + command = [], + dds = False, + arguments = "show all" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py new file mode 100644 index 00000000..ab2731f6 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "TopicsCommand", + one_shot = True, + command = [], + dds = False, + arguments = "topics" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_trivial.py b/fastddsspy_tool/test/application/one_shot_trivial.py new file mode 100644 index 00000000..d0dae89c --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_trivial.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "TrivialCommand", + one_shot = True, + command = [], + dds = False, + arguments = "" + ) + + # @override + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_version.py b/fastddsspy_tool/test/application/one_shot_version.py new file mode 100644 index 00000000..8a27c6f7 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_version.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name = "VersionCommand", + one_shot = True, + command = [], + dds = False, + arguments = "version" + ) + + + def valid_output_tool(self, stderr): + super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/participants.py b/fastddsspy_tool/test/application/participants.py deleted file mode 100644 index 9932494f..00000000 --- a/fastddsspy_tool/test/application/participants.py +++ /dev/null @@ -1,57 +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. - -import logging -import sys -import time -from utils import * - -# Sleep time to let process init and finish -SLEEP_TIME = 2 - - -if __name__ == '__main__': - - args = parse_options() - - # Create a custom logger - logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - logger.addHandler(l_handler) - # Set log level - if args.debug: - logger.setLevel(logging.DEBUG) - else: - logger.setLevel(logging.INFO) - - if args.exe is None: - logger.error( - 'Executable binary file does not exist or has no ' - 'executable permissions.') - sys.exit(1) - - spy = test_spy_start(args.exe, logger) - - # sleep to let the spy run - time.sleep(SLEEP_TIME) - - sys.exit( - test_spy_command( - spy, 'participants', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 38f915bb..ee1fc900 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -22,74 +22,19 @@ Fast DDS Spy binary path : -e | --exe binary_path - Run test in Debug mode : -d | --debug + Run test in Debug mode : -t | --test """ import argparse -import logging import os -import subprocess import ast +import importlib DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' ' [-d]') -class TestCase(): - - def __init__(self, name, one_shot, command, dds, arguments): - self.name = name - self.one_shot = one_shot - self.command = command - self.dds = dds - self.arguments = arguments - self.exec_spy = "" - - # Create a custom logger - self.logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - self.logger.addHandler(l_handler) - - def run(self): - if (self.dds): - self.run_dds() - self.run_tool() - - def run_tool(self): - self.logger.info('Run tool') - if (self.one_shot): - self.command = [self.exec_spy + " " + self.arguments] - else: - self.command = [self.exec_spy] - - self.logger.info('Executing command: ' + str(self.command)) - - proc = subprocess.Popen(self.command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) - return proc - - # proc = Popen(f"fastddspy {self.arguments} {self.one_shot}") - # proc.communicate(self.command) - - def run_dds(self): - self.logger.info('Run dds') - # proc = Popen(f"example {self.dds}") - # proc.communicate(self.command) - - def valid_output_tool(stdout, stderr): - return stderr == "" - - def executable_permission_value(): """Return executable permissions value depending on the OS.""" if os.name == 'nt': @@ -125,6 +70,13 @@ def parse_options(): required=True, help='Path to discovery-server executable.' ) + required_args.add_argument( + '-t', + '--test', + type=str, + required=True, + help='Test to run.' + ) parser.add_argument( '-d', '--debug', @@ -133,35 +85,21 @@ def parse_options(): ) return parser.parse_args() -from one_shot_help import TestCase_instance - def main(): args = parse_options() - with open("one_shot_help.py") as file: - test_file = ast.parse(file.read()) - - # test_case = test_file.body - # test_case = test_case.__class__ - for t in test_file.body: - if isinstance(t, ast.ClassDef): - test_function = t - break + module = importlib.import_module(args.test) + test_function = module.TestCase_instance() - # test_case = TestCase_instance() - # test_case.args.args.exec_spy = "hello" - print(test_function) - print(test_function.name) - # print(test_function.body) - # print(test_function.arguments) + test_function.exec_spy = args.exe result = test_function.run() if not result: return 1 - if not test_function.valid_output_tool(result.stdout, result.stderr): + if not test_function.valid_output_tool(result.stderr): return 1 return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py new file mode 100644 index 00000000..2c3549d5 --- /dev/null +++ b/fastddsspy_tool/test/application/test_class.py @@ -0,0 +1,85 @@ +# 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 -e + +Arguments: + + Fast DDS Spy binary path : -e | --exe binary_path + + Run test in Debug mode : -d | --debug + +""" + +import logging +import subprocess + +DESCRIPTION = """Script to execute Fast DDS Spy executable test""" +USAGE = ('python3 tests.py -e ' + ' [-d]') + +class TestCase(): + + def __init__(self, name, one_shot, command, dds, arguments): + self.name = name + self.one_shot = one_shot + self.command = command + self.dds = dds + self.arguments = arguments + self.exec_spy = "" + + # Create a custom logger + self.logger = logging.getLogger('SYS_TEST') + # Create handlers + l_handler = logging.StreamHandler() + # Create formatters and add it to handlers + l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' + l_format = logging.Formatter(l_format) + l_handler.setFormatter(l_format) + # Add handlers to the logger + self.logger.addHandler(l_handler) + + def run(self): + if (self.dds): + self.run_dds() + return self.run_tool() + + def run_tool(self): + self.logger.info('Run tool') + if (self.one_shot): + self.command = [self.exec_spy, self.arguments] + else: + self.command = [self.exec_spy] + + self.logger.info('Executing command: ' + str(self.command)) + + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True) + + return proc + + def run_dds(self): + self.logger.info('Run dds') + # proc = Popen(f"example {self.dds}") + # proc.communicate(self.command) + + def valid_output_tool(self, stderr): + return stderr == "" diff --git a/fastddsspy_tool/test/application/topics.py b/fastddsspy_tool/test/application/topics.py deleted file mode 100644 index 4946aa79..00000000 --- a/fastddsspy_tool/test/application/topics.py +++ /dev/null @@ -1,57 +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. - -import logging -import sys -import time -from utils import * - -# Sleep time to let process init and finish -SLEEP_TIME = 2 - - -if __name__ == '__main__': - - args = parse_options() - - # Create a custom logger - logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - logger.addHandler(l_handler) - # Set log level - if args.debug: - logger.setLevel(logging.DEBUG) - else: - logger.setLevel(logging.INFO) - - if args.exe is None: - logger.error( - 'Executable binary file does not exist or has no ' - 'executable permissions.') - sys.exit(1) - - spy = test_spy_start(args.exe, logger) - - # sleep to let the spy run - time.sleep(SLEEP_TIME) - - sys.exit( - test_spy_command( - spy, 'topics', logger)) # Path to executable diff --git a/fastddsspy_tool/test/application/utils.py b/fastddsspy_tool/test/application/utils.py deleted file mode 100644 index 8a90fa97..00000000 --- a/fastddsspy_tool/test/application/utils.py +++ /dev/null @@ -1,110 +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. -""" -Tests for the fastddsspy executable. - -Contains a package of system test for fastddsspy tool - -Usage: test.py -e - -Arguments: - - Fast DDS Spy binary path : -e | --exe binary_path - - Run test in Debug mode : -d | --debug - -""" - -import argparse -import os -import subprocess - -DESCRIPTION = """Script to execute Fast DDS Spy executable test""" -USAGE = ('python3 tests.py -e ' - ' [-d]') - -def executable_permission_value(): - """Return executable permissions value depending on the OS.""" - if os.name == 'nt': - return os.X_OK # windows - else: - return os.EX_OK - - -def file_exist_and_have_permissions(file_path): - """Check if a file exists and have executable permissions.""" - if os.access(file_path, executable_permission_value()): - return file_path - else: - return None - - -def parse_options(): - """ - Parse arguments. - - :return: The arguments parsed. - """ - 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 discovery-server executable.' - ) - parser.add_argument( - '-d', - '--debug', - action='store_true', - help='Print test debugging info.' - ) - return parser.parse_args() - - -def test_spy_start(fastddsspy, logger): - - command = [fastddsspy] - logger.info('Executing command: ' + str(command)) - - proc = subprocess.Popen(command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) - return proc - - -def test_spy_command(proc, command, logger): - - try: - proc.communicate(input=command, timeout=5) - # proc.kill() - logger.debug('-----------------------------------------------------') - logger.debug('Command ' + str(command) + ' worked.') - logger.debug('-----------------------------------------------------') - except subprocess.TimeoutExpired: - proc.kill() - logger.error('-----------------------------------------------------') - logger.error('Command ' + str(command) + ' failed.') - logger.error('-----------------------------------------------------') - return 1 - - return 0 From ffca21e6f8d13aecf8ca12cd64e71ac80d47103b Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 29 Mar 2023 12:21:56 +0200 Subject: [PATCH 12/63] Update Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 7 ++++- .../test/application/one_shot_datareader.py | 15 ++++------ .../test/application/one_shot_datawriter.py | 15 ++++------ .../test/application/one_shot_help.py | 15 ++++------ .../test/application/one_shot_participants.py | 15 ++++------ .../test/application/one_shot_quit.py | 15 ++++------ .../test/application/one_shot_show.py | 15 ++++------ .../test/application/one_shot_topics.py | 15 ++++------ .../test/application/one_shot_version.py | 15 ++++------ fastddsspy_tool/test/application/test.py | 25 ++++++++++++---- .../test/application/test_class.py | 29 ++++++++++++++++--- ...one_shot_trivial.py => tool_datareader.py} | 15 ++++------ .../test/application/tool_datawriter.py | 27 +++++++++++++++++ fastddsspy_tool/test/application/tool_help.py | 27 +++++++++++++++++ .../test/application/tool_participants.py | 27 +++++++++++++++++ fastddsspy_tool/test/application/tool_show.py | 27 +++++++++++++++++ .../test/application/tool_topics.py | 27 +++++++++++++++++ 17 files changed, 240 insertions(+), 91 deletions(-) rename fastddsspy_tool/test/application/{one_shot_trivial.py => tool_datareader.py} (75%) create mode 100644 fastddsspy_tool/test/application/tool_datawriter.py create mode 100644 fastddsspy_tool/test/application/tool_help.py create mode 100644 fastddsspy_tool/test/application/tool_participants.py create mode 100644 fastddsspy_tool/test/application/tool_show.py create mode 100644 fastddsspy_tool/test/application/tool_topics.py diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index e57bca6f..e6b4f54f 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -20,7 +20,6 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test set(TEST_LIST - one_shot_trivial one_shot_help one_shot_datareader one_shot_datawriter @@ -29,6 +28,12 @@ set(TEST_LIST one_shot_show one_shot_topics one_shot_version + tool_datareader + tool_datawriter + tool_help + tool_participants + tool_show + tool_topics ) # windows auxiliary script to fork test execution diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index 45ea2968..37c321ee 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "DatareaderCommand", - one_shot = True, - command = [], - dds = False, - arguments = "datawriter" + name='DatareaderCommand', + one_shot=True, + command=[], + dds=False, + arguments='datareader' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index 8e13db50..8ed8c2eb 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "DatawriterCommand", - one_shot = True, - command = [], - dds = False, - arguments = "datawriter" + name='DatawriterCommand', + one_shot=True, + command=[], + dds=False, + arguments='datawriter' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index c95cb037..9f9940ac 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "HelpCommand", - one_shot = True, - command = [], - dds = False, - arguments = "help" + name='HelpCommand', + one_shot=True, + command=[], + dds=False, + arguments='help' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index 2fa2e446..1624f487 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "ParticipantsCommand", - one_shot = True, - command = [], - dds = False, - arguments = "participants" + name='ParticipantsCommand', + one_shot=True, + command=[], + dds=False, + arguments='participants' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py index 378871c2..c428b2df 100644 --- a/fastddsspy_tool/test/application/one_shot_quit.py +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "QuitCommand", - one_shot = True, - command = [], - dds = False, - arguments = "exit" + name='QuitCommand', + one_shot=True, + command=[], + dds=False, + arguments='exit' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_show.py b/fastddsspy_tool/test/application/one_shot_show.py index 67e08702..6a152eb0 100644 --- a/fastddsspy_tool/test/application/one_shot_show.py +++ b/fastddsspy_tool/test/application/one_shot_show.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "ShowCommand", - one_shot = True, - command = [], - dds = False, - arguments = "show all" + name='ShowCommand', + one_shot=True, + command=[], + dds=False, + arguments='show all' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index ab2731f6..f4f186d8 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "TopicsCommand", - one_shot = True, - command = [], - dds = False, - arguments = "topics" + name='TopicsCommand', + one_shot=True, + command=[], + dds=False, + arguments='topics' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/one_shot_version.py b/fastddsspy_tool/test/application/one_shot_version.py index 8a27c6f7..8be132ce 100644 --- a/fastddsspy_tool/test/application/one_shot_version.py +++ b/fastddsspy_tool/test/application/one_shot_version.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "VersionCommand", - one_shot = True, - command = [], - dds = False, - arguments = "version" + name='VersionCommand', + one_shot=True, + command=[], + dds=False, + arguments='version' ) - - - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index ee1fc900..c7d3b6ef 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -28,13 +28,15 @@ import argparse import os -import ast import importlib +import time +import sys DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' ' [-d]') + def executable_permission_value(): """Return executable permissions value depending on the OS.""" if os.name == 'nt': @@ -50,6 +52,7 @@ def file_exist_and_have_permissions(file_path): else: return None + def parse_options(): """ Parse arguments. @@ -85,6 +88,7 @@ def parse_options(): ) return parser.parse_args() + def main(): args = parse_options() @@ -96,11 +100,22 @@ def main(): result = test_function.run() - if not result: - return 1 + if(test_function.one_shot): + if not test_function.is_stop_tool(result): + sys.exit(1) + if not test_function.valid_output_tool(result.stderr): + sys.exit(1) + else: + if test_function.is_stop_tool(result): + sys.exit(1) + + test_function.send_command_tool(result) - if not test_function.valid_output_tool(result.stderr): - return 1 + test_function.stop_tool(result) + # not working: + # if(not test_function.is_stop_tool(result)): + # print("not stop") + # sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 2c3549d5..55c1d984 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -28,11 +28,13 @@ import logging import subprocess +import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' ' [-d]') + class TestCase(): def __init__(self, name, one_shot, command, dds, arguments): @@ -41,7 +43,7 @@ def __init__(self, name, one_shot, command, dds, arguments): self.command = command self.dds = dds self.arguments = arguments - self.exec_spy = "" + self.exec_spy = '' # Create a custom logger self.logger = logging.getLogger('SYS_TEST') @@ -71,15 +73,34 @@ def run_tool(self): proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) + stderr=subprocess.PIPE) + + if (self.one_shot): + proc.wait(timeout=2) return proc + def is_stop_tool(self, proc): + return_code = proc.poll() + + if(return_code == None): + return False + return True + + def send_command_tool(self, proc): + proc.stdin.write(bytes(self.arguments, 'utf-8')) + if (self.dds): + output = proc.stdout.read() + error = proc.stderr.read() + self.valid_output_tool(error) + + def stop_tool(self, proc): + proc.stdin.write(b'exit') + def run_dds(self): self.logger.info('Run dds') # proc = Popen(f"example {self.dds}") # proc.communicate(self.command) def valid_output_tool(self, stderr): - return stderr == "" + return (len(stderr.read()) == 0) diff --git a/fastddsspy_tool/test/application/one_shot_trivial.py b/fastddsspy_tool/test/application/tool_datareader.py similarity index 75% rename from fastddsspy_tool/test/application/one_shot_trivial.py rename to fastddsspy_tool/test/application/tool_datareader.py index d0dae89c..fa41bb87 100644 --- a/fastddsspy_tool/test/application/one_shot_trivial.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -14,17 +14,14 @@ import test_class + class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name = "TrivialCommand", - one_shot = True, - command = [], - dds = False, - arguments = "" + name='ToolDatareaderCommand', + one_shot=False, + command=[], + dds=False, + arguments='datareader' ) - - # @override - def valid_output_tool(self, stderr): - super().valid_output_tool(stderr) diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py new file mode 100644 index 00000000..4d5cde62 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolDatawriterCommand', + one_shot=False, + command=[], + dds=False, + arguments='datawriter' + ) diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py new file mode 100644 index 00000000..4978b409 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_help.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolHelpCommand', + one_shot=False, + command=[], + dds=False, + arguments='help' + ) diff --git a/fastddsspy_tool/test/application/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py new file mode 100644 index 00000000..555f76ab --- /dev/null +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolParticipantsCommand', + one_shot=False, + command=[], + dds=False, + arguments='participants' + ) diff --git a/fastddsspy_tool/test/application/tool_show.py b/fastddsspy_tool/test/application/tool_show.py new file mode 100644 index 00000000..cfac2a19 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_show.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolHelpCommand', + one_shot=False, + command=[], + dds=False, + arguments='show all' + ) diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py new file mode 100644 index 00000000..6a22a133 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolParticipantsCommand', + one_shot=False, + command=[], + dds=False, + arguments='topics' + ) From 95d8eb2e2c323392c85e779b017784711d4d910d Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 29 Mar 2023 13:53:17 +0200 Subject: [PATCH 13/63] Working without fast Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 15 +++---- .../test/application/test_class.py | 39 ++++++++++++++----- fastddsspy_tool/test/application/tool_show.py | 4 +- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index c7d3b6ef..e3070a00 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -29,7 +29,6 @@ import argparse import os import importlib -import time import sys DESCRIPTION = """Script to execute Fast DDS Spy executable test""" @@ -100,10 +99,10 @@ def main(): result = test_function.run() - if(test_function.one_shot): + if test_function.one_shot: if not test_function.is_stop_tool(result): sys.exit(1) - if not test_function.valid_output_tool(result.stderr): + if not test_function.valid_output_tool(result.returncode): sys.exit(1) else: if test_function.is_stop_tool(result): @@ -112,10 +111,12 @@ def main(): test_function.send_command_tool(result) test_function.stop_tool(result) - # not working: - # if(not test_function.is_stop_tool(result)): - # print("not stop") - # sys.exit(1) + + if not test_function.is_stop_tool(result): + sys.exit(1) + + if not test_function.valid_output_tool(result.returncode): + sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 55c1d984..4e25ebce 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -28,7 +28,6 @@ import logging import subprocess -import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -76,31 +75,53 @@ def run_tool(self): stderr=subprocess.PIPE) if (self.one_shot): - proc.wait(timeout=2) + try: + output_bytes, error_bytes = proc.communicate(timeout=5) + except subprocess.TimeoutExpired: + proc.kill() + output_bytes, error_bytes = proc.communicate() return proc def is_stop_tool(self, proc): return_code = proc.poll() - if(return_code == None): + if (return_code is None): return False return True def send_command_tool(self, proc): - proc.stdin.write(bytes(self.arguments, 'utf-8')) - if (self.dds): - output = proc.stdout.read() + proc.stdin.write(('self.arguments'+'\n').encode('utf-8')) + if self.dds: + # proc.stdin.close() + # proc.stdout.read() + # proc.stderr.read() + # proc.stdout.close() + # proc.stderr.close() + # output = proc.stdout.read() error = proc.stderr.read() self.valid_output_tool(error) def stop_tool(self, proc): - proc.stdin.write(b'exit') + try: + output_bytes, error_bytes = proc.communicate(input=b'exit\n', timeout=5) + except subprocess.TimeoutExpired: + proc.kill() + output_bytes, error_bytes = proc.communicate() def run_dds(self): self.logger.info('Run dds') # proc = Popen(f"example {self.dds}") # proc.communicate(self.command) - def valid_output_tool(self, stderr): - return (len(stderr.read()) == 0) + def valid_output_tool(self, returncode): + # -9: corresponds to the SIGKILL signal + # 0: Successful termination + # 1: General error + # 2: Misuse of shell builtins + # 126: Command invoked cannot execute + # 127: Command not found + # 128: Invalid argument to exit + # 130: Terminated by Ctrl-C + # 255: Exit status out of range + return (returncode == 0) diff --git a/fastddsspy_tool/test/application/tool_show.py b/fastddsspy_tool/test/application/tool_show.py index cfac2a19..e47a626e 100644 --- a/fastddsspy_tool/test/application/tool_show.py +++ b/fastddsspy_tool/test/application/tool_show.py @@ -19,9 +19,9 @@ class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name='ToolHelpCommand', + name='ToolShowCommand', one_shot=False, command=[], dds=False, - arguments='show all' + arguments='show topic' ) From 632bf1849448c9c4383ffeb255f2d47c4ac41a85 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 29 Mar 2023 15:54:58 +0200 Subject: [PATCH 14/63] Add one shot with dds tests Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 8 +++ .../application/one_shot_datareader_dds.py | 27 ++++++++ .../application/one_shot_datawriter_dds.py | 27 ++++++++ .../test/application/one_shot_help_dds.py | 27 ++++++++ .../application/one_shot_participants_dds.py | 27 ++++++++ .../test/application/one_shot_quit_dds.py | 27 ++++++++ .../test/application/one_shot_show_dds.py | 27 ++++++++ .../test/application/one_shot_topics_dds.py | 27 ++++++++ .../test/application/one_shot_version_dds.py | 27 ++++++++ fastddsspy_tool/test/application/test.py | 33 +++++++--- .../test/application/test_class.py | 61 ++++++++++++------- 11 files changed, 288 insertions(+), 30 deletions(-) create mode 100644 fastddsspy_tool/test/application/one_shot_datareader_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_datawriter_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_help_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_participants_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_quit_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_show_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_topics_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_version_dds.py diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index e6b4f54f..553b6c46 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -21,13 +21,21 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test set(TEST_LIST one_shot_help + one_shot_help_dds one_shot_datareader + one_shot_datareader_dds one_shot_datawriter + one_shot_datawriter_dds one_shot_participants + one_shot_participants_dds one_shot_quit + one_shot_quit_dds one_shot_show + one_shot_show_dds one_shot_topics + one_shot_topics_dds one_shot_version + one_shot_version_dds tool_datareader tool_datawriter tool_help diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py new file mode 100644 index 00000000..2ca5fea2 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatareaderDDSCommand', + one_shot=True, + command=[], + dds=True, + arguments='datareader' + ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py new file mode 100644 index 00000000..2184824b --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatawriterDDSCommand', + one_shot=True, + command=[], + dds=True, + arguments='datawriter' + ) diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py new file mode 100644 index 00000000..58452dd3 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='HelpDDSCommand', + one_shot=True, + command=[], + dds=True, + arguments='help' + ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py new file mode 100644 index 00000000..33abcbfa --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ParticipantsDDSCommand', + one_shot=True, + command=[], + dds=False, + arguments='participants' + ) diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py new file mode 100644 index 00000000..118559e2 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='QuitDDSCommand', + one_shot=True, + command=[], + dds=False, + arguments='exit' + ) diff --git a/fastddsspy_tool/test/application/one_shot_show_dds.py b/fastddsspy_tool/test/application/one_shot_show_dds.py new file mode 100644 index 00000000..4098d3c0 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_show_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ShowDDSCommand', + one_shot=True, + command=[], + dds=False, + arguments='show all' + ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py new file mode 100644 index 00000000..d66c077f --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsDDSCommand', + one_shot=True, + command=[], + dds=False, + arguments='topics' + ) diff --git a/fastddsspy_tool/test/application/one_shot_version_dds.py b/fastddsspy_tool/test/application/one_shot_version_dds.py new file mode 100644 index 00000000..a3292b87 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_version_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='VersionDDSCommand', + one_shot=True, + command=[], + dds=False, + arguments='version' + ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index e3070a00..53fc0b0b 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -97,27 +97,44 @@ def main(): test_function.exec_spy = args.exe - result = test_function.run() + spy, dds = test_function.run() + # if (test_function.dds): + # dds = test_function.run_dds() if test_function.one_shot: - if not test_function.is_stop_tool(result): + if not test_function.is_stop(spy): sys.exit(1) - if not test_function.valid_output_tool(result.returncode): + if not test_function.valid_output_tool(spy.returncode, 0): sys.exit(1) + + if (test_function.dds): + test_function.stop_dds(dds) + if not test_function.is_stop(dds): + sys.exit(1) + + if not test_function.valid_output_tool(dds.returncode, 1): + sys.exit(1) else: - if test_function.is_stop_tool(result): + if test_function.is_stop(spy): sys.exit(1) - test_function.send_command_tool(result) + test_function.send_command_tool(spy) - test_function.stop_tool(result) + test_function.stop(spy, dds) - if not test_function.is_stop_tool(result): + if not test_function.is_stop(spy): sys.exit(1) - if not test_function.valid_output_tool(result.returncode): + if not test_function.valid_output_tool(spy.returncode, 0): sys.exit(1) + if (test_function.dds): + if not test_function.is_stop(dds): + sys.exit(1) + + if not test_function.valid_output_tool(dds.returncode, 1): + sys.exit(1) + return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 4e25ebce..9f54484a 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -28,6 +28,8 @@ import logging import subprocess +import os +import signal DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -56,9 +58,10 @@ def __init__(self, name, one_shot, command, dds, arguments): self.logger.addHandler(l_handler) def run(self): + dds = None if (self.dds): - self.run_dds() - return self.run_tool() + dds = self.run_dds() + return self.run_tool(), dds def run_tool(self): self.logger.info('Run tool') @@ -76,14 +79,20 @@ def run_tool(self): if (self.one_shot): try: - output_bytes, error_bytes = proc.communicate(timeout=5) + proc.communicate(timeout=5) except subprocess.TimeoutExpired: proc.kill() - output_bytes, error_bytes = proc.communicate() + proc.communicate() return proc - def is_stop_tool(self, proc): + def stop(self, spy, dds): + self.stop_tool(spy) + if (self.dds): + self.stop_dds(dds) + + + def is_stop(self, proc): return_code = proc.poll() if (return_code is None): @@ -104,24 +113,32 @@ def send_command_tool(self, proc): def stop_tool(self, proc): try: - output_bytes, error_bytes = proc.communicate(input=b'exit\n', timeout=5) + proc.communicate(input=b'exit\n', timeout=5) except subprocess.TimeoutExpired: proc.kill() - output_bytes, error_bytes = proc.communicate() + proc.communicate() def run_dds(self): - self.logger.info('Run dds') - # proc = Popen(f"example {self.dds}") - # proc.communicate(self.command) - - def valid_output_tool(self, returncode): - # -9: corresponds to the SIGKILL signal - # 0: Successful termination - # 1: General error - # 2: Misuse of shell builtins - # 126: Command invoked cannot execute - # 127: Command not found - # 128: Invalid argument to exit - # 130: Terminated by Ctrl-C - # 255: Exit status out of range - return (returncode == 0) + self.logger.info('Run tool') + self.command = ["/home/irenebm/eprosima/annapurna/DDS-Spy/build/fastddsspy_tool/test/integration/dds/AdvancedConfigurationExample/AdvancedConfigurationExample"] + + self.logger.info('Executing command: ' + str(self.command)) + + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + return proc + + def stop_dds(self, proc): + # send a ctrl+c signal to the subprocess + proc.send_signal(signal.SIGINT) + try: + proc.communicate(timeout=5) + except subprocess.TimeoutExpired: + proc.send_signal(signal.SIGINT) + proc.communicate() + + def valid_output_tool(self, returncode, expected): + return (returncode == expected) From ef4e0c9cf380b7918bf17f09704f4f5fd8443fc6 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 07:55:43 +0200 Subject: [PATCH 15/63] Add dds publisher Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 2 + .../AdvancedConfigurationPublisher.cpp | 357 ++++++++++++++++++ .../AdvancedConfigurationPublisher.h | 150 ++++++++ .../AdvancedConfigurationSubscriber.cpp | 314 +++++++++++++++ .../AdvancedConfigurationSubscriber.h | 136 +++++++ .../AdvancedConfiguration_main.cpp | 267 +++++++++++++ .../CMakeLists.txt | 51 +++ .../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/test.py | 5 +- .../test/application/test_class.py | 5 +- 17 files changed, 2396 insertions(+), 5 deletions(-) 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 diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 553b6c46..18cb091f 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -124,3 +124,5 @@ foreach(TEST IN LISTS TEST_LIST) endforeach() unset(TEST_ENVIRONMENT) + +add_subdirectory(dds/AdvancedConfigurationExample) 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..60fba184 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp @@ -0,0 +1,357 @@ +// 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; + } + + 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..36ac38e1 --- /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 (topic_ != nullptr) + { + participant_->delete_topic(topic_); + } + if (subscriber_ != nullptr) + { + if (reader_ != nullptr) + { + subscriber_->delete_datareader(reader_); + } + participant_->delete_subscriber(subscriber_); + } + 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..f6f6c764 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt @@ -0,0 +1,51 @@ +# 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 VERSION 1 LANGUAGES CXX) + +# 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(${PROJECT_NAME} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP}) +target_compile_definitions(${PROJECT_NAME} PRIVATE + $<$>,$>:__DEBUG> + $<$:__INTERNALDEBUG> # Internal debug activated. + $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport +) + +target_link_libraries(${PROJECT_NAME} fastrtps fastcdr fastdds::optionparser) +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION examples/cpp/dds/${PROJECT_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..0741f6fd --- /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/test.py b/fastddsspy_tool/test/application/test.py index 53fc0b0b..64432bfe 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -97,9 +97,10 @@ def main(): test_function.exec_spy = args.exe + local_dds = "fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationExample" + test_function.exec_dds = args.exe.replace("fastddsspy_tool/fastddsspy", local_dds) + spy, dds = test_function.run() - # if (test_function.dds): - # dds = test_function.run_dds() if test_function.one_shot: if not test_function.is_stop(spy): diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 9f54484a..4e99fce7 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -28,7 +28,6 @@ import logging import subprocess -import os import signal DESCRIPTION = """Script to execute Fast DDS Spy executable test""" @@ -45,6 +44,7 @@ def __init__(self, name, one_shot, command, dds, arguments): self.dds = dds self.arguments = arguments self.exec_spy = '' + self.exec_dds = '' # Create a custom logger self.logger = logging.getLogger('SYS_TEST') @@ -91,7 +91,6 @@ def stop(self, spy, dds): if (self.dds): self.stop_dds(dds) - def is_stop(self, proc): return_code = proc.poll() @@ -120,7 +119,7 @@ def stop_tool(self, proc): def run_dds(self): self.logger.info('Run tool') - self.command = ["/home/irenebm/eprosima/annapurna/DDS-Spy/build/fastddsspy_tool/test/integration/dds/AdvancedConfigurationExample/AdvancedConfigurationExample"] + self.command = [self.exec_dds] self.logger.info('Executing command: ' + str(self.command)) From bda586064bcaea9f374958bd3c1f8fa568725bd3 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 10:00:28 +0200 Subject: [PATCH 16/63] Get output commands Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 6 +++ .../application/one_shot_participants_dds.py | 2 +- .../test/application/one_shot_quit_dds.py | 2 +- .../test/application/one_shot_show_dds.py | 2 +- .../test/application/one_shot_topics_dds.py | 2 +- .../test/application/one_shot_version_dds.py | 2 +- fastddsspy_tool/test/application/test.py | 43 ++++++++----------- .../test/application/test_class.py | 43 +++++++++++-------- .../test/application/tool_datareader_dds.py | 27 ++++++++++++ .../test/application/tool_datawriter_dds.py | 27 ++++++++++++ .../test/application/tool_help_dds.py | 27 ++++++++++++ .../test/application/tool_participants_dds.py | 27 ++++++++++++ .../test/application/tool_show_dds.py | 27 ++++++++++++ .../test/application/tool_topics.py | 2 +- .../test/application/tool_topics_dds.py | 27 ++++++++++++ 15 files changed, 216 insertions(+), 50 deletions(-) create mode 100644 fastddsspy_tool/test/application/tool_datareader_dds.py create mode 100644 fastddsspy_tool/test/application/tool_datawriter_dds.py create mode 100644 fastddsspy_tool/test/application/tool_help_dds.py create mode 100644 fastddsspy_tool/test/application/tool_participants_dds.py create mode 100644 fastddsspy_tool/test/application/tool_show_dds.py create mode 100644 fastddsspy_tool/test/application/tool_topics_dds.py diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 18cb091f..33b3f774 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -37,11 +37,17 @@ set(TEST_LIST one_shot_version one_shot_version_dds tool_datareader + tool_datareader_dds tool_datawriter + tool_datawriter_dds tool_help + tool_help_dds tool_participants + tool_participants_dds tool_show + tool_show_dds tool_topics + tool_topics_dds ) # windows auxiliary script to fork test execution diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index 33abcbfa..862afe4c 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -22,6 +22,6 @@ def __init__(self): name='ParticipantsDDSCommand', one_shot=True, command=[], - dds=False, + dds=True, arguments='participants' ) diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py index 118559e2..e7286b64 100644 --- a/fastddsspy_tool/test/application/one_shot_quit_dds.py +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -22,6 +22,6 @@ def __init__(self): name='QuitDDSCommand', one_shot=True, command=[], - dds=False, + dds=True, arguments='exit' ) diff --git a/fastddsspy_tool/test/application/one_shot_show_dds.py b/fastddsspy_tool/test/application/one_shot_show_dds.py index 4098d3c0..028df5ff 100644 --- a/fastddsspy_tool/test/application/one_shot_show_dds.py +++ b/fastddsspy_tool/test/application/one_shot_show_dds.py @@ -22,6 +22,6 @@ def __init__(self): name='ShowDDSCommand', one_shot=True, command=[], - dds=False, + dds=True, arguments='show all' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index d66c077f..54b370b8 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -22,6 +22,6 @@ def __init__(self): name='TopicsDDSCommand', one_shot=True, command=[], - dds=False, + dds=True, arguments='topics' ) diff --git a/fastddsspy_tool/test/application/one_shot_version_dds.py b/fastddsspy_tool/test/application/one_shot_version_dds.py index a3292b87..4a0eb6aa 100644 --- a/fastddsspy_tool/test/application/one_shot_version_dds.py +++ b/fastddsspy_tool/test/application/one_shot_version_dds.py @@ -22,6 +22,6 @@ def __init__(self): name='VersionDDSCommand', one_shot=True, command=[], - dds=False, + dds=True, arguments='version' ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 64432bfe..79df938e 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -97,44 +97,35 @@ def main(): test_function.exec_spy = args.exe - local_dds = "fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationExample" - test_function.exec_dds = args.exe.replace("fastddsspy_tool/fastddsspy", local_dds) + local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' + local_dds = local_path_dds + 'AdvancedConfigurationExample' + test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) spy, dds = test_function.run() - if test_function.one_shot: - if not test_function.is_stop(spy): - sys.exit(1) - if not test_function.valid_output_tool(spy.returncode, 0): - sys.exit(1) - - if (test_function.dds): - test_function.stop_dds(dds) - if not test_function.is_stop(dds): - sys.exit(1) - if not test_function.valid_output_tool(dds.returncode, 1): - sys.exit(1) - else: + if not test_function.one_shot: if test_function.is_stop(spy): sys.exit(1) - test_function.send_command_tool(spy) + output = test_function.send_command_tool(spy) - test_function.stop(spy, dds) + test_function.stop_tool(spy) - if not test_function.is_stop(spy): - sys.exit(1) + if not test_function.is_stop(spy): + sys.exit(1) - if not test_function.valid_output_tool(spy.returncode, 0): - sys.exit(1) + if not test_function.valid_output_tool(spy.returncode): + sys.exit(1) + + if (test_function.dds): + test_function.stop_dds(dds) - if (test_function.dds): - if not test_function.is_stop(dds): - sys.exit(1) + if not test_function.is_stop(dds): + sys.exit(1) - if not test_function.valid_output_tool(dds.returncode, 1): - sys.exit(1) + if not test_function.valid_output_tool(dds.returncode): + sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 4e99fce7..a662192d 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -29,6 +29,7 @@ import logging import subprocess import signal +import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -77,6 +78,8 @@ def run_tool(self): stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.read_output(proc) + if (self.one_shot): try: proc.communicate(timeout=5) @@ -86,11 +89,6 @@ def run_tool(self): return proc - def stop(self, spy, dds): - self.stop_tool(spy) - if (self.dds): - self.stop_dds(dds) - def is_stop(self, proc): return_code = proc.poll() @@ -98,17 +96,26 @@ def is_stop(self, proc): return False return True + def read_output(self, proc): + output = "" + while True: + if (self.one_shot): + line = proc.stdout.readline().decode() + if ("" in line): + break + output = output + f"{line}\n" + else: + line = proc.stdout.readline().decode() + if ("Insert a command for Fast DDS Spy:" in line): + break + output = output + f"{line}\n" + return output + def send_command_tool(self, proc): - proc.stdin.write(('self.arguments'+'\n').encode('utf-8')) - if self.dds: - # proc.stdin.close() - # proc.stdout.read() - # proc.stderr.read() - # proc.stdout.close() - # proc.stderr.close() - # output = proc.stdout.read() - error = proc.stderr.read() - self.valid_output_tool(error) + proc.stdin.write((self.arguments+'\n').encode('utf-8')) + proc.stdin.flush() + output = self.read_output(proc) + return(output) def stop_tool(self, proc): try: @@ -119,7 +126,7 @@ def stop_tool(self, proc): def run_dds(self): self.logger.info('Run tool') - self.command = [self.exec_dds] + self.command = [self.exec_dds, 'publisher'] self.logger.info('Executing command: ' + str(self.command)) @@ -139,5 +146,5 @@ def stop_dds(self, proc): proc.send_signal(signal.SIGINT) proc.communicate() - def valid_output_tool(self, returncode, expected): - return (returncode == expected) + def valid_output_tool(self, returncode): + return (returncode == 0) diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py new file mode 100644 index 00000000..221b9f2f --- /dev/null +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolDatareaderDDSCommand', + one_shot=False, + command=[], + dds=True, + arguments='datareader' + ) diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py new file mode 100644 index 00000000..73ab485c --- /dev/null +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolDatawriterDDSCommand', + one_shot=False, + command=[], + dds=True, + arguments='datawriter' + ) diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py new file mode 100644 index 00000000..89b87aec --- /dev/null +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolHelpDDSCommand', + one_shot=False, + command=[], + dds=True, + arguments='help' + ) diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py new file mode 100644 index 00000000..6dc68e18 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolParticipantsDDSCommand', + one_shot=False, + command=[], + dds=True, + arguments='participants' + ) diff --git a/fastddsspy_tool/test/application/tool_show_dds.py b/fastddsspy_tool/test/application/tool_show_dds.py new file mode 100644 index 00000000..43344b19 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_show_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolShowDDSCommand', + one_shot=False, + command=[], + dds=True, + arguments='show topic' + ) diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index 6a22a133..c4cbd35f 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -19,7 +19,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): super().__init__( - name='ToolParticipantsCommand', + name='ToolTopicsCommand', one_shot=False, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py new file mode 100644 index 00000000..40f6c40f --- /dev/null +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -0,0 +1,27 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolTopicsDDSCommand', + one_shot=False, + command=[], + dds=True, + arguments='topics' + ) From b6841735dcacc5815ecf3bdb76323632fafafb96 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 10:01:59 +0200 Subject: [PATCH 17/63] Rename function Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 4 ++-- fastddsspy_tool/test/application/test_class.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 79df938e..e4540874 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -115,7 +115,7 @@ def main(): if not test_function.is_stop(spy): sys.exit(1) - if not test_function.valid_output_tool(spy.returncode): + if not test_function.valid_returncode(spy.returncode): sys.exit(1) if (test_function.dds): @@ -124,7 +124,7 @@ def main(): if not test_function.is_stop(dds): sys.exit(1) - if not test_function.valid_output_tool(dds.returncode): + if not test_function.valid_returncode(dds.returncode): sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index a662192d..a704933a 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -29,7 +29,6 @@ import logging import subprocess import signal -import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -146,5 +145,5 @@ def stop_dds(self, proc): proc.send_signal(signal.SIGINT) proc.communicate() - def valid_output_tool(self, returncode): + def valid_returncode(self, returncode): return (returncode == 0) From 11b026f871401f04fc86f92a7d55ace0a49a66a6 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 11:23:05 +0200 Subject: [PATCH 18/63] Test output without dds working Signed-off-by: Irene Bandera --- .../test/application/one_shot_datareader.py | 3 +- .../application/one_shot_datareader_dds.py | 3 +- .../test/application/one_shot_datawriter.py | 3 +- .../application/one_shot_datawriter_dds.py | 3 +- .../test/application/one_shot_help.py | 3 +- .../test/application/one_shot_help_dds.py | 3 +- .../test/application/one_shot_participants.py | 3 +- .../application/one_shot_participants_dds.py | 3 +- .../test/application/one_shot_quit.py | 3 +- .../test/application/one_shot_quit_dds.py | 3 +- .../test/application/one_shot_show.py | 3 +- .../test/application/one_shot_show_dds.py | 3 +- .../test/application/one_shot_topics.py | 3 +- .../test/application/one_shot_topics_dds.py | 3 +- .../test/application/one_shot_version.py | 3 +- .../test/application/one_shot_version_dds.py | 3 +- fastddsspy_tool/test/application/test.py | 5 ++ .../test/application/test_class.py | 40 +++++++++--- .../test/application/tool_datareader.py | 7 ++- .../test/application/tool_datareader_dds.py | 7 ++- .../test/application/tool_datawriter.py | 7 ++- .../test/application/tool_datawriter_dds.py | 7 ++- fastddsspy_tool/test/application/tool_help.py | 63 ++++++++++++++++++- .../test/application/tool_help_dds.py | 63 ++++++++++++++++++- .../test/application/tool_participants.py | 7 ++- .../test/application/tool_participants_dds.py | 7 ++- fastddsspy_tool/test/application/tool_show.py | 7 ++- .../test/application/tool_show_dds.py | 7 ++- .../test/application/tool_topics.py | 7 ++- .../test/application/tool_topics_dds.py | 7 ++- 30 files changed, 252 insertions(+), 37 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index 37c321ee..cb8f0606 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='datareader' + arguments='datareader', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py index 2ca5fea2..044d0d46 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='datareader' + arguments='datareader', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index 8ed8c2eb..ad65e3a4 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='datawriter' + arguments='datawriter', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py index 2184824b..d0d38679 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='datawriter' + arguments='datawriter', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index 9f9940ac..59a12389 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='help' + arguments='help', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index 58452dd3..e7d8e578 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='help' + arguments='help', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index 1624f487..a3df6139 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='participants' + arguments='participants', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index 862afe4c..3de7ddfb 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='participants' + arguments='participants', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py index c428b2df..0990df2c 100644 --- a/fastddsspy_tool/test/application/one_shot_quit.py +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='exit' + arguments='exit', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py index e7286b64..f607858f 100644 --- a/fastddsspy_tool/test/application/one_shot_quit_dds.py +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='exit' + arguments='exit', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_show.py b/fastddsspy_tool/test/application/one_shot_show.py index 6a152eb0..27d07722 100644 --- a/fastddsspy_tool/test/application/one_shot_show.py +++ b/fastddsspy_tool/test/application/one_shot_show.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='show all' + arguments='show all', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_show_dds.py b/fastddsspy_tool/test/application/one_shot_show_dds.py index 028df5ff..4c3e2cf4 100644 --- a/fastddsspy_tool/test/application/one_shot_show_dds.py +++ b/fastddsspy_tool/test/application/one_shot_show_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='show all' + arguments='show all', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index f4f186d8..9459b089 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='topics' + arguments='topics', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index 54b370b8..fd850f0c 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='topics' + arguments='topics', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_version.py b/fastddsspy_tool/test/application/one_shot_version.py index 8be132ce..d34dea74 100644 --- a/fastddsspy_tool/test/application/one_shot_version.py +++ b/fastddsspy_tool/test/application/one_shot_version.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='version' + arguments='version', + output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_version_dds.py b/fastddsspy_tool/test/application/one_shot_version_dds.py index 4a0eb6aa..ce104646 100644 --- a/fastddsspy_tool/test/application/one_shot_version_dds.py +++ b/fastddsspy_tool/test/application/one_shot_version_dds.py @@ -23,5 +23,6 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='version' + arguments='version', + output='' ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index e4540874..62ac952c 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -103,6 +103,8 @@ def main(): spy, dds = test_function.run() + if (spy == "wrong output"): + sys.exit(1) if not test_function.one_shot: if test_function.is_stop(spy): @@ -110,6 +112,9 @@ def main(): output = test_function.send_command_tool(spy) + if not test_function.valid_output(output): + sys.exit(1) + test_function.stop_tool(spy) if not test_function.is_stop(spy): diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index a704933a..abbabab4 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -29,6 +29,7 @@ import logging import subprocess import signal +import difflib DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -37,12 +38,13 @@ class TestCase(): - def __init__(self, name, one_shot, command, dds, arguments): + def __init__(self, name, one_shot, command, dds, arguments, output): self.name = name self.one_shot = one_shot self.command = command self.dds = dds self.arguments = arguments + self.output = output self.exec_spy = '' self.exec_dds = '' @@ -77,9 +79,11 @@ def run_tool(self): stdout=subprocess.PIPE, stderr=subprocess.PIPE) - self.read_output(proc) + output = self.read_output(proc) if (self.one_shot): + if not self.valid_output(output): + return("wrong output") try: proc.communicate(timeout=5) except subprocess.TimeoutExpired: @@ -96,18 +100,19 @@ def is_stop(self, proc): return True def read_output(self, proc): - output = "" + output = '' while True: if (self.one_shot): - line = proc.stdout.readline().decode() - if ("" in line): + line = proc.stdout.readline().decode('utf-8') + if ('' in line): break - output = output + f"{line}\n" + output = output + f'{line}\n' else: - line = proc.stdout.readline().decode() - if ("Insert a command for Fast DDS Spy:" in line): + line = proc.stdout.readline().decode('utf-8') + if ('Insert a command for Fast DDS Spy:' in line): break - output = output + f"{line}\n" + output = output + f'{line}\n' + return output def send_command_tool(self, proc): @@ -147,3 +152,20 @@ def stop_dds(self, proc): def valid_returncode(self, returncode): return (returncode == 0) + + def output_command(self): + return(self.output) + + + + def valid_output(self, output): + expected_output = self.output_command() + matcher = difflib.SequenceMatcher(None, expected_output, output) + for tag, i1, i2, j1, j2 in matcher.get_opcodes(): + if tag == 'replace': + print(f"Replace {bytes(expected_output[i1:i2], 'utf-8')} with {bytes(output[j1:j2], 'utf-8')}") + elif tag == 'delete': + print(f"Delete {bytes(expected_output[i1:i2], 'utf-8')}") + elif tag == 'insert': + print(f"Insert {bytes(output[j1:j2], 'utf-8')}") + return(expected_output == output) diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/tool_datareader.py index fa41bb87..a1cf0c81 100644 --- a/fastddsspy_tool/test/application/tool_datareader.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='datareader' + arguments='datareader', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py index 221b9f2f..d8a34816 100644 --- a/fastddsspy_tool/test/application/tool_datareader_dds.py +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='datareader' + arguments='datareader', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py index 4d5cde62..40d1a9e0 100644 --- a/fastddsspy_tool/test/application/tool_datawriter.py +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='datawriter' + arguments='datawriter', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index 73ab485c..040d64cc 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='datawriter' + arguments='datawriter', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index 4978b409..6a1e6953 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -23,5 +23,66 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='help' + arguments='help', + output='''>> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. + +Each command shows data related with the network in Yaml format. + +Commands available and the information they show: + +\thelp : this help. + +\tversion : tool version. + +\tquit : exit interactive CLI and close program. + +\tparticipants : DomainParticipants discovered in the network. + +\tparticipants verbose : verbose information about DomainParticipants discovered in the network. + +\tparticipants : verbose information related with a specific DomainParticipant. + +\twriters : DataWriters discovered in the network. + +\twriters verbose : verbose information about DataWriters discovered in the network. + +\twriters : verbose information related with a specific DataWriter. + +\treader : DataReaders discovered in the network. + +\treader verbose : verbose information about DataReaders discovered in the network. + +\treader : verbose information related with a specific DataReader. + +\ttopics : Topics discovered in the network. + +\ttopics verbose : verbose information about Topics discovered in the network. + +\ttopics : verbose information related with a specific Topic. + +\tshow : data of a specific Topic (Data Type must be discovered). + +\tshow verbose : data with additional source info of a specific Topic. + +\tshow all : verbose data of all topics (only those whose Data Type is discovered). + + + +Notes and comments: + +\tTo exit from data printing, press enter. + +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). + + + +For more information about these commands and formats, please refer to the documentation: + +https://fast-dds-spy.readthedocs.io/en/latest/ + + + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index 89b87aec..59292ee7 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -23,5 +23,66 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='help' + arguments='help', + output='''>> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. + +Each command shows data related with the network in Yaml format. + +Commands available and the information they show: + +\thelp : this help. + +\tversion : tool version. + +\tquit : exit interactive CLI and close program. + +\tparticipants : DomainParticipants discovered in the network. + +\tparticipants verbose : verbose information about DomainParticipants discovered in the network. + +\tparticipants : verbose information related with a specific DomainParticipant. + +\twriters : DataWriters discovered in the network. + +\twriters verbose : verbose information about DataWriters discovered in the network. + +\twriters : verbose information related with a specific DataWriter. + +\treader : DataReaders discovered in the network. + +\treader verbose : verbose information about DataReaders discovered in the network. + +\treader : verbose information related with a specific DataReader. + +\ttopics : Topics discovered in the network. + +\ttopics verbose : verbose information about Topics discovered in the network. + +\ttopics : verbose information related with a specific Topic. + +\tshow : data of a specific Topic (Data Type must be discovered). + +\tshow verbose : data with additional source info of a specific Topic. + +\tshow all : verbose data of all topics (only those whose Data Type is discovered). + + + +Notes and comments: + +\tTo exit from data printing, press enter. + +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). + + + +For more information about these commands and formats, please refer to the documentation: + +https://fast-dds-spy.readthedocs.io/en/latest/ + + + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py index 555f76ab..8091aa65 100644 --- a/fastddsspy_tool/test/application/tool_participants.py +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='participants' + arguments='participants', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index 6dc68e18..63d2dd52 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='participants' + arguments='participants', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_show.py b/fastddsspy_tool/test/application/tool_show.py index e47a626e..d8984a52 100644 --- a/fastddsspy_tool/test/application/tool_show.py +++ b/fastddsspy_tool/test/application/tool_show.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='show topic' + arguments='show topic', + output='''>> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_show_dds.py b/fastddsspy_tool/test/application/tool_show_dds.py index 43344b19..afe6bd3c 100644 --- a/fastddsspy_tool/test/application/tool_show_dds.py +++ b/fastddsspy_tool/test/application/tool_show_dds.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='show topic' + arguments='show topic', + output='''>> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index c4cbd35f..8737828b 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='topics' + arguments='topics', + output='''>> \x1b[0m + + + +''' ) diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index 40f6c40f..04f72861 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -23,5 +23,10 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='topics' + arguments='topics', + output='''>> \x1b[0m + + + +''' ) From 6ab987fba73b559d64c2278f1cd8cbb88c16568b Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 16:23:50 +0200 Subject: [PATCH 19/63] Everything working except for tool with dds Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 4 -- .../test/application/one_shot_datareader.py | 2 +- .../application/one_shot_datareader_dds.py | 2 +- .../test/application/one_shot_datawriter.py | 2 +- .../application/one_shot_datawriter_dds.py | 5 +- .../test/application/one_shot_help.py | 31 +++++++++- .../test/application/one_shot_help_dds.py | 31 +++++++++- .../test/application/one_shot_participants.py | 2 +- .../application/one_shot_participants_dds.py | 4 +- .../test/application/one_shot_show.py | 28 --------- .../test/application/one_shot_show_dds.py | 28 --------- .../test/application/one_shot_topics.py | 2 +- .../test/application/one_shot_topics_dds.py | 7 ++- .../test/application/one_shot_version.py | 28 --------- .../test/application/one_shot_version_dds.py | 28 --------- fastddsspy_tool/test/application/test.py | 4 +- .../test/application/test_class.py | 61 ++++++++++--------- .../test/application/tool_datareader.py | 4 +- .../test/application/tool_datareader_dds.py | 4 +- .../test/application/tool_datawriter.py | 4 +- .../test/application/tool_datawriter_dds.py | 4 +- fastddsspy_tool/test/application/tool_help.py | 4 +- .../test/application/tool_help_dds.py | 4 +- .../test/application/tool_participants.py | 4 +- .../test/application/tool_participants_dds.py | 4 +- fastddsspy_tool/test/application/tool_show.py | 4 +- .../test/application/tool_show_dds.py | 4 +- .../test/application/tool_topics.py | 4 +- .../test/application/tool_topics_dds.py | 4 +- 29 files changed, 136 insertions(+), 181 deletions(-) delete mode 100644 fastddsspy_tool/test/application/one_shot_show.py delete mode 100644 fastddsspy_tool/test/application/one_shot_show_dds.py delete mode 100644 fastddsspy_tool/test/application/one_shot_version.py delete mode 100644 fastddsspy_tool/test/application/one_shot_version_dds.py diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 33b3f774..195b7bfc 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -30,12 +30,8 @@ set(TEST_LIST one_shot_participants_dds one_shot_quit one_shot_quit_dds - one_shot_show - one_shot_show_dds one_shot_topics one_shot_topics_dds - one_shot_version - one_shot_version_dds tool_datareader tool_datareader_dds tool_datawriter diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index cb8f0606..1e6714ff 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -24,5 +24,5 @@ def __init__(self): command=[], dds=False, arguments='datareader', - output='' + output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py index 044d0d46..580ef9e5 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -24,5 +24,5 @@ def __init__(self): command=[], dds=True, arguments='datareader', - output='' + output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index ad65e3a4..0c4a79d6 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -24,5 +24,5 @@ def __init__(self): command=[], dds=False, arguments='datawriter', - output='' + output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py index d0d38679..aa495f04 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -24,5 +24,8 @@ def __init__(self): command=[], dds=True, arguments='datawriter', - output='' + output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3 + participant: Participant_pub + topic: HelloWorldTopic [HelloWorld] +""" ) diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index 59a12389..df31984a 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -24,5 +24,34 @@ def __init__(self): command=[], dds=False, arguments='help', - output='' + output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. +Each command shows data related with the network in Yaml format. +Commands available and the information they show: +\thelp : this help. +\tversion : tool version. +\tquit : exit interactive CLI and close program. +\tparticipants : DomainParticipants discovered in the network. +\tparticipants verbose : verbose information about DomainParticipants discovered in the network. +\tparticipants : verbose information related with a specific DomainParticipant. +\twriters : DataWriters discovered in the network. +\twriters verbose : verbose information about DataWriters discovered in the network. +\twriters : verbose information related with a specific DataWriter. +\treader : DataReaders discovered in the network. +\treader verbose : verbose information about DataReaders discovered in the network. +\treader : verbose information related with a specific DataReader. +\ttopics : Topics discovered in the network. +\ttopics verbose : verbose information about Topics discovered in the network. +\ttopics : verbose information related with a specific Topic. +\tshow : data of a specific Topic (Data Type must be discovered). +\tshow verbose : data with additional source info of a specific Topic. +\tshow all : verbose data of all topics (only those whose Data Type is discovered). + +Notes and comments: +\tTo exit from data printing, press enter. +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). + +For more information about these commands and formats, please refer to the documentation: +https://fast-dds-spy.readthedocs.io/en/latest/ + +""" ) diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index e7d8e578..fa37e4a3 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -24,5 +24,34 @@ def __init__(self): command=[], dds=True, arguments='help', - output='' + output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. +Each command shows data related with the network in Yaml format. +Commands available and the information they show: +\thelp : this help. +\tversion : tool version. +\tquit : exit interactive CLI and close program. +\tparticipants : DomainParticipants discovered in the network. +\tparticipants verbose : verbose information about DomainParticipants discovered in the network. +\tparticipants : verbose information related with a specific DomainParticipant. +\twriters : DataWriters discovered in the network. +\twriters verbose : verbose information about DataWriters discovered in the network. +\twriters : verbose information related with a specific DataWriter. +\treader : DataReaders discovered in the network. +\treader verbose : verbose information about DataReaders discovered in the network. +\treader : verbose information related with a specific DataReader. +\ttopics : Topics discovered in the network. +\ttopics verbose : verbose information about Topics discovered in the network. +\ttopics : verbose information related with a specific Topic. +\tshow : data of a specific Topic (Data Type must be discovered). +\tshow verbose : data with additional source info of a specific Topic. +\tshow all : verbose data of all topics (only those whose Data Type is discovered). + +Notes and comments: +\tTo exit from data printing, press enter. +\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). + +For more information about these commands and formats, please refer to the documentation: +https://fast-dds-spy.readthedocs.io/en/latest/ + +""" ) diff --git a/fastddsspy_tool/test/application/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index a3df6139..9aa850c7 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -24,5 +24,5 @@ def __init__(self): command=[], dds=False, arguments='participants', - output='' + output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index 3de7ddfb..9c4e8f56 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -24,5 +24,7 @@ def __init__(self): command=[], dds=True, arguments='participants', - output='' + output="""- name: Participant_pub + guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1 +""" ) diff --git a/fastddsspy_tool/test/application/one_shot_show.py b/fastddsspy_tool/test/application/one_shot_show.py deleted file mode 100644 index 27d07722..00000000 --- a/fastddsspy_tool/test/application/one_shot_show.py +++ /dev/null @@ -1,28 +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. - -import test_class - - -class TestCase_instance (test_class.TestCase): - - def __init__(self): - super().__init__( - name='ShowCommand', - one_shot=True, - command=[], - dds=False, - arguments='show all', - output='' - ) diff --git a/fastddsspy_tool/test/application/one_shot_show_dds.py b/fastddsspy_tool/test/application/one_shot_show_dds.py deleted file mode 100644 index 4c3e2cf4..00000000 --- a/fastddsspy_tool/test/application/one_shot_show_dds.py +++ /dev/null @@ -1,28 +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. - -import test_class - - -class TestCase_instance (test_class.TestCase): - - def __init__(self): - super().__init__( - name='ShowDDSCommand', - one_shot=True, - command=[], - dds=True, - arguments='show all', - output='' - ) diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index 9459b089..30afda52 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -24,5 +24,5 @@ def __init__(self): command=[], dds=False, arguments='topics', - output='' + output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index fd850f0c..888f9dd9 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -24,5 +24,10 @@ def __init__(self): command=[], dds=True, arguments='topics', - output='' + output='''- name: HelloWorldTopic + type: HelloWorld + datawriters: 1 + datareaders: 0 + rate: 10 Hz +''' ) diff --git a/fastddsspy_tool/test/application/one_shot_version.py b/fastddsspy_tool/test/application/one_shot_version.py deleted file mode 100644 index d34dea74..00000000 --- a/fastddsspy_tool/test/application/one_shot_version.py +++ /dev/null @@ -1,28 +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. - -import test_class - - -class TestCase_instance (test_class.TestCase): - - def __init__(self): - super().__init__( - name='VersionCommand', - one_shot=True, - command=[], - dds=False, - arguments='version', - output='' - ) diff --git a/fastddsspy_tool/test/application/one_shot_version_dds.py b/fastddsspy_tool/test/application/one_shot_version_dds.py deleted file mode 100644 index ce104646..00000000 --- a/fastddsspy_tool/test/application/one_shot_version_dds.py +++ /dev/null @@ -1,28 +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. - -import test_class - - -class TestCase_instance (test_class.TestCase): - - def __init__(self): - super().__init__( - name='VersionDDSCommand', - one_shot=True, - command=[], - dds=True, - arguments='version', - output='' - ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 62ac952c..16f2d1d2 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -103,7 +103,7 @@ def main(): spy, dds = test_function.run() - if (spy == "wrong output"): + if (spy == 'wrong output'): sys.exit(1) if not test_function.one_shot: @@ -113,7 +113,7 @@ def main(): output = test_function.send_command_tool(spy) if not test_function.valid_output(output): - sys.exit(1) + sys.exit(1) test_function.stop_tool(spy) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index abbabab4..3abf7f7c 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -29,7 +29,8 @@ import logging import subprocess import signal -import difflib +import time +import re DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -79,17 +80,19 @@ def run_tool(self): stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = self.read_output(proc) - if (self.one_shot): - if not self.valid_output(output): - return("wrong output") + try: - proc.communicate(timeout=5) + output, error = proc.communicate(timeout=5) except subprocess.TimeoutExpired: proc.kill() - proc.communicate() + output, error = proc.communicate() + + if not self.valid_output(output.decode("utf-8")): + return ('wrong output') + else: + self.read_output(proc) return proc def is_stop(self, proc): @@ -102,16 +105,10 @@ def is_stop(self, proc): def read_output(self, proc): output = '' while True: - if (self.one_shot): - line = proc.stdout.readline().decode('utf-8') - if ('' in line): - break - output = output + f'{line}\n' - else: - line = proc.stdout.readline().decode('utf-8') - if ('Insert a command for Fast DDS Spy:' in line): - break - output = output + f'{line}\n' + line = proc.stdout.readline().decode('utf-8') + if ('Insert a command for Fast DDS Spy:' in line): + break + output = output + f'{line}\n' return output @@ -119,7 +116,9 @@ def send_command_tool(self, proc): proc.stdin.write((self.arguments+'\n').encode('utf-8')) proc.stdin.flush() output = self.read_output(proc) - return(output) + print("output:") + print(output) + return (output) def stop_tool(self, proc): try: @@ -154,18 +153,22 @@ def valid_returncode(self, returncode): return (returncode == 0) def output_command(self): - return(self.output) - + return (self.output) + def valid_guid(self, guid): + pattern = r'^((guid:)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' + id_guid = guid[2:] + if not re.match(pattern, id_guid): + return False + return True def valid_output(self, output): expected_output = self.output_command() - matcher = difflib.SequenceMatcher(None, expected_output, output) - for tag, i1, i2, j1, j2 in matcher.get_opcodes(): - if tag == 'replace': - print(f"Replace {bytes(expected_output[i1:i2], 'utf-8')} with {bytes(output[j1:j2], 'utf-8')}") - elif tag == 'delete': - print(f"Delete {bytes(expected_output[i1:i2], 'utf-8')}") - elif tag == 'insert': - print(f"Insert {bytes(output[j1:j2], 'utf-8')}") - return(expected_output == output) + lines_expected_output = expected_output.splitlines() + if expected_output == output: + return True + for i in range(len(lines_expected_output)): + if "guid:" in lines_expected_output[i]: + return self.valid_guid(lines_expected_output[i]) + + return False diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/tool_datareader.py index a1cf0c81..ebee5a84 100644 --- a/fastddsspy_tool/test/application/tool_datareader.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=False, arguments='datareader', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py index d8a34816..11b56b85 100644 --- a/fastddsspy_tool/test/application/tool_datareader_dds.py +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=True, arguments='datareader', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py index 40d1a9e0..47cad3f3 100644 --- a/fastddsspy_tool/test/application/tool_datawriter.py +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=False, arguments='datawriter', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index 040d64cc..d540c059 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=True, arguments='datawriter', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index 6a1e6953..d588535e 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -24,7 +24,7 @@ def __init__(self): command=[], dds=False, arguments='help', - output='''>> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. + output=""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. Each command shows data related with the network in Yaml format. @@ -84,5 +84,5 @@ def __init__(self): -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index 59292ee7..c39a8ca7 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -24,7 +24,7 @@ def __init__(self): command=[], dds=True, arguments='help', - output='''>> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. + output=""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. Each command shows data related with the network in Yaml format. @@ -84,5 +84,5 @@ def __init__(self): -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py index 8091aa65..e0c4551f 100644 --- a/fastddsspy_tool/test/application/tool_participants.py +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=False, arguments='participants', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index 63d2dd52..ce84df52 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=True, arguments='participants', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_show.py b/fastddsspy_tool/test/application/tool_show.py index d8984a52..e9215716 100644 --- a/fastddsspy_tool/test/application/tool_show.py +++ b/fastddsspy_tool/test/application/tool_show.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=False, arguments='show topic', - output='''>> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m + output=""">> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_show_dds.py b/fastddsspy_tool/test/application/tool_show_dds.py index afe6bd3c..531101b8 100644 --- a/fastddsspy_tool/test/application/tool_show_dds.py +++ b/fastddsspy_tool/test/application/tool_show_dds.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=True, arguments='show topic', - output='''>> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m + output=""">> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index 8737828b..8d72d939 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=False, arguments='topics', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index 04f72861..2bb043fc 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -24,9 +24,9 @@ def __init__(self): command=[], dds=True, arguments='topics', - output='''>> \x1b[0m + output=""">> \x1b[0m -''' +""" ) From 610fb0e265cc29035022ca3a7cdb40e63a6bce94 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 16:34:16 +0200 Subject: [PATCH 20/63] Add xtsan flag to dds tests Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 195b7bfc..4a348dfa 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -19,31 +19,34 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test +set(TEST_LIST_DDS + one_shot_help_dds + one_shot_datareader_dds + one_shot_datawriter_dds + one_shot_participants_dds + one_shot_quit_dds + one_shot_topics_dds + tool_datareader_dds + tool_datawriter_dds + tool_help_dds + tool_participants_dds + tool_show_dds + tool_topics_dds +) + set(TEST_LIST one_shot_help - one_shot_help_dds one_shot_datareader - one_shot_datareader_dds one_shot_datawriter - one_shot_datawriter_dds one_shot_participants - one_shot_participants_dds one_shot_quit - one_shot_quit_dds one_shot_topics - one_shot_topics_dds tool_datareader - tool_datareader_dds tool_datawriter - tool_datawriter_dds tool_help - tool_help_dds tool_participants - tool_participants_dds tool_show - tool_show_dds tool_topics - tool_topics_dds ) # windows auxiliary script to fork test execution @@ -123,6 +126,29 @@ foreach(TEST IN LISTS TEST_LIST) PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}" ) + +endforeach() + +foreach(TEST IN LISTS TEST_LIST_DDS) + set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") + add_test( + NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/test.py + "--exe" $ + "--test" ${TEST} + ) + + # Set test properties + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + ) + + # TSAN captures and handles raised signals, thus these tests cannot succeed + add_xtsan_label(${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}) + endforeach() unset(TEST_ENVIRONMENT) From 728f56b17345f6d1cc5113946ffc05e814a9af52 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 30 Mar 2023 17:16:35 +0200 Subject: [PATCH 21/63] Update Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 2 +- fastddsspy_tool/test/application/test_class.py | 13 +++++-------- fastddsspy_tool/test/application/tool_help.py | 3 ++- fastddsspy_tool/test/application/tool_help_dds.py | 3 ++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 16f2d1d2..e4799d51 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -109,7 +109,7 @@ def main(): if not test_function.one_shot: if test_function.is_stop(spy): sys.exit(1) - + print("send command") output = test_function.send_command_tool(spy) if not test_function.valid_output(output): diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 3abf7f7c..c636cd4d 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -29,7 +29,6 @@ import logging import subprocess import signal -import time import re DESCRIPTION = """Script to execute Fast DDS Spy executable test""" @@ -83,12 +82,12 @@ def run_tool(self): if (self.one_shot): try: - output, error = proc.communicate(timeout=5) + output = proc.communicate(timeout=5)[0] except subprocess.TimeoutExpired: proc.kill() - output, error = proc.communicate() + output = proc.communicate()[0] - if not self.valid_output(output.decode("utf-8")): + if not self.valid_output(output.decode('utf-8')): return ('wrong output') else: @@ -113,11 +112,9 @@ def read_output(self, proc): return output def send_command_tool(self, proc): - proc.stdin.write((self.arguments+'\n').encode('utf-8')) + proc.stdin.write((self.arguments + '\n').encode('utf-8')) proc.stdin.flush() output = self.read_output(proc) - print("output:") - print(output) return (output) def stop_tool(self, proc): @@ -168,7 +165,7 @@ def valid_output(self, output): if expected_output == output: return True for i in range(len(lines_expected_output)): - if "guid:" in lines_expected_output[i]: + if 'guid:' in lines_expected_output[i]: return self.valid_guid(lines_expected_output[i]) return False diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index d588535e..ddf5f1c3 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -24,7 +24,8 @@ def __init__(self): command=[], dds=False, arguments='help', - output=""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. + output= +""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. Each command shows data related with the network in Yaml format. diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index c39a8ca7..4b3953e3 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -24,7 +24,8 @@ def __init__(self): command=[], dds=True, arguments='help', - output=""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. + output= +""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. Each command shows data related with the network in Yaml format. From 21daf166de6e700dcb02480a937622dff0860ba1 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 31 Mar 2023 08:25:02 +0200 Subject: [PATCH 22/63] Rate with regexp Signed-off-by: Irene Bandera --- .../test/application/one_shot_topics_dds.py | 4 ++-- fastddsspy_tool/test/application/test.py | 14 +++++++++++++- fastddsspy_tool/test/application/test_class.py | 9 +++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index 888f9dd9..17997dc5 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -24,10 +24,10 @@ def __init__(self): command=[], dds=True, arguments='topics', - output='''- name: HelloWorldTopic + output="""- name: HelloWorldTopic type: HelloWorld datawriters: 1 datareaders: 0 rate: 10 Hz -''' +""" ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index e4799d51..6f66eb52 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -104,32 +104,44 @@ def main(): spy, dds = test_function.run() if (spy == 'wrong output'): + print("ERROR: Wrong output") sys.exit(1) + if (test_function.dds): + if test_function.is_stop(dds): + print("ERROR: DDS Publisher not running") + sys.exit(1) + if not test_function.one_shot: if test_function.is_stop(spy): + print("ERROR: Fast DDS Spy not running") sys.exit(1) - print("send command") + output = test_function.send_command_tool(spy) if not test_function.valid_output(output): + print("ERROR: Output command not valid") sys.exit(1) test_function.stop_tool(spy) if not test_function.is_stop(spy): + print("ERROR: Fast DDS Spy still running") sys.exit(1) if not test_function.valid_returncode(spy.returncode): + print("ERROR: Wrong Fast DDS Spy return code") sys.exit(1) if (test_function.dds): test_function.stop_dds(dds) if not test_function.is_stop(dds): + print("ERROR: DDS Publisher still running") sys.exit(1) if not test_function.valid_returncode(dds.returncode): + print("ERROR: Wrong DDS Publisher return code") sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index c636cd4d..6b8e43a4 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -159,6 +159,13 @@ def valid_guid(self, guid): return False return True + def valid_rate(self, rate): + pattern = r'^((rate:)\s\d{1,}\s(Hz))$' + id_rate = rate[2:] + if not re.match(pattern, id_rate): + return False + return True + def valid_output(self, output): expected_output = self.output_command() lines_expected_output = expected_output.splitlines() @@ -167,5 +174,7 @@ def valid_output(self, output): for i in range(len(lines_expected_output)): if 'guid:' in lines_expected_output[i]: return self.valid_guid(lines_expected_output[i]) + if 'rate:' in lines_expected_output[i]: + return self.valid_rate(lines_expected_output[i]) return False From ff56f55cbe38e156c6501a3aabeaef21d9bc66fc Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 31 Mar 2023 11:44:19 +0200 Subject: [PATCH 23/63] Everything working Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 16 ++++----- .../test/application/test_class.py | 34 +++++++++++-------- .../test/application/tool_datawriter_dds.py | 5 +-- .../test/application/tool_participants_dds.py | 5 ++- .../test/application/tool_show_dds.py | 4 +-- .../test/application/tool_topics_dds.py | 7 +++- 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 6f66eb52..d46b2678 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -104,44 +104,44 @@ def main(): spy, dds = test_function.run() if (spy == 'wrong output'): - print("ERROR: Wrong output") + print('ERROR: Wrong output') sys.exit(1) if (test_function.dds): if test_function.is_stop(dds): - print("ERROR: DDS Publisher not running") + print('ERROR: DDS Publisher not running') sys.exit(1) if not test_function.one_shot: if test_function.is_stop(spy): - print("ERROR: Fast DDS Spy not running") + print('ERROR: Fast DDS Spy not running') sys.exit(1) output = test_function.send_command_tool(spy) if not test_function.valid_output(output): - print("ERROR: Output command not valid") + print('ERROR: Output command not valid') sys.exit(1) test_function.stop_tool(spy) if not test_function.is_stop(spy): - print("ERROR: Fast DDS Spy still running") + print('ERROR: Fast DDS Spy still running') sys.exit(1) if not test_function.valid_returncode(spy.returncode): - print("ERROR: Wrong Fast DDS Spy return code") + print('ERROR: Wrong Fast DDS Spy return code') sys.exit(1) if (test_function.dds): test_function.stop_dds(dds) if not test_function.is_stop(dds): - print("ERROR: DDS Publisher still running") + print('ERROR: DDS Publisher still running') sys.exit(1) if not test_function.valid_returncode(dds.returncode): - print("ERROR: Wrong DDS Publisher return code") + print('ERROR: Wrong DDS Publisher return code') sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 6b8e43a4..5747a386 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -30,6 +30,7 @@ import subprocess import signal import re +import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -77,7 +78,8 @@ def run_tool(self): proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + encoding='utf8') if (self.one_shot): @@ -86,8 +88,7 @@ def run_tool(self): except subprocess.TimeoutExpired: proc.kill() output = proc.communicate()[0] - - if not self.valid_output(output.decode('utf-8')): + if not self.valid_output(output): return ('wrong output') else: @@ -104,22 +105,23 @@ def is_stop(self, proc): def read_output(self, proc): output = '' while True: - line = proc.stdout.readline().decode('utf-8') + line = proc.stdout.readline() if ('Insert a command for Fast DDS Spy:' in line): break output = output + f'{line}\n' - return output def send_command_tool(self, proc): - proc.stdin.write((self.arguments + '\n').encode('utf-8')) + # give time to start publishing + time.sleep(0.5) + proc.stdin.write((self.arguments+'\n')) proc.stdin.flush() output = self.read_output(proc) return (output) def stop_tool(self, proc): try: - proc.communicate(input=b'exit\n', timeout=5) + proc.communicate(input='exit\n', timeout=5)[0] except subprocess.TimeoutExpired: proc.kill() proc.communicate() @@ -134,7 +136,6 @@ def run_dds(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - return proc def stop_dds(self, proc): @@ -154,14 +155,14 @@ def output_command(self): def valid_guid(self, guid): pattern = r'^((guid:)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' - id_guid = guid[2:] + id_guid = guid[guid.find("guid:"):] if not re.match(pattern, id_guid): return False return True def valid_rate(self, rate): pattern = r'^((rate:)\s\d{1,}\s(Hz))$' - id_rate = rate[2:] + id_rate = rate[rate.find("rate:"):] if not re.match(pattern, id_rate): return False return True @@ -169,12 +170,17 @@ def valid_rate(self, rate): def valid_output(self, output): expected_output = self.output_command() lines_expected_output = expected_output.splitlines() + lines_output = output.splitlines() if expected_output == output: return True + guid = True + rate = True for i in range(len(lines_expected_output)): if 'guid:' in lines_expected_output[i]: - return self.valid_guid(lines_expected_output[i]) - if 'rate:' in lines_expected_output[i]: - return self.valid_rate(lines_expected_output[i]) + guid = self.valid_guid(lines_expected_output[i]) + elif 'rate:' in lines_expected_output[i]: + rate = self.valid_rate(lines_expected_output[i]) + elif lines_expected_output[i] != lines_output[i]: + return False - return False + return (guid and rate) diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index d540c059..5539a2c5 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -24,9 +24,10 @@ def __init__(self): command=[], dds=True, arguments='datawriter', - output=""">> \x1b[0m - + output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3 + participant: Participant_pub + topic: HelloWorldTopic [HelloWorld] """ ) diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index ce84df52..e0d24776 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -24,9 +24,8 @@ def __init__(self): command=[], dds=True, arguments='participants', - output=""">> \x1b[0m - - + output=""">> \x1b[0m- name: Participant_pub + guid: 01.0f.d8.74.09.0b.fa.ae.00.00.00.00|0.0.1.c1 """ ) diff --git a/fastddsspy_tool/test/application/tool_show_dds.py b/fastddsspy_tool/test/application/tool_show_dds.py index 531101b8..105b4bf8 100644 --- a/fastddsspy_tool/test/application/tool_show_dds.py +++ b/fastddsspy_tool/test/application/tool_show_dds.py @@ -23,8 +23,8 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='show topic', - output=""">> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m + arguments='show HelloWorldTopic', + output=""">> \x1b[0m\x1b[1;31mTopic Type has not been discovered, and thus cannot print its data.\x1b[0m diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index 2bb043fc..b891d839 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -24,9 +24,14 @@ def __init__(self): command=[], dds=True, arguments='topics', - output=""">> \x1b[0m + output=""">> \x1b[0m- name: HelloWorldTopic + type: HelloWorld + datawriters: 1 + datareaders: 0 + + rate: 10 Hz """ ) From 23275fc0e5d0d4f42a3c8cd56070afd0fe192868 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 5 Apr 2023 08:11:07 +0200 Subject: [PATCH 24/63] Add signal windows Signed-off-by: Irene Bandera --- .../test/application/test_class.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 5747a386..8562ddf1 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -31,6 +31,7 @@ import signal import re import time +import os DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -138,13 +139,27 @@ def run_dds(self): stderr=subprocess.PIPE) return proc + def is_linux(self): + """Return whether the script is running in a Linux environment.""" + return os.name == 'posix' + + def is_windows(self): + """Return whether the script is running in a Windows environment.""" + return os.name == 'nt' + def stop_dds(self, proc): # send a ctrl+c signal to the subprocess - proc.send_signal(signal.SIGINT) + if self.is_linux(): + proc.send_signal(signal.SIGINT) + elif self.is_windows(): + proc.send_signal(signal.CTRL_C_EVENT) try: proc.communicate(timeout=5) except subprocess.TimeoutExpired: - proc.send_signal(signal.SIGINT) + if self.is_linux(): + proc.send_signal(signal.SIGINT) + elif self.is_windows(): + proc.send_signal(signal.CTRL_C_EVENT) proc.communicate() def valid_returncode(self, returncode): From 03dabfbd0ef63093b507dbad9af01161af2f951c Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 13 Apr 2023 12:18:36 +0200 Subject: [PATCH 25/63] More coverage Signed-off-by: Irene Bandera --- .../visualization/ModelParser.hpp | 26 ++++----- .../src/cpp/visualization/ModelParser.cpp | 40 ++++++------- .../test/application/CMakeLists.txt | 58 ++++++++++++++++++- .../configuration/configuration_basic.yaml | 11 ++++ .../configuration_wrong_empty_arg.yaml | 11 ++++ .../configuration_wrong_type.yaml | 11 ++++ .../test/application/one_shot__config.py | 30 ++++++++++ .../one_shot__config_fail_empty_arg.py | 30 ++++++++++ .../application/one_shot__config_fail_file.py | 49 ++++++++++++++++ .../application/one_shot__config_fail_type.py | 30 ++++++++++ .../test/application/one_shot__debug.py | 30 ++++++++++ .../test/application/one_shot__help.py | 48 +++++++++++++++ .../test/application/one_shot__log_filter.py | 30 ++++++++++ .../application/one_shot__log_filter_fail.py | 30 ++++++++++ .../application/one_shot__log_verb_error.py | 30 ++++++++++ .../application/one_shot__log_verb_fail.py | 49 ++++++++++++++++ .../application/one_shot__log_verb_info.py | 30 ++++++++++ .../application/one_shot__log_verb_warning.py | 30 ++++++++++ .../test/application/one_shot__null.py | 49 ++++++++++++++++ .../test/application/one_shot__reload_time.py | 30 ++++++++++ .../application/one_shot__reload_time_fail.py | 49 ++++++++++++++++ .../test/application/one_shot__version.py | 30 ++++++++++ .../test/application/one_shot_datareader.py | 4 +- .../application/one_shot_datareader_dds.py | 4 +- .../one_shot_datareader_guid_dds.py | 31 ++++++++++ .../one_shot_datareader_verbose.py | 30 ++++++++++ .../one_shot_datareader_verbose_dds.py | 30 ++++++++++ .../test/application/one_shot_datawriter.py | 4 +- .../application/one_shot_datawriter_dds.py | 4 +- .../one_shot_datawriter_guid_dds_fail.py | 31 ++++++++++ .../one_shot_datawriter_verbose.py | 30 ++++++++++ .../one_shot_datawriter_verbose_dds.py | 38 ++++++++++++ .../one_shot_datawriter_verbose_dds_qos.py | 38 ++++++++++++ .../test/application/one_shot_help.py | 4 +- .../test/application/one_shot_help_dds.py | 4 +- .../test/application/one_shot_null.py | 30 ++++++++++ .../test/application/one_shot_participants.py | 4 +- .../application/one_shot_participants_dds.py | 4 +- .../one_shot_participants_guid_dds.py | 31 ++++++++++ .../one_shot_participants_verbose.py | 30 ++++++++++ .../one_shot_participants_verbose_dds.py | 34 +++++++++++ .../test/application/one_shot_quit.py | 4 +- .../test/application/one_shot_quit_dds.py | 4 +- .../test/application/one_shot_show_all.py | 30 ++++++++++ .../test/application/one_shot_show_fail.py | 31 ++++++++++ .../test/application/one_shot_show_topic.py | 31 ++++++++++ .../one_shot_show_topic_verbose.py | 31 ++++++++++ .../test/application/one_shot_topics.py | 4 +- .../test/application/one_shot_topics_dds.py | 4 +- .../test/application/one_shot_topics_name.py | 31 ++++++++++ .../application/one_shot_topics_name_dds.py | 36 ++++++++++++ .../application/one_shot_topics_verbose.py | 30 ++++++++++ .../one_shot_topics_verbose_dds.py | 36 ++++++++++++ fastddsspy_tool/test/application/test.py | 4 ++ .../test/application/test_class.py | 34 +++++++++-- .../test/application/tool_datareader.py | 4 +- .../test/application/tool_datareader_dds.py | 4 +- .../test/application/tool_datawriter.py | 4 +- .../test/application/tool_datawriter_dds.py | 4 +- fastddsspy_tool/test/application/tool_help.py | 4 +- .../test/application/tool_help_dds.py | 4 +- fastddsspy_tool/test/application/tool_null.py | 34 +++++++++++ .../test/application/tool_participants.py | 4 +- .../test/application/tool_participants_dds.py | 4 +- .../test/application/tool_show_all.py | 32 ++++++++++ .../{tool_show.py => tool_show_topic.py} | 4 +- ...ool_show_dds.py => tool_show_topic_dds.py} | 4 +- .../test/application/tool_topics.py | 4 +- .../test/application/tool_topics_dds.py | 4 +- .../test/application/tool_version.py | 35 +++++++++++ fastddsspy_yaml/src/cpp/YamlReader.cpp | 40 ------------- 71 files changed, 1509 insertions(+), 106 deletions(-) create mode 100644 fastddsspy_tool/test/application/configuration/configuration_basic.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/one_shot__config.py create mode 100644 fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py create mode 100644 fastddsspy_tool/test/application/one_shot__config_fail_file.py create mode 100644 fastddsspy_tool/test/application/one_shot__config_fail_type.py create mode 100644 fastddsspy_tool/test/application/one_shot__debug.py create mode 100644 fastddsspy_tool/test/application/one_shot__help.py create mode 100644 fastddsspy_tool/test/application/one_shot__log_filter.py create mode 100644 fastddsspy_tool/test/application/one_shot__log_filter_fail.py create mode 100644 fastddsspy_tool/test/application/one_shot__log_verb_error.py create mode 100644 fastddsspy_tool/test/application/one_shot__log_verb_fail.py create mode 100644 fastddsspy_tool/test/application/one_shot__log_verb_info.py create mode 100644 fastddsspy_tool/test/application/one_shot__log_verb_warning.py create mode 100644 fastddsspy_tool/test/application/one_shot__null.py create mode 100644 fastddsspy_tool/test/application/one_shot__reload_time.py create mode 100644 fastddsspy_tool/test/application/one_shot__reload_time_fail.py create mode 100644 fastddsspy_tool/test/application/one_shot__version.py create mode 100644 fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_datareader_verbose.py create mode 100644 fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py create mode 100644 fastddsspy_tool/test/application/one_shot_datawriter_verbose.py create mode 100644 fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py create mode 100644 fastddsspy_tool/test/application/one_shot_null.py create mode 100644 fastddsspy_tool/test/application/one_shot_participants_guid_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_participants_verbose.py create mode 100644 fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_show_all.py create mode 100644 fastddsspy_tool/test/application/one_shot_show_fail.py create mode 100644 fastddsspy_tool/test/application/one_shot_show_topic.py create mode 100644 fastddsspy_tool/test/application/one_shot_show_topic_verbose.py create mode 100644 fastddsspy_tool/test/application/one_shot_topics_name.py create mode 100644 fastddsspy_tool/test/application/one_shot_topics_name_dds.py create mode 100644 fastddsspy_tool/test/application/one_shot_topics_verbose.py create mode 100644 fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py create mode 100644 fastddsspy_tool/test/application/tool_null.py create mode 100644 fastddsspy_tool/test/application/tool_show_all.py rename fastddsspy_tool/test/application/{tool_show.py => tool_show_topic.py} (90%) rename fastddsspy_tool/test/application/{tool_show_dds.py => tool_show_topic_dds.py} (89%) create mode 100644 fastddsspy_tool/test/application/tool_version.py 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/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 4a348dfa..76b6692a 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -20,33 +20,71 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test set(TEST_LIST_DDS + one_shot__config + one_shot__config_fail_file + one_shot__config_fail_type + one_shot__config_fail_empty_arg one_shot_help_dds one_shot_datareader_dds + one_shot_datareader_guid_dds + one_shot_datareader_verbose_dds one_shot_datawriter_dds + one_shot_datawriter_verbose_dds_qos + one_shot_datawriter_guid_dds_fail + one_shot_datawriter_verbose_dds one_shot_participants_dds + one_shot_participants_guid_dds + one_shot_participants_verbose_dds one_shot_quit_dds one_shot_topics_dds + one_shot_topics_name_dds + one_shot_topics_verbose_dds tool_datareader_dds tool_datawriter_dds tool_help_dds tool_participants_dds - tool_show_dds + tool_show_topic_dds tool_topics_dds ) set(TEST_LIST + one_shot__log_filter + one_shot__log_filter_fail + one_shot__log_verb_fail + one_shot__log_verb_info + one_shot__log_verb_warning + one_shot__log_verb_error + one_shot__reload_time + one_shot__reload_time_fail + one_shot__debug one_shot_help + one_shot__help + one_shot_null + one_shot__null + one_shot__version one_shot_datareader + one_shot_datareader_verbose one_shot_datawriter + one_shot_datawriter_verbose one_shot_participants + one_shot_participants_verbose one_shot_quit + one_shot_show_all + one_shot_show_fail + one_shot_show_topic + one_shot_show_topic_verbose one_shot_topics + one_shot_topics_name + one_shot_topics_verbose tool_datareader tool_datawriter tool_help + tool_null tool_participants - tool_show + tool_show_all + tool_show_topic tool_topics + tool_version ) # windows auxiliary script to fork test execution @@ -109,6 +147,18 @@ if(WIN32) endif(WIN32) +set(TEST_NEEDED_SOURCES + configuration/configuration_basic.yaml + configuration/configuration_wrong_empty_arg.yaml + configuration/configuration_wrong_type.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_LIST) set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") @@ -147,10 +197,12 @@ foreach(TEST IN LISTS TEST_LIST_DDS) ) # TSAN captures and handles raised signals, thus these tests cannot succeed - add_xtsan_label(${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}) + add_xtsan_label(${TEST_NAME}) endforeach() + + unset(TEST_ENVIRONMENT) add_subdirectory(dds/AdvancedConfigurationExample) 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..5cc08062 --- /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: 1000 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..a618a19e --- /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: 1000 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..8d2776ee --- /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: 1000 diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/one_shot__config.py new file mode 100644 index 00000000..76e5ffdd --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__config.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--configCommand', + one_shot=True, + command=[], + dds=True, + configuration='fastddsspy_tool/test/application/configuration/configuration_basic.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'participants'], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py new file mode 100644 index 00000000..e49ce167 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--configFailArgCommand', + one_shot=True, + command=[], + dds=True, + configuration='fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'participants'], + 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/irenebm/eprosima/annapurna/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''' + ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_file.py b/fastddsspy_tool/test/application/one_shot__config_fail_file.py new file mode 100644 index 00000000..12902662 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__config_fail_file.py @@ -0,0 +1,49 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--configFailCommand', + one_shot=True, + command=[], + dds=True, + configuration='hello', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration'], + output="""Usage: Fast DDS Spy \n""" \ +"""Start an interactive CLI to introspect a DDS network. +General options: + +Application help and information. + -h --help Print this help message. + -v --version Print version, branch and commit hash. + +Application parameters + -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. + -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]. + +Debug parameters + -d --debug Set log verbosity to Info \n""" \ +""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). + --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 + +\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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/one_shot__config_fail_type.py new file mode 100644 index 00000000..9db6ddbb --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__config_fail_type.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--configFailTypeCommand', + one_shot=True, + command=[], + dds=True, + configuration='fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml', + arguments_dds=[], + arguments_spy=['--config-path', 'configuration', 'participants'], + 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/irenebm/eprosima/annapurna/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''' + ) diff --git a/fastddsspy_tool/test/application/one_shot__debug.py b/fastddsspy_tool/test/application/one_shot__debug.py new file mode 100644 index 00000000..7be38006 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__debug.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--DebugCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--debug', 'exit'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot__help.py b/fastddsspy_tool/test/application/one_shot__help.py new file mode 100644 index 00000000..53d8274e --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__help.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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--HelpCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--help'], + output="""Usage: Fast DDS Spy \n""" \ +"""Start an interactive CLI to introspect a DDS network. +General options: + +Application help and information. + -h --help Print this help message. + -v --version Print version, branch and commit hash. + +Application parameters + -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. + -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]. + +Debug parameters + -d --debug Set log verbosity to Info \n""" \ +""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). + --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 + +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot__log_filter.py b/fastddsspy_tool/test/application/one_shot__log_filter.py new file mode 100644 index 00000000..ec80de28 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__log_filter.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--log-filterCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--log-filter', '(FASTDDSSPY)', 'exit'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py new file mode 100644 index 00000000..3311328e --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--log-filterFailCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--log-filter'], + output='Usage: Fast DDS Spy \nStart an interactive CLI to introspect a DDS network.\nGeneral options:\n\nApplication help and information.\n -h --help Print this help message.\n -v --version Print version, branch and commit hash.\n\nApplication 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\nDebug 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\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' + ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_error.py b/fastddsspy_tool/test/application/one_shot__log_verb_error.py new file mode 100644 index 00000000..018a59c1 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__log_verb_error.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--log-verbosityCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'error', 'exit'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py new file mode 100644 index 00000000..bdb7911a --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py @@ -0,0 +1,49 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--log-verbosityFailCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'hello', 'exit'], + output="""Usage: Fast DDS Spy \n""" \ +"""Start an interactive CLI to introspect a DDS network. +General options: + +Application help and information. + -h --help Print this help message. + -v --version Print version, branch and commit hash. + +Application parameters + -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. + -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]. + +Debug parameters + -d --debug Set log verbosity to Info \n""" \ +""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). + --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 + +\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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_info.py b/fastddsspy_tool/test/application/one_shot__log_verb_info.py new file mode 100644 index 00000000..81c0d1ad --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__log_verb_info.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--log-verbosityCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'info', 'exit'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py new file mode 100644 index 00000000..6fd158cd --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--log-verbosityCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--log-verbosity', 'warning', 'exit'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot__null.py b/fastddsspy_tool/test/application/one_shot__null.py new file mode 100644 index 00000000..5956e216 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__null.py @@ -0,0 +1,49 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--NullCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--nullarg'], + output="""Usage: Fast DDS Spy \n""" \ +"""Start an interactive CLI to introspect a DDS network. +General options: + +Application help and information. + -h --help Print this help message. + -v --version Print version, branch and commit hash. + +Application parameters + -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. + -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]. + +Debug parameters + -d --debug Set log verbosity to Info \n""" \ +""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). + --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 + +\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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot__reload_time.py b/fastddsspy_tool/test/application/one_shot__reload_time.py new file mode 100644 index 00000000..e86de5a4 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__reload_time.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--reloadCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--reload-time', '2', 'exit'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py new file mode 100644 index 00000000..39a11c06 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py @@ -0,0 +1,49 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='--reloadFailCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--reload-time', 'hello', 'exit'], + output="""Usage: Fast DDS Spy \n""" \ +"""Start an interactive CLI to introspect a DDS network. +General options: + +Application help and information. + -h --help Print this help message. + -v --version Print version, branch and commit hash. + +Application parameters + -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. + -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]. + +Debug parameters + -d --debug Set log verbosity to Info \n""" \ +""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). + --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 + +\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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot__version.py b/fastddsspy_tool/test/application/one_shot__version.py new file mode 100644 index 00000000..8b63b1b6 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot__version.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + +class TestCase_instance (test_class.TestCase): + def __init__(self): + super().__init__( + name='--VersionCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['--version'], + output="""Fast DDS Spy v0.1.0 +commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index 1e6714ff..ec0619dd 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='datareader', + configuration='', + arguments_dds=[], + arguments_spy=['datareader'], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py index 580ef9e5..9fab721e 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='datareader', + configuration='', + arguments_dds=[], + arguments_spy=['datareader'], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py new file mode 100644 index 00000000..c7e6b024 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DataReaderCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['datareader', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + 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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py new file mode 100644 index 00000000..d4a876ab --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatareaderCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['datareader', 'verbose'], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py new file mode 100644 index 00000000..41e99db6 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatareaderCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['datareader', 'verbose'], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index 0c4a79d6..15f570af 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='datawriter', + configuration='', + arguments_dds=[], + arguments_spy=['datawriter'], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py index aa495f04..68795f5e 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='datawriter', + configuration='', + arguments_dds=[], + arguments_spy=['datawriter'], output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3 participant: Participant_pub topic: HelloWorldTopic [HelloWorld] diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py new file mode 100644 index 00000000..09b225dc --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatawriterCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['datawriter', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + 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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py new file mode 100644 index 00000000..53614682 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatawriterCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['datawriter', 'verbose'], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py new file mode 100644 index 00000000..597cf800 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py @@ -0,0 +1,38 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatawriterCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['datawriter', 'verbose'], + output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 + participant: Participant_pub + topic: + name: HelloWorldTopic + type: HelloWorld + qos: + durability: volatile + reliability: best-effort +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py new file mode 100644 index 00000000..6a608bb9 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py @@ -0,0 +1,38 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='DatawriterCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=['--reliable', '--transient'], + arguments_spy=['datawriter', 'verbose'], + output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 + participant: Participant_pub + topic: + name: HelloWorldTopic + type: HelloWorld + qos: + durability: transient-local + reliability: reliable +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index df31984a..f34f1eed 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='help', + configuration='', + arguments_dds=[], + arguments_spy=['help'], output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. Each command shows data related with the network in Yaml format. Commands available and the information they show: diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index fa37e4a3..27ed7d9e 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='help', + configuration='', + arguments_dds=[], + arguments_spy=['help'], output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. Each command shows data related with the network in Yaml format. Commands available and the information they show: diff --git a/fastddsspy_tool/test/application/one_shot_null.py b/fastddsspy_tool/test/application/one_shot_null.py new file mode 100644 index 00000000..c3df9450 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_null.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='NullCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['nullarg'], + 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/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index 9aa850c7..448b83ea 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='participants', + configuration='', + arguments_dds=[], + arguments_spy=['participants'], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index 9c4e8f56..fb119332 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='participants', + configuration='', + arguments_dds=[], + arguments_spy=['participants'], output="""- name: Participant_pub guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1 """ diff --git a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py new file mode 100644 index 00000000..c389da59 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ParticipantCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['participant', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + 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 +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/one_shot_participants_verbose.py new file mode 100644 index 00000000..f0cd5ee7 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ParticipantsCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['participants', 'verbose'], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py new file mode 100644 index 00000000..38cecade --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py @@ -0,0 +1,34 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ParticipantsCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['participants', 'verbose'], + output="""- name: Participant_pub + guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1 + datawriters: + - HelloWorldTopic [HelloWorld] (1) +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py index 0990df2c..64e550e8 100644 --- a/fastddsspy_tool/test/application/one_shot_quit.py +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='exit', + configuration='', + arguments_dds=[], + arguments_spy=['exit'], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py index f607858f..f9ce0eb2 100644 --- a/fastddsspy_tool/test/application/one_shot_quit_dds.py +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='exit', + configuration='', + arguments_dds=[], + arguments_spy=['exit'], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_show_all.py b/fastddsspy_tool/test/application/one_shot_show_all.py new file mode 100644 index 00000000..7d7b2952 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_show_all.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ShowAllCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['show', 'all', '\n'], + output='' + ) diff --git a/fastddsspy_tool/test/application/one_shot_show_fail.py b/fastddsspy_tool/test/application/one_shot_show_fail.py new file mode 100644 index 00000000..d4870dbe --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_show_fail.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['show'], + output="""\x1b[1;31mCommand requires at least one argument.\x1b[0m +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_show_topic.py b/fastddsspy_tool/test/application/one_shot_show_topic.py new file mode 100644 index 00000000..4826d7dd --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_show_topic.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['show', 'hello'], + output="""\x1b[1;31mTopic does not exist.\x1b[0m +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py new file mode 100644 index 00000000..88471b5c --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['show', 'hello', 'verbose'], + output="""\x1b[1;31mTopic does not exist.\x1b[0m +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index 30afda52..ae2dabcf 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -23,6 +23,8 @@ def __init__(self): one_shot=True, command=[], dds=False, - arguments='topics', + configuration='', + arguments_dds=[], + arguments_spy=['topics'], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index 17997dc5..d107a45b 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=True, command=[], dds=True, - arguments='topics', + configuration='', + arguments_dds=[], + arguments_spy=['topics'], output="""- name: HelloWorldTopic type: HelloWorld datawriters: 1 diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/one_shot_topics_name.py new file mode 100644 index 00000000..0a0c8a55 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_topics_name.py @@ -0,0 +1,31 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsDDSCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['topics', 'hello'], + output="""\x1b[1;31m topic does not exist in the DDS network.\x1b[0m +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py new file mode 100644 index 00000000..edc958ef --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py @@ -0,0 +1,36 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsDDSCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['topics', 'HelloWorldTopic'], + output="""name: HelloWorldTopic +type: HelloWorld +datawriters: +- 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3 +rate: 10 Hz +dynamic_type_discovered: false +""" + ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/one_shot_topics_verbose.py new file mode 100644 index 00000000..5415b356 --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose.py @@ -0,0 +1,30 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsCommand', + one_shot=True, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['topics', 'verbose'], + output='\n' + ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py new file mode 100644 index 00000000..39f10d6e --- /dev/null +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py @@ -0,0 +1,36 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='TopicsDDSCommand', + one_shot=True, + command=[], + dds=True, + configuration='', + arguments_dds=[], + arguments_spy=['topics', 'verbose'], + output="""- name: HelloWorldTopic + type: HelloWorld + datawriters: + - 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3 + rate: 10 Hz + dynamic_type_discovered: false +""" + ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index d46b2678..cf50e22b 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -101,6 +101,10 @@ def main(): local_dds = local_path_dds + 'AdvancedConfigurationExample' test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) + if test_function.configuration != '': + index = test_function.arguments_spy.index('configuration') + test_function.arguments_spy[index] = args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) + spy, dds = test_function.run() if (spy == 'wrong output'): diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 8562ddf1..c10915d6 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -32,6 +32,7 @@ import re import time import os +import difflib DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -40,12 +41,14 @@ class TestCase(): - def __init__(self, name, one_shot, command, dds, arguments, output): + def __init__(self, name, one_shot, command, dds, configuration, arguments_dds, arguments_spy, output): self.name = name self.one_shot = one_shot self.command = command self.dds = dds - self.arguments = arguments + self.configuration = configuration + self.arguments_dds = arguments_dds + self.arguments_spy = arguments_spy self.output = output self.exec_spy = '' self.exec_dds = '' @@ -70,7 +73,7 @@ def run(self): def run_tool(self): self.logger.info('Run tool') if (self.one_shot): - self.command = [self.exec_spy, self.arguments] + self.command = [self.exec_spy] + self.arguments_spy else: self.command = [self.exec_spy] @@ -115,7 +118,7 @@ def read_output(self, proc): def send_command_tool(self, proc): # give time to start publishing time.sleep(0.5) - proc.stdin.write((self.arguments+'\n')) + proc.stdin.write((self.arguments_spy[0]+'\n')) proc.stdin.flush() output = self.read_output(proc) return (output) @@ -129,7 +132,7 @@ def stop_tool(self, proc): def run_dds(self): self.logger.info('Run tool') - self.command = [self.exec_dds, 'publisher'] + self.command = [self.exec_dds, 'publisher'] + self.arguments_dds self.logger.info('Executing command: ' + str(self.command)) @@ -163,6 +166,16 @@ def stop_dds(self, proc): proc.communicate() def valid_returncode(self, returncode): + if self.name == '--NullCommand' or self.name == '--configFailCommand' or self.name == '--log-verbosityFailCommand': + return (returncode != 0) + if self.name == '--reloadFailCommand': + return (returncode != 0) + if self.name == '--configFailTypeCommand': + return (returncode != 0) + if self.name == '--configFailArgCommand': + return (returncode != 0) + if self.name == '--log-filterFailCommand': + return (returncode != 0) return (returncode == 0) def output_command(self): @@ -195,7 +208,16 @@ def valid_output(self, output): guid = self.valid_guid(lines_expected_output[i]) elif 'rate:' in lines_expected_output[i]: rate = self.valid_rate(lines_expected_output[i]) + elif 'commit hash:' in lines_expected_output[i]: + pass + elif '--nullarg is not a valid argument.' in lines_expected_output[i]: + pass + elif '\x1b[34;1m -> Function \x1b[36m' in lines_expected_output[i]: + pass + elif '\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Error]' in lines_expected_output[i]: + pass + elif '- 01.0f' in lines_expected_output[i]: + pass elif lines_expected_output[i] != lines_output[i]: return False - return (guid and rate) diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/tool_datareader.py index ebee5a84..94d85daa 100644 --- a/fastddsspy_tool/test/application/tool_datareader.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='datareader', + configuration='', + arguments_dds=[], + arguments_spy=['datareader'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py index 11b56b85..082fb026 100644 --- a/fastddsspy_tool/test/application/tool_datareader_dds.py +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='datareader', + configuration='', + arguments_dds=[], + arguments_spy=['datareader'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py index 47cad3f3..6877fdc6 100644 --- a/fastddsspy_tool/test/application/tool_datawriter.py +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='datawriter', + configuration='', + arguments_dds=[], + arguments_spy=['datawriter'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index 5539a2c5..1af5071a 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='datawriter', + configuration='', + arguments_dds=[], + arguments_spy=['datawriter'], output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3 participant: Participant_pub diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index ddf5f1c3..e89a6dcd 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='help', + configuration='', + arguments_dds=[], + arguments_spy=['help'], output= """>> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index 4b3953e3..41b422b5 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='help', + configuration='', + arguments_dds=[], + arguments_spy=['help'], output= """>> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. diff --git a/fastddsspy_tool/test/application/tool_null.py b/fastddsspy_tool/test/application/tool_null.py new file mode 100644 index 00000000..0641d8d1 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_null.py @@ -0,0 +1,34 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolDatareaderCommand', + one_shot=False, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['null'], + output=""">> \x1b[0m\x1b[1;31m is not a known command. Use command to see valid commands and arguments.\x1b[0m + + + +""" + ) diff --git a/fastddsspy_tool/test/application/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py index e0c4551f..9a719285 100644 --- a/fastddsspy_tool/test/application/tool_participants.py +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='participants', + configuration='', + arguments_dds=[], + arguments_spy=['participants'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index e0d24776..a887f2ce 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='participants', + configuration='', + arguments_dds=[], + arguments_spy=['participants'], output=""">> \x1b[0m- name: Participant_pub guid: 01.0f.d8.74.09.0b.fa.ae.00.00.00.00|0.0.1.c1 diff --git a/fastddsspy_tool/test/application/tool_show_all.py b/fastddsspy_tool/test/application/tool_show_all.py new file mode 100644 index 00000000..41ed3ff1 --- /dev/null +++ b/fastddsspy_tool/test/application/tool_show_all.py @@ -0,0 +1,32 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolShowAllCommand', + one_shot=False, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['show all \n'], + output=""">> \x1b[0m + +""" + ) diff --git a/fastddsspy_tool/test/application/tool_show.py b/fastddsspy_tool/test/application/tool_show_topic.py similarity index 90% rename from fastddsspy_tool/test/application/tool_show.py rename to fastddsspy_tool/test/application/tool_show_topic.py index e9215716..a8a15616 100644 --- a/fastddsspy_tool/test/application/tool_show.py +++ b/fastddsspy_tool/test/application/tool_show_topic.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='show topic', + configuration='', + arguments_dds=[], + arguments_spy=['show topic'], output=""">> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m diff --git a/fastddsspy_tool/test/application/tool_show_dds.py b/fastddsspy_tool/test/application/tool_show_topic_dds.py similarity index 89% rename from fastddsspy_tool/test/application/tool_show_dds.py rename to fastddsspy_tool/test/application/tool_show_topic_dds.py index 105b4bf8..7d0e25df 100644 --- a/fastddsspy_tool/test/application/tool_show_dds.py +++ b/fastddsspy_tool/test/application/tool_show_topic_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='show HelloWorldTopic', + configuration='', + arguments_dds=[], + arguments_spy=['show HelloWorldTopic'], output=""">> \x1b[0m\x1b[1;31mTopic Type has not been discovered, and thus cannot print its data.\x1b[0m diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index 8d72d939..7fa5abfe 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=False, - arguments='topics', + configuration='', + arguments_dds=[], + arguments_spy=['topics'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index b891d839..2ec0bfb2 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -23,7 +23,9 @@ def __init__(self): one_shot=False, command=[], dds=True, - arguments='topics', + configuration='', + arguments_dds=[], + arguments_spy=['topics'], output=""">> \x1b[0m- name: HelloWorldTopic type: HelloWorld diff --git a/fastddsspy_tool/test/application/tool_version.py b/fastddsspy_tool/test/application/tool_version.py new file mode 100644 index 00000000..f5b8a8ff --- /dev/null +++ b/fastddsspy_tool/test/application/tool_version.py @@ -0,0 +1,35 @@ +# 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. + +import test_class + + +class TestCase_instance (test_class.TestCase): + + def __init__(self): + super().__init__( + name='ToolVersionCommand', + one_shot=False, + command=[], + dds=False, + configuration='', + arguments_dds=[], + arguments_spy=['version'], + output= +""">> \x1b[0mFast DDS Spy v0.1.0 + +commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451 + +""" + ) 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 */ From 4ad8d72c095af8c6984a793a297cdfb58d77a38b Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 13 Apr 2023 12:51:43 +0200 Subject: [PATCH 26/63] Fix tests Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/CMakeLists.txt | 6 +++--- .../test/application/one_shot__config.py | 2 +- .../one_shot__config_fail_empty_arg.py | 15 ++++++++++++--- .../application/one_shot__config_fail_file.py | 4 ++-- .../application/one_shot__config_fail_type.py | 4 ++-- .../test/application/one_shot__debug.py | 2 +- .../test/application/one_shot__help.py | 2 +- .../test/application/one_shot__log_filter.py | 2 +- .../test/application/one_shot__log_filter_fail.py | 2 +- .../test/application/one_shot__log_verb_error.py | 2 +- .../test/application/one_shot__log_verb_fail.py | 2 +- .../test/application/one_shot__log_verb_info.py | 2 +- .../application/one_shot__log_verb_warning.py | 2 +- .../test/application/one_shot__null.py | 2 +- .../test/application/one_shot__reload_time.py | 2 +- .../application/one_shot__reload_time_fail.py | 2 +- .../test/application/one_shot__version.py | 2 +- .../test/application/one_shot_datareader.py | 2 +- .../test/application/one_shot_datareader_dds.py | 2 +- .../application/one_shot_datareader_guid_dds.py | 2 +- .../application/one_shot_datareader_verbose.py | 2 +- .../one_shot_datareader_verbose_dds.py | 2 +- .../test/application/one_shot_datawriter.py | 2 +- .../test/application/one_shot_datawriter_dds.py | 2 +- .../one_shot_datawriter_guid_dds_fail.py | 2 +- .../application/one_shot_datawriter_verbose.py | 2 +- .../one_shot_datawriter_verbose_dds.py | 2 +- .../one_shot_datawriter_verbose_dds_qos.py | 2 +- fastddsspy_tool/test/application/one_shot_help.py | 2 +- .../test/application/one_shot_help_dds.py | 2 +- fastddsspy_tool/test/application/one_shot_null.py | 2 +- .../test/application/one_shot_participants.py | 2 +- .../test/application/one_shot_participants_dds.py | 2 +- .../application/one_shot_participants_guid_dds.py | 2 +- .../application/one_shot_participants_verbose.py | 2 +- .../one_shot_participants_verbose_dds.py | 2 +- fastddsspy_tool/test/application/one_shot_quit.py | 2 +- .../test/application/one_shot_quit_dds.py | 2 +- .../test/application/one_shot_show_all.py | 2 +- .../test/application/one_shot_show_fail.py | 2 +- .../test/application/one_shot_show_topic.py | 2 +- .../application/one_shot_show_topic_verbose.py | 2 +- .../test/application/one_shot_topics.py | 2 +- .../test/application/one_shot_topics_dds.py | 2 +- .../test/application/one_shot_topics_name.py | 2 +- .../test/application/one_shot_topics_name_dds.py | 2 +- .../test/application/one_shot_topics_verbose.py | 2 +- .../application/one_shot_topics_verbose_dds.py | 2 +- fastddsspy_tool/test/application/test_class.py | 10 +++++++--- .../test/application/tool_datareader.py | 2 +- .../test/application/tool_datareader_dds.py | 2 +- .../test/application/tool_datawriter.py | 2 +- .../test/application/tool_datawriter_dds.py | 2 +- fastddsspy_tool/test/application/tool_help.py | 2 +- fastddsspy_tool/test/application/tool_help_dds.py | 2 +- fastddsspy_tool/test/application/tool_null.py | 2 +- .../test/application/tool_participants.py | 2 +- .../test/application/tool_participants_dds.py | 2 +- fastddsspy_tool/test/application/tool_show_all.py | 2 +- .../test/application/tool_show_topic.py | 2 +- .../test/application/tool_show_topic_dds.py | 2 +- fastddsspy_tool/test/application/tool_topics.py | 2 +- .../test/application/tool_topics_dds.py | 2 +- fastddsspy_tool/test/application/tool_version.py | 2 +- 64 files changed, 85 insertions(+), 72 deletions(-) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 76b6692a..8ee999ef 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -21,9 +21,6 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test set(TEST_LIST_DDS one_shot__config - one_shot__config_fail_file - one_shot__config_fail_type - one_shot__config_fail_empty_arg one_shot_help_dds one_shot_datareader_dds one_shot_datareader_guid_dds @@ -48,6 +45,9 @@ set(TEST_LIST_DDS ) set(TEST_LIST + one_shot__config_fail_file + one_shot__config_fail_type + one_shot__config_fail_empty_arg one_shot__log_filter one_shot__log_filter_fail one_shot__log_verb_fail diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/one_shot__config.py index 76e5ffdd..0ed2a640 100644 --- a/fastddsspy_tool/test/application/one_shot__config.py +++ b/fastddsspy_tool/test/application/one_shot__config.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='fastddsspy_tool/test/application/configuration/configuration_basic.yaml', + config='fastddsspy_tool/test/application/configuration/configuration_basic.yaml', arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py index e49ce167..6b3fb76e 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -22,9 +22,18 @@ def __init__(self): name='--configFailArgCommand', one_shot=True, command=[], - dds=True, - configuration='fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml', + dds=False, + config='fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml', arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], - 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/irenebm/eprosima/annapurna/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''' + 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/irenebm/eprosima/annapurna/DDS-Spy/build/fastddsspy_tool"""\ +"""/test/application/configuration/configuration_wrong_empty_arg.yaml. """\ +"""Error message: + Error loading DDS Router configuration from yaml: + Error getting required value of type in tag : + Trying to read a primitive value of type from a non scalar yaml.\x1b[34;1m -> Function \x1b[36mmain\x1b[m +""" ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_file.py b/fastddsspy_tool/test/application/one_shot__config_fail_file.py index 12902662..5dfe6d5b 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_file.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_file.py @@ -22,8 +22,8 @@ def __init__(self): name='--configFailCommand', one_shot=True, command=[], - dds=True, - configuration='hello', + dds=False, + config='hello', arguments_dds=[], arguments_spy=['--config-path', 'configuration'], output="""Usage: Fast DDS Spy \n""" \ diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/one_shot__config_fail_type.py index 9db6ddbb..2bd696bf 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_type.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_type.py @@ -22,8 +22,8 @@ def __init__(self): name='--configFailTypeCommand', one_shot=True, command=[], - dds=True, - configuration='fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml', + dds=False, + config='fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml', arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], 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/irenebm/eprosima/annapurna/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''' diff --git a/fastddsspy_tool/test/application/one_shot__debug.py b/fastddsspy_tool/test/application/one_shot__debug.py index 7be38006..b4e16f49 100644 --- a/fastddsspy_tool/test/application/one_shot__debug.py +++ b/fastddsspy_tool/test/application/one_shot__debug.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--debug', 'exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot__help.py b/fastddsspy_tool/test/application/one_shot__help.py index 53d8274e..d17987dc 100644 --- a/fastddsspy_tool/test/application/one_shot__help.py +++ b/fastddsspy_tool/test/application/one_shot__help.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--help'], output="""Usage: Fast DDS Spy \n""" \ diff --git a/fastddsspy_tool/test/application/one_shot__log_filter.py b/fastddsspy_tool/test/application/one_shot__log_filter.py index ec80de28..8f08aa3e 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter.py +++ b/fastddsspy_tool/test/application/one_shot__log_filter.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--log-filter', '(FASTDDSSPY)', 'exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py index 3311328e..39300da8 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py +++ b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--log-filter'], output='Usage: Fast DDS Spy \nStart an interactive CLI to introspect a DDS network.\nGeneral options:\n\nApplication help and information.\n -h --help Print this help message.\n -v --version Print version, branch and commit hash.\n\nApplication 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\nDebug 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\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' diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_error.py b/fastddsspy_tool/test/application/one_shot__log_verb_error.py index 018a59c1..2e796fae 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_error.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_error.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'error', 'exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py index bdb7911a..5fbd2443 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'hello', 'exit'], output="""Usage: Fast DDS Spy \n""" \ diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_info.py b/fastddsspy_tool/test/application/one_shot__log_verb_info.py index 81c0d1ad..3f3f6321 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_info.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_info.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'info', 'exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py index 6fd158cd..43f36209 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'warning', 'exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot__null.py b/fastddsspy_tool/test/application/one_shot__null.py index 5956e216..265efdd2 100644 --- a/fastddsspy_tool/test/application/one_shot__null.py +++ b/fastddsspy_tool/test/application/one_shot__null.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--nullarg'], output="""Usage: Fast DDS Spy \n""" \ diff --git a/fastddsspy_tool/test/application/one_shot__reload_time.py b/fastddsspy_tool/test/application/one_shot__reload_time.py index e86de5a4..6e959b78 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--reload-time', '2', 'exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py index 39a11c06..c994b867 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--reload-time', 'hello', 'exit'], output="""Usage: Fast DDS Spy \n""" \ diff --git a/fastddsspy_tool/test/application/one_shot__version.py b/fastddsspy_tool/test/application/one_shot__version.py index 8b63b1b6..6014bbb3 100644 --- a/fastddsspy_tool/test/application/one_shot__version.py +++ b/fastddsspy_tool/test/application/one_shot__version.py @@ -21,7 +21,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['--version'], output="""Fast DDS Spy v0.1.0 diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index ec0619dd..49d177fa 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py index 9fab721e..91b93a79 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py index c7e6b024..840ecc2b 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], 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 diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py index d4a876ab..6c36414f 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader', 'verbose'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py index 41e99db6..a134d15b 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader', 'verbose'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index 15f570af..140afdc3 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py index 68795f5e..988b9c06 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter'], output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3 diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py index 09b225dc..268bec06 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], 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 diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py index 53614682..e4a667c4 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter', 'verbose'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py index 597cf800..d00ba980 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter', 'verbose'], output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py index 6a608bb9..5c28c0fb 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=['--reliable', '--transient'], arguments_spy=['datawriter', 'verbose'], output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index f34f1eed..b5d1bb67 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['help'], output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index 27ed7d9e..6b659f0a 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['help'], output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. diff --git a/fastddsspy_tool/test/application/one_shot_null.py b/fastddsspy_tool/test/application/one_shot_null.py index c3df9450..7ea5720f 100644 --- a/fastddsspy_tool/test/application/one_shot_null.py +++ b/fastddsspy_tool/test/application/one_shot_null.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['nullarg'], 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/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index 448b83ea..f2e5db9c 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['participants'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index fb119332..5ca0a861 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['participants'], output="""- name: Participant_pub diff --git a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py index c389da59..c69da21d 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['participant', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], 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 diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/one_shot_participants_verbose.py index f0cd5ee7..588463c9 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['participants', 'verbose'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py index 38cecade..d33a5239 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['participants', 'verbose'], output="""- name: Participant_pub diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py index 64e550e8..0617243c 100644 --- a/fastddsspy_tool/test/application/one_shot_quit.py +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py index f9ce0eb2..2332adfd 100644 --- a/fastddsspy_tool/test/application/one_shot_quit_dds.py +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['exit'], output='' diff --git a/fastddsspy_tool/test/application/one_shot_show_all.py b/fastddsspy_tool/test/application/one_shot_show_all.py index 7d7b2952..8256a8ae 100644 --- a/fastddsspy_tool/test/application/one_shot_show_all.py +++ b/fastddsspy_tool/test/application/one_shot_show_all.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['show', 'all', '\n'], output='' diff --git a/fastddsspy_tool/test/application/one_shot_show_fail.py b/fastddsspy_tool/test/application/one_shot_show_fail.py index d4870dbe..51b74e04 100644 --- a/fastddsspy_tool/test/application/one_shot_show_fail.py +++ b/fastddsspy_tool/test/application/one_shot_show_fail.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['show'], output="""\x1b[1;31mCommand requires at least one argument.\x1b[0m diff --git a/fastddsspy_tool/test/application/one_shot_show_topic.py b/fastddsspy_tool/test/application/one_shot_show_topic.py index 4826d7dd..a37686df 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['show', 'hello'], output="""\x1b[1;31mTopic does not exist.\x1b[0m diff --git a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py index 88471b5c..99d9396d 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['show', 'hello', 'verbose'], output="""\x1b[1;31mTopic does not exist.\x1b[0m diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index ae2dabcf..1eb601ab 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index d107a45b..5d053f9c 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics'], output="""- name: HelloWorldTopic diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/one_shot_topics_name.py index 0a0c8a55..e148ec05 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics', 'hello'], output="""\x1b[1;31m topic does not exist in the DDS network.\x1b[0m diff --git a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py index edc958ef..92f32628 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics', 'HelloWorldTopic'], output="""name: HelloWorldTopic diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/one_shot_topics_verbose.py index 5415b356..7a083237 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics', 'verbose'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py index 39f10d6e..9907844a 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=True, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics', 'verbose'], output="""- name: HelloWorldTopic diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index c10915d6..7bbf034c 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -41,12 +41,12 @@ class TestCase(): - def __init__(self, name, one_shot, command, dds, configuration, arguments_dds, arguments_spy, output): + def __init__(self, name, one_shot, command, dds, config, arguments_dds, arguments_spy, output): self.name = name self.one_shot = one_shot self.command = command self.dds = dds - self.configuration = configuration + self.configuration = config self.arguments_dds = arguments_dds self.arguments_spy = arguments_spy self.output = output @@ -166,7 +166,11 @@ def stop_dds(self, proc): proc.communicate() def valid_returncode(self, returncode): - if self.name == '--NullCommand' or self.name == '--configFailCommand' or self.name == '--log-verbosityFailCommand': + if self.name == '--NullCommand': + return (returncode != 0) + if self.name == '--configFailCommand': + return (returncode != 0) + if self.name == '--log-verbosityFailCommand': return (returncode != 0) if self.name == '--reloadFailCommand': return (returncode != 0) diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/tool_datareader.py index 94d85daa..f0a180e3 100644 --- a/fastddsspy_tool/test/application/tool_datareader.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py index 082fb026..5aa17f3f 100644 --- a/fastddsspy_tool/test/application/tool_datareader_dds.py +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datareader'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py index 6877fdc6..c1e83382 100644 --- a/fastddsspy_tool/test/application/tool_datawriter.py +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index 1af5071a..8c0132ff 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['datawriter'], output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3 diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index e89a6dcd..faf9451f 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['help'], output= diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index 41b422b5..507f739b 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['help'], output= diff --git a/fastddsspy_tool/test/application/tool_null.py b/fastddsspy_tool/test/application/tool_null.py index 0641d8d1..dadb56ca 100644 --- a/fastddsspy_tool/test/application/tool_null.py +++ b/fastddsspy_tool/test/application/tool_null.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['null'], output=""">> \x1b[0m\x1b[1;31m is not a known command. Use command to see valid commands and arguments.\x1b[0m diff --git a/fastddsspy_tool/test/application/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py index 9a719285..d0ffa4d3 100644 --- a/fastddsspy_tool/test/application/tool_participants.py +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['participants'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index a887f2ce..8f631bb3 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['participants'], output=""">> \x1b[0m- name: Participant_pub diff --git a/fastddsspy_tool/test/application/tool_show_all.py b/fastddsspy_tool/test/application/tool_show_all.py index 41ed3ff1..5d849f34 100644 --- a/fastddsspy_tool/test/application/tool_show_all.py +++ b/fastddsspy_tool/test/application/tool_show_all.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['show all \n'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_show_topic.py b/fastddsspy_tool/test/application/tool_show_topic.py index a8a15616..3d2d2899 100644 --- a/fastddsspy_tool/test/application/tool_show_topic.py +++ b/fastddsspy_tool/test/application/tool_show_topic.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['show topic'], output=""">> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m diff --git a/fastddsspy_tool/test/application/tool_show_topic_dds.py b/fastddsspy_tool/test/application/tool_show_topic_dds.py index 7d0e25df..577b5b7d 100644 --- a/fastddsspy_tool/test/application/tool_show_topic_dds.py +++ b/fastddsspy_tool/test/application/tool_show_topic_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['show HelloWorldTopic'], output=""">> \x1b[0m\x1b[1;31mTopic Type has not been discovered, and thus cannot print its data.\x1b[0m diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index 7fa5abfe..34dc0a15 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics'], output=""">> \x1b[0m diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index 2ec0bfb2..eaec683f 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=True, - configuration='', + config='', arguments_dds=[], arguments_spy=['topics'], output=""">> \x1b[0m- name: HelloWorldTopic diff --git a/fastddsspy_tool/test/application/tool_version.py b/fastddsspy_tool/test/application/tool_version.py index f5b8a8ff..55e6a8dc 100644 --- a/fastddsspy_tool/test/application/tool_version.py +++ b/fastddsspy_tool/test/application/tool_version.py @@ -23,7 +23,7 @@ def __init__(self): one_shot=False, command=[], dds=False, - configuration='', + config='', arguments_dds=[], arguments_spy=['version'], output= From 44617032c8714989be3f3c6758d209f523206ff9 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 13 Apr 2023 13:00:47 +0200 Subject: [PATCH 27/63] Long lines Signed-off-by: Irene Bandera --- .../one_shot__config_fail_empty_arg.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py index 6b3fb76e..88a36a01 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -26,14 +26,14 @@ def __init__(self): config='fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml', arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], - 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/irenebm/eprosima/annapurna/DDS-Spy/build/fastddsspy_tool"""\ -"""/test/application/configuration/configuration_wrong_empty_arg.yaml. """\ -"""Error message: - Error loading DDS Router configuration from yaml: - Error getting required value of type in tag : - Trying to read a primitive value of type from a non scalar yaml.\x1b[34;1m -> Function \x1b[36mmain\x1b[m -""" + 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/irenebm/eprosima/annapurna/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""" ) From d077c34d05ecb8f9d5fe3f379c8f6a35f90aed21 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 13 Apr 2023 13:04:52 +0200 Subject: [PATCH 28/63] Long lines Signed-off-by: Irene Bandera --- .../one_shot__config_fail_empty_arg.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py index 88a36a01..749db81b 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -27,13 +27,13 @@ def __init__(self): arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], 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/irenebm/eprosima/annapurna/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""" + """\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Error] """ + """\x1b[37mError Loading Fast DDS Spy Configuration from file """ + """/home/irenebm/eprosima/annapurna/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""" ) From 186b08a5c8b85d678ead15b2859dbe9580479441 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 14 Apr 2023 12:45:11 +0200 Subject: [PATCH 29/63] Some style fixes Signed-off-by: Irene Bandera --- .../test/application/one_shot__config.py | 7 +- .../one_shot__config_fail_empty_arg.py | 29 +++--- .../application/one_shot__config_fail_file.py | 52 ++++++---- .../application/one_shot__config_fail_type.py | 18 +++- .../test/application/one_shot__debug.py | 4 + .../test/application/one_shot__help.py | 45 +++++---- .../test/application/one_shot__log_filter.py | 4 + .../application/one_shot__log_filter_fail.py | 33 ++++++- .../application/one_shot__log_verb_error.py | 4 + .../application/one_shot__log_verb_fail.py | 52 ++++++---- .../application/one_shot__log_verb_info.py | 4 + .../application/one_shot__log_verb_warning.py | 4 + .../test/application/one_shot__null.py | 52 ++++++---- .../test/application/one_shot__reload_time.py | 4 + .../application/one_shot__reload_time_fail.py | 51 ++++++---- .../test/application/one_shot__version.py | 11 ++- .../test/application/one_shot_datareader.py | 4 + .../application/one_shot_datareader_dds.py | 4 + .../one_shot_datareader_guid_dds.py | 8 +- .../one_shot_datareader_verbose.py | 4 + .../one_shot_datareader_verbose_dds.py | 4 + .../test/application/one_shot_datawriter.py | 4 + .../application/one_shot_datawriter_dds.py | 11 ++- .../one_shot_datawriter_guid_dds_fail.py | 8 +- .../one_shot_datawriter_verbose.py | 4 + .../one_shot_datawriter_verbose_dds.py | 21 ++-- .../one_shot_datawriter_verbose_dds_qos.py | 21 ++-- .../test/application/one_shot_help.py | 62 ++++++------ .../test/application/one_shot_help_dds.py | 62 ++++++------ .../test/application/one_shot_null.py | 7 +- .../test/application/one_shot_participants.py | 4 + .../application/one_shot_participants_dds.py | 9 +- .../one_shot_participants_guid_dds.py | 8 +- .../one_shot_participants_verbose.py | 4 + .../one_shot_participants_verbose_dds.py | 13 ++- .../test/application/one_shot_quit.py | 4 + .../test/application/one_shot_quit_dds.py | 4 + .../test/application/one_shot_show_all.py | 4 + .../test/application/one_shot_show_fail.py | 8 +- .../test/application/one_shot_show_topic.py | 7 +- .../one_shot_show_topic_verbose.py | 7 +- .../test/application/one_shot_topics.py | 4 + .../test/application/one_shot_topics_dds.py | 15 +-- .../test/application/one_shot_topics_name.py | 8 +- .../application/one_shot_topics_name_dds.py | 17 ++-- .../application/one_shot_topics_verbose.py | 4 + .../one_shot_topics_verbose_dds.py | 17 ++-- fastddsspy_tool/test/application/test.py | 11 +-- .../test/application/test_class.py | 71 ++++++++----- .../test/application/tool_datareader.py | 10 +- .../test/application/tool_datareader_dds.py | 10 +- .../test/application/tool_datawriter.py | 10 +- .../test/application/tool_datawriter_dds.py | 15 +-- fastddsspy_tool/test/application/tool_help.py | 99 +++++++------------ .../test/application/tool_help_dds.py | 99 +++++++------------ fastddsspy_tool/test/application/tool_null.py | 11 ++- .../test/application/tool_participants.py | 10 +- .../test/application/tool_participants_dds.py | 11 ++- .../test/application/tool_show_all.py | 8 +- .../test/application/tool_show_topic.py | 11 ++- .../test/application/tool_show_topic_dds.py | 11 ++- .../test/application/tool_topics.py | 10 +- .../test/application/tool_topics_dds.py | 23 +++-- .../test/application/tool_version.py | 13 +-- 64 files changed, 710 insertions(+), 458 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/one_shot__config.py index 0ed2a640..b382da43 100644 --- a/fastddsspy_tool/test/application/one_shot__config.py +++ b/fastddsspy_tool/test/application/one_shot__config.py @@ -12,18 +12,23 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--configCommand', one_shot=True, command=[], dds=True, - config='fastddsspy_tool/test/application/configuration/configuration_basic.yaml', + config="""fastddsspy_tool/test/application/configuration/\ +configuration_basic.yaml""", arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], output='\n' diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py index 749db81b..12a166f4 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -12,28 +12,35 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--configFailArgCommand', one_shot=True, command=[], dds=False, - config='fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml', + config="""fastddsspy_tool/test/application/configuration/\ +configuration_wrong_empty_arg.yaml""", arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], - 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/irenebm/eprosima/annapurna/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""" + 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/irenebm/eprosima/annapurna/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""" ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_file.py b/fastddsspy_tool/test/application/one_shot__config_fail_file.py index 5dfe6d5b..64f24afc 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_file.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_file.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--configFailCommand', one_shot=True, @@ -26,24 +30,32 @@ def __init__(self): config='hello', arguments_dds=[], arguments_spy=['--config-path', 'configuration'], - output="""Usage: Fast DDS Spy \n""" \ -"""Start an interactive CLI to introspect a DDS network. -General options: - -Application help and information. - -h --help Print this help message. - -v --version Print version, branch and commit hash. - -Application parameters - -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. - -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]. - -Debug parameters - -d --debug Set log verbosity to Info \n""" \ -""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). - --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 - -\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 -""" + 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 = "(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 '--config-path' requires an existing readable file as argument.\ +\x1b[34;1m -> Function \x1b[36mReadable_File\x1b[m\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/one_shot__config_fail_type.py index 2bd696bf..d23c31f8 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_type.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_type.py @@ -12,19 +12,33 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--configFailTypeCommand', one_shot=True, command=[], dds=False, - config='fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml', + config="""fastddsspy_tool/test/application/configuration/\ +configuration_wrong_type.yaml""", arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'participants'], - 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/irenebm/eprosima/annapurna/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''' + 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/irenebm/eprosima/annapurna/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""" ) diff --git a/fastddsspy_tool/test/application/one_shot__debug.py b/fastddsspy_tool/test/application/one_shot__debug.py index b4e16f49..65d793ab 100644 --- a/fastddsspy_tool/test/application/one_shot__debug.py +++ b/fastddsspy_tool/test/application/one_shot__debug.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--DebugCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot__help.py b/fastddsspy_tool/test/application/one_shot__help.py index d17987dc..42dfc045 100644 --- a/fastddsspy_tool/test/application/one_shot__help.py +++ b/fastddsspy_tool/test/application/one_shot__help.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--HelpCommand', one_shot=True, @@ -26,23 +30,30 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--help'], - output="""Usage: Fast DDS Spy \n""" \ -"""Start an interactive CLI to introspect a DDS network. -General options: - -Application help and information. - -h --help Print this help message. - -v --version Print version, branch and commit hash. - -Application parameters - -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. - -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]. - -Debug parameters - -d --debug Set log verbosity to Info \n""" \ -""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). - --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 + 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\ """ ) diff --git a/fastddsspy_tool/test/application/one_shot__log_filter.py b/fastddsspy_tool/test/application/one_shot__log_filter.py index 8f08aa3e..e2d67562 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter.py +++ b/fastddsspy_tool/test/application/one_shot__log_filter.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--log-filterCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py index 39300da8..fa7b9de3 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py +++ b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--log-filterFailCommand', one_shot=True, @@ -26,5 +30,32 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--log-filter'], - output='Usage: Fast DDS Spy \nStart an interactive CLI to introspect a DDS network.\nGeneral options:\n\nApplication help and information.\n -h --help Print this help message.\n -v --version Print version, branch and commit hash.\n\nApplication 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\nDebug 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\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' + 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""" ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_error.py b/fastddsspy_tool/test/application/one_shot__log_verb_error.py index 2e796fae..4151d9ee 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_error.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_error.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--log-verbosityCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py index 5fbd2443..6850d978 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--log-verbosityFailCommand', one_shot=True, @@ -26,24 +30,32 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'hello', 'exit'], - output="""Usage: Fast DDS Spy \n""" \ -"""Start an interactive CLI to introspect a DDS network. -General options: - -Application help and information. - -h --help Print this help message. - -v --version Print version, branch and commit hash. - -Application parameters - -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. - -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]. - -Debug parameters - -d --debug Set log verbosity to Info \n""" \ -""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). - --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 - -\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 -""" + 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""" ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_info.py b/fastddsspy_tool/test/application/one_shot__log_verb_info.py index 3f3f6321..1b782342 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_info.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_info.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--log-verbosityCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py index 43f36209..bf83f16a 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--log-verbosityCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot__null.py b/fastddsspy_tool/test/application/one_shot__null.py index 265efdd2..9065c4c5 100644 --- a/fastddsspy_tool/test/application/one_shot__null.py +++ b/fastddsspy_tool/test/application/one_shot__null.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--NullCommand', one_shot=True, @@ -26,24 +30,32 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--nullarg'], - output="""Usage: Fast DDS Spy \n""" \ -"""Start an interactive CLI to introspect a DDS network. -General options: - -Application help and information. - -h --help Print this help message. - -v --version Print version, branch and commit hash. - -Application parameters - -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. - -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]. - -Debug parameters - -d --debug Set log verbosity to Info \n""" \ -""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). - --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 - -\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 -""" + 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[37m--nullarg is not a valid argument.\ +\x1b[34;1m -> Function \x1b[36mparse_arguments\x1b[m\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot__reload_time.py b/fastddsspy_tool/test/application/one_shot__reload_time.py index 6e959b78..5b3cd338 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--reloadCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py index c994b867..01383767 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='--reloadFailCommand', one_shot=True, @@ -26,24 +30,33 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--reload-time', 'hello', 'exit'], - output="""Usage: Fast DDS Spy \n""" \ -"""Start an interactive CLI to introspect a DDS network. -General options: - -Application help and information. - -h --help Print this help message. - -v --version Print version, branch and commit hash. - -Application parameters - -c --config-path Path to the Configuration File (yaml format) [Default: ./FASTDDSSPY_CONFIGURATION.yaml]. - -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]. - -Debug parameters - -d --debug Set log verbosity to Info \n""" \ -""" (Using this option with --log-filter and/or --log-verbosity will head to undefined behaviour). - --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 - -\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 + 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 '--reload-time' requires a numeric argument.\ +\x1b[34;1m -> Function \x1b[36mValid_Options\x1b[m\ """ ) diff --git a/fastddsspy_tool/test/application/one_shot__version.py b/fastddsspy_tool/test/application/one_shot__version.py index 6014bbb3..a2e5ea7c 100644 --- a/fastddsspy_tool/test/application/one_shot__version.py +++ b/fastddsspy_tool/test/application/one_shot__version.py @@ -12,10 +12,16 @@ # 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): + """TODO.""" + def __init__(self): + """TODO.""" super().__init__( name='--VersionCommand', one_shot=True, @@ -24,7 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--version'], - output="""Fast DDS Spy v0.1.0 -commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451 -""" + output="""Fast DDS Spy v0.1.0\ +commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index 49d177fa..8d616069 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatareaderCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py index 91b93a79..b9f893ab 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatareaderDDSCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py index 840ecc2b..58d0cc24 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DataReaderCommand', one_shot=True, @@ -26,6 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datareader', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], - 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 -""" + 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/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py index 6c36414f..a7b20651 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatareaderCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py index a134d15b..967650c1 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatareaderCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index 140afdc3..38a5ca40 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatawriterCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py index 988b9c06..c41f0aca 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatawriterDDSCommand', one_shot=True, @@ -26,8 +30,7 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter'], - output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3 - participant: Participant_pub - topic: HelloWorldTopic [HelloWorld] -""" + output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3\n\ + participant: Participant_pub\n\ + topic: HelloWorldTopic [HelloWorld]\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py index 268bec06..c3a3d7b5 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatawriterCommand', one_shot=True, @@ -26,6 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], - 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 -""" + 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/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py index e4a667c4..f7d03898 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatawriterCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py index d00ba980..8aec0389 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatawriterCommand', one_shot=True, @@ -26,13 +30,12 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter', 'verbose'], - output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 - participant: Participant_pub - topic: - name: HelloWorldTopic - type: HelloWorld - qos: - durability: volatile - reliability: best-effort -""" + output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3\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/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py index 5c28c0fb..e6529e2e 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='DatawriterCommand', one_shot=True, @@ -26,13 +30,12 @@ def __init__(self): config='', arguments_dds=['--reliable', '--transient'], arguments_spy=['datawriter', 'verbose'], - output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3 - participant: Participant_pub - topic: - name: HelloWorldTopic - type: HelloWorld - qos: - durability: transient-local - reliability: reliable -""" + output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3\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/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index b5d1bb67..f0a49eb1 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='HelpCommand', one_shot=True, @@ -26,34 +30,36 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['help'], - output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. -Each command shows data related with the network in Yaml format. -Commands available and the information they show: -\thelp : this help. -\tversion : tool version. -\tquit : exit interactive CLI and close program. -\tparticipants : DomainParticipants discovered in the network. -\tparticipants verbose : verbose information about DomainParticipants discovered in the network. -\tparticipants : verbose information related with a specific DomainParticipant. -\twriters : DataWriters discovered in the network. -\twriters verbose : verbose information about DataWriters discovered in the network. -\twriters : verbose information related with a specific DataWriter. -\treader : DataReaders discovered in the network. -\treader verbose : verbose information about DataReaders discovered in the network. -\treader : verbose information related with a specific DataReader. -\ttopics : Topics discovered in the network. -\ttopics verbose : verbose information about Topics discovered in the network. -\ttopics : verbose information related with a specific Topic. -\tshow : data of a specific Topic (Data Type must be discovered). -\tshow verbose : data with additional source info of a specific Topic. -\tshow all : verbose data of all topics (only those whose Data Type is discovered). - -Notes and comments: -\tTo exit from data printing, press enter. -\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). - -For more information about these commands and formats, please refer to the documentation: -https://fast-dds-spy.readthedocs.io/en/latest/ + 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/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index 6b659f0a..e2a90b13 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='HelpDDSCommand', one_shot=True, @@ -26,34 +30,36 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['help'], - output="""Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks. -Each command shows data related with the network in Yaml format. -Commands available and the information they show: -\thelp : this help. -\tversion : tool version. -\tquit : exit interactive CLI and close program. -\tparticipants : DomainParticipants discovered in the network. -\tparticipants verbose : verbose information about DomainParticipants discovered in the network. -\tparticipants : verbose information related with a specific DomainParticipant. -\twriters : DataWriters discovered in the network. -\twriters verbose : verbose information about DataWriters discovered in the network. -\twriters : verbose information related with a specific DataWriter. -\treader : DataReaders discovered in the network. -\treader verbose : verbose information about DataReaders discovered in the network. -\treader : verbose information related with a specific DataReader. -\ttopics : Topics discovered in the network. -\ttopics verbose : verbose information about Topics discovered in the network. -\ttopics : verbose information related with a specific Topic. -\tshow : data of a specific Topic (Data Type must be discovered). -\tshow verbose : data with additional source info of a specific Topic. -\tshow all : verbose data of all topics (only those whose Data Type is discovered). - -Notes and comments: -\tTo exit from data printing, press enter. -\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). - -For more information about these commands and formats, please refer to the documentation: -https://fast-dds-spy.readthedocs.io/en/latest/ + 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/one_shot_null.py b/fastddsspy_tool/test/application/one_shot_null.py index 7ea5720f..95d0bba5 100644 --- a/fastddsspy_tool/test/application/one_shot_null.py +++ b/fastddsspy_tool/test/application/one_shot_null.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='NullCommand', one_shot=True, @@ -26,5 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['nullarg'], - output='\x1b[1;31m is not a known command. Use command to see valid commands and arguments.\x1b[0m\n' + 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/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index f2e5db9c..ad142148 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ParticipantsCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index 5ca0a861..6d9379f2 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ParticipantsDDSCommand', one_shot=True, @@ -26,7 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participants'], - output="""- name: Participant_pub - guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1 -""" + output="""- name: Participant_pub\n\ +guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py index c69da21d..b36a6244 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ParticipantCommand', one_shot=True, @@ -26,6 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participant', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], - 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 -""" + 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/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/one_shot_participants_verbose.py index 588463c9..f0618de7 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ParticipantsCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py index d33a5239..1df502a5 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ParticipantsCommand', one_shot=True, @@ -26,9 +30,8 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participants', 'verbose'], - output="""- name: Participant_pub - guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1 - datawriters: - - HelloWorldTopic [HelloWorld] (1) -""" + output="""- name: Participant_pub\n\ + guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1\n\ + datawriters:\n\ + - HelloWorldTopic [HelloWorld] (1)\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py index 0617243c..d16b5029 100644 --- a/fastddsspy_tool/test/application/one_shot_quit.py +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='QuitCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py index 2332adfd..251fd560 100644 --- a/fastddsspy_tool/test/application/one_shot_quit_dds.py +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='QuitDDSCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_show_all.py b/fastddsspy_tool/test/application/one_shot_show_all.py index 8256a8ae..78f9e585 100644 --- a/fastddsspy_tool/test/application/one_shot_show_all.py +++ b/fastddsspy_tool/test/application/one_shot_show_all.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ShowAllCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_show_fail.py b/fastddsspy_tool/test/application/one_shot_show_fail.py index 51b74e04..6cecb9c2 100644 --- a/fastddsspy_tool/test/application/one_shot_show_fail.py +++ b/fastddsspy_tool/test/application/one_shot_show_fail.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsCommand', one_shot=True, @@ -26,6 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show'], - output="""\x1b[1;31mCommand requires at least one argument.\x1b[0m -""" + output="""\x1b[1;31mCommand requires at least \ +one argument.\x1b[0m\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_show_topic.py b/fastddsspy_tool/test/application/one_shot_show_topic.py index a37686df..9ec3cc62 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsCommand', one_shot=True, @@ -26,6 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show', 'hello'], - output="""\x1b[1;31mTopic does not exist.\x1b[0m -""" + output="""\x1b[1;31mTopic does not exist.\x1b[0m\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py index 99d9396d..82832e02 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsCommand', one_shot=True, @@ -26,6 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show', 'hello', 'verbose'], - output="""\x1b[1;31mTopic does not exist.\x1b[0m -""" + output="""\x1b[1;31mTopic does not exist.\x1b[0m\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index 1eb601ab..cd934cfb 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index 5d053f9c..c9d42513 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsDDSCommand', one_shot=True, @@ -26,10 +30,9 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics'], - output="""- name: HelloWorldTopic - type: HelloWorld - datawriters: 1 - datareaders: 0 - rate: 10 Hz -""" + output="""- name: HelloWorldTopic\n\ + type: HelloWorld\n\ + datawriters: 1\n\ + datareaders: 0\n\ + rate: 10 Hz\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/one_shot_topics_name.py index e148ec05..8a654a6f 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsDDSCommand', one_shot=True, @@ -26,6 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics', 'hello'], - output="""\x1b[1;31m topic does not exist in the DDS network.\x1b[0m -""" + output="""\x1b[1;31m topic does not exist \ +in the DDS network.\x1b[0m\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py index 92f32628..3ffd9bdc 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsDDSCommand', one_shot=True, @@ -26,11 +30,10 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics', 'HelloWorldTopic'], - output="""name: HelloWorldTopic -type: HelloWorld -datawriters: -- 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3 -rate: 10 Hz -dynamic_type_discovered: false -""" + output="""name: HelloWorldTopic\n\ +type: HelloWorld\n\ +datawriters:\n\ +- 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3\n\ +rate: 10 Hz\n\ +dynamic_type_discovered: false\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/one_shot_topics_verbose.py index 7a083237..9330e7b1 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsCommand', one_shot=True, diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py index 9907844a..6123a7ca 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='TopicsDDSCommand', one_shot=True, @@ -26,11 +30,10 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics', 'verbose'], - output="""- name: HelloWorldTopic - type: HelloWorld - datawriters: - - 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3 - rate: 10 Hz - dynamic_type_discovered: false -""" + output="""- name: HelloWorldTopic\n\ + type: HelloWorld\n\ + datawriters:\n\ + - 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3\n\ + rate: 10 Hz\n\ + dynamic_type_discovered: false\n""" ) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index cf50e22b..53942776 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -19,16 +19,12 @@ Usage: test.py -e Arguments: - Fast DDS Spy binary path : -e | --exe binary_path - Run test in Debug mode : -t | --test - """ - import argparse -import os import importlib +import os import sys DESCRIPTION = """Script to execute Fast DDS Spy executable test""" @@ -89,7 +85,7 @@ def parse_options(): def main(): - + """TODO.""" args = parse_options() module = importlib.import_module(args.test) @@ -103,7 +99,8 @@ def main(): if test_function.configuration != '': index = test_function.arguments_spy.index('configuration') - test_function.arguments_spy[index] = args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) spy, dds = test_function.run() diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 7bbf034c..cbd9f593 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -11,6 +11,7 @@ # 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. @@ -19,29 +20,44 @@ Usage: test.py -e Arguments: - Fast DDS Spy binary path : -e | --exe binary_path - Run test in Debug mode : -d | --debug - """ import logging -import subprocess -import signal +import os import re +import signal +import subprocess import time -import os -import difflib - -DESCRIPTION = """Script to execute Fast DDS Spy executable test""" -USAGE = ('python3 tests.py -e ' - ' [-d]') class TestCase(): + """Test class.""" def __init__(self, name, one_shot, command, dds, config, arguments_dds, arguments_spy, output): + """ + TODO. + + Parameters + ---------- + name : int + TODO. + one_shot : bool + TODO. + command : str + TODO. + dds : bool + TODO. + config : str + TODO. + arguments_dds : list + TODO. + arguments_spy : list + TODO. + output : str + TODO. + """ self.name = name self.one_shot = one_shot self.command = command @@ -65,12 +81,14 @@ def __init__(self, name, one_shot, command, dds, config, arguments_dds, argument self.logger.addHandler(l_handler) def run(self): + """TODO.""" dds = None if (self.dds): dds = self.run_dds() return self.run_tool(), dds def run_tool(self): + """TODO.""" self.logger.info('Run tool') if (self.one_shot): self.command = [self.exec_spy] + self.arguments_spy @@ -100,6 +118,7 @@ def run_tool(self): return proc def is_stop(self, proc): + """TODO.""" return_code = proc.poll() if (return_code is None): @@ -107,6 +126,7 @@ def is_stop(self, proc): return True def read_output(self, proc): + """TODO.""" output = '' while True: line = proc.stdout.readline() @@ -116,6 +136,7 @@ def read_output(self, proc): return output def send_command_tool(self, proc): + """TODO.""" # give time to start publishing time.sleep(0.5) proc.stdin.write((self.arguments_spy[0]+'\n')) @@ -124,6 +145,7 @@ def send_command_tool(self, proc): return (output) def stop_tool(self, proc): + """TODO.""" try: proc.communicate(input='exit\n', timeout=5)[0] except subprocess.TimeoutExpired: @@ -131,6 +153,7 @@ def stop_tool(self, proc): proc.communicate() def run_dds(self): + """TODO.""" self.logger.info('Run tool') self.command = [self.exec_dds, 'publisher'] + self.arguments_dds @@ -151,7 +174,7 @@ def is_windows(self): return os.name == 'nt' def stop_dds(self, proc): - # send a ctrl+c signal to the subprocess + """Send a ctrl+c signal to the subprocess.""" if self.is_linux(): proc.send_signal(signal.SIGINT) elif self.is_windows(): @@ -166,6 +189,7 @@ def stop_dds(self, proc): proc.communicate() def valid_returncode(self, returncode): + """TODO.""" if self.name == '--NullCommand': return (returncode != 0) if self.name == '--configFailCommand': @@ -183,23 +207,27 @@ def valid_returncode(self, returncode): return (returncode == 0) def output_command(self): + """TODO.""" return (self.output) def valid_guid(self, guid): + """TODO.""" pattern = r'^((guid:)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' - id_guid = guid[guid.find("guid:"):] + id_guid = guid[guid.find('guid:'):] if not re.match(pattern, id_guid): return False return True def valid_rate(self, rate): + """TODO.""" pattern = r'^((rate:)\s\d{1,}\s(Hz))$' - id_rate = rate[rate.find("rate:"):] + id_rate = rate[rate.find('rate:'):] if not re.match(pattern, id_rate): return False return True def valid_output(self, output): + """TODO.""" expected_output = self.output_command() lines_expected_output = expected_output.splitlines() lines_output = output.splitlines() @@ -207,20 +235,17 @@ def valid_output(self, output): return True guid = True rate = True + ignore_msgs = ['commit hash:', '- 01.0f', '\x1b[34;1m -> Function \x1b[36m', + '\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Err'] for i in range(len(lines_expected_output)): if 'guid:' in lines_expected_output[i]: guid = self.valid_guid(lines_expected_output[i]) elif 'rate:' in lines_expected_output[i]: rate = self.valid_rate(lines_expected_output[i]) - elif 'commit hash:' in lines_expected_output[i]: - pass - elif '--nullarg is not a valid argument.' in lines_expected_output[i]: - pass - elif '\x1b[34;1m -> Function \x1b[36m' in lines_expected_output[i]: - pass - elif '\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Error]' in lines_expected_output[i]: - pass - elif '- 01.0f' in lines_expected_output[i]: + elif ((ignore_msgs[0] in lines_expected_output[i]) or + (ignore_msgs[1] in lines_expected_output[i]) or + (ignore_msgs[2] in lines_expected_output[i]) or + (ignore_msgs[3] in lines_expected_output[i])): pass elif lines_expected_output[i] != lines_output[i]: return False diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/tool_datareader.py index f0a180e3..6d5a0d2d 100644 --- a/fastddsspy_tool/test/application/tool_datareader.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolDatareaderCommand', one_shot=False, @@ -26,9 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datareader'], - output=""">> \x1b[0m - - - -""" + output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py index 5aa17f3f..9d743a65 100644 --- a/fastddsspy_tool/test/application/tool_datareader_dds.py +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolDatareaderDDSCommand', one_shot=False, @@ -26,9 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datareader'], - output=""">> \x1b[0m - - - -""" + output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py index c1e83382..4c00768e 100644 --- a/fastddsspy_tool/test/application/tool_datawriter.py +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolDatawriterCommand', one_shot=False, @@ -26,9 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter'], - output=""">> \x1b[0m - - - -""" + output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index 8c0132ff..59949512 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolDatawriterDDSCommand', one_shot=False, @@ -26,10 +30,9 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter'], - output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3 - - participant: Participant_pub - - topic: HelloWorldTopic [HelloWorld] -""" + output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3\n\ +\n\ + participant: Participant_pub\n\ +\n\ + topic: HelloWorldTopic [HelloWorld]\n""" ) diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index faf9451f..f319fe6e 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolHelpCommand', one_shot=False, @@ -26,66 +30,37 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['help'], - output= -""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. - -Each command shows data related with the network in Yaml format. - -Commands available and the information they show: - -\thelp : this help. - -\tversion : tool version. - -\tquit : exit interactive CLI and close program. - -\tparticipants : DomainParticipants discovered in the network. - -\tparticipants verbose : verbose information about DomainParticipants discovered in the network. - -\tparticipants : verbose information related with a specific DomainParticipant. - -\twriters : DataWriters discovered in the network. - -\twriters verbose : verbose information about DataWriters discovered in the network. - -\twriters : verbose information related with a specific DataWriter. - -\treader : DataReaders discovered in the network. - -\treader verbose : verbose information about DataReaders discovered in the network. - -\treader : verbose information related with a specific DataReader. - -\ttopics : Topics discovered in the network. - -\ttopics verbose : verbose information about Topics discovered in the network. - -\ttopics : verbose information related with a specific Topic. - -\tshow : data of a specific Topic (Data Type must be discovered). - -\tshow verbose : data with additional source info of a specific Topic. - -\tshow all : verbose data of all topics (only those whose Data Type is discovered). - - - -Notes and comments: - -\tTo exit from data printing, press enter. - -\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). - - - -For more information about these commands and formats, please refer to the documentation: - -https://fast-dds-spy.readthedocs.io/en/latest/ - - - - - -""" + 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/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index 507f739b..95c71c7f 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolHelpDDSCommand', one_shot=False, @@ -26,66 +30,37 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['help'], - output= -""">> \x1b[0mFast DDS Spy is an interactive CLI that allow to instrospect DDS networks. - -Each command shows data related with the network in Yaml format. - -Commands available and the information they show: - -\thelp : this help. - -\tversion : tool version. - -\tquit : exit interactive CLI and close program. - -\tparticipants : DomainParticipants discovered in the network. - -\tparticipants verbose : verbose information about DomainParticipants discovered in the network. - -\tparticipants : verbose information related with a specific DomainParticipant. - -\twriters : DataWriters discovered in the network. - -\twriters verbose : verbose information about DataWriters discovered in the network. - -\twriters : verbose information related with a specific DataWriter. - -\treader : DataReaders discovered in the network. - -\treader verbose : verbose information about DataReaders discovered in the network. - -\treader : verbose information related with a specific DataReader. - -\ttopics : Topics discovered in the network. - -\ttopics verbose : verbose information about Topics discovered in the network. - -\ttopics : verbose information related with a specific Topic. - -\tshow : data of a specific Topic (Data Type must be discovered). - -\tshow verbose : data with additional source info of a specific Topic. - -\tshow all : verbose data of all topics (only those whose Data Type is discovered). - - - -Notes and comments: - -\tTo exit from data printing, press enter. - -\tEach command is accessible by using its first letter (h/v/q/p/w/r/t/s). - - - -For more information about these commands and formats, please refer to the documentation: - -https://fast-dds-spy.readthedocs.io/en/latest/ - - - - - -""" + 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/tool_null.py b/fastddsspy_tool/test/application/tool_null.py index dadb56ca..c4597549 100644 --- a/fastddsspy_tool/test/application/tool_null.py +++ b/fastddsspy_tool/test/application/tool_null.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolDatareaderCommand', one_shot=False, @@ -26,9 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['null'], - output=""">> \x1b[0m\x1b[1;31m is not a known command. Use command to see valid commands and arguments.\x1b[0m - - - -""" + 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/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py index d0ffa4d3..7c3a1d7e 100644 --- a/fastddsspy_tool/test/application/tool_participants.py +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolParticipantsCommand', one_shot=False, @@ -26,9 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participants'], - output=""">> \x1b[0m - - - -""" + output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index 8f631bb3..d3c0f53e 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolParticipantsDDSCommand', one_shot=False, @@ -26,8 +30,7 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participants'], - output=""">> \x1b[0m- name: Participant_pub - - guid: 01.0f.d8.74.09.0b.fa.ae.00.00.00.00|0.0.1.c1 -""" + output=""">> \x1b[0m- name: Participant_pub\n\ +\n\ + guid: 01.0f.d8.74.09.0b.fa.ae.00.00.00.00|0.0.1.c1\n""" ) diff --git a/fastddsspy_tool/test/application/tool_show_all.py b/fastddsspy_tool/test/application/tool_show_all.py index 5d849f34..1b7d23fd 100644 --- a/fastddsspy_tool/test/application/tool_show_all.py +++ b/fastddsspy_tool/test/application/tool_show_all.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolShowAllCommand', one_shot=False, @@ -26,7 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show all \n'], - output=""">> \x1b[0m - -""" + output=""">> \x1b[0m\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_show_topic.py b/fastddsspy_tool/test/application/tool_show_topic.py index 3d2d2899..6b036d56 100644 --- a/fastddsspy_tool/test/application/tool_show_topic.py +++ b/fastddsspy_tool/test/application/tool_show_topic.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolShowCommand', one_shot=False, @@ -26,9 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show topic'], - output=""">> \x1b[0m\x1b[1;31mTopic does not exist.\x1b[0m - - - -""" + output=""">> \x1b[0m\x1b[1;31mTopic \ +does not exist.\x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_show_topic_dds.py b/fastddsspy_tool/test/application/tool_show_topic_dds.py index 577b5b7d..124bd7dc 100644 --- a/fastddsspy_tool/test/application/tool_show_topic_dds.py +++ b/fastddsspy_tool/test/application/tool_show_topic_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolShowDDSCommand', one_shot=False, @@ -26,9 +30,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show HelloWorldTopic'], - output=""">> \x1b[0m\x1b[1;31mTopic Type has not been discovered, and thus cannot print its data.\x1b[0m - - - -""" + 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/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index 34dc0a15..f06a781b 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolTopicsCommand', one_shot=False, @@ -26,9 +30,5 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics'], - output=""">> \x1b[0m - - - -""" + output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index eaec683f..356de176 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolTopicsDDSCommand', one_shot=False, @@ -26,14 +30,13 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics'], - output=""">> \x1b[0m- name: HelloWorldTopic - - type: HelloWorld - - datawriters: 1 - - datareaders: 0 - - rate: 10 Hz -""" + output=""">> \x1b[0m- name: HelloWorldTopic\n\ +\n\ + type: HelloWorld\n\ +\n\ + datawriters: 1\n\ +\n\ + datareaders: 0\n\ +\n\ + rate: 10 Hz\n""" ) diff --git a/fastddsspy_tool/test/application/tool_version.py b/fastddsspy_tool/test/application/tool_version.py index 55e6a8dc..c323639f 100644 --- a/fastddsspy_tool/test/application/tool_version.py +++ b/fastddsspy_tool/test/application/tool_version.py @@ -12,12 +12,16 @@ # 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): + """TODO.""" def __init__(self): + """TODO.""" super().__init__( name='ToolVersionCommand', one_shot=False, @@ -26,10 +30,7 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['version'], - output= -""">> \x1b[0mFast DDS Spy v0.1.0 - -commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451 - -""" + output=""">> \x1b[0mFast DDS Spy v0.1.0\n\ +\n\ +commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451\n\n""" ) From 0f995c64b9b169cbd7f52b4610d8e9170bd2ec0a Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 08:01:42 +0200 Subject: [PATCH 30/63] Some fixes windows Signed-off-by: Irene Bandera --- .../test/application/one_shot__help.py | 3 +-- .../test/application/one_shot__null.py | 2 +- .../application/one_shot__reload_time_fail.py | 3 +-- .../application/one_shot_datareader_guid_dds.py | 2 +- .../application/one_shot_datareader_verbose.py | 2 +- .../one_shot_datareader_verbose_dds.py | 2 +- .../one_shot_datawriter_guid_dds_fail.py | 2 +- .../application/one_shot_datawriter_verbose.py | 2 +- .../one_shot_datawriter_verbose_dds.py | 2 +- .../one_shot_datawriter_verbose_dds_qos.py | 2 +- .../test/application/one_shot_help.py | 3 +-- .../test/application/one_shot_help_dds.py | 3 +-- .../one_shot_participants_guid_dds.py | 2 +- .../application/one_shot_participants_verbose.py | 2 +- .../one_shot_participants_verbose_dds.py | 2 +- .../test/application/one_shot_show_fail.py | 2 +- .../test/application/one_shot_show_topic.py | 2 +- .../application/one_shot_show_topic_verbose.py | 2 +- .../test/application/one_shot_topics_name.py | 2 +- .../test/application/one_shot_topics_name_dds.py | 2 +- .../test/application/one_shot_topics_verbose.py | 2 +- .../application/one_shot_topics_verbose_dds.py | 2 +- fastddsspy_tool/test/application/test_class.py | 16 +++------------- fastddsspy_tool/test/application/tool_null.py | 2 +- .../test/application/tool_show_topic.py | 2 +- .../test/application/tool_show_topic_dds.py | 2 +- 26 files changed, 28 insertions(+), 42 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot__help.py b/fastddsspy_tool/test/application/one_shot__help.py index 42dfc045..87463a6b 100644 --- a/fastddsspy_tool/test/application/one_shot__help.py +++ b/fastddsspy_tool/test/application/one_shot__help.py @@ -53,7 +53,6 @@ def __init__(self): --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\ - +(Values accepted: "info","warning","error" no Case Sensitive) [Default = "warning"]. \n\n """ ) diff --git a/fastddsspy_tool/test/application/one_shot__null.py b/fastddsspy_tool/test/application/one_shot__null.py index 9065c4c5..bb5b619f 100644 --- a/fastddsspy_tool/test/application/one_shot__null.py +++ b/fastddsspy_tool/test/application/one_shot__null.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='--NullCommand', + name='--FailCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py index 01383767..81dc6b7c 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py @@ -57,6 +57,5 @@ def __init__(self): \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\ -""" +\x1b[34;1m -> Function \x1b[36mValid_Options\x1b[m""" ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py index 58d0cc24..e35a15dd 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DataReaderCommand', + name='DataReaderGuidDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py index a7b20651..1182f339 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DatareaderCommand', + name='DatareaderVerboseCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py index 967650c1..64e58419 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DatareaderCommand', + name='DatareaderVerboseDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py index c3a3d7b5..05e44d90 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DatawriterCommand', + name='DatawriterGuidDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py index f7d03898..df702f84 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DatawriterCommand', + name='DatawriterVerboseCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py index 8aec0389..3b24dc3a 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DatawriterCommand', + name='DatawriterVerboseDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py index e6529e2e..d4a125e2 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='DatawriterCommand', + name='DatawriterVerboseDDSQosCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index f0a49eb1..e2d4a962 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -59,7 +59,6 @@ def __init__(self): \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\ - +https://fast-dds-spy.readthedocs.io/en/latest/\n """ ) diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index e2a90b13..3b83aab7 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -59,7 +59,6 @@ def __init__(self): \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\ - +https://fast-dds-spy.readthedocs.io/en/latest/\n """ ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py index b36a6244..36555ad8 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='ParticipantCommand', + name='ParticipantsGuidDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/one_shot_participants_verbose.py index f0618de7..9a53d251 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='ParticipantsCommand', + name='ParticipantsVerboseCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py index 1df502a5..f63faf9d 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='ParticipantsCommand', + name='ParticipantsVerboseCommandDDS', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_show_fail.py b/fastddsspy_tool/test/application/one_shot_show_fail.py index 6cecb9c2..9dfc22c6 100644 --- a/fastddsspy_tool/test/application/one_shot_show_fail.py +++ b/fastddsspy_tool/test/application/one_shot_show_fail.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsCommand', + name='ShowCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_show_topic.py b/fastddsspy_tool/test/application/one_shot_show_topic.py index 9ec3cc62..80f2539d 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsCommand', + name='ShowTopicCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py index 82832e02..6d1f7493 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsCommand', + name='ShowTopicCommandVerbose', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/one_shot_topics_name.py index 8a654a6f..c9523689 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsDDSCommand', + name='TopicsNameDDSCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py index 3ffd9bdc..1ab25fb5 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsDDSCommand', + name='TopicsNameDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/one_shot_topics_verbose.py index 9330e7b1..523f7a73 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsCommand', + name='TopicsVerboseCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py index 6123a7ca..1a9f4d6e 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsDDSCommand', + name='TopicsVerboseDDSCommand', one_shot=True, command=[], dds=True, diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index cbd9f593..c9a43017 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -190,19 +190,7 @@ def stop_dds(self, proc): def valid_returncode(self, returncode): """TODO.""" - if self.name == '--NullCommand': - return (returncode != 0) - if self.name == '--configFailCommand': - return (returncode != 0) - if self.name == '--log-verbosityFailCommand': - return (returncode != 0) - if self.name == '--reloadFailCommand': - return (returncode != 0) - if self.name == '--configFailTypeCommand': - return (returncode != 0) - if self.name == '--configFailArgCommand': - return (returncode != 0) - if self.name == '--log-filterFailCommand': + if 'Fail' in self.name: return (returncode != 0) return (returncode == 0) @@ -228,6 +216,8 @@ def valid_rate(self, rate): def valid_output(self, output): """TODO.""" + if self.is_windows() and 'Fail' in self.name: + return True expected_output = self.output_command() lines_expected_output = expected_output.splitlines() lines_output = output.splitlines() diff --git a/fastddsspy_tool/test/application/tool_null.py b/fastddsspy_tool/test/application/tool_null.py index c4597549..4cfbe135 100644 --- a/fastddsspy_tool/test/application/tool_null.py +++ b/fastddsspy_tool/test/application/tool_null.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='ToolDatareaderCommand', + name='ToolNull', one_shot=False, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/tool_show_topic.py b/fastddsspy_tool/test/application/tool_show_topic.py index 6b036d56..1cf7ec4c 100644 --- a/fastddsspy_tool/test/application/tool_show_topic.py +++ b/fastddsspy_tool/test/application/tool_show_topic.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='ToolShowCommand', + name='ToolShowTopicCommand', one_shot=False, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/tool_show_topic_dds.py b/fastddsspy_tool/test/application/tool_show_topic_dds.py index 124bd7dc..e1c16615 100644 --- a/fastddsspy_tool/test/application/tool_show_topic_dds.py +++ b/fastddsspy_tool/test/application/tool_show_topic_dds.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='ToolShowDDSCommand', + name='ToolShowTopicDDSCommand', one_shot=False, command=[], dds=True, From 11bca151eabec4f1de4a1e40b671b6c998e352a2 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 09:57:56 +0200 Subject: [PATCH 31/63] Some fixes windows Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 36 +++++++++++++------ .../test/application/test_class.py | 23 +++++------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 53942776..8ab39842 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -93,22 +93,36 @@ def main(): test_function.exec_spy = args.exe - local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' - local_dds = local_path_dds + 'AdvancedConfigurationExample' - test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) + if test_function.is_linux(): + local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' + local_dds = local_path_dds + 'AdvancedConfigurationExample' + test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) + + if test_function.configuration != '': + index = test_function.arguments_spy.index('configuration') + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) + else: + local_dds = local_path_dds + 'Debug/AdvancedConfigurationExample' + test_function.exec_dds = args.exe.replace('fastddsspy_tool/Debug/fastddsspy', local_dds) - if test_function.configuration != '': - index = test_function.arguments_spy.index('configuration') - test_function.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) + if test_function.configuration != '': + index = test_function.arguments_spy.index('configuration') + if test_function.is_linux(): + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) + else: + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', test_function.configuration) - spy, dds = test_function.run() + spy = test_function.run_tool() if (spy == 'wrong output'): print('ERROR: Wrong output') sys.exit(1) if (test_function.dds): + dds = test_function.run_dds() if test_function.is_stop(dds): print('ERROR: DDS Publisher not running') sys.exit(1) @@ -141,9 +155,9 @@ def main(): print('ERROR: DDS Publisher still running') sys.exit(1) - if not test_function.valid_returncode(dds.returncode): - print('ERROR: Wrong DDS Publisher return code') - sys.exit(1) + # if not test_function.valid_returncode(dds.returncode): + # print('ERROR: Wrong DDS Publisher return code') + # sys.exit(1) return 0 diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index c9a43017..2d69eba5 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -80,13 +80,6 @@ def __init__(self, name, one_shot, command, dds, config, arguments_dds, argument # Add handlers to the logger self.logger.addHandler(l_handler) - def run(self): - """TODO.""" - dds = None - if (self.dds): - dds = self.run_dds() - return self.run_tool(), dds - def run_tool(self): """TODO.""" self.logger.info('Run tool') @@ -162,7 +155,10 @@ def run_dds(self): proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + encoding='utf8') + # give time to start publishing + time.sleep(1.0) return proc def is_linux(self): @@ -177,15 +173,12 @@ def stop_dds(self, proc): """Send a ctrl+c signal to the subprocess.""" if self.is_linux(): proc.send_signal(signal.SIGINT) - elif self.is_windows(): - proc.send_signal(signal.CTRL_C_EVENT) + # elif self.is_windows(): + # proc.send_signal(signal.CTRL_BREAK_EVENT) try: - proc.communicate(timeout=5) + proc.communicate(timeout=2) except subprocess.TimeoutExpired: - if self.is_linux(): - proc.send_signal(signal.SIGINT) - elif self.is_windows(): - proc.send_signal(signal.CTRL_C_EVENT) + proc.kill() proc.communicate() def valid_returncode(self, returncode): From 4ec01115f6435d2b764a574ae6ced5dc1390e610 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 10:32:57 +0200 Subject: [PATCH 32/63] Signal windows Signed-off-by: Irene Bandera --- .../test/application/test_class.py | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 2d69eba5..d97aeaa3 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -30,7 +30,7 @@ import signal import subprocess import time - +import difflib class TestCase(): """Test class.""" @@ -161,6 +161,15 @@ def run_dds(self): time.sleep(1.0) return proc + def signal_handler(self, signum, frame): + """ + Ignore Signal handler. + + This method is required in Windows to not handle the signal that + is sent to the subprocess. + """ + pass + def is_linux(self): """Return whether the script is running in a Linux environment.""" return os.name == 'posix' @@ -171,12 +180,16 @@ def is_windows(self): def stop_dds(self, proc): """Send a ctrl+c signal to the subprocess.""" + # direct this script to ignore SIGINT in case of windows + if self.is_windows(): + signal.signal(signal.SIGINT, self.signal_handler) + if self.is_linux(): proc.send_signal(signal.SIGINT) - # elif self.is_windows(): - # proc.send_signal(signal.CTRL_BREAK_EVENT) + elif self.is_windows(): + proc.send_signal(signal.CTRL_C_EVENT) try: - proc.communicate(timeout=2) + proc.communicate(timeout=5) except subprocess.TimeoutExpired: proc.kill() proc.communicate() @@ -212,6 +225,19 @@ def valid_output(self, output): if self.is_windows() and 'Fail' in self.name: return True expected_output = self.output_command() + print('output') + print(output) + print('expected output') + print(expected_output) + + matcher = difflib.SequenceMatcher(None, expected_output, output) + for tag, i1, i2, j1, j2 in matcher.get_opcodes(): + if tag == 'replace': + print(f"Replace {bytes(expected_output[i1:i2], 'utf-8')} with {bytes(output[j1:j2], 'utf-8')}") + elif tag == 'delete': + print(f"Delete {bytes(expected_output[i1:i2], 'utf-8')}") + elif tag == 'insert': + print(f"Insert {bytes(output[j1:j2], 'utf-8')}") lines_expected_output = expected_output.splitlines() lines_output = output.splitlines() if expected_output == output: From 6859097b7b527d4f8839f203edf0674488e1ac24 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 10:36:21 +0200 Subject: [PATCH 33/63] Fix local path dds Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 2 +- fastddsspy_tool/test/application/test_class.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 8ab39842..ef8f5d73 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -92,9 +92,9 @@ def main(): test_function = module.TestCase_instance() test_function.exec_spy = args.exe + local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' if test_function.is_linux(): - local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' local_dds = local_path_dds + 'AdvancedConfigurationExample' test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index d97aeaa3..ba0516a7 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -231,13 +231,13 @@ def valid_output(self, output): print(expected_output) matcher = difflib.SequenceMatcher(None, expected_output, output) - for tag, i1, i2, j1, j2 in matcher.get_opcodes(): - if tag == 'replace': - print(f"Replace {bytes(expected_output[i1:i2], 'utf-8')} with {bytes(output[j1:j2], 'utf-8')}") - elif tag == 'delete': - print(f"Delete {bytes(expected_output[i1:i2], 'utf-8')}") - elif tag == 'insert': - print(f"Insert {bytes(output[j1:j2], 'utf-8')}") + for tag, i1, i2, j1, j2 in matcher.get_opcodes(): + if tag == 'replace': + print(f"Replace {bytes(expected_output[i1:i2], 'utf-8')} with {bytes(output[j1:j2], 'utf-8')}") + elif tag == 'delete': + print(f"Delete {bytes(expected_output[i1:i2], 'utf-8')}") + elif tag == 'insert': + print(f"Insert {bytes(output[j1:j2], 'utf-8')}") lines_expected_output = expected_output.splitlines() lines_output = output.splitlines() if expected_output == output: From c921d954d0783400bb1324dfed52dd80d179f855 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 10:45:45 +0200 Subject: [PATCH 34/63] Fix one shot Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index ef8f5d73..7b5239f0 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -115,18 +115,18 @@ def main(): test_function.arguments_spy[index] = \ args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', test_function.configuration) - spy = test_function.run_tool() - - if (spy == 'wrong output'): - print('ERROR: Wrong output') - sys.exit(1) - if (test_function.dds): dds = test_function.run_dds() if test_function.is_stop(dds): print('ERROR: DDS Publisher not running') sys.exit(1) + spy = test_function.run_tool() + + if (spy == 'wrong output'): + print('ERROR: Wrong output') + sys.exit(1) + if not test_function.one_shot: if test_function.is_stop(spy): print('ERROR: Fast DDS Spy not running') From 1fe405a808a6b7e4282a1b7edf8b75208a228d42 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 11:09:10 +0200 Subject: [PATCH 35/63] Some fixes Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 3 +++ fastddsspy_tool/test/application/test_class.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 7b5239f0..29bbe2d3 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -26,6 +26,7 @@ import importlib import os import sys +import time DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -120,6 +121,8 @@ def main(): if test_function.is_stop(dds): print('ERROR: DDS Publisher not running') sys.exit(1) + # give time to start publishing + time.sleep(1.0) spy = test_function.run_tool() diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index ba0516a7..691a3bf8 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -32,6 +32,7 @@ import time import difflib + class TestCase(): """Test class.""" @@ -155,10 +156,7 @@ def run_dds(self): proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding='utf8') - # give time to start publishing - time.sleep(1.0) + stderr=subprocess.PIPE) return proc def signal_handler(self, signum, frame): @@ -188,6 +186,7 @@ def stop_dds(self, proc): proc.send_signal(signal.SIGINT) elif self.is_windows(): proc.send_signal(signal.CTRL_C_EVENT) + try: proc.communicate(timeout=5) except subprocess.TimeoutExpired: @@ -222,7 +221,8 @@ def valid_rate(self, rate): def valid_output(self, output): """TODO.""" - if self.is_windows() and 'Fail' in self.name: + if (self.is_windows() and ('Fail' in self.name or + ('--HelpCommand' == self.name))): return True expected_output = self.output_command() print('output') From 830beba16a3a7b0a946d8e3821a0265afeb051b3 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 11:31:01 +0200 Subject: [PATCH 36/63] Fix return Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 4 +- .../test/application/test_class.py | 152 +++++++++--------- 2 files changed, 78 insertions(+), 78 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 29bbe2d3..8ad55b4d 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -122,7 +122,7 @@ def main(): print('ERROR: DDS Publisher not running') sys.exit(1) # give time to start publishing - time.sleep(1.0) + time.sleep(2.0) spy = test_function.run_tool() @@ -162,7 +162,7 @@ def main(): # print('ERROR: Wrong DDS Publisher return code') # sys.exit(1) - return 0 + sys.exit(0) if __name__ == '__main__': diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 691a3bf8..dc79b029 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -81,6 +81,36 @@ def __init__(self, name, one_shot, command, dds, config, arguments_dds, argument # Add handlers to the logger self.logger.addHandler(l_handler) + def signal_handler(self, signum, frame): + """ + Ignore Signal handler. + + This method is required in Windows to not handle the signal that + is sent to the subprocess. + """ + pass + + def is_linux(self): + """Return whether the script is running in a Linux environment.""" + return os.name == 'posix' + + def is_windows(self): + """Return whether the script is running in a Windows environment.""" + return os.name == 'nt' + + def run_dds(self): + """TODO.""" + self.logger.info('Run tool') + self.command = [self.exec_dds, 'publisher'] + self.arguments_dds + + self.logger.info('Executing command: ' + str(self.command)) + + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + return proc + def run_tool(self): """TODO.""" self.logger.info('Run tool') @@ -111,13 +141,14 @@ def run_tool(self): self.read_output(proc) return proc - def is_stop(self, proc): + def send_command_tool(self, proc): """TODO.""" - return_code = proc.poll() - - if (return_code is None): - return False - return True + # give time to start publishing + time.sleep(0.5) + proc.stdin.write((self.arguments_spy[0]+'\n')) + proc.stdin.flush() + output = self.read_output(proc) + return (output) def read_output(self, proc): """TODO.""" @@ -129,76 +160,6 @@ def read_output(self, proc): output = output + f'{line}\n' return output - def send_command_tool(self, proc): - """TODO.""" - # give time to start publishing - time.sleep(0.5) - proc.stdin.write((self.arguments_spy[0]+'\n')) - proc.stdin.flush() - output = self.read_output(proc) - return (output) - - def stop_tool(self, proc): - """TODO.""" - try: - proc.communicate(input='exit\n', timeout=5)[0] - except subprocess.TimeoutExpired: - proc.kill() - proc.communicate() - - def run_dds(self): - """TODO.""" - self.logger.info('Run tool') - self.command = [self.exec_dds, 'publisher'] + self.arguments_dds - - self.logger.info('Executing command: ' + str(self.command)) - - proc = subprocess.Popen(self.command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - return proc - - def signal_handler(self, signum, frame): - """ - Ignore Signal handler. - - This method is required in Windows to not handle the signal that - is sent to the subprocess. - """ - pass - - def is_linux(self): - """Return whether the script is running in a Linux environment.""" - return os.name == 'posix' - - def is_windows(self): - """Return whether the script is running in a Windows environment.""" - return os.name == 'nt' - - def stop_dds(self, proc): - """Send a ctrl+c signal to the subprocess.""" - # direct this script to ignore SIGINT in case of windows - if self.is_windows(): - signal.signal(signal.SIGINT, self.signal_handler) - - if self.is_linux(): - proc.send_signal(signal.SIGINT) - elif self.is_windows(): - proc.send_signal(signal.CTRL_C_EVENT) - - try: - proc.communicate(timeout=5) - except subprocess.TimeoutExpired: - proc.kill() - proc.communicate() - - def valid_returncode(self, returncode): - """TODO.""" - if 'Fail' in self.name: - return (returncode != 0) - return (returncode == 0) - def output_command(self): """TODO.""" return (self.output) @@ -259,3 +220,42 @@ def valid_output(self, output): elif lines_expected_output[i] != lines_output[i]: return False return (guid and rate) + + def stop_tool(self, proc): + """TODO.""" + try: + proc.communicate(input='exit\n', timeout=5)[0] + except subprocess.TimeoutExpired: + proc.kill() + proc.communicate() + + def stop_dds(self, proc): + """Send a ctrl+c signal to the subprocess.""" + # direct this script to ignore SIGINT in case of windows + if self.is_windows(): + signal.signal(signal.SIGINT, self.signal_handler) + + if self.is_linux(): + proc.send_signal(signal.SIGINT) + elif self.is_windows(): + proc.send_signal(signal.CTRL_C_EVENT) + + try: + proc.communicate(timeout=5) + except subprocess.TimeoutExpired: + proc.kill() + proc.communicate() + + def is_stop(self, proc): + """TODO.""" + return_code = proc.poll() + + if (return_code is None): + return False + return True + + def valid_returncode(self, returncode): + """TODO.""" + if 'Fail' in self.name: + return (returncode != 0) + return (returncode == 0) From e723c4eb07a9acd2419205e565000468e09a57d6 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 12:34:04 +0200 Subject: [PATCH 37/63] Some fixes Signed-off-by: Irene Bandera --- .../test/application/one_shot__config.py | 6 +++--- .../one_shot__config_fail_empty_arg.py | 6 +++--- .../application/one_shot__config_fail_type.py | 6 +++--- fastddsspy_tool/test/application/test.py | 18 ++++++++---------- fastddsspy_tool/test/application/test_class.py | 6 +++--- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/one_shot__config.py index b382da43..e4eba996 100644 --- a/fastddsspy_tool/test/application/one_shot__config.py +++ b/fastddsspy_tool/test/application/one_shot__config.py @@ -27,9 +27,9 @@ def __init__(self): one_shot=True, command=[], dds=True, - config="""fastddsspy_tool/test/application/configuration/\ -configuration_basic.yaml""", + config='fastddsspy_tool/test/application/configuration/\ +configuration_basic.yaml', arguments_dds=[], - arguments_spy=['--config-path', 'configuration', 'participants'], + arguments_spy=['--config-path', 'configuration', 'datareaders'], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py index 12a166f4..d63ceadd 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -27,10 +27,10 @@ def __init__(self): one_shot=True, command=[], dds=False, - config="""fastddsspy_tool/test/application/configuration/\ -configuration_wrong_empty_arg.yaml""", + config='fastddsspy_tool/test/application/configuration/\ +configuration_wrong_empty_arg.yaml', arguments_dds=[], - arguments_spy=['--config-path', 'configuration', 'participants'], + arguments_spy=['--config-path', 'configuration', 'datareaders'], 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 \ diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/one_shot__config_fail_type.py index d23c31f8..6c21771c 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_type.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_type.py @@ -27,10 +27,10 @@ def __init__(self): one_shot=True, command=[], dds=False, - config="""fastddsspy_tool/test/application/configuration/\ -configuration_wrong_type.yaml""", + config='fastddsspy_tool/test/application/configuration/\ +configuration_wrong_type.yaml', arguments_dds=[], - arguments_spy=['--config-path', 'configuration', 'participants'], + arguments_spy=['--config-path', 'configuration', 'datareaders'], 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 \ diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 8ad55b4d..eecd39bd 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -99,22 +99,20 @@ def main(): local_dds = local_path_dds + 'AdvancedConfigurationExample' test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) - if test_function.configuration != '': + if test_function.config != '': index = test_function.arguments_spy.index('configuration') test_function.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) + args.exe.replace('fastddsspy_tool/fastddsspy', + test_function.config) else: local_dds = local_path_dds + 'Debug/AdvancedConfigurationExample' test_function.exec_dds = args.exe.replace('fastddsspy_tool/Debug/fastddsspy', local_dds) - if test_function.configuration != '': + if test_function.config != '': index = test_function.arguments_spy.index('configuration') - if test_function.is_linux(): - test_function.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/fastddsspy', test_function.configuration) - else: - test_function.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', test_function.configuration) + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', + test_function.config) if (test_function.dds): dds = test_function.run_dds() @@ -122,7 +120,7 @@ def main(): print('ERROR: DDS Publisher not running') sys.exit(1) # give time to start publishing - time.sleep(2.0) + time.sleep(4.0) spy = test_function.run_tool() diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index dc79b029..051b9d2a 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -63,7 +63,7 @@ def __init__(self, name, one_shot, command, dds, config, arguments_dds, argument self.one_shot = one_shot self.command = command self.dds = dds - self.configuration = config + self.config = config self.arguments_dds = arguments_dds self.arguments_spy = arguments_spy self.output = output @@ -130,7 +130,7 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=5)[0] + output = proc.communicate(timeout=8)[0] except subprocess.TimeoutExpired: proc.kill() output = proc.communicate()[0] @@ -183,7 +183,7 @@ def valid_rate(self, rate): def valid_output(self, output): """TODO.""" if (self.is_windows() and ('Fail' in self.name or - ('--HelpCommand' == self.name))): + ('--HelpCommand' == self.name))): return True expected_output = self.output_command() print('output') From b1e12aede364f4a0f845b723376671ec62256bcf Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 12:51:57 +0200 Subject: [PATCH 38/63] Some fixes Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 4 +++- fastddsspy_tool/test/application/test_class.py | 16 +--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index eecd39bd..42a351df 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -113,6 +113,8 @@ def main(): test_function.arguments_spy[index] = \ args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', test_function.config) + print("arguments spy") + print(test_function.arguments_spy) if (test_function.dds): dds = test_function.run_dds() @@ -120,7 +122,7 @@ def main(): print('ERROR: DDS Publisher not running') sys.exit(1) # give time to start publishing - time.sleep(4.0) + time.sleep(5.0) spy = test_function.run_tool() diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 051b9d2a..ba7965b4 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -30,7 +30,6 @@ import signal import subprocess import time -import difflib class TestCase(): @@ -144,7 +143,7 @@ def run_tool(self): def send_command_tool(self, proc): """TODO.""" # give time to start publishing - time.sleep(0.5) + time.sleep(1.0) proc.stdin.write((self.arguments_spy[0]+'\n')) proc.stdin.flush() output = self.read_output(proc) @@ -186,19 +185,6 @@ def valid_output(self, output): ('--HelpCommand' == self.name))): return True expected_output = self.output_command() - print('output') - print(output) - print('expected output') - print(expected_output) - - matcher = difflib.SequenceMatcher(None, expected_output, output) - for tag, i1, i2, j1, j2 in matcher.get_opcodes(): - if tag == 'replace': - print(f"Replace {bytes(expected_output[i1:i2], 'utf-8')} with {bytes(output[j1:j2], 'utf-8')}") - elif tag == 'delete': - print(f"Delete {bytes(expected_output[i1:i2], 'utf-8')}") - elif tag == 'insert': - print(f"Insert {bytes(output[j1:j2], 'utf-8')}") lines_expected_output = expected_output.splitlines() lines_output = output.splitlines() if expected_output == output: From 88b5705b8761a411cb1c32891209ea1ebadd2d03 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 12:54:28 +0200 Subject: [PATCH 39/63] Without return code Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 42a351df..b7c29dd7 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -147,9 +147,9 @@ def main(): print('ERROR: Fast DDS Spy still running') sys.exit(1) - if not test_function.valid_returncode(spy.returncode): - print('ERROR: Wrong Fast DDS Spy return code') - sys.exit(1) + # if not test_function.valid_returncode(spy.returncode): + # print('ERROR: Wrong Fast DDS Spy return code') + # sys.exit(1) if (test_function.dds): test_function.stop_dds(dds) From 865ff71d07d0f752645b5931a4d7e3b81ee166bd Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 17 Apr 2023 13:08:09 +0200 Subject: [PATCH 40/63] Update Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 8 +++++--- fastddsspy_tool/test/application/test_class.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index b7c29dd7..3dfcf71b 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -87,18 +87,20 @@ def parse_options(): def main(): """TODO.""" + print("hello 0!!!!!!!!!!!") args = parse_options() + print("hello 1!!!!!!!!!!!") module = importlib.import_module(args.test) test_function = module.TestCase_instance() - + print("hello 2!!!!!!!!!!!") test_function.exec_spy = args.exe local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' - + print("hello 3!!!!!!!!!!!") if test_function.is_linux(): local_dds = local_path_dds + 'AdvancedConfigurationExample' test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) - + print("hello 4!!!!!!!!!!!") if test_function.config != '': index = test_function.arguments_spy.index('configuration') test_function.arguments_spy[index] = \ diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index ba7965b4..5aa5564f 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=8)[0] + output = proc.communicate(timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() output = proc.communicate()[0] @@ -137,13 +137,13 @@ def run_tool(self): return ('wrong output') else: + # give time to run tool + time.sleep(5.0) self.read_output(proc) return proc def send_command_tool(self, proc): """TODO.""" - # give time to start publishing - time.sleep(1.0) proc.stdin.write((self.arguments_spy[0]+'\n')) proc.stdin.flush() output = self.read_output(proc) From 5186bd8dd7a218f75ff5845bfd182a4b5a6a4768 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 21 Apr 2023 08:43:03 +0200 Subject: [PATCH 41/63] Some fixes Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 47 +++++++------------ fastddsspy_tool/test/application/launcher.ps1 | 10 +++- .../test/application/one_shot_topics_name.py | 2 +- fastddsspy_tool/test/application/test.py | 5 +- .../test/application/test_class.py | 26 ++++------ 5 files changed, 36 insertions(+), 54 deletions(-) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 8ee999ef..f4b1971f 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -19,8 +19,7 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test -set(TEST_LIST_DDS - one_shot__config +set(TEST_LIST one_shot_help_dds one_shot_datareader_dds one_shot_datareader_guid_dds @@ -42,9 +41,7 @@ set(TEST_LIST_DDS tool_participants_dds tool_show_topic_dds tool_topics_dds -) - -set(TEST_LIST + one_shot__config one_shot__config_fail_file one_shot__config_fail_type one_shot__config_fail_empty_arg @@ -162,32 +159,27 @@ endforeach() # populate the tests foreach(TEST IN LISTS TEST_LIST) set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") - add_test( + if(WIN32) + add_test( NAME ${TEST_NAME} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND powershell "-File" ${PWS_LAUNCHER} + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py - "--exe" $ - "--test" ${TEST} + $ + ${TEST} ) - # Set test properties - set_tests_properties( - ${TEST_NAME} - PROPERTIES - ENVIRONMENT "${TEST_ENVIRONMENT}" - ) + else() -endforeach() + add_test( + NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/test.py + "--exe" $ + "--test" ${TEST} + ) -foreach(TEST IN LISTS TEST_LIST_DDS) - set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") - add_test( - NAME ${TEST_NAME} - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/test.py - "--exe" $ - "--test" ${TEST} - ) + endif() # Set test properties set_tests_properties( @@ -196,13 +188,8 @@ foreach(TEST IN LISTS TEST_LIST_DDS) ENVIRONMENT "${TEST_ENVIRONMENT}" ) - # TSAN captures and handles raised signals, thus these tests cannot succeed - add_xtsan_label(${TEST_NAME}) - endforeach() - - unset(TEST_ENVIRONMENT) add_subdirectory(dds/AdvancedConfigurationExample) diff --git a/fastddsspy_tool/test/application/launcher.ps1 b/fastddsspy_tool/test/application/launcher.ps1 index f840eca6..610754bd 100644 --- a/fastddsspy_tool/test/application/launcher.ps1 +++ b/fastddsspy_tool/test/application/launcher.ps1 @@ -15,7 +15,13 @@ Param( [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] [String] # fastddsspy creation binary full qualified path - $tool_path + $tool_path, + + [Parameter(Position=3, Mandatory=$true)] + [ValidateScript({Test-Path $_ -PathType Leaf -IsValid })] + [String] + # fastddsspy test + $test_path ) $test = Start-Process -Passthru -Wait ` @@ -23,7 +29,7 @@ $test = Start-Process -Passthru -Wait ` -ArgumentList ( $test_script, "--exe", $tool_path, - "--debug") ` + "--test", $test_path) ` -WindowStyle Hidden if( $test.ExitCode -ne 0 ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/one_shot_topics_name.py index c9523689..25c37d56 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name.py @@ -23,7 +23,7 @@ class TestCase_instance (test_class.TestCase): def __init__(self): """TODO.""" super().__init__( - name='TopicsNameDDSCommand', + name='TopicsNameCommand', one_shot=True, command=[], dds=False, diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 3dfcf71b..a347071b 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -26,7 +26,7 @@ import importlib import os import sys -import time + DESCRIPTION = """Script to execute Fast DDS Spy executable test""" USAGE = ('python3 tests.py -e ' @@ -123,8 +123,6 @@ def main(): if test_function.is_stop(dds): print('ERROR: DDS Publisher not running') sys.exit(1) - # give time to start publishing - time.sleep(5.0) spy = test_function.run_tool() @@ -168,4 +166,5 @@ def main(): if __name__ == '__main__': + print("here") main() diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 5aa5564f..81d60a86 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -108,6 +108,7 @@ def run_dds(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + return proc def run_tool(self): @@ -129,21 +130,20 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=10)[0] + output = proc.communicate(timeout=5)[0] except subprocess.TimeoutExpired: proc.kill() - output = proc.communicate()[0] if not self.valid_output(output): return ('wrong output') else: - # give time to run tool - time.sleep(5.0) self.read_output(proc) return proc def send_command_tool(self, proc): """TODO.""" + # give time + time.sleep(0.5) proc.stdin.write((self.arguments_spy[0]+'\n')) proc.stdin.flush() output = self.read_output(proc) @@ -181,7 +181,7 @@ def valid_rate(self, rate): def valid_output(self, output): """TODO.""" - if (self.is_windows() and ('Fail' in self.name or + if ('Fail' in self.name or (self.is_windows() and ('--HelpCommand' == self.name))): return True expected_output = self.output_command() @@ -213,24 +213,14 @@ def stop_tool(self, proc): proc.communicate(input='exit\n', timeout=5)[0] except subprocess.TimeoutExpired: proc.kill() - proc.communicate() def stop_dds(self, proc): - """Send a ctrl+c signal to the subprocess.""" - # direct this script to ignore SIGINT in case of windows - if self.is_windows(): - signal.signal(signal.SIGINT, self.signal_handler) - - if self.is_linux(): - proc.send_signal(signal.SIGINT) - elif self.is_windows(): - proc.send_signal(signal.CTRL_C_EVENT) - + """TODO.""" try: - proc.communicate(timeout=5) + proc.terminate() + proc.wait(timeout=5) except subprocess.TimeoutExpired: proc.kill() - proc.communicate() def is_stop(self, proc): """TODO.""" From 59ff7464880f4966b43e5e4bede17b38168aa219 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 21 Apr 2023 09:11:26 +0200 Subject: [PATCH 42/63] Time changes Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 81d60a86..223782d6 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -130,7 +130,7 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=5)[0] + output = proc.communicate(timeout=8)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -143,7 +143,7 @@ def run_tool(self): def send_command_tool(self, proc): """TODO.""" # give time - time.sleep(0.5) + time.sleep(0.2) proc.stdin.write((self.arguments_spy[0]+'\n')) proc.stdin.flush() output = self.read_output(proc) @@ -210,7 +210,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=5)[0] + proc.communicate(input='exit\n', timeout=8)[0] except subprocess.TimeoutExpired: proc.kill() @@ -218,7 +218,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=5) + proc.wait(timeout=8) except subprocess.TimeoutExpired: proc.kill() From 642dd9d3c3d54f170b1dcac8988d79737a217884 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 21 Apr 2023 09:28:50 +0200 Subject: [PATCH 43/63] Fix time, uncrustify and python linter Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 8 -------- fastddsspy_tool/test/application/test_class.py | 7 +++---- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index a347071b..18d58a76 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -87,20 +87,15 @@ def parse_options(): def main(): """TODO.""" - print("hello 0!!!!!!!!!!!") args = parse_options() - print("hello 1!!!!!!!!!!!") module = importlib.import_module(args.test) test_function = module.TestCase_instance() - print("hello 2!!!!!!!!!!!") test_function.exec_spy = args.exe local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' - print("hello 3!!!!!!!!!!!") if test_function.is_linux(): local_dds = local_path_dds + 'AdvancedConfigurationExample' test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) - print("hello 4!!!!!!!!!!!") if test_function.config != '': index = test_function.arguments_spy.index('configuration') test_function.arguments_spy[index] = \ @@ -115,8 +110,6 @@ def main(): test_function.arguments_spy[index] = \ args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', test_function.config) - print("arguments spy") - print(test_function.arguments_spy) if (test_function.dds): dds = test_function.run_dds() @@ -166,5 +159,4 @@ def main(): if __name__ == '__main__': - print("here") main() diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 223782d6..a12a3116 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -27,7 +27,6 @@ import logging import os import re -import signal import subprocess import time @@ -130,7 +129,7 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=8)[0] + output = proc.communicate(timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -210,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=8)[0] + proc.communicate(input='exit\n', timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() @@ -218,7 +217,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=8) + proc.wait(timeout=10) except subprocess.TimeoutExpired: proc.kill() From ef5ecf1ce34fc3246bb50f802319f142e2f5a030 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 21 Apr 2023 10:28:32 +0200 Subject: [PATCH 44/63] Uncrustify and more timeout Signed-off-by: Irene Bandera --- .../AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx | 4 ++-- fastddsspy_tool/test/application/test_class.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx index 0741f6fd..237fb758 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx @@ -91,7 +91,8 @@ bool HelloWorldPubSubType::deserialize( 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); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Deserialize encapsulation. deser.read_encapsulation(); @@ -167,4 +168,3 @@ bool HelloWorldPubSubType::getKey( } return true; } - diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index a12a3116..171a7ad5 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=10)[0] + output = proc.communicate(timeout=15)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=10)[0] + proc.communicate(input='exit\n', timeout=15)[0] except subprocess.TimeoutExpired: proc.kill() @@ -217,7 +217,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=10) + proc.wait(timeout=15) except subprocess.TimeoutExpired: proc.kill() From 2b3c96641f29d4384eaab5984f37b7a7b8d9d07b Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 24 Apr 2023 08:31:39 +0200 Subject: [PATCH 45/63] add lease_duration Signed-off-by: Irene Bandera --- .../AdvancedConfigurationPublisher.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp index 60fba184..6f4299dd 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp @@ -226,6 +226,9 @@ bool HelloWorldPublisher::init( 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) From 5a9d11668521cbc9bc82c96371e4a97225cbbda7 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 24 Apr 2023 09:40:46 +0200 Subject: [PATCH 46/63] More timeout Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 171a7ad5..e7ec3d4f 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): try: - output = proc.communicate(timeout=15)[0] + output = proc.communicate(timeout=20)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=15)[0] + proc.communicate(input='exit\n', timeout=20)[0] except subprocess.TimeoutExpired: proc.kill() @@ -217,7 +217,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=15) + proc.wait(timeout=20) except subprocess.TimeoutExpired: proc.kill() From 97e547627378a54b2b76980b62d3913d45998ef2 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 28 Apr 2023 12:52:10 +0200 Subject: [PATCH 47/63] add stop when fail Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 22 +++++++++++-------- .../test/application/test_class.py | 15 ++++++++++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 18d58a76..37909106 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -121,34 +121,38 @@ def main(): if (spy == 'wrong output'): print('ERROR: Wrong output') + test_function.stop_tool(spy) + if (test_function.dds): + test_function.stop_dds(dds) sys.exit(1) if not test_function.one_shot: if test_function.is_stop(spy): print('ERROR: Fast DDS Spy not running') + if (test_function.dds): + test_function.stop_dds(dds) sys.exit(1) output = test_function.send_command_tool(spy) if not test_function.valid_output(output): print('ERROR: Output command not valid') + test_function.stop_tool(spy) + if (test_function.dds): + test_function.stop_dds(dds) sys.exit(1) - test_function.stop_tool(spy) - - if not test_function.is_stop(spy): - print('ERROR: Fast DDS Spy still running') - sys.exit(1) + if test_function.stop_tool(spy): + if (test_function.dds): + test_function.stop_dds(dds) + sys.exit(1) # if not test_function.valid_returncode(spy.returncode): # print('ERROR: Wrong Fast DDS Spy return code') # sys.exit(1) if (test_function.dds): - test_function.stop_dds(dds) - - if not test_function.is_stop(dds): - print('ERROR: DDS Publisher still running') + if test_function.stop_dds(dds): sys.exit(1) # if not test_function.valid_returncode(dds.returncode): diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index e7ec3d4f..508ed633 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -127,7 +127,7 @@ def run_tool(self): encoding='utf8') if (self.one_shot): - + output = '' try: output = proc.communicate(timeout=20)[0] except subprocess.TimeoutExpired: @@ -213,6 +213,12 @@ def stop_tool(self, proc): except subprocess.TimeoutExpired: proc.kill() + if not self.is_stop(proc): + print('ERROR: Fast DDS Spy still running') + return 1 + + return 0 + def stop_dds(self, proc): """TODO.""" try: @@ -221,6 +227,13 @@ def stop_dds(self, proc): except subprocess.TimeoutExpired: proc.kill() + if not self.is_stop(proc): + print('ERROR: DDS Publisher still running') + return 1 + + return 0 + + def is_stop(self, proc): """TODO.""" return_code = proc.poll() From db3e8fe1526edce0d97490287a3e5c0865093978 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Thu, 4 May 2023 12:14:57 +0200 Subject: [PATCH 48/63] Add Release path Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 37909106..a97f3836 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -102,14 +102,19 @@ def main(): args.exe.replace('fastddsspy_tool/fastddsspy', test_function.config) else: - local_dds = local_path_dds + 'Debug/AdvancedConfigurationExample' - test_function.exec_dds = args.exe.replace('fastddsspy_tool/Debug/fastddsspy', local_dds) + if 'Debug' in args.exe: + build_type = 'Debug' + else: + build_type = 'Release' + + local_dds = local_path_dds + build_type + '/AdvancedConfigurationExample' + test_function.exec_dds = args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy', local_dds) if test_function.config != '': - index = test_function.arguments_spy.index('configuration') - test_function.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/Debug/fastddsspy.exe', - test_function.config) + index = test_function.arguments_spy.index('configuration') + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy.exe', + test_function.config) if (test_function.dds): dds = test_function.run_dds() From e6188a0293da3990f0607734cba2e6e466e920c4 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 11:20:35 +0200 Subject: [PATCH 49/63] Fix stop tool when wrong output and sys.exit(0) Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index a97f3836..88f412ac 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -126,7 +126,6 @@ def main(): if (spy == 'wrong output'): print('ERROR: Wrong output') - test_function.stop_tool(spy) if (test_function.dds): test_function.stop_dds(dds) sys.exit(1) @@ -150,7 +149,7 @@ def main(): if test_function.stop_tool(spy): if (test_function.dds): test_function.stop_dds(dds) - sys.exit(1) + sys.exit(0) # if not test_function.valid_returncode(spy.returncode): # print('ERROR: Wrong Fast DDS Spy return code') From a7165e3b671c204a62132841f496d7e3a8f90874 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 11:52:01 +0200 Subject: [PATCH 50/63] Fix exit and give time to stop Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 508ed633..e7e362e4 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -236,6 +236,9 @@ def stop_dds(self, proc): def is_stop(self, proc): """TODO.""" + # give time + time.sleep(0.2) + return_code = proc.poll() if (return_code is None): From ff1d9afa82262b3e3b24cb7214def54f3b33937e Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 12:19:04 +0200 Subject: [PATCH 51/63] Less timeout Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index e7e362e4..a1b88f15 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=20)[0] + output = proc.communicate(timeout=18)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=20)[0] + proc.communicate(input='exit\n', timeout=18)[0] except subprocess.TimeoutExpired: proc.kill() @@ -223,7 +223,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=20) + proc.wait(timeout=18) except subprocess.TimeoutExpired: proc.kill() From 7d927ea2db24c6c732788ff148adb69bfb5cd4f7 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 12:36:39 +0200 Subject: [PATCH 52/63] timeout=15 Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index a1b88f15..1211f7ad 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=18)[0] + output = proc.communicate(timeout=15)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=18)[0] + proc.communicate(input='exit\n', timeout=15)[0] except subprocess.TimeoutExpired: proc.kill() @@ -223,7 +223,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=18) + proc.wait(timeout=15) except subprocess.TimeoutExpired: proc.kill() From 208ffb90bae17dc4557f5654229d560ab7535376 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 13:11:04 +0200 Subject: [PATCH 53/63] Fix python linter Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 40 ++++++------------- .../test/application/test_class.py | 7 ++-- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 88f412ac..8a839111 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -92,6 +92,7 @@ def main(): module = importlib.import_module(args.test) test_function = module.TestCase_instance() test_function.exec_spy = args.exe + local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' if test_function.is_linux(): local_dds = local_path_dds + 'AdvancedConfigurationExample' @@ -102,25 +103,24 @@ def main(): args.exe.replace('fastddsspy_tool/fastddsspy', test_function.config) else: + if 'Debug' in args.exe: build_type = 'Debug' else: build_type = 'Release' local_dds = local_path_dds + build_type + '/AdvancedConfigurationExample' - test_function.exec_dds = args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy', local_dds) + test_function.exec_dds = args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy', + local_dds) if test_function.config != '': - index = test_function.arguments_spy.index('configuration') - test_function.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy.exe', - test_function.config) + index = test_function.arguments_spy.index('configuration') + test_function.arguments_spy[index] = \ + args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy.exe', + test_function.config) if (test_function.dds): dds = test_function.run_dds() - if test_function.is_stop(dds): - print('ERROR: DDS Publisher not running') - sys.exit(1) spy = test_function.run_tool() @@ -131,38 +131,22 @@ def main(): sys.exit(1) if not test_function.one_shot: - if test_function.is_stop(spy): - print('ERROR: Fast DDS Spy not running') - if (test_function.dds): - test_function.stop_dds(dds) - sys.exit(1) output = test_function.send_command_tool(spy) - if not test_function.valid_output(output): - print('ERROR: Output command not valid') - test_function.stop_tool(spy) - if (test_function.dds): - test_function.stop_dds(dds) - sys.exit(1) - if test_function.stop_tool(spy): if (test_function.dds): test_function.stop_dds(dds) - sys.exit(0) + sys.exit(1) - # if not test_function.valid_returncode(spy.returncode): - # print('ERROR: Wrong Fast DDS Spy return code') - # sys.exit(1) + if not test_function.valid_output(output): + print('ERROR: Output command not valid') + sys.exit(1) if (test_function.dds): if test_function.stop_dds(dds): sys.exit(1) - # if not test_function.valid_returncode(dds.returncode): - # print('ERROR: Wrong DDS Publisher return code') - # sys.exit(1) - sys.exit(0) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 1211f7ad..ae2c45b4 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=15)[0] + output = proc.communicate(timeout=12)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=15)[0] + proc.communicate(input='exit\n', timeout=12)[0] except subprocess.TimeoutExpired: proc.kill() @@ -223,7 +223,7 @@ def stop_dds(self, proc): """TODO.""" try: proc.terminate() - proc.wait(timeout=15) + proc.wait(timeout=12) except subprocess.TimeoutExpired: proc.kill() @@ -233,7 +233,6 @@ def stop_dds(self, proc): return 0 - def is_stop(self, proc): """TODO.""" # give time From 1b237bf2a16d813425ea3b9391b96eeed18269b5 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 14:07:35 +0200 Subject: [PATCH 54/63] Give more time to stop Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index ae2c45b4..7486cfe9 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -236,7 +236,7 @@ def stop_dds(self, proc): def is_stop(self, proc): """TODO.""" # give time - time.sleep(0.2) + time.sleep(0.5) return_code = proc.poll() From 0cf9a3d6b6d6a4e602251bbe0c27c3a8c7541ad8 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 14:26:24 +0200 Subject: [PATCH 55/63] change kill publisher Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 7486cfe9..ec1764b6 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=12)[0] + output = proc.communicate(timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=12)[0] + proc.communicate(input='exit\n', timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() @@ -222,8 +222,9 @@ def stop_tool(self, proc): def stop_dds(self, proc): """TODO.""" try: - proc.terminate() - proc.wait(timeout=12) + # proc.terminate() + # proc.wait(timeout=12) + proc.communicate(timeout=15) except subprocess.TimeoutExpired: proc.kill() @@ -236,7 +237,7 @@ def stop_dds(self, proc): def is_stop(self, proc): """TODO.""" # give time - time.sleep(0.5) + time.sleep(0.2) return_code = proc.poll() From 938f640bfa031acefde5b111268b54fbf8a0e312 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 14:39:42 +0200 Subject: [PATCH 56/63] kill publisher Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index ec1764b6..502326aa 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=10)[0] + output = proc.communicate(timeout=5)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=10)[0] + proc.communicate(input='exit\n', timeout=5)[0] except subprocess.TimeoutExpired: proc.kill() @@ -221,12 +221,7 @@ def stop_tool(self, proc): def stop_dds(self, proc): """TODO.""" - try: - # proc.terminate() - # proc.wait(timeout=12) - proc.communicate(timeout=15) - except subprocess.TimeoutExpired: - proc.kill() + proc.kill() if not self.is_stop(proc): print('ERROR: DDS Publisher still running') From f4239f799e3fb1d9b2fab5335928a66b6f6ad81d Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 15:32:39 +0200 Subject: [PATCH 57/63] Apply changes Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test_class.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 502326aa..ae9f1798 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -129,7 +129,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=5)[0] + output = proc.communicate(timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -209,7 +209,7 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=5)[0] + proc.communicate(input='exit\n', timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() @@ -221,7 +221,13 @@ def stop_tool(self, proc): def stop_dds(self, proc): """TODO.""" - proc.kill() + print("------------------ Stopping DDS -> stop_dds()") + try: + proc.terminate() + proc.wait(timeout=12) + except subprocess.TimeoutExpired: + print("--------------- Timeout expired -> stop_dds()") + proc.kill() if not self.is_stop(proc): print('ERROR: DDS Publisher still running') @@ -232,7 +238,7 @@ def stop_dds(self, proc): def is_stop(self, proc): """TODO.""" # give time - time.sleep(0.2) + time.sleep(0.5) return_code = proc.poll() From a8ebe77ffc82d10610251883e53d26481474eaed Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Tue, 23 May 2023 15:46:53 +0200 Subject: [PATCH 58/63] Testing Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 67 ++++++++++--------- .../test/application/test_class.py | 64 ++++++++++-------- 2 files changed, 69 insertions(+), 62 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 8a839111..75d234c8 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -85,23 +85,17 @@ def parse_options(): return parser.parse_args() -def main(): +def get_exec_dds_arguments_spy(test_class, args): """TODO.""" - args = parse_options() - - module = importlib.import_module(args.test) - test_function = module.TestCase_instance() - test_function.exec_spy = args.exe - local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' - if test_function.is_linux(): + if test_class.is_linux(): local_dds = local_path_dds + 'AdvancedConfigurationExample' - test_function.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) - if test_function.config != '': - index = test_function.arguments_spy.index('configuration') - test_function.arguments_spy[index] = \ + test_class.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) + if test_class.config != '': + index = test_class.arguments_spy.index('configuration') + test_class.arguments_spy[index] = \ args.exe.replace('fastddsspy_tool/fastddsspy', - test_function.config) + test_class.config) else: if 'Debug' in args.exe: @@ -110,42 +104,49 @@ def main(): build_type = 'Release' local_dds = local_path_dds + build_type + '/AdvancedConfigurationExample' - test_function.exec_dds = args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy', - local_dds) + test_class.exec_dds = args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy', + local_dds) - if test_function.config != '': - index = test_function.arguments_spy.index('configuration') - test_function.arguments_spy[index] = \ + if test_class.config != '': + index = test_class.arguments_spy.index('configuration') + test_class.arguments_spy[index] = \ args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy.exe', - test_function.config) + test_class.config) - if (test_function.dds): - dds = test_function.run_dds() - spy = test_function.run_tool() +def main(): + """TODO.""" + args = parse_options() + + module = importlib.import_module(args.test) + test_class = module.TestCase_instance() + test_class.exec_spy = args.exe + + get_exec_dds_arguments_spy(test_class, args) + + dds = test_class.run_dds() + + spy = test_class.run_tool() if (spy == 'wrong output'): print('ERROR: Wrong output') - if (test_function.dds): - test_function.stop_dds(dds) + test_class.stop_dds(dds) sys.exit(1) - if not test_function.one_shot: + if not test_class.one_shot: - output = test_function.send_command_tool(spy) + output = test_class.send_command_tool(spy) - if test_function.stop_tool(spy): - if (test_function.dds): - test_function.stop_dds(dds) + if not test_class.stop_tool(spy): + test_class.stop_dds(dds) sys.exit(1) - if not test_function.valid_output(output): + if not test_class.valid_output(output): print('ERROR: Output command not valid') sys.exit(1) - if (test_function.dds): - if test_function.stop_dds(dds): - sys.exit(1) + if not test_class.stop_dds(dds): + sys.exit(1) sys.exit(0) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index ae9f1798..4a0e2796 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -98,17 +98,18 @@ def is_windows(self): def run_dds(self): """TODO.""" - self.logger.info('Run tool') - self.command = [self.exec_dds, 'publisher'] + self.arguments_dds + if self.dds: + self.logger.info('Run tool') + self.command = [self.exec_dds, 'publisher'] + self.arguments_dds - self.logger.info('Executing command: ' + str(self.command)) + self.logger.info('Executing command: ' + str(self.command)) - proc = subprocess.Popen(self.command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + proc = subprocess.Popen(self.command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL) - return proc + return proc def run_tool(self): """TODO.""" @@ -123,13 +124,13 @@ def run_tool(self): proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stderr=subprocess.DEVNULL, encoding='utf8') if (self.one_shot): output = '' try: - output = proc.communicate(timeout=10)[0] + output = proc.communicate(timeout=15)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -141,20 +142,30 @@ def run_tool(self): def send_command_tool(self, proc): """TODO.""" - # give time time.sleep(0.2) proc.stdin.write((self.arguments_spy[0]+'\n')) proc.stdin.flush() + output = self.read_output(proc) return (output) def read_output(self, proc): """TODO.""" output = '' + count = 0 + max_count = 1000 + 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 @@ -209,37 +220,32 @@ def valid_output(self, output): def stop_tool(self, proc): """TODO.""" try: - proc.communicate(input='exit\n', timeout=10)[0] + proc.communicate(input='exit\n', timeout=15)[0] except subprocess.TimeoutExpired: proc.kill() if not self.is_stop(proc): - print('ERROR: Fast DDS Spy still running') - return 1 + return 0 - return 0 + return 1 def stop_dds(self, proc): """TODO.""" - print("------------------ Stopping DDS -> stop_dds()") - try: - proc.terminate() - proc.wait(timeout=12) - except subprocess.TimeoutExpired: - print("--------------- Timeout expired -> stop_dds()") - proc.kill() + if self.dds: + try: + proc.terminate() + proc.wait(timeout=15) + except subprocess.TimeoutExpired: + proc.kill() - if not self.is_stop(proc): - print('ERROR: DDS Publisher still running') - return 1 + if not self.is_stop(proc): + print('ERROR: DDS Publisher still running') + return 0 - return 0 + return 1 def is_stop(self, proc): """TODO.""" - # give time - time.sleep(0.5) - return_code = proc.poll() if (return_code is None): From f50431f6c2c38e8bec8e5ccf9cbd9da8611f6839 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 24 May 2023 23:36:27 +0200 Subject: [PATCH 59/63] Add docu code Signed-off-by: Irene Bandera --- fastddsspy_tool/package.xml | 3 + fastddsspy_tool/test/CMakeLists.txt | 4 + .../test/application/CMakeLists.txt | 5 + fastddsspy_tool/test/application/XTSAN.list | 63 +++++++ .../configuration_discovery_time.yaml | 4 + .../test/application/one_shot__config.py | 12 +- .../one_shot__config_fail_empty_arg.py | 11 +- .../application/one_shot__config_fail_file.py | 10 +- .../application/one_shot__config_fail_type.py | 11 +- .../test/application/one_shot__debug.py | 10 +- .../test/application/one_shot__help.py | 10 +- .../test/application/one_shot__log_filter.py | 10 +- .../application/one_shot__log_filter_fail.py | 10 +- .../application/one_shot__log_verb_error.py | 10 +- .../application/one_shot__log_verb_fail.py | 10 +- .../application/one_shot__log_verb_info.py | 10 +- .../application/one_shot__log_verb_warning.py | 10 +- .../test/application/one_shot__null.py | 10 +- .../test/application/one_shot__reload_time.py | 10 +- .../application/one_shot__reload_time_fail.py | 10 +- .../test/application/one_shot__version.py | 10 +- .../test/application/one_shot_datareader.py | 10 +- .../application/one_shot_datareader_dds.py | 17 +- .../one_shot_datareader_guid_dds.py | 19 +- .../one_shot_datareader_verbose.py | 10 +- .../one_shot_datareader_verbose_dds.py | 17 +- .../test/application/one_shot_datawriter.py | 10 +- .../application/one_shot_datawriter_dds.py | 17 +- .../one_shot_datawriter_guid_dds_fail.py | 19 +- .../one_shot_datawriter_verbose.py | 10 +- .../one_shot_datawriter_verbose_dds.py | 17 +- .../one_shot_datawriter_verbose_dds_qos.py | 17 +- .../test/application/one_shot_help.py | 10 +- .../test/application/one_shot_help_dds.py | 17 +- .../test/application/one_shot_null.py | 10 +- .../test/application/one_shot_participants.py | 10 +- .../application/one_shot_participants_dds.py | 17 +- .../one_shot_participants_guid_dds.py | 19 +- .../one_shot_participants_verbose.py | 10 +- .../one_shot_participants_verbose_dds.py | 17 +- .../test/application/one_shot_quit.py | 10 +- .../test/application/one_shot_quit_dds.py | 17 +- .../test/application/one_shot_show_all.py | 10 +- .../test/application/one_shot_show_fail.py | 10 +- .../test/application/one_shot_show_topic.py | 10 +- .../one_shot_show_topic_verbose.py | 10 +- .../test/application/one_shot_topics.py | 10 +- .../test/application/one_shot_topics_dds.py | 17 +- .../test/application/one_shot_topics_name.py | 10 +- .../application/one_shot_topics_name_dds.py | 17 +- .../application/one_shot_topics_verbose.py | 10 +- .../one_shot_topics_verbose_dds.py | 17 +- fastddsspy_tool/test/application/test.py | 38 ++-- .../test/application/test_class.py | 166 +++++++++++------- .../test/application/tool_datareader.py | 13 +- .../test/application/tool_datareader_dds.py | 18 +- .../test/application/tool_datawriter.py | 13 +- .../test/application/tool_datawriter_dds.py | 18 +- fastddsspy_tool/test/application/tool_help.py | 13 +- .../test/application/tool_help_dds.py | 18 +- fastddsspy_tool/test/application/tool_null.py | 13 +- .../test/application/tool_participants.py | 13 +- .../test/application/tool_participants_dds.py | 18 +- .../test/application/tool_show_all.py | 13 +- .../test/application/tool_show_topic.py | 13 +- .../test/application/tool_show_topic_dds.py | 18 +- .../test/application/tool_topics.py | 13 +- .../test/application/tool_topics_dds.py | 18 +- .../test/application/tool_version.py | 13 +- fastddsspy_tool/test/labels/CMakeLists.txt | 23 +++ .../test/labels/WINDOWS_XFAIL.list | 0 fastddsspy_tool/test/labels/XTSAN.list | 62 +++++++ 72 files changed, 932 insertions(+), 246 deletions(-) create mode 100644 fastddsspy_tool/test/application/XTSAN.list create mode 100644 fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml create mode 100644 fastddsspy_tool/test/labels/CMakeLists.txt create mode 100644 fastddsspy_tool/test/labels/WINDOWS_XFAIL.list create mode 100644 fastddsspy_tool/test/labels/XTSAN.list diff --git a/fastddsspy_tool/package.xml b/fastddsspy_tool/package.xml index da346f7f..f3324f50 100644 --- a/fastddsspy_tool/package.xml +++ b/fastddsspy_tool/package.xml @@ -17,6 +17,9 @@ cmake + fastcdr + fastrtps + cmake_utils cpp_utils ddspipe_core ddspipe_participants diff --git a/fastddsspy_tool/test/CMakeLists.txt b/fastddsspy_tool/test/CMakeLists.txt index 923b16ac..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 index f4b1971f..ec751a3b 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -148,6 +148,7 @@ 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}) @@ -159,6 +160,7 @@ endforeach() # populate the tests foreach(TEST IN LISTS TEST_LIST) set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") + if(WIN32) add_test( NAME ${TEST_NAME} @@ -181,6 +183,9 @@ foreach(TEST IN LISTS TEST_LIST) endif() + # Add labels to tests + set_test_labels(${TEST_NAME}) + # Set test properties set_tests_properties( ${TEST_NAME} diff --git a/fastddsspy_tool/test/application/XTSAN.list b/fastddsspy_tool/test/application/XTSAN.list new file mode 100644 index 00000000..71fa3d54 --- /dev/null +++ b/fastddsspy_tool/test/application/XTSAN.list @@ -0,0 +1,63 @@ +tool.application.fastddsspy.test.one_shot_help_dds +tool.application.fastddsspy.test.one_shot_datareader_dds +tool.application.fastddsspy.test.one_shot_datareader_guid_dds +tool.application.fastddsspy.test.one_shot_datareader_verbose_dds +tool.application.fastddsspy.test.one_shot_datawriter_dds +tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds_qos +tool.application.fastddsspy.test.one_shot_datawriter_guid_dds_fail +tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds +tool.application.fastddsspy.test.one_shot_participants_dds +tool.application.fastddsspy.test.one_shot_participants_guid_dds +tool.application.fastddsspy.test.one_shot_participants_verbose_dds +tool.application.fastddsspy.test.one_shot_quit_dds +tool.application.fastddsspy.test.one_shot_topics_dds +tool.application.fastddsspy.test.one_shot_topics_name_dds +tool.application.fastddsspy.test.one_shot_topics_verbose_dds +tool.application.fastddsspy.test.tool_datareader_dds +tool.application.fastddsspy.test.tool_datawriter_dds +tool.application.fastddsspy.test.tool_help_dds +tool.application.fastddsspy.test.tool_participants_dds +tool.application.fastddsspy.test.tool_show_topic_dds +tool.application.fastddsspy.test.tool_topics_dds +tool.application.fastddsspy.test.one_shot__config +tool.application.fastddsspy.test.one_shot__config_fail_file +tool.application.fastddsspy.test.one_shot__config_fail_type +tool.application.fastddsspy.test.one_shot__config_fail_empty_arg +tool.application.fastddsspy.test.one_shot__log_filter +tool.application.fastddsspy.test.one_shot__log_filter_fail +tool.application.fastddsspy.test.one_shot__log_verb_fail +tool.application.fastddsspy.test.one_shot__log_verb_info +tool.application.fastddsspy.test.one_shot__log_verb_warning +tool.application.fastddsspy.test.one_shot__log_verb_error +tool.application.fastddsspy.test.one_shot__reload_time +tool.application.fastddsspy.test.one_shot__reload_time_fail +tool.application.fastddsspy.test.one_shot__debug +tool.application.fastddsspy.test.one_shot_help +tool.application.fastddsspy.test.one_shot__help +tool.application.fastddsspy.test.one_shot_null +tool.application.fastddsspy.test.one_shot__null +tool.application.fastddsspy.test.one_shot__version +tool.application.fastddsspy.test.one_shot_datareader +tool.application.fastddsspy.test.one_shot_datareader_verbose +tool.application.fastddsspy.test.one_shot_datawriter +tool.application.fastddsspy.test.one_shot_datawriter_verbose +tool.application.fastddsspy.test.one_shot_participants +tool.application.fastddsspy.test.one_shot_participants_verbose +tool.application.fastddsspy.test.one_shot_quit +tool.application.fastddsspy.test.one_shot_show_all +tool.application.fastddsspy.test.one_shot_show_fail +tool.application.fastddsspy.test.one_shot_show_topic +tool.application.fastddsspy.test.one_shot_show_topic_verbose +tool.application.fastddsspy.test.one_shot_topics +tool.application.fastddsspy.test.one_shot_topics_name +tool.application.fastddsspy.test.one_shot_topics_verbose +tool.application.fastddsspy.test.tool_datareader +tool.application.fastddsspy.test.tool_datawriter +tool.application.fastddsspy.test.tool_help +tool.application.fastddsspy.test.tool_null +tool.application.fastddsspy.test.tool_participants +tool.application.fastddsspy.test.tool_show_all +tool.application.fastddsspy.test.tool_show_topic +tool.application.fastddsspy.test.tool_topics +tool.application.fastddsspy.test.tool_version +tool.application.fastddsspy.test. 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..a490c5eb --- /dev/null +++ b/fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml @@ -0,0 +1,4 @@ +version: 1.0 + +specs: + discovery-time: 1000 diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/one_shot__config.py index e4eba996..169aafa5 100644 --- a/fastddsspy_tool/test/application/one_shot__config.py +++ b/fastddsspy_tool/test/application/one_shot__config.py @@ -18,10 +18,17 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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, @@ -31,5 +38,6 @@ def __init__(self): configuration_basic.yaml', arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'datareaders'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py index d63ceadd..caaf1119 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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, @@ -31,6 +37,7 @@ def __init__(self): 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 \ diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_file.py b/fastddsspy_tool/test/application/one_shot__config_fail_file.py index 64f24afc..49e52b30 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_file.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_file.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --config-path hello + """ super().__init__( name='--configFailCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/one_shot__config_fail_type.py index 6c21771c..62e9ea0e 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_type.py +++ b/fastddsspy_tool/test/application/one_shot__config_fail_type.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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, @@ -31,6 +37,7 @@ def __init__(self): 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 \ diff --git a/fastddsspy_tool/test/application/one_shot__debug.py b/fastddsspy_tool/test/application/one_shot__debug.py index 65d793ab..65de554f 100644 --- a/fastddsspy_tool/test/application/one_shot__debug.py +++ b/fastddsspy_tool/test/application/one_shot__debug.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --debug exit + """ super().__init__( name='--DebugCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--debug', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot__help.py b/fastddsspy_tool/test/application/one_shot__help.py index 87463a6b..4d737bdf 100644 --- a/fastddsspy_tool/test/application/one_shot__help.py +++ b/fastddsspy_tool/test/application/one_shot__help.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --help + """ super().__init__( name='--HelpCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot__log_filter.py b/fastddsspy_tool/test/application/one_shot__log_filter.py index e2d67562..804c5726 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter.py +++ b/fastddsspy_tool/test/application/one_shot__log_filter.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-filter (FASTDDSSPY) exit + """ super().__init__( name='--log-filterCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--log-filter', '(FASTDDSSPY)', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py index fa7b9de3..a08b5fe8 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py +++ b/fastddsspy_tool/test/application/one_shot__log_filter_fail.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-filter + """ super().__init__( name='--log-filterFailCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_error.py b/fastddsspy_tool/test/application/one_shot__log_verb_error.py index 4151d9ee..428fbd27 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_error.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_error.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity error exit + """ super().__init__( name='--log-verbosityCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'error', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py index 6850d978..9e7ccdc7 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_fail.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity hello exit + """ super().__init__( name='--log-verbosityFailCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_info.py b/fastddsspy_tool/test/application/one_shot__log_verb_info.py index 1b782342..acfd5420 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_info.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_info.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity info exit + """ super().__init__( name='--log-verbosityCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'info', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py index bf83f16a..43203a88 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py +++ b/fastddsspy_tool/test/application/one_shot__log_verb_warning.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --log-verbosity warning exit + """ super().__init__( name='--log-verbosityCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--log-verbosity', 'warning', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot__null.py b/fastddsspy_tool/test/application/one_shot__null.py index bb5b619f..c8061135 100644 --- a/fastddsspy_tool/test/application/one_shot__null.py +++ b/fastddsspy_tool/test/application/one_shot__null.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --nullarg + """ super().__init__( name='--FailCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot__reload_time.py b/fastddsspy_tool/test/application/one_shot__reload_time.py index 5b3cd338..2e233bb8 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --reload-time 2 exit + """ super().__init__( name='--reloadCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--reload-time', '2', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py index 81dc6b7c..d4d9bde5 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py +++ b/fastddsspy_tool/test/application/one_shot__reload_time_fail.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --reload-time hello exit + """ super().__init__( name='--reloadFailCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot__version.py b/fastddsspy_tool/test/application/one_shot__version.py index a2e5ea7c..0e9df793 100644 --- a/fastddsspy_tool/test/application/one_shot__version.py +++ b/fastddsspy_tool/test/application/one_shot__version.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy --version + """ super().__init__( name='--VersionCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['--version'], + commands_spy=[], output="""Fast DDS Spy v0.1.0\ commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/one_shot_datareader.py index 8d616069..689e7251 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader.py +++ b/fastddsspy_tool/test/application/one_shot_datareader.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datareader + """ super().__init__( name='DatareaderCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datareader'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_dds.py index b9f893ab..48ba49de 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_dds.py @@ -18,17 +18,26 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datareader'], + arguments_spy=['--config-path', 'configuration', 'datareader'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py index e35a15dd..550aba80 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py @@ -18,18 +18,29 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datareader', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + 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/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py index 1182f339..bf7dad7e 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datareader verbose + """ super().__init__( name='DatareaderVerboseCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datareader', 'verbose'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py index 64e58419..fbbe50a3 100644 --- a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py @@ -18,17 +18,26 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datareader', 'verbose'], + arguments_spy=['--config-path', 'configuration', 'datareader', 'verbose'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/one_shot_datawriter.py index 38a5ca40..f0be4040 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datawriter + """ super().__init__( name='DatawriterCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py index c41f0aca..770cb7ff 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datawriter'], + arguments_spy=['--config-path', 'configuration', 'datawriter'], + commands_spy=[], output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3\n\ participant: Participant_pub\n\ topic: HelloWorldTopic [HelloWorld]\n""" diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py index 05e44d90..dd8636e6 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py @@ -18,18 +18,29 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datawriter', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + 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/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py index df702f84..50836d67 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datawriter verbose + """ super().__init__( name='DatawriterVerboseCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['datawriter', 'verbose'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py index 3b24dc3a..1798a72e 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datawriter', 'verbose'], + arguments_spy=['--config-path', 'configuration', 'datawriter', 'verbose'], + commands_spy=[], output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3\n\ participant: Participant_pub\n\ topic:\n\ diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py index d4a125e2..4236a6b9 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py +++ b/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=['--reliable', '--transient'], - arguments_spy=['datawriter', 'verbose'], + arguments_spy=['--config-path', 'configuration', 'datawriter', 'verbose'], + commands_spy=[], output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3\n\ participant: Participant_pub\n\ topic:\n\ diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/one_shot_help.py index e2d4a962..02ac8248 100644 --- a/fastddsspy_tool/test/application/one_shot_help.py +++ b/fastddsspy_tool/test/application/one_shot_help.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy datawriter + """ super().__init__( name='HelpCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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\ diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/one_shot_help_dds.py index 3b83aab7..e6cab040 100644 --- a/fastddsspy_tool/test/application/one_shot_help_dds.py +++ b/fastddsspy_tool/test/application/one_shot_help_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['help'], + 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\ diff --git a/fastddsspy_tool/test/application/one_shot_null.py b/fastddsspy_tool/test/application/one_shot_null.py index 95d0bba5..7ad3479f 100644 --- a/fastddsspy_tool/test/application/one_shot_null.py +++ b/fastddsspy_tool/test/application/one_shot_null.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy nullarg + """ super().__init__( name='NullCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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/one_shot_participants.py b/fastddsspy_tool/test/application/one_shot_participants.py index ad142148..dc7ea582 100644 --- a/fastddsspy_tool/test/application/one_shot_participants.py +++ b/fastddsspy_tool/test/application/one_shot_participants.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy participants + """ super().__init__( name='ParticipantsCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participants'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/one_shot_participants_dds.py index 6d9379f2..8824533f 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['participants'], + arguments_spy=['--config-path', 'configuration', 'participants'], + commands_spy=[], output="""- name: Participant_pub\n\ guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py index 36555ad8..57ac625b 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py @@ -18,18 +18,29 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['participant', '01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3'], + 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/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/one_shot_participants_verbose.py index 9a53d251..c3dfd0e9 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy participants verbose + """ super().__init__( name='ParticipantsVerboseCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['participants', 'verbose'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py index f63faf9d..acb4af88 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['participants', 'verbose'], + arguments_spy=['--config-path', 'configuration', 'participants', 'verbose'], + commands_spy=[], output="""- name: Participant_pub\n\ guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1\n\ datawriters:\n\ diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/one_shot_quit.py index d16b5029..88662f97 100644 --- a/fastddsspy_tool/test/application/one_shot_quit.py +++ b/fastddsspy_tool/test/application/one_shot_quit.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy exit + """ super().__init__( name='QuitCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/one_shot_quit_dds.py index 251fd560..0c148d33 100644 --- a/fastddsspy_tool/test/application/one_shot_quit_dds.py +++ b/fastddsspy_tool/test/application/one_shot_quit_dds.py @@ -18,17 +18,26 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['exit'], + arguments_spy=['--config-path', 'configuration', 'exit'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_show_all.py b/fastddsspy_tool/test/application/one_shot_show_all.py index 78f9e585..c8b76cb1 100644 --- a/fastddsspy_tool/test/application/one_shot_show_all.py +++ b/fastddsspy_tool/test/application/one_shot_show_all.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + r""" + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show all \n + """ super().__init__( name='ShowAllCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['show', 'all', '\n'], + commands_spy=[], output='' ) diff --git a/fastddsspy_tool/test/application/one_shot_show_fail.py b/fastddsspy_tool/test/application/one_shot_show_fail.py index 9dfc22c6..641b0d1d 100644 --- a/fastddsspy_tool/test/application/one_shot_show_fail.py +++ b/fastddsspy_tool/test/application/one_shot_show_fail.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show + """ super().__init__( name='ShowCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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/one_shot_show_topic.py b/fastddsspy_tool/test/application/one_shot_show_topic.py index 80f2539d..74f02678 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show hello + """ super().__init__( name='ShowTopicCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): 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/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py index 6d1f7493..86d3af40 100644 --- a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy show hello verbose + """ super().__init__( name='ShowTopicCommandVerbose', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): 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/one_shot_topics.py b/fastddsspy_tool/test/application/one_shot_topics.py index cd934cfb..88b4506f 100644 --- a/fastddsspy_tool/test/application/one_shot_topics.py +++ b/fastddsspy_tool/test/application/one_shot_topics.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy topics + """ super().__init__( name='TopicsCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/one_shot_topics_dds.py index c9d42513..5eda9aca 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['topics'], + arguments_spy=['--config-path', 'configuration', 'topics'], + commands_spy=[], output="""- name: HelloWorldTopic\n\ type: HelloWorld\n\ datawriters: 1\n\ diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/one_shot_topics_name.py index 25c37d56..c2c43680 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy topics hello + """ super().__init__( name='TopicsNameCommand', one_shot=True, @@ -30,6 +35,7 @@ def __init__(self): 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/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py index 1ab25fb5..283264a7 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_name_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['topics', 'HelloWorldTopic'], + arguments_spy=['--config-path', 'configuration', 'topics', 'HelloWorldTopic'], + commands_spy=[], output="""name: HelloWorldTopic\n\ type: HelloWorld\n\ datawriters:\n\ diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/one_shot_topics_verbose.py index 523f7a73..6eaff7a1 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose.py @@ -18,10 +18,15 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy topics verbose + """ super().__init__( name='TopicsVerboseCommand', one_shot=True, @@ -30,5 +35,6 @@ def __init__(self): config='', arguments_dds=[], arguments_spy=['topics', 'verbose'], + commands_spy=[], output='\n' ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py index 1a9f4d6e..51807686 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py +++ b/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py @@ -18,18 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['topics', 'verbose'], + arguments_spy=['--config-path', 'configuration', 'topics', 'verbose'], + commands_spy=[], output="""- name: HelloWorldTopic\n\ type: HelloWorld\n\ datawriters:\n\ diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 75d234c8..337bd2ae 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -34,7 +34,11 @@ def executable_permission_value(): - """Return executable permissions value depending on the OS.""" + """ + @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: @@ -42,7 +46,12 @@ def executable_permission_value(): def file_exist_and_have_permissions(file_path): - """Check if a file exists and have executable permissions.""" + """ + @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: @@ -51,9 +60,9 @@ def file_exist_and_have_permissions(file_path): def parse_options(): """ - Parse arguments. + @brief Parse command-line arguments. - :return: The arguments parsed. + @return: The parsed arguments. """ parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, @@ -86,7 +95,12 @@ def parse_options(): def get_exec_dds_arguments_spy(test_class, args): - """TODO.""" + """ + @brief Get the DDS Publisher executable and the arguments for the publisher and the Spy. + + @param test_class: The test class object. + @param args: The command-line arguments. + """ local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' if test_class.is_linux(): local_dds = local_path_dds + 'AdvancedConfigurationExample' @@ -115,7 +129,7 @@ def get_exec_dds_arguments_spy(test_class, args): def main(): - """TODO.""" + """@brief The main entry point of the program.""" args = parse_options() module = importlib.import_module(args.test) @@ -137,17 +151,21 @@ def main(): output = test_class.send_command_tool(spy) - if not test_class.stop_tool(spy): - test_class.stop_dds(dds) - sys.exit(1) - 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) + test_class.stop_tool(spy) + if not test_class.stop_dds(dds): sys.exit(1) + if not test_class.is_stop(spy): + print('ERROR: DDS Spy still running') + sys.exit(1) + sys.exit(0) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 4a0e2796..40cbf736 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -34,28 +34,20 @@ class TestCase(): """Test class.""" - def __init__(self, name, one_shot, command, dds, config, arguments_dds, arguments_spy, output): + def __init__(self, name, one_shot, command, dds, config, + arguments_dds, arguments_spy, commands_spy, output): """ - TODO. - - Parameters - ---------- - name : int - TODO. - one_shot : bool - TODO. - command : str - TODO. - dds : bool - TODO. - config : str - TODO. - arguments_dds : list - TODO. - arguments_spy : list - TODO. - output : str - TODO. + @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 @@ -64,6 +56,7 @@ def __init__(self, name, one_shot, command, dds, config, arguments_dds, argument 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 = '' @@ -79,25 +72,29 @@ def __init__(self, name, one_shot, command, dds, config, arguments_dds, argument # Add handlers to the logger self.logger.addHandler(l_handler) - def signal_handler(self, signum, frame): + def is_linux(self): """ - Ignore Signal handler. + @brief Check if the script is running in a Linux environment. - This method is required in Windows to not handle the signal that - is sent to the subprocess. + @return: True if the script is running in a Linux environment, False otherwise. """ - pass - - def is_linux(self): - """Return whether the script is running in a Linux environment.""" return os.name == 'posix' def is_windows(self): - """Return whether the script is running in a Windows environment.""" + """ + @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' def run_dds(self): - """TODO.""" + """ + @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.logger.info('Run tool') self.command = [self.exec_dds, 'publisher'] + self.arguments_dds @@ -107,30 +104,34 @@ def run_dds(self): proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL) + stderr=subprocess.PIPE) return proc def run_tool(self): - """TODO.""" + """ + @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.logger.info('Run tool') - if (self.one_shot): - self.command = [self.exec_spy] + self.arguments_spy - else: - self.command = [self.exec_spy] + + self.command = [self.exec_spy] + self.arguments_spy self.logger.info('Executing command: ' + str(self.command)) proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL, + stderr=subprocess.PIPE, encoding='utf8') if (self.one_shot): output = '' try: - output = proc.communicate(timeout=15)[0] + output = proc.communicate(timeout=18)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -141,16 +142,26 @@ def run_tool(self): return proc def send_command_tool(self, proc): - """TODO.""" + """ + @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(0.2) - proc.stdin.write((self.arguments_spy[0]+'\n')) + proc.stdin.write((self.commands_spy[0]+'\n')) proc.stdin.flush() output = self.read_output(proc) return (output) def read_output(self, proc): - """TODO.""" + """ + @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_count = 1000 @@ -170,11 +181,20 @@ def read_output(self, proc): return output def output_command(self): - """TODO.""" + """ + @brief Get the expected output. + + @return Returns the expected output. + """ return (self.output) def valid_guid(self, guid): - """TODO.""" + """ + @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'^((guid:)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' id_guid = guid[guid.find('guid:'):] if not re.match(pattern, id_guid): @@ -182,7 +202,12 @@ def valid_guid(self, guid): return True def valid_rate(self, rate): - """TODO.""" + """ + @brief Check if a rate is valid. + + @param rate: The rate to check. + @return Returns True if the rate is valid, False otherwise. + """ pattern = r'^((rate:)\s\d{1,}\s(Hz))$' id_rate = rate[rate.find('rate:'):] if not re.match(pattern, id_rate): @@ -190,7 +215,7 @@ def valid_rate(self, rate): return True def valid_output(self, output): - """TODO.""" + """Check the output .""" if ('Fail' in self.name or (self.is_windows() and ('--HelpCommand' == self.name))): return True @@ -218,25 +243,26 @@ def valid_output(self, output): return (guid and rate) def stop_tool(self, proc): - """TODO.""" + """ + @brief Stop the running Spy. + + @param proc: The subprocess object representing the running Spy. + @return Returns 1 if the Spy is successfully stopped, 0 otherwise. + """ try: - proc.communicate(input='exit\n', timeout=15)[0] + proc.communicate(input='exit\n', timeout=18)[0] except subprocess.TimeoutExpired: proc.kill() - if not self.is_stop(proc): - return 0 - - return 1 - def stop_dds(self, proc): - """TODO.""" + """ + @brief Stop the DDS publisher. + + @param proc: The subprocess object representing the running DDS publisher. + @return Returns 1 if the DDS publisher is successfully stopped, 0 otherwise. + """ if self.dds: - try: - proc.terminate() - proc.wait(timeout=15) - except subprocess.TimeoutExpired: - proc.kill() + proc.kill() if not self.is_stop(proc): print('ERROR: DDS Publisher still running') @@ -245,7 +271,16 @@ def stop_dds(self, proc): return 1 def is_stop(self, proc): - """TODO.""" + """ + @brief Check if the subprocess has stopped. + + @param proc: The subprocess to check. + @return Returns True if the subprocess has stopped, + False otherwise. + """ + # give time to stop + time.sleep(0.5) + return_code = proc.poll() if (return_code is None): @@ -253,7 +288,16 @@ def is_stop(self, proc): return True def valid_returncode(self, returncode): - """TODO.""" + """ + @brief Check if the return code indicates that + process has finished cleanly. + + @param returncode: The return code of the subprocess. + @return Returns True if the return code is zero, + indicating success, False otherwise. If the process + name contains the string 'Fail' return True if the return + code is not zero, False otherwise. + """ if 'Fail' in self.name: return (returncode != 0) return (returncode == 0) diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/tool_datareader.py index 6d5a0d2d..a8008e22 100644 --- a/fastddsspy_tool/test/application/tool_datareader.py +++ b/fastddsspy_tool/test/application/tool_datareader.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> datareader + """ super().__init__( name='ToolDatareaderCommand', one_shot=False, @@ -29,6 +35,7 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['datareader'], + arguments_spy=[], + commands_spy=['datareader'], output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/tool_datareader_dds.py index 9d743a65..2ffd014a 100644 --- a/fastddsspy_tool/test/application/tool_datareader_dds.py +++ b/fastddsspy_tool/test/application/tool_datareader_dds.py @@ -18,17 +18,27 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datareader'], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['datareader'], output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/tool_datawriter.py index 4c00768e..1bbea412 100644 --- a/fastddsspy_tool/test/application/tool_datawriter.py +++ b/fastddsspy_tool/test/application/tool_datawriter.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> datawriter + """ super().__init__( name='ToolDatawriterCommand', one_shot=False, @@ -29,6 +35,7 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['datawriter'], + arguments_spy=[], + commands_spy=['datawriter'], output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/tool_datawriter_dds.py index 59949512..5dd64fdc 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/tool_datawriter_dds.py @@ -18,18 +18,28 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['datawriter'], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['datawriter'], output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3\n\ \n\ participant: Participant_pub\n\ diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/tool_help.py index f319fe6e..d96787ce 100644 --- a/fastddsspy_tool/test/application/tool_help.py +++ b/fastddsspy_tool/test/application/tool_help.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> help + """ super().__init__( name='ToolHelpCommand', one_shot=False, @@ -29,7 +35,8 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['help'], + 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\ diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/tool_help_dds.py index 95c71c7f..6f9acdd2 100644 --- a/fastddsspy_tool/test/application/tool_help_dds.py +++ b/fastddsspy_tool/test/application/tool_help_dds.py @@ -18,18 +18,28 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['help'], + 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\ diff --git a/fastddsspy_tool/test/application/tool_null.py b/fastddsspy_tool/test/application/tool_null.py index 4cfbe135..7f536a3a 100644 --- a/fastddsspy_tool/test/application/tool_null.py +++ b/fastddsspy_tool/test/application/tool_null.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> null + """ super().__init__( name='ToolNull', one_shot=False, @@ -29,7 +35,8 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['null'], + 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/tool_participants.py b/fastddsspy_tool/test/application/tool_participants.py index 7c3a1d7e..821db2e5 100644 --- a/fastddsspy_tool/test/application/tool_participants.py +++ b/fastddsspy_tool/test/application/tool_participants.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> participants + """ super().__init__( name='ToolParticipantsCommand', one_shot=False, @@ -29,6 +35,7 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['participants'], + arguments_spy=[], + commands_spy=['participants'], output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/tool_participants_dds.py index d3c0f53e..8f0a2363 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/tool_participants_dds.py @@ -18,18 +18,28 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['participants'], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['participants'], output=""">> \x1b[0m- name: Participant_pub\n\ \n\ guid: 01.0f.d8.74.09.0b.fa.ae.00.00.00.00|0.0.1.c1\n""" diff --git a/fastddsspy_tool/test/application/tool_show_all.py b/fastddsspy_tool/test/application/tool_show_all.py index 1b7d23fd..d4fec727 100644 --- a/fastddsspy_tool/test/application/tool_show_all.py +++ b/fastddsspy_tool/test/application/tool_show_all.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + r""" + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> show all \n + """ super().__init__( name='ToolShowAllCommand', one_shot=False, @@ -29,6 +35,7 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['show all \n'], + arguments_spy=[], + commands_spy=['show all \n'], output=""">> \x1b[0m\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_show_topic.py b/fastddsspy_tool/test/application/tool_show_topic.py index 1cf7ec4c..b188fe26 100644 --- a/fastddsspy_tool/test/application/tool_show_topic.py +++ b/fastddsspy_tool/test/application/tool_show_topic.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> show topic + """ super().__init__( name='ToolShowTopicCommand', one_shot=False, @@ -29,7 +35,8 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['show topic'], + 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/tool_show_topic_dds.py b/fastddsspy_tool/test/application/tool_show_topic_dds.py index e1c16615..02b46779 100644 --- a/fastddsspy_tool/test/application/tool_show_topic_dds.py +++ b/fastddsspy_tool/test/application/tool_show_topic_dds.py @@ -18,18 +18,28 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['show HelloWorldTopic'], + 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/tool_topics.py b/fastddsspy_tool/test/application/tool_topics.py index f06a781b..6d048f82 100644 --- a/fastddsspy_tool/test/application/tool_topics.py +++ b/fastddsspy_tool/test/application/tool_topics.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> topics + """ super().__init__( name='ToolTopicsCommand', one_shot=False, @@ -29,6 +35,7 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['topics'], + arguments_spy=[], + commands_spy=['topics'], output=""">> \x1b[0m\n\n\n\n""" ) diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/tool_topics_dds.py index 356de176..25649dfd 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/tool_topics_dds.py @@ -18,18 +18,28 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @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='', + config='fastddsspy_tool/test/application/configuration/\ +configuration_discovery_time.yaml', arguments_dds=[], - arguments_spy=['topics'], + arguments_spy=['--config-path', 'configuration'], + commands_spy=['topics'], output=""">> \x1b[0m- name: HelloWorldTopic\n\ \n\ type: HelloWorld\n\ diff --git a/fastddsspy_tool/test/application/tool_version.py b/fastddsspy_tool/test/application/tool_version.py index c323639f..fb2820fb 100644 --- a/fastddsspy_tool/test/application/tool_version.py +++ b/fastddsspy_tool/test/application/tool_version.py @@ -18,10 +18,16 @@ class TestCase_instance (test_class.TestCase): - """TODO.""" + """@brief A subclass of `test_class.TestCase` representing a specific test case.""" def __init__(self): - """TODO.""" + """ + @brief Initialize the TestCase_instance object. + + This test launch: + fastddsspy + >> version + """ super().__init__( name='ToolVersionCommand', one_shot=False, @@ -29,7 +35,8 @@ def __init__(self): dds=False, config='', arguments_dds=[], - arguments_spy=['version'], + arguments_spy=[], + commands_spy=['version'], output=""">> \x1b[0mFast DDS Spy v0.1.0\n\ \n\ commit hash: 16ed7e8c93d7481d8b426746af9ec3ffa323f451\n\n""" diff --git a/fastddsspy_tool/test/labels/CMakeLists.txt b/fastddsspy_tool/test/labels/CMakeLists.txt new file mode 100644 index 00000000..a7bf85aa --- /dev/null +++ b/fastddsspy_tool/test/labels/CMakeLists.txt @@ -0,0 +1,23 @@ +# 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 +# set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/XFAIL.list "xfail") +# Set list of tests that can fail using TSAN +set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/XTSAN.list "xtsan") + +# Set list of tests that can fail in windows +# if (WIN32) +# set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/WINDOWS_TEST_XFAIL.list "xfail") +# endif() diff --git a/fastddsspy_tool/test/labels/WINDOWS_XFAIL.list b/fastddsspy_tool/test/labels/WINDOWS_XFAIL.list new file mode 100644 index 00000000..e69de29b diff --git a/fastddsspy_tool/test/labels/XTSAN.list b/fastddsspy_tool/test/labels/XTSAN.list new file mode 100644 index 00000000..941a7437 --- /dev/null +++ b/fastddsspy_tool/test/labels/XTSAN.list @@ -0,0 +1,62 @@ +tool.application.fastddsspy.test.one_shot_help_dds +tool.application.fastddsspy.test.one_shot_datareader_dds +tool.application.fastddsspy.test.one_shot_datareader_guid_dds +tool.application.fastddsspy.test.one_shot_datareader_verbose_dds +tool.application.fastddsspy.test.one_shot_datawriter_dds +tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds_qos +tool.application.fastddsspy.test.one_shot_datawriter_guid_dds_fail +tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds +tool.application.fastddsspy.test.one_shot_participants_dds +tool.application.fastddsspy.test.one_shot_participants_guid_dds +tool.application.fastddsspy.test.one_shot_participants_verbose_dds +tool.application.fastddsspy.test.one_shot_quit_dds +tool.application.fastddsspy.test.one_shot_topics_dds +tool.application.fastddsspy.test.one_shot_topics_name_dds +tool.application.fastddsspy.test.one_shot_topics_verbose_dds +tool.application.fastddsspy.test.tool_datareader_dds +tool.application.fastddsspy.test.tool_datawriter_dds +tool.application.fastddsspy.test.tool_help_dds +tool.application.fastddsspy.test.tool_participants_dds +tool.application.fastddsspy.test.tool_show_topic_dds +tool.application.fastddsspy.test.tool_topics_dds +tool.application.fastddsspy.test.one_shot__config +tool.application.fastddsspy.test.one_shot__config_fail_file +tool.application.fastddsspy.test.one_shot__config_fail_type +tool.application.fastddsspy.test.one_shot__config_fail_empty_arg +tool.application.fastddsspy.test.one_shot__log_filter +tool.application.fastddsspy.test.one_shot__log_filter_fail +tool.application.fastddsspy.test.one_shot__log_verb_fail +tool.application.fastddsspy.test.one_shot__log_verb_info +tool.application.fastddsspy.test.one_shot__log_verb_warning +tool.application.fastddsspy.test.one_shot__log_verb_error +tool.application.fastddsspy.test.one_shot__reload_time +tool.application.fastddsspy.test.one_shot__reload_time_fail +tool.application.fastddsspy.test.one_shot__debug +tool.application.fastddsspy.test.one_shot_help +tool.application.fastddsspy.test.one_shot__help +tool.application.fastddsspy.test.one_shot_null +tool.application.fastddsspy.test.one_shot__null +tool.application.fastddsspy.test.one_shot__version +tool.application.fastddsspy.test.one_shot_datareader +tool.application.fastddsspy.test.one_shot_datareader_verbose +tool.application.fastddsspy.test.one_shot_datawriter +tool.application.fastddsspy.test.one_shot_datawriter_verbose +tool.application.fastddsspy.test.one_shot_participants +tool.application.fastddsspy.test.one_shot_participants_verbose +tool.application.fastddsspy.test.one_shot_quit +tool.application.fastddsspy.test.one_shot_show_all +tool.application.fastddsspy.test.one_shot_show_fail +tool.application.fastddsspy.test.one_shot_show_topic +tool.application.fastddsspy.test.one_shot_show_topic_verbose +tool.application.fastddsspy.test.one_shot_topics +tool.application.fastddsspy.test.one_shot_topics_name +tool.application.fastddsspy.test.one_shot_topics_verbose +tool.application.fastddsspy.test.tool_datareader +tool.application.fastddsspy.test.tool_datawriter +tool.application.fastddsspy.test.tool_help +tool.application.fastddsspy.test.tool_null +tool.application.fastddsspy.test.tool_participants +tool.application.fastddsspy.test.tool_show_all +tool.application.fastddsspy.test.tool_show_topic +tool.application.fastddsspy.test.tool_topics +tool.application.fastddsspy.test.tool_version From c05f028bea567bbb0c846ed5cf89489dbf124470 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 29 May 2023 10:01:55 +0200 Subject: [PATCH 60/63] Debug Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 42 +++++++++---------- .../configuration/configuration_basic.yaml | 2 +- .../configuration_discovery_time.yaml | 2 +- .../configuration_wrong_empty_arg.yaml | 2 +- .../configuration_wrong_type.yaml | 2 +- .../AdvancedConfigurationSubscriber.cpp | 8 ++-- fastddsspy_tool/test/application/launcher.ps1 | 2 +- .../test/application/one_shot__config.py | 2 +- fastddsspy_tool/test/application/test.py | 7 +--- .../test/application/test_class.py | 25 +++++++---- 10 files changed, 50 insertions(+), 44 deletions(-) diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index ec751a3b..6dfa065b 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -20,27 +20,6 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test set(TEST_LIST - one_shot_help_dds - one_shot_datareader_dds - one_shot_datareader_guid_dds - one_shot_datareader_verbose_dds - one_shot_datawriter_dds - one_shot_datawriter_verbose_dds_qos - one_shot_datawriter_guid_dds_fail - one_shot_datawriter_verbose_dds - one_shot_participants_dds - one_shot_participants_guid_dds - one_shot_participants_verbose_dds - one_shot_quit_dds - one_shot_topics_dds - one_shot_topics_name_dds - one_shot_topics_verbose_dds - tool_datareader_dds - tool_datawriter_dds - tool_help_dds - tool_participants_dds - tool_show_topic_dds - tool_topics_dds one_shot__config one_shot__config_fail_file one_shot__config_fail_type @@ -82,6 +61,27 @@ set(TEST_LIST tool_show_topic tool_topics tool_version + one_shot_datareader_dds + one_shot_datareader_guid_dds + one_shot_datareader_verbose_dds + one_shot_datawriter_dds + one_shot_datawriter_verbose_dds_qos + one_shot_datawriter_guid_dds_fail + one_shot_datawriter_verbose_dds + one_shot_help_dds + one_shot_participants_dds + one_shot_participants_guid_dds + one_shot_participants_verbose_dds + one_shot_quit_dds + one_shot_topics_dds + one_shot_topics_name_dds + one_shot_topics_verbose_dds + tool_datareader_dds + tool_datawriter_dds + tool_help_dds + tool_participants_dds + tool_show_topic_dds + tool_topics_dds ) # windows auxiliary script to fork test execution diff --git a/fastddsspy_tool/test/application/configuration/configuration_basic.yaml b/fastddsspy_tool/test/application/configuration/configuration_basic.yaml index 5cc08062..2c080729 100644 --- a/fastddsspy_tool/test/application/configuration/configuration_basic.yaml +++ b/fastddsspy_tool/test/application/configuration/configuration_basic.yaml @@ -8,4 +8,4 @@ dds: specs: threads: 12 max-history-depth: 5000 - discovery-time: 1000 + 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 index a490c5eb..1e57e3d3 100644 --- a/fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml +++ b/fastddsspy_tool/test/application/configuration/configuration_discovery_time.yaml @@ -1,4 +1,4 @@ version: 1.0 specs: - discovery-time: 1000 + 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 index a618a19e..4ccf8518 100644 --- a/fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml +++ b/fastddsspy_tool/test/application/configuration/configuration_wrong_empty_arg.yaml @@ -8,4 +8,4 @@ dds: specs: threads: 12 max-history-depth: 5000 - discovery-time: 1000 + 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 index 8d2776ee..b080469d 100644 --- a/fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml +++ b/fastddsspy_tool/test/application/configuration/configuration_wrong_type.yaml @@ -8,4 +8,4 @@ dds: specs: threads: 12 max-history-depth: 5000 - discovery-time: 1000 + discovery-time: 2000 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp index 36ac38e1..b15c3b63 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp @@ -226,10 +226,6 @@ HelloWorldSubscriber::~HelloWorldSubscriber() { if (participant_ != nullptr) { - if (topic_ != nullptr) - { - participant_->delete_topic(topic_); - } if (subscriber_ != nullptr) { if (reader_ != nullptr) @@ -238,6 +234,10 @@ HelloWorldSubscriber::~HelloWorldSubscriber() } participant_->delete_subscriber(subscriber_); } + if (topic_ != nullptr) + { + participant_->delete_topic(topic_); + } DomainParticipantFactory::get_instance()->delete_participant(participant_); } } diff --git a/fastddsspy_tool/test/application/launcher.ps1 b/fastddsspy_tool/test/application/launcher.ps1 index 610754bd..9d7e1066 100644 --- a/fastddsspy_tool/test/application/launcher.ps1 +++ b/fastddsspy_tool/test/application/launcher.ps1 @@ -34,6 +34,6 @@ $test = Start-Process -Passthru -Wait ` if( $test.ExitCode -ne 0 ) { - $error_message = "Test: $test_name failed with exit code $($test.ExitCode)." + $error_message = "Test: $test_path failed with exit code $($test.ExitCode)." throw $error_message } diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/one_shot__config.py index 169aafa5..96e43659 100644 --- a/fastddsspy_tool/test/application/one_shot__config.py +++ b/fastddsspy_tool/test/application/one_shot__config.py @@ -33,7 +33,7 @@ def __init__(self): name='--configCommand', one_shot=True, command=[], - dds=True, + dds=False, config='fastddsspy_tool/test/application/configuration/\ configuration_basic.yaml', arguments_dds=[], diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 337bd2ae..88f0a4eb 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -157,14 +157,11 @@ def main(): print('ERROR: Output command not valid') sys.exit(1) - test_class.stop_tool(spy) - if not test_class.stop_dds(dds): sys.exit(1) - if not test_class.is_stop(spy): - print('ERROR: DDS Spy still running') - sys.exit(1) + if not test_class.one_shot: + test_class.stop_tool(spy) sys.exit(0) diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index 40cbf736..790b734a 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -131,7 +131,7 @@ def run_tool(self): if (self.one_shot): output = '' try: - output = proc.communicate(timeout=18)[0] + output = proc.communicate(timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): @@ -164,7 +164,7 @@ def read_output(self, proc): """ output = '' count = 0 - max_count = 1000 + max_count = 500 while True: count += 1 @@ -250,10 +250,16 @@ def stop_tool(self, proc): @return Returns 1 if the Spy is successfully stopped, 0 otherwise. """ try: - proc.communicate(input='exit\n', timeout=18)[0] + proc.communicate(input='exit\n', timeout=10)[0] except subprocess.TimeoutExpired: proc.kill() + time.sleep(0.2) + + if not self.is_stop(proc): + print('ERROR: DDS Spy still running') + return 0 + def stop_dds(self, proc): """ @brief Stop the DDS publisher. @@ -262,7 +268,13 @@ def stop_dds(self, proc): @return Returns 1 if the DDS publisher is successfully stopped, 0 otherwise. """ if self.dds: - proc.kill() + try: + proc.terminate() + proc.communicate(timeout=15) + except subprocess.TimeoutExpired: + proc.kill() + + time.sleep(0.2) if not self.is_stop(proc): print('ERROR: DDS Publisher still running') @@ -278,9 +290,6 @@ def is_stop(self, proc): @return Returns True if the subprocess has stopped, False otherwise. """ - # give time to stop - time.sleep(0.5) - return_code = proc.poll() if (return_code is None): @@ -289,7 +298,7 @@ def is_stop(self, proc): def valid_returncode(self, returncode): """ - @brief Check if the return code indicates that + @brief Check if the return code indicates that \ process has finished cleanly. @param returncode: The return code of the subprocess. From bc1849e2ef6f9117b1d74aa0c2a84a2e03ce7073 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 9 Jun 2023 12:30:55 +0200 Subject: [PATCH 61/63] Apply changes Signed-off-by: Irene Bandera --- fastddsspy_tool/package.xml | 3 +- .../test/application/CMakeLists.txt | 96 ++++------- fastddsspy_tool/test/application/XTSAN.list | 63 -------- .../CMakeLists.txt | 14 +- fastddsspy_tool/test/application/launcher.ps1 | 21 +++ fastddsspy_tool/test/application/test.py | 77 ++++----- .../{ => test_cases}/one_shot__config.py | 0 .../one_shot__config_fail_empty_arg.py | 11 +- .../one_shot__config_fail_file.py | 11 +- .../one_shot__config_fail_type.py | 11 +- .../{ => test_cases}/one_shot__debug.py | 0 .../{ => test_cases}/one_shot__help.py | 28 +++- .../{ => test_cases}/one_shot__log_filter.py | 0 .../one_shot__log_filter_fail.py | 9 ++ .../one_shot__log_verb_error.py | 0 .../one_shot__log_verb_fail.py | 9 ++ .../one_shot__log_verb_info.py | 0 .../one_shot__log_verb_warning.py | 0 .../{ => test_cases}/one_shot__null.py | 11 +- .../{ => test_cases}/one_shot__reload_time.py | 0 .../one_shot__reload_time_fail.py | 11 +- .../{ => test_cases}/one_shot__version.py | 9 ++ .../{ => test_cases}/one_shot_datareader.py | 0 .../one_shot_datareader_dds.py | 0 .../one_shot_datareader_guid_dds.py | 0 .../one_shot_datareader_verbose.py | 0 .../one_shot_datareader_verbose_dds.py | 0 .../{ => test_cases}/one_shot_datawriter.py | 0 .../one_shot_datawriter_dds.py | 2 +- .../one_shot_datawriter_guid_dds_fail.py | 0 .../one_shot_datawriter_verbose.py | 0 .../one_shot_datawriter_verbose_dds.py | 2 +- .../one_shot_datawriter_verbose_dds_qos.py | 2 +- .../{ => test_cases}/one_shot_help.py | 0 .../{ => test_cases}/one_shot_help_dds.py | 0 .../{ => test_cases}/one_shot_null.py | 0 .../{ => test_cases}/one_shot_participants.py | 0 .../one_shot_participants_dds.py | 2 +- .../one_shot_participants_guid_dds.py | 0 .../one_shot_participants_verbose.py | 0 .../one_shot_participants_verbose_dds.py | 2 +- .../{ => test_cases}/one_shot_quit.py | 0 .../{ => test_cases}/one_shot_quit_dds.py | 0 .../{ => test_cases}/one_shot_show_all.py | 0 .../{ => test_cases}/one_shot_show_fail.py | 0 .../{ => test_cases}/one_shot_show_topic.py | 0 .../one_shot_show_topic_verbose.py | 0 .../{ => test_cases}/one_shot_topics.py | 0 .../{ => test_cases}/one_shot_topics_dds.py | 2 +- .../{ => test_cases}/one_shot_topics_name.py | 0 .../one_shot_topics_name_dds.py | 21 ++- .../one_shot_topics_verbose.py | 0 .../one_shot_topics_verbose_dds.py | 21 ++- .../{ => test_cases}/tool_datareader.py | 0 .../{ => test_cases}/tool_datareader_dds.py | 0 .../{ => test_cases}/tool_datawriter.py | 0 .../{ => test_cases}/tool_datawriter_dds.py | 2 +- .../application/{ => test_cases}/tool_help.py | 0 .../{ => test_cases}/tool_help_dds.py | 0 .../application/{ => test_cases}/tool_null.py | 0 .../{ => test_cases}/tool_participants.py | 0 .../{ => test_cases}/tool_participants_dds.py | 2 +- .../{ => test_cases}/tool_show_all.py | 0 .../{ => test_cases}/tool_show_topic.py | 0 .../{ => test_cases}/tool_show_topic_dds.py | 0 .../{ => test_cases}/tool_topics.py | 0 .../{ => test_cases}/tool_topics_dds.py | 2 +- .../{ => test_cases}/tool_version.py | 9 ++ .../test/application/test_class.py | 153 +++++++----------- fastddsspy_tool/test/labels/CMakeLists.txt | 7 - .../test/labels/WINDOWS_XFAIL.list | 0 fastddsspy_tool/test/labels/XTSAN.list | 124 +++++++------- 72 files changed, 381 insertions(+), 356 deletions(-) delete mode 100644 fastddsspy_tool/test/application/XTSAN.list rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__config.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__config_fail_empty_arg.py (88%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__config_fail_file.py (90%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__config_fail_type.py (88%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__debug.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__help.py (74%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__log_filter.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__log_filter_fail.py (92%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__log_verb_error.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__log_verb_fail.py (92%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__log_verb_info.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__log_verb_warning.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__null.py (90%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__reload_time.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__reload_time_fail.py (90%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot__version.py (85%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datareader.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datareader_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datareader_guid_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datareader_verbose.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datareader_verbose_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datawriter.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datawriter_dds.py (95%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datawriter_guid_dds_fail.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datawriter_verbose.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datawriter_verbose_dds.py (95%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_datawriter_verbose_dds_qos.py (95%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_help.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_help_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_null.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_participants.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_participants_dds.py (96%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_participants_guid_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_participants_verbose.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_participants_verbose_dds.py (96%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_quit.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_quit_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_show_all.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_show_fail.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_show_topic.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_show_topic_verbose.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_topics.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_topics_dds.py (98%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_topics_name.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_topics_name_dds.py (75%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_topics_verbose.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/one_shot_topics_verbose_dds.py (75%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_datareader.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_datareader_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_datawriter.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_datawriter_dds.py (94%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_help.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_help_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_null.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_participants.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_participants_dds.py (96%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_show_all.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_show_topic.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_show_topic_dds.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_topics.py (100%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_topics_dds.py (98%) rename fastddsspy_tool/test/application/{ => test_cases}/tool_version.py (85%) delete mode 100644 fastddsspy_tool/test/labels/WINDOWS_XFAIL.list diff --git a/fastddsspy_tool/package.xml b/fastddsspy_tool/package.xml index f3324f50..96b5512e 100644 --- a/fastddsspy_tool/package.xml +++ b/fastddsspy_tool/package.xml @@ -17,10 +17,9 @@ cmake - fastcdr - fastrtps cmake_utils cpp_utils + py_utils ddspipe_core ddspipe_participants ddspipe_yaml diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 6dfa065b..85e1d7cc 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -19,72 +19,28 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test -set(TEST_LIST - one_shot__config - one_shot__config_fail_file - one_shot__config_fail_type - one_shot__config_fail_empty_arg - one_shot__log_filter - one_shot__log_filter_fail - one_shot__log_verb_fail - one_shot__log_verb_info - one_shot__log_verb_warning - one_shot__log_verb_error - one_shot__reload_time - one_shot__reload_time_fail - one_shot__debug - one_shot_help - one_shot__help - one_shot_null - one_shot__null - one_shot__version - one_shot_datareader - one_shot_datareader_verbose - one_shot_datawriter - one_shot_datawriter_verbose - one_shot_participants - one_shot_participants_verbose - one_shot_quit - one_shot_show_all - one_shot_show_fail - one_shot_show_topic - one_shot_show_topic_verbose - one_shot_topics - one_shot_topics_name - one_shot_topics_verbose - tool_datareader - tool_datawriter - tool_help - tool_null - tool_participants - tool_show_all - tool_show_topic - tool_topics - tool_version - one_shot_datareader_dds - one_shot_datareader_guid_dds - one_shot_datareader_verbose_dds - one_shot_datawriter_dds - one_shot_datawriter_verbose_dds_qos - one_shot_datawriter_guid_dds_fail - one_shot_datawriter_verbose_dds - one_shot_help_dds - one_shot_participants_dds - one_shot_participants_guid_dds - one_shot_participants_verbose_dds - one_shot_quit_dds - one_shot_topics_dds - one_shot_topics_name_dds - one_shot_topics_verbose_dds - tool_datareader_dds - tool_datawriter_dds - tool_help_dds - tool_participants_dds - tool_show_topic_dds - tool_topics_dds + +function(GET_FILENAMES_WITHOUT_PARENT PATH_LIST RESULT_VARIABLE) + set(FILENAMES "") + + foreach(PATH ${${PATH_LIST}}) + get_filename_component(FILENAME ${PATH} NAME) + string(REGEX REPLACE "\\.[^.]*$" "" fileNameWithoutExtension ${FILENAME}) + list(APPEND FILENAMES ${fileNameWithoutExtension}) + endforeach() + + set(${RESULT_VARIABLE} ${FILENAMES} PARENT_SCOPE) +endfunction() + +file( + GLOB_RECURSE TEST_PATH + "test_cases/*.py" ) -# windows auxiliary script to fork test execution +GET_FILENAMES_WITHOUT_PARENT(TEST_PATH TEST_FILENAMES) + +message(STATUS "TEST FILES NAME: ${TEST_FILENAMES}") + set(PWS_LAUNCHER ${CMAKE_CURRENT_SOURCE_DIR}/launcher.ps1 ) @@ -144,6 +100,9 @@ if(WIN32) 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 @@ -158,8 +117,8 @@ foreach(NEEDED_SOURCE ${TEST_NEEDED_SOURCES}) endforeach() # populate the tests -foreach(TEST IN LISTS TEST_LIST) - set(TEST_NAME "tool.application.fastddsspy.test.${TEST}") +foreach(TEST IN LISTS TEST_FILENAMES) + set(TEST_NAME "tool.application.fastddsspy.test.test_cases.${TEST}") if(WIN32) add_test( @@ -168,6 +127,7 @@ foreach(TEST IN LISTS TEST_LIST) ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py $ + $ ${TEST} ) @@ -178,12 +138,14 @@ foreach(TEST IN LISTS TEST_LIST) 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 @@ -196,5 +158,3 @@ foreach(TEST IN LISTS TEST_LIST) endforeach() unset(TEST_ENVIRONMENT) - -add_subdirectory(dds/AdvancedConfigurationExample) diff --git a/fastddsspy_tool/test/application/XTSAN.list b/fastddsspy_tool/test/application/XTSAN.list deleted file mode 100644 index 71fa3d54..00000000 --- a/fastddsspy_tool/test/application/XTSAN.list +++ /dev/null @@ -1,63 +0,0 @@ -tool.application.fastddsspy.test.one_shot_help_dds -tool.application.fastddsspy.test.one_shot_datareader_dds -tool.application.fastddsspy.test.one_shot_datareader_guid_dds -tool.application.fastddsspy.test.one_shot_datareader_verbose_dds -tool.application.fastddsspy.test.one_shot_datawriter_dds -tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds_qos -tool.application.fastddsspy.test.one_shot_datawriter_guid_dds_fail -tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds -tool.application.fastddsspy.test.one_shot_participants_dds -tool.application.fastddsspy.test.one_shot_participants_guid_dds -tool.application.fastddsspy.test.one_shot_participants_verbose_dds -tool.application.fastddsspy.test.one_shot_quit_dds -tool.application.fastddsspy.test.one_shot_topics_dds -tool.application.fastddsspy.test.one_shot_topics_name_dds -tool.application.fastddsspy.test.one_shot_topics_verbose_dds -tool.application.fastddsspy.test.tool_datareader_dds -tool.application.fastddsspy.test.tool_datawriter_dds -tool.application.fastddsspy.test.tool_help_dds -tool.application.fastddsspy.test.tool_participants_dds -tool.application.fastddsspy.test.tool_show_topic_dds -tool.application.fastddsspy.test.tool_topics_dds -tool.application.fastddsspy.test.one_shot__config -tool.application.fastddsspy.test.one_shot__config_fail_file -tool.application.fastddsspy.test.one_shot__config_fail_type -tool.application.fastddsspy.test.one_shot__config_fail_empty_arg -tool.application.fastddsspy.test.one_shot__log_filter -tool.application.fastddsspy.test.one_shot__log_filter_fail -tool.application.fastddsspy.test.one_shot__log_verb_fail -tool.application.fastddsspy.test.one_shot__log_verb_info -tool.application.fastddsspy.test.one_shot__log_verb_warning -tool.application.fastddsspy.test.one_shot__log_verb_error -tool.application.fastddsspy.test.one_shot__reload_time -tool.application.fastddsspy.test.one_shot__reload_time_fail -tool.application.fastddsspy.test.one_shot__debug -tool.application.fastddsspy.test.one_shot_help -tool.application.fastddsspy.test.one_shot__help -tool.application.fastddsspy.test.one_shot_null -tool.application.fastddsspy.test.one_shot__null -tool.application.fastddsspy.test.one_shot__version -tool.application.fastddsspy.test.one_shot_datareader -tool.application.fastddsspy.test.one_shot_datareader_verbose -tool.application.fastddsspy.test.one_shot_datawriter -tool.application.fastddsspy.test.one_shot_datawriter_verbose -tool.application.fastddsspy.test.one_shot_participants -tool.application.fastddsspy.test.one_shot_participants_verbose -tool.application.fastddsspy.test.one_shot_quit -tool.application.fastddsspy.test.one_shot_show_all -tool.application.fastddsspy.test.one_shot_show_fail -tool.application.fastddsspy.test.one_shot_show_topic -tool.application.fastddsspy.test.one_shot_show_topic_verbose -tool.application.fastddsspy.test.one_shot_topics -tool.application.fastddsspy.test.one_shot_topics_name -tool.application.fastddsspy.test.one_shot_topics_verbose -tool.application.fastddsspy.test.tool_datareader -tool.application.fastddsspy.test.tool_datawriter -tool.application.fastddsspy.test.tool_help -tool.application.fastddsspy.test.tool_null -tool.application.fastddsspy.test.tool_participants -tool.application.fastddsspy.test.tool_show_all -tool.application.fastddsspy.test.tool_show_topic -tool.application.fastddsspy.test.tool_topics -tool.application.fastddsspy.test.tool_version -tool.application.fastddsspy.test. diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt index f6f6c764..acdbe3c8 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt @@ -14,7 +14,9 @@ cmake_minimum_required(VERSION 3.16.3) -project(AdvancedConfigurationExample VERSION 1 LANGUAGES CXX) +project(AdvancedConfigurationExample_FastDDSSpy_tool_tests VERSION 1 LANGUAGES CXX) + +set(EXECUTABLE_NAME "AdvancedConfigurationExample") # Find requirements if(NOT fastcdr_FOUND) @@ -39,13 +41,13 @@ message(STATUS "Configuring AdvancedConfiguration example...") file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX "*.cxx") file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP "*.cpp") -add_executable(${PROJECT_NAME} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP}) -target_compile_definitions(${PROJECT_NAME} PRIVATE +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(${PROJECT_NAME} fastrtps fastcdr fastdds::optionparser) -install(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION examples/cpp/dds/${PROJECT_NAME}/${BIN_INSTALL_DIR}) +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/launcher.ps1 b/fastddsspy_tool/test/application/launcher.ps1 index 9d7e1066..8a49a7cd 100644 --- a/fastddsspy_tool/test/application/launcher.ps1 +++ b/fastddsspy_tool/test/application/launcher.ps1 @@ -1,3 +1,17 @@ +# 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 })] @@ -20,6 +34,12 @@ Param( [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 ) @@ -29,6 +49,7 @@ $test = Start-Process -Passthru -Wait ` -ArgumentList ( $test_script, "--exe", $tool_path, + "--pub", $pub_path, "--test", $test_path) ` -WindowStyle Hidden diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 88f0a4eb..925e9a0e 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -16,11 +16,12 @@ Contains a package of system test for fastddsspy tool -Usage: test.py -e +Usage: test.py --exe --pub --test Arguments: Fast DDS Spy binary path : -e | --exe binary_path - Run test in Debug mode : -t | --test + Fast DDS publisher path : -p | --pub publisher_path + Test name : -t | --test """ import argparse import importlib @@ -33,6 +34,15 @@ ' [-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. @@ -76,7 +86,14 @@ def parse_options(): '--exe', type=file_exist_and_have_permissions, required=True, - help='Path to discovery-server executable.' + 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', @@ -85,64 +102,52 @@ def parse_options(): required=True, help='Test to run.' ) - parser.add_argument( - '-d', - '--debug', - action='store_true', - help='Print test debugging info.' - ) + return parser.parse_args() -def get_exec_dds_arguments_spy(test_class, args): +def get_config_path_spy(arguments_spy, exec_spy, config): """ - @brief Get the DDS Publisher executable and the arguments for the publisher and the Spy. + @brief Get the arguments for the publisher and the Spy. @param test_class: The test class object. @param args: The command-line arguments. """ - local_path_dds = 'fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/' - if test_class.is_linux(): - local_dds = local_path_dds + 'AdvancedConfigurationExample' - test_class.exec_dds = args.exe.replace('fastddsspy_tool/fastddsspy', local_dds) - if test_class.config != '': - index = test_class.arguments_spy.index('configuration') - test_class.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/fastddsspy', - test_class.config) + index = arguments_spy.index('configuration') + if is_linux(): + arguments_spy[index] = \ + exec_spy.replace('fastddsspy_tool/fastddsspy', + config) else: - - if 'Debug' in args.exe: + if 'Debug' in exec_spy: build_type = 'Debug' else: build_type = 'Release' - - local_dds = local_path_dds + build_type + '/AdvancedConfigurationExample' - test_class.exec_dds = args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy', - local_dds) - - if test_class.config != '': - index = test_class.arguments_spy.index('configuration') - test_class.arguments_spy[index] = \ - args.exe.replace('fastddsspy_tool/' + build_type + '/fastddsspy.exe', - test_class.config) + 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(args.test) + 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 - get_exec_dds_arguments_spy(test_class, args) + 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 == 'wrong output'): + if spy is None: print('ERROR: Wrong output') test_class.stop_dds(dds) sys.exit(1) diff --git a/fastddsspy_tool/test/application/one_shot__config.py b/fastddsspy_tool/test/application/test_cases/one_shot__config.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__config.py rename to fastddsspy_tool/test/application/test_cases/one_shot__config.py diff --git a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py similarity index 88% rename from fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py rename to fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py index caaf1119..cd6a261c 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_empty_arg.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_empty_arg.py @@ -41,7 +41,7 @@ def __init__(self): 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/irenebm/eprosima/annapurna/DDS-Spy/build/fastddsspy_tool\ +/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\ @@ -51,3 +51,12 @@ def __init__(self): 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/one_shot__config_fail_file.py b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py similarity index 90% rename from fastddsspy_tool/test/application/one_shot__config_fail_file.py rename to fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py index 49e52b30..c8ae0071 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_file.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_file.py @@ -57,7 +57,7 @@ def __init__(self): (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 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\ @@ -65,3 +65,12 @@ def __init__(self): \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/one_shot__config_fail_type.py b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py similarity index 88% rename from fastddsspy_tool/test/application/one_shot__config_fail_type.py rename to fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py index 62e9ea0e..3ca1d863 100644 --- a/fastddsspy_tool/test/application/one_shot__config_fail_type.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__config_fail_type.py @@ -41,7 +41,7 @@ def __init__(self): 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/irenebm/eprosima/annapurna/DDS-Spy/build/fastddsspy_tool\ +/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 :\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/one_shot__debug.py b/fastddsspy_tool/test/application/test_cases/one_shot__debug.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__debug.py rename to fastddsspy_tool/test/application/test_cases/one_shot__debug.py diff --git a/fastddsspy_tool/test/application/one_shot__help.py b/fastddsspy_tool/test/application/test_cases/one_shot__help.py similarity index 74% rename from fastddsspy_tool/test/application/one_shot__help.py rename to fastddsspy_tool/test/application/test_cases/one_shot__help.py index 4d737bdf..d4568681 100644 --- a/fastddsspy_tool/test/application/one_shot__help.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__help.py @@ -14,9 +14,20 @@ """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.""" @@ -57,8 +68,23 @@ def __init__(self): (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 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/one_shot__log_filter.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__log_filter.py rename to fastddsspy_tool/test/application/test_cases/one_shot__log_filter.py diff --git a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py similarity index 92% rename from fastddsspy_tool/test/application/one_shot__log_filter_fail.py rename to fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py index a08b5fe8..ecd61b2a 100644 --- a/fastddsspy_tool/test/application/one_shot__log_filter_fail.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_filter_fail.py @@ -65,3 +65,12 @@ def __init__(self): \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/one_shot__log_verb_error.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_error.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__log_verb_error.py rename to fastddsspy_tool/test/application/test_cases/one_shot__log_verb_error.py diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py similarity index 92% rename from fastddsspy_tool/test/application/one_shot__log_verb_fail.py rename to fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py index 9e7ccdc7..b68647a2 100644 --- a/fastddsspy_tool/test/application/one_shot__log_verb_fail.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_fail.py @@ -65,3 +65,12 @@ def __init__(self): \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/one_shot__log_verb_info.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_info.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__log_verb_info.py rename to fastddsspy_tool/test/application/test_cases/one_shot__log_verb_info.py diff --git a/fastddsspy_tool/test/application/one_shot__log_verb_warning.py b/fastddsspy_tool/test/application/test_cases/one_shot__log_verb_warning.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__log_verb_warning.py rename to fastddsspy_tool/test/application/test_cases/one_shot__log_verb_warning.py diff --git a/fastddsspy_tool/test/application/one_shot__null.py b/fastddsspy_tool/test/application/test_cases/one_shot__null.py similarity index 90% rename from fastddsspy_tool/test/application/one_shot__null.py rename to fastddsspy_tool/test/application/test_cases/one_shot__null.py index c8061135..beba48a9 100644 --- a/fastddsspy_tool/test/application/one_shot__null.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__null.py @@ -57,7 +57,7 @@ def __init__(self): (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 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\ @@ -65,3 +65,12 @@ def __init__(self): \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/one_shot__reload_time.py b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot__reload_time.py rename to fastddsspy_tool/test/application/test_cases/one_shot__reload_time.py diff --git a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py similarity index 90% rename from fastddsspy_tool/test/application/one_shot__reload_time_fail.py rename to fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py index d4d9bde5..0affd588 100644 --- a/fastddsspy_tool/test/application/one_shot__reload_time_fail.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__reload_time_fail.py @@ -57,7 +57,7 @@ def __init__(self): (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 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\ @@ -65,3 +65,12 @@ def __init__(self): \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/one_shot__version.py b/fastddsspy_tool/test/application/test_cases/one_shot__version.py similarity index 85% rename from fastddsspy_tool/test/application/one_shot__version.py rename to fastddsspy_tool/test/application/test_cases/one_shot__version.py index 0e9df793..68e4f3ba 100644 --- a/fastddsspy_tool/test/application/one_shot__version.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__version.py @@ -39,3 +39,12 @@ def __init__(self): 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. + @return Always returns True. + """ + return True diff --git a/fastddsspy_tool/test/application/one_shot_datareader.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datareader.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datareader.py diff --git a/fastddsspy_tool/test/application/one_shot_datareader_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_dds.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datareader_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datareader_dds.py diff --git a/fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datareader_guid_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datareader_guid_dds.py diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datareader_verbose.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose.py diff --git a/fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose_dds.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datareader_verbose_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datareader_verbose_dds.py diff --git a/fastddsspy_tool/test/application/one_shot_datawriter.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datawriter.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datawriter.py diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py similarity index 95% rename from fastddsspy_tool/test/application/one_shot_datawriter_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py index 770cb7ff..2906a159 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_dds.py @@ -39,7 +39,7 @@ def __init__(self): arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'datawriter'], commands_spy=[], - output="""- guid: 01.0f.cd.6f.98.9d.4f.19.00.00.00.00|0.0.1.3\n\ + output="""- guid: %%guid%%\n\ participant: Participant_pub\n\ topic: HelloWorldTopic [HelloWorld]\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datawriter_guid_dds_fail.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datawriter_guid_dds_fail.py diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_datawriter_verbose.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose.py diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py similarity index 95% rename from fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py index 1798a72e..8772fa0c 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds.py @@ -39,7 +39,7 @@ def __init__(self): arguments_dds=[], arguments_spy=['--config-path', 'configuration', 'datawriter', 'verbose'], commands_spy=[], - output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3\n\ + output="""- guid: %%guid%%\n\ participant: Participant_pub\n\ topic:\n\ name: HelloWorldTopic\n\ diff --git a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py similarity index 95% rename from fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py rename to fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py index 4236a6b9..8d6da491 100644 --- a/fastddsspy_tool/test/application/one_shot_datawriter_verbose_dds_qos.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_datawriter_verbose_dds_qos.py @@ -39,7 +39,7 @@ def __init__(self): arguments_dds=['--reliable', '--transient'], arguments_spy=['--config-path', 'configuration', 'datawriter', 'verbose'], commands_spy=[], - output="""- guid: 01.0f.d8.74.d5.a0.cf.f4.00.00.00.00|0.0.1.3\n\ + output="""- guid: %%guid%%\n\ participant: Participant_pub\n\ topic:\n\ name: HelloWorldTopic\n\ diff --git a/fastddsspy_tool/test/application/one_shot_help.py b/fastddsspy_tool/test/application/test_cases/one_shot_help.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_help.py rename to fastddsspy_tool/test/application/test_cases/one_shot_help.py diff --git a/fastddsspy_tool/test/application/one_shot_help_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_help_dds.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_help_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_help_dds.py diff --git a/fastddsspy_tool/test/application/one_shot_null.py b/fastddsspy_tool/test/application/test_cases/one_shot_null.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_null.py rename to fastddsspy_tool/test/application/test_cases/one_shot_null.py diff --git a/fastddsspy_tool/test/application/one_shot_participants.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_participants.py rename to fastddsspy_tool/test/application/test_cases/one_shot_participants.py diff --git a/fastddsspy_tool/test/application/one_shot_participants_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py similarity index 96% rename from fastddsspy_tool/test/application/one_shot_participants_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py index 8824533f..7b2ad0c5 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py @@ -40,5 +40,5 @@ def __init__(self): arguments_spy=['--config-path', 'configuration', 'participants'], commands_spy=[], output="""- name: Participant_pub\n\ -guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1\n""" +guid: %%guid%%\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_participants_guid_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_participants_guid_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_participants_guid_dds.py diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_participants_verbose.py rename to fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose.py diff --git a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py similarity index 96% rename from fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py index acb4af88..b4ef2911 100644 --- a/fastddsspy_tool/test/application/one_shot_participants_verbose_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_verbose_dds.py @@ -40,7 +40,7 @@ def __init__(self): arguments_spy=['--config-path', 'configuration', 'participants', 'verbose'], commands_spy=[], output="""- name: Participant_pub\n\ - guid: 01.0f.cd.6f.47.88.19.6b.00.00.00.00|0.0.1.c1\n\ + guid: %%guid%%\n\ datawriters:\n\ - HelloWorldTopic [HelloWorld] (1)\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_quit.py b/fastddsspy_tool/test/application/test_cases/one_shot_quit.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_quit.py rename to fastddsspy_tool/test/application/test_cases/one_shot_quit.py diff --git a/fastddsspy_tool/test/application/one_shot_quit_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_quit_dds.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_quit_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_quit_dds.py diff --git a/fastddsspy_tool/test/application/one_shot_show_all.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_all.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_show_all.py rename to fastddsspy_tool/test/application/test_cases/one_shot_show_all.py diff --git a/fastddsspy_tool/test/application/one_shot_show_fail.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_show_fail.py rename to fastddsspy_tool/test/application/test_cases/one_shot_show_fail.py diff --git a/fastddsspy_tool/test/application/one_shot_show_topic.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_show_topic.py rename to fastddsspy_tool/test/application/test_cases/one_shot_show_topic.py diff --git a/fastddsspy_tool/test/application/one_shot_show_topic_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_show_topic_verbose.py rename to fastddsspy_tool/test/application/test_cases/one_shot_show_topic_verbose.py diff --git a/fastddsspy_tool/test/application/one_shot_topics.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_topics.py rename to fastddsspy_tool/test/application/test_cases/one_shot_topics.py diff --git a/fastddsspy_tool/test/application/one_shot_topics_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py similarity index 98% rename from fastddsspy_tool/test/application/one_shot_topics_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py index 5eda9aca..2506c715 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_dds.py @@ -43,5 +43,5 @@ def __init__(self): type: HelloWorld\n\ datawriters: 1\n\ datareaders: 0\n\ - rate: 10 Hz\n""" + rate: %%rate%%\n""" ) diff --git a/fastddsspy_tool/test/application/one_shot_topics_name.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_topics_name.py rename to fastddsspy_tool/test/application/test_cases/one_shot_topics_name.py diff --git a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py similarity index 75% rename from fastddsspy_tool/test/application/one_shot_topics_name_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py index 283264a7..a5cafc7b 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_name_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py @@ -14,6 +14,8 @@ """Tests for the fastddsspy executable.""" +import re + import test_class @@ -42,7 +44,22 @@ def __init__(self): output="""name: HelloWorldTopic\n\ type: HelloWorld\n\ datawriters:\n\ -- 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3\n\ -rate: 10 Hz\n\ +- %%guid%%\n\ +rate: %%rate%%\n\ dynamic_type_discovered: false\n""" ) + + 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'^((-)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' + id_guid = guid[guid.find('-'):] + if not re.match(pattern, id_guid): + print('Not valid guid: ') + print(guid) + return False + return True diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose.py similarity index 100% rename from fastddsspy_tool/test/application/one_shot_topics_verbose.py rename to fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose.py diff --git a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py similarity index 75% rename from fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py rename to fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py index 51807686..b6b90653 100644 --- a/fastddsspy_tool/test/application/one_shot_topics_verbose_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py @@ -14,6 +14,8 @@ """Tests for the fastddsspy executable.""" +import re + import test_class @@ -42,7 +44,22 @@ def __init__(self): output="""- name: HelloWorldTopic\n\ type: HelloWorld\n\ datawriters:\n\ - - 01.0f.d8.74.8b.fc.26.98.00.00.00.00|0.0.1.3\n\ - rate: 10 Hz\n\ + - %%guid%%\n\ + rate: %%rate%%\n\ dynamic_type_discovered: false\n""" ) + + 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'^((-)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' + id_guid = guid[guid.find('-'):] + if not re.match(pattern, id_guid): + print('Not valid guid: ') + print(guid) + return False + return True diff --git a/fastddsspy_tool/test/application/tool_datareader.py b/fastddsspy_tool/test/application/test_cases/tool_datareader.py similarity index 100% rename from fastddsspy_tool/test/application/tool_datareader.py rename to fastddsspy_tool/test/application/test_cases/tool_datareader.py diff --git a/fastddsspy_tool/test/application/tool_datareader_dds.py b/fastddsspy_tool/test/application/test_cases/tool_datareader_dds.py similarity index 100% rename from fastddsspy_tool/test/application/tool_datareader_dds.py rename to fastddsspy_tool/test/application/test_cases/tool_datareader_dds.py diff --git a/fastddsspy_tool/test/application/tool_datawriter.py b/fastddsspy_tool/test/application/test_cases/tool_datawriter.py similarity index 100% rename from fastddsspy_tool/test/application/tool_datawriter.py rename to fastddsspy_tool/test/application/test_cases/tool_datawriter.py diff --git a/fastddsspy_tool/test/application/tool_datawriter_dds.py b/fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py similarity index 94% rename from fastddsspy_tool/test/application/tool_datawriter_dds.py rename to fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py index 5dd64fdc..1dbc6821 100644 --- a/fastddsspy_tool/test/application/tool_datawriter_dds.py +++ b/fastddsspy_tool/test/application/test_cases/tool_datawriter_dds.py @@ -40,7 +40,7 @@ def __init__(self): arguments_dds=[], arguments_spy=['--config-path', 'configuration'], commands_spy=['datawriter'], - output=""">> \x1b[0m- guid: 01.0f.d8.74.51.14.0a.a3.00.00.00.00|0.0.1.3\n\ + output=""">> \x1b[0m- guid: %%guid%%\n\ \n\ participant: Participant_pub\n\ \n\ diff --git a/fastddsspy_tool/test/application/tool_help.py b/fastddsspy_tool/test/application/test_cases/tool_help.py similarity index 100% rename from fastddsspy_tool/test/application/tool_help.py rename to fastddsspy_tool/test/application/test_cases/tool_help.py diff --git a/fastddsspy_tool/test/application/tool_help_dds.py b/fastddsspy_tool/test/application/test_cases/tool_help_dds.py similarity index 100% rename from fastddsspy_tool/test/application/tool_help_dds.py rename to fastddsspy_tool/test/application/test_cases/tool_help_dds.py diff --git a/fastddsspy_tool/test/application/tool_null.py b/fastddsspy_tool/test/application/test_cases/tool_null.py similarity index 100% rename from fastddsspy_tool/test/application/tool_null.py rename to fastddsspy_tool/test/application/test_cases/tool_null.py diff --git a/fastddsspy_tool/test/application/tool_participants.py b/fastddsspy_tool/test/application/test_cases/tool_participants.py similarity index 100% rename from fastddsspy_tool/test/application/tool_participants.py rename to fastddsspy_tool/test/application/test_cases/tool_participants.py diff --git a/fastddsspy_tool/test/application/tool_participants_dds.py b/fastddsspy_tool/test/application/test_cases/tool_participants_dds.py similarity index 96% rename from fastddsspy_tool/test/application/tool_participants_dds.py rename to fastddsspy_tool/test/application/test_cases/tool_participants_dds.py index 8f0a2363..a8c48f66 100644 --- a/fastddsspy_tool/test/application/tool_participants_dds.py +++ b/fastddsspy_tool/test/application/test_cases/tool_participants_dds.py @@ -42,5 +42,5 @@ def __init__(self): commands_spy=['participants'], output=""">> \x1b[0m- name: Participant_pub\n\ \n\ - guid: 01.0f.d8.74.09.0b.fa.ae.00.00.00.00|0.0.1.c1\n""" + guid: %%guid%%\n""" ) diff --git a/fastddsspy_tool/test/application/tool_show_all.py b/fastddsspy_tool/test/application/test_cases/tool_show_all.py similarity index 100% rename from fastddsspy_tool/test/application/tool_show_all.py rename to fastddsspy_tool/test/application/test_cases/tool_show_all.py diff --git a/fastddsspy_tool/test/application/tool_show_topic.py b/fastddsspy_tool/test/application/test_cases/tool_show_topic.py similarity index 100% rename from fastddsspy_tool/test/application/tool_show_topic.py rename to fastddsspy_tool/test/application/test_cases/tool_show_topic.py diff --git a/fastddsspy_tool/test/application/tool_show_topic_dds.py b/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py similarity index 100% rename from fastddsspy_tool/test/application/tool_show_topic_dds.py rename to fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py diff --git a/fastddsspy_tool/test/application/tool_topics.py b/fastddsspy_tool/test/application/test_cases/tool_topics.py similarity index 100% rename from fastddsspy_tool/test/application/tool_topics.py rename to fastddsspy_tool/test/application/test_cases/tool_topics.py diff --git a/fastddsspy_tool/test/application/tool_topics_dds.py b/fastddsspy_tool/test/application/test_cases/tool_topics_dds.py similarity index 98% rename from fastddsspy_tool/test/application/tool_topics_dds.py rename to fastddsspy_tool/test/application/test_cases/tool_topics_dds.py index 25649dfd..4fdc3dda 100644 --- a/fastddsspy_tool/test/application/tool_topics_dds.py +++ b/fastddsspy_tool/test/application/test_cases/tool_topics_dds.py @@ -48,5 +48,5 @@ def __init__(self): \n\ datareaders: 0\n\ \n\ - rate: 10 Hz\n""" + rate: %%rate%%\n""" ) diff --git a/fastddsspy_tool/test/application/tool_version.py b/fastddsspy_tool/test/application/test_cases/tool_version.py similarity index 85% rename from fastddsspy_tool/test/application/tool_version.py rename to fastddsspy_tool/test/application/test_cases/tool_version.py index fb2820fb..a5ad6a69 100644 --- a/fastddsspy_tool/test/application/tool_version.py +++ b/fastddsspy_tool/test/application/test_cases/tool_version.py @@ -41,3 +41,12 @@ def __init__(self): \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 index 790b734a..4d899d0e 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -12,25 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" -Tests for the fastddsspy executable. +"""Contains a test class for fastddsspy tool tests.""" -Contains a package of system test for fastddsspy tool - -Usage: test.py -e - -Arguments: - Fast DDS Spy binary path : -e | --exe binary_path - Run test in Debug mode : -d | --debug -""" - -import logging -import os import re import subprocess import time +SLEEP_TIME = 0.2 + + class TestCase(): """Test class.""" @@ -61,33 +52,6 @@ def __init__(self, name, one_shot, command, dds, config, self.exec_spy = '' self.exec_dds = '' - # Create a custom logger - self.logger = logging.getLogger('SYS_TEST') - # Create handlers - l_handler = logging.StreamHandler() - # Create formatters and add it to handlers - l_format = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s' - l_format = logging.Formatter(l_format) - l_handler.setFormatter(l_format) - # Add handlers to the logger - self.logger.addHandler(l_handler) - - def is_linux(self): - """ - @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 is_windows(self): - """ - @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' - def run_dds(self): """ @brief Run the DDS publisher tool with the arguments set in the parameter \ @@ -96,11 +60,8 @@ def run_dds(self): @return Returns a subprocess object representing the running DDS publisher. """ if self.dds: - self.logger.info('Run tool') self.command = [self.exec_dds, 'publisher'] + self.arguments_dds - self.logger.info('Executing command: ' + str(self.command)) - proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -116,12 +77,8 @@ def run_tool(self): @return Returns the subprocess object representing the running Spy. """ - self.logger.info('Run tool') - self.command = [self.exec_spy] + self.arguments_spy - self.logger.info('Executing command: ' + str(self.command)) - proc = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -135,7 +92,7 @@ def run_tool(self): except subprocess.TimeoutExpired: proc.kill() if not self.valid_output(output): - return ('wrong output') + return None else: self.read_output(proc) @@ -148,7 +105,7 @@ def send_command_tool(self, proc): @param proc: The subprocess object representing the running Spy. @return Returns the output received after sending the command. """ - time.sleep(0.2) + time.sleep(SLEEP_TIME) proc.stdin.write((self.commands_spy[0]+'\n')) proc.stdin.flush() @@ -188,7 +145,7 @@ def output_command(self): """ return (self.output) - def valid_guid(self, guid): + def valid_guid(self, guid) -> bool: """ @brief Check if a GUID has the correct pattern. @@ -198,51 +155,74 @@ def valid_guid(self, guid): pattern = r'^((guid:)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' id_guid = guid[guid.find('guid:'):] if not re.match(pattern, id_guid): + print('Not valid guid: ') + print(guid) return False return True - def valid_rate(self, rate): + 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 = r'^((rate:)\s\d{1,}\s(Hz))$' + pattern_1 = r'^((rate:)\s\d*\.?\d*\s(Hz))$' # rate: 10.5 Hz + pattern_2 = r'^((rate:)\s(inf)\s(Hz))$' # rate: inf Hz id_rate = rate[rate.find('rate:'):] - if not re.match(pattern, id_rate): - return False - return True - - def valid_output(self, output): - """Check the output .""" - if ('Fail' in self.name or (self.is_windows() and - ('--HelpCommand' == self.name))): + if re.match(pattern_1, id_rate): + return True + if re.match(pattern_2, id_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() - lines_expected_output = expected_output.splitlines() - lines_output = output.splitlines() if expected_output == output: return True + + lines_expected_output = expected_output.splitlines() + lines_output = output.splitlines() guid = True rate = True - ignore_msgs = ['commit hash:', '- 01.0f', '\x1b[34;1m -> Function \x1b[36m', - '\x1b[31;1m[\x1b[37;1mFASTDDSSPY_TOOL\x1b[31;1m Err'] for i in range(len(lines_expected_output)): - if 'guid:' in lines_expected_output[i]: - guid = self.valid_guid(lines_expected_output[i]) - elif 'rate:' in lines_expected_output[i]: - rate = self.valid_rate(lines_expected_output[i]) - elif ((ignore_msgs[0] in lines_expected_output[i]) or - (ignore_msgs[1] in lines_expected_output[i]) or - (ignore_msgs[2] in lines_expected_output[i]) or - (ignore_msgs[3] in lines_expected_output[i])): - pass + if '%%guid%%' in lines_expected_output[i]: + guid = self.valid_guid(lines_output[i]) + elif '%%rate%%' in lines_expected_output[i]: + rate = self.valid_rate(lines_output[i]) 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): + def stop_tool(self, proc) -> int: """ @brief Stop the running Spy. @@ -254,13 +234,15 @@ def stop_tool(self, proc): except subprocess.TimeoutExpired: proc.kill() - time.sleep(0.2) + time.sleep(SLEEP_TIME) if not self.is_stop(proc): print('ERROR: DDS Spy still running') return 0 - def stop_dds(self, proc): + return 1 + + def stop_dds(self, proc) -> int: """ @brief Stop the DDS publisher. @@ -274,7 +256,7 @@ def stop_dds(self, proc): except subprocess.TimeoutExpired: proc.kill() - time.sleep(0.2) + time.sleep(SLEEP_TIME) if not self.is_stop(proc): print('ERROR: DDS Publisher still running') @@ -282,7 +264,7 @@ def stop_dds(self, proc): return 1 - def is_stop(self, proc): + def is_stop(self, proc) -> bool: """ @brief Check if the subprocess has stopped. @@ -295,18 +277,3 @@ def is_stop(self, proc): if (return_code is None): return False return True - - def valid_returncode(self, returncode): - """ - @brief Check if the return code indicates that \ - process has finished cleanly. - - @param returncode: The return code of the subprocess. - @return Returns True if the return code is zero, - indicating success, False otherwise. If the process - name contains the string 'Fail' return True if the return - code is not zero, False otherwise. - """ - if 'Fail' in self.name: - return (returncode != 0) - return (returncode == 0) diff --git a/fastddsspy_tool/test/labels/CMakeLists.txt b/fastddsspy_tool/test/labels/CMakeLists.txt index a7bf85aa..d9a82ad5 100644 --- a/fastddsspy_tool/test/labels/CMakeLists.txt +++ b/fastddsspy_tool/test/labels/CMakeLists.txt @@ -12,12 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Set list of tests that can fail -# set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/XFAIL.list "xfail") # Set list of tests that can fail using TSAN set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/XTSAN.list "xtsan") - -# Set list of tests that can fail in windows -# if (WIN32) -# set_test_label_file(${CMAKE_CURRENT_SOURCE_DIR}/WINDOWS_TEST_XFAIL.list "xfail") -# endif() diff --git a/fastddsspy_tool/test/labels/WINDOWS_XFAIL.list b/fastddsspy_tool/test/labels/WINDOWS_XFAIL.list deleted file mode 100644 index e69de29b..00000000 diff --git a/fastddsspy_tool/test/labels/XTSAN.list b/fastddsspy_tool/test/labels/XTSAN.list index 941a7437..5c73a4c8 100644 --- a/fastddsspy_tool/test/labels/XTSAN.list +++ b/fastddsspy_tool/test/labels/XTSAN.list @@ -1,62 +1,62 @@ -tool.application.fastddsspy.test.one_shot_help_dds -tool.application.fastddsspy.test.one_shot_datareader_dds -tool.application.fastddsspy.test.one_shot_datareader_guid_dds -tool.application.fastddsspy.test.one_shot_datareader_verbose_dds -tool.application.fastddsspy.test.one_shot_datawriter_dds -tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds_qos -tool.application.fastddsspy.test.one_shot_datawriter_guid_dds_fail -tool.application.fastddsspy.test.one_shot_datawriter_verbose_dds -tool.application.fastddsspy.test.one_shot_participants_dds -tool.application.fastddsspy.test.one_shot_participants_guid_dds -tool.application.fastddsspy.test.one_shot_participants_verbose_dds -tool.application.fastddsspy.test.one_shot_quit_dds -tool.application.fastddsspy.test.one_shot_topics_dds -tool.application.fastddsspy.test.one_shot_topics_name_dds -tool.application.fastddsspy.test.one_shot_topics_verbose_dds -tool.application.fastddsspy.test.tool_datareader_dds -tool.application.fastddsspy.test.tool_datawriter_dds -tool.application.fastddsspy.test.tool_help_dds -tool.application.fastddsspy.test.tool_participants_dds -tool.application.fastddsspy.test.tool_show_topic_dds -tool.application.fastddsspy.test.tool_topics_dds -tool.application.fastddsspy.test.one_shot__config -tool.application.fastddsspy.test.one_shot__config_fail_file -tool.application.fastddsspy.test.one_shot__config_fail_type -tool.application.fastddsspy.test.one_shot__config_fail_empty_arg -tool.application.fastddsspy.test.one_shot__log_filter -tool.application.fastddsspy.test.one_shot__log_filter_fail -tool.application.fastddsspy.test.one_shot__log_verb_fail -tool.application.fastddsspy.test.one_shot__log_verb_info -tool.application.fastddsspy.test.one_shot__log_verb_warning -tool.application.fastddsspy.test.one_shot__log_verb_error -tool.application.fastddsspy.test.one_shot__reload_time -tool.application.fastddsspy.test.one_shot__reload_time_fail -tool.application.fastddsspy.test.one_shot__debug -tool.application.fastddsspy.test.one_shot_help -tool.application.fastddsspy.test.one_shot__help -tool.application.fastddsspy.test.one_shot_null -tool.application.fastddsspy.test.one_shot__null -tool.application.fastddsspy.test.one_shot__version -tool.application.fastddsspy.test.one_shot_datareader -tool.application.fastddsspy.test.one_shot_datareader_verbose -tool.application.fastddsspy.test.one_shot_datawriter -tool.application.fastddsspy.test.one_shot_datawriter_verbose -tool.application.fastddsspy.test.one_shot_participants -tool.application.fastddsspy.test.one_shot_participants_verbose -tool.application.fastddsspy.test.one_shot_quit -tool.application.fastddsspy.test.one_shot_show_all -tool.application.fastddsspy.test.one_shot_show_fail -tool.application.fastddsspy.test.one_shot_show_topic -tool.application.fastddsspy.test.one_shot_show_topic_verbose -tool.application.fastddsspy.test.one_shot_topics -tool.application.fastddsspy.test.one_shot_topics_name -tool.application.fastddsspy.test.one_shot_topics_verbose -tool.application.fastddsspy.test.tool_datareader -tool.application.fastddsspy.test.tool_datawriter -tool.application.fastddsspy.test.tool_help -tool.application.fastddsspy.test.tool_null -tool.application.fastddsspy.test.tool_participants -tool.application.fastddsspy.test.tool_show_all -tool.application.fastddsspy.test.tool_show_topic -tool.application.fastddsspy.test.tool_topics -tool.application.fastddsspy.test.tool_version +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 From d5fc618dfa6be08c89f3d33f0ef5f08f84d5a3e9 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 21 Jun 2023 13:18:27 +0200 Subject: [PATCH 62/63] Apply changes Signed-off-by: Irene Bandera --- .../test/application/CMakeLists.txt | 8 +-- fastddsspy_tool/test/application/README.md | 60 +++++++++++++++++++ fastddsspy_tool/test/application/test.py | 7 ++- .../test_cases/one_shot__version.py | 1 + .../test/application/test_class.py | 9 +-- 5 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 fastddsspy_tool/test/application/README.md diff --git a/fastddsspy_tool/test/application/CMakeLists.txt b/fastddsspy_tool/test/application/CMakeLists.txt index 85e1d7cc..b08f0adb 100644 --- a/fastddsspy_tool/test/application/CMakeLists.txt +++ b/fastddsspy_tool/test/application/CMakeLists.txt @@ -20,13 +20,13 @@ find_package(PythonInterp 3 REQUIRED) # Name of files to test -function(GET_FILENAMES_WITHOUT_PARENT PATH_LIST RESULT_VARIABLE) +function(get_filenames_without_parent PATH_LIST RESULT_VARIABLE) set(FILENAMES "") foreach(PATH ${${PATH_LIST}}) get_filename_component(FILENAME ${PATH} NAME) - string(REGEX REPLACE "\\.[^.]*$" "" fileNameWithoutExtension ${FILENAME}) - list(APPEND FILENAMES ${fileNameWithoutExtension}) + string(REGEX REPLACE "\\.[^.]*$" "" FILE_NAME_WITHOUT_EXTENSION ${FILENAME}) + list(APPEND FILENAMES ${FILE_NAME_WITHOUT_EXTENSION}) endforeach() set(${RESULT_VARIABLE} ${FILENAMES} PARENT_SCOPE) @@ -37,7 +37,7 @@ file( "test_cases/*.py" ) -GET_FILENAMES_WITHOUT_PARENT(TEST_PATH TEST_FILENAMES) +get_filenames_without_parent(TEST_PATH TEST_FILENAMES) message(STATUS "TEST FILES NAME: ${TEST_FILENAMES}") 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/test.py b/fastddsspy_tool/test/application/test.py index 925e9a0e..667713d3 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -108,10 +108,11 @@ def parse_options(): def get_config_path_spy(arguments_spy, exec_spy, config): """ - @brief Get the arguments for the publisher and the Spy. + @brief Get the path of the configuration of the Spy - @param test_class: The test class object. - @param args: The command-line arguments. + @param arguments_spy: List of arguments for the DDS Spy. + @param exec_spy: Fastd DDS Spy executable file path. + @param config: Name of the configuration file. """ index = arguments_spy.index('configuration') if is_linux(): diff --git a/fastddsspy_tool/test/application/test_cases/one_shot__version.py b/fastddsspy_tool/test/application/test_cases/one_shot__version.py index 68e4f3ba..08f81d9d 100644 --- a/fastddsspy_tool/test/application/test_cases/one_shot__version.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot__version.py @@ -45,6 +45,7 @@ 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_class.py b/fastddsspy_tool/test/application/test_class.py index 4d899d0e..ed424c82 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -95,7 +95,7 @@ def run_tool(self): return None else: - self.read_output(proc) + self.read_command_output(proc) return proc def send_command_tool(self, proc): @@ -109,10 +109,10 @@ def send_command_tool(self, proc): proc.stdin.write((self.commands_spy[0]+'\n')) proc.stdin.flush() - output = self.read_output(proc) + output = self.read_command_output(proc) return (output) - def read_output(self, proc): + def read_command_output(self, proc): """ @brief Read the output from the subprocess. @@ -121,6 +121,7 @@ def read_output(self, proc): """ output = '' count = 0 + # max number of loops while can take to avoid waiting forever if something goes wrong max_count = 500 while True: @@ -252,7 +253,7 @@ def stop_dds(self, proc) -> int: if self.dds: try: proc.terminate() - proc.communicate(timeout=15) + proc.communicate(timeout=13) except subprocess.TimeoutExpired: proc.kill() From 701426c785f37e65244271fdc01dcc26adea18c5 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 21 Jun 2023 16:51:11 +0200 Subject: [PATCH 63/63] Apply changes Signed-off-by: Irene Bandera --- fastddsspy_tool/test/application/test.py | 2 +- .../test_cases/one_shot_participants_dds.py | 2 +- .../test_cases/one_shot_topics_name_dds.py | 19 +--------- .../test_cases/one_shot_topics_verbose_dds.py | 17 --------- .../test/application/test_class.py | 38 +++++++++---------- 5 files changed, 22 insertions(+), 56 deletions(-) diff --git a/fastddsspy_tool/test/application/test.py b/fastddsspy_tool/test/application/test.py index 667713d3..37a9aaa2 100644 --- a/fastddsspy_tool/test/application/test.py +++ b/fastddsspy_tool/test/application/test.py @@ -111,7 +111,7 @@ 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: Fastd DDS Spy executable file path. + @param exec_spy: Fast DDS Spy executable file path. @param config: Name of the configuration file. """ index = arguments_spy.index('configuration') 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 index 7b2ad0c5..1ccc8595 100644 --- a/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_participants_dds.py @@ -40,5 +40,5 @@ def __init__(self): arguments_spy=['--config-path', 'configuration', 'participants'], commands_spy=[], output="""- name: Participant_pub\n\ -guid: %%guid%%\n""" + guid: %%guid%%\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 index a5cafc7b..a019c48a 100644 --- 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 @@ -14,8 +14,6 @@ """Tests for the fastddsspy executable.""" -import re - import test_class @@ -44,22 +42,7 @@ def __init__(self): output="""name: HelloWorldTopic\n\ type: HelloWorld\n\ datawriters:\n\ -- %%guid%%\n\ + - %%guid%%\n\ rate: %%rate%%\n\ dynamic_type_discovered: false\n""" ) - - 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'^((-)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' - id_guid = guid[guid.find('-'):] - if not re.match(pattern, id_guid): - print('Not valid guid: ') - print(guid) - return False - return True 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 index b6b90653..b3af2276 100644 --- 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 @@ -14,8 +14,6 @@ """Tests for the fastddsspy executable.""" -import re - import test_class @@ -48,18 +46,3 @@ def __init__(self): rate: %%rate%%\n\ dynamic_type_discovered: false\n""" ) - - 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'^((-)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' - id_guid = guid[guid.find('-'):] - if not re.match(pattern, id_guid): - print('Not valid guid: ') - print(guid) - return False - return True diff --git a/fastddsspy_tool/test/application/test_class.py b/fastddsspy_tool/test/application/test_class.py index ed424c82..636dcfc2 100644 --- a/fastddsspy_tool/test/application/test_class.py +++ b/fastddsspy_tool/test/application/test_class.py @@ -122,7 +122,7 @@ def read_command_output(self, proc): output = '' count = 0 # max number of loops while can take to avoid waiting forever if something goes wrong - max_count = 500 + max_count = 250 while True: count += 1 @@ -153,9 +153,8 @@ def valid_guid(self, guid) -> bool: @param guid: The GUID to check. @return Returns True if the GUID is valid, False otherwise. """ - pattern = r'^((guid:)\s([0-9a-f]{2}\.){11}[0-9a-f]{2}\|([0-9a-f]\.){3}[0-9a-f]{1,})$' - id_guid = guid[guid.find('guid:'):] - if not re.match(pattern, id_guid): + 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 @@ -168,12 +167,11 @@ def valid_rate(self, rate) -> bool: @param rate: The rate to check. @return Returns True if the rate is valid, False otherwise. """ - pattern_1 = r'^((rate:)\s\d*\.?\d*\s(Hz))$' # rate: 10.5 Hz - pattern_2 = r'^((rate:)\s(inf)\s(Hz))$' # rate: inf Hz - id_rate = rate[rate.find('rate:'):] - if re.match(pattern_1, id_rate): + 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, id_rate): + if re.match(pattern_2, rate): return True print('Not valid rate: ') print(rate) @@ -212,9 +210,11 @@ def valid_output(self, output) -> bool: rate = True for i in range(len(lines_expected_output)): if '%%guid%%' in lines_expected_output[i]: - guid = self.valid_guid(lines_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]: - rate = self.valid_rate(lines_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) @@ -223,12 +223,12 @@ def valid_output(self, output) -> bool: return False return (guid and rate) - def stop_tool(self, proc) -> int: + def stop_tool(self, proc) -> bool: """ @brief Stop the running Spy. @param proc: The subprocess object representing the running Spy. - @return Returns 1 if the Spy is successfully stopped, 0 otherwise. + @return Returns True if the Spy is successfully stopped, False otherwise. """ try: proc.communicate(input='exit\n', timeout=10)[0] @@ -239,16 +239,16 @@ def stop_tool(self, proc) -> int: if not self.is_stop(proc): print('ERROR: DDS Spy still running') - return 0 + return False - return 1 + return True - def stop_dds(self, proc) -> int: + def stop_dds(self, proc) -> bool: """ @brief Stop the DDS publisher. @param proc: The subprocess object representing the running DDS publisher. - @return Returns 1 if the DDS publisher is successfully stopped, 0 otherwise. + @return Returns True if the DDS publisher is successfully stopped, False otherwise. """ if self.dds: try: @@ -261,9 +261,9 @@ def stop_dds(self, proc) -> int: if not self.is_stop(proc): print('ERROR: DDS Publisher still running') - return 0 + return False - return 1 + return True def is_stop(self, proc) -> bool: """