diff --git a/test/system/tools/fastdds/CMakeLists.txt b/test/system/tools/fastdds/CMakeLists.txt index ad28206c96e..4a9321a42b0 100644 --- a/test/system/tools/fastdds/CMakeLists.txt +++ b/test/system/tools/fastdds/CMakeLists.txt @@ -20,6 +20,10 @@ find_package(Python3 COMPONENTS Interpreter REQUIRED) if(Python3_Interpreter_FOUND) + # Set environment for tests + set(TEST_ENVIRONMENT + "PYTHON_VERSION=${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") + set(TESTS test_fastdds_installed test_fastdds_discovery @@ -43,184 +47,200 @@ if(Python3_Interpreter_FOUND) PROPERTY LABELS "NoMemoryCheck" ) + # Set environment + set_property( + TEST system.tools.fastdds.${TEST} + PROPERTY ENVIRONMENT ${TEST_ENVIRONMENT} + ) + endforeach() -endif() + ############################################################################### + # XML GENERAL validation + ############################################################################### + message(STATUS "Configuring CLI xml validation...") -############################################################################### -# XML GENERAL validation -############################################################################### -message(STATUS "Configuring CLI xml validation...") + # Configure command based on the OS running + if (MSVC) + set(env_fast_command "fastdds.bat") # WINDOWS + else() + set(env_fast_command "fastdds") # POSIX + endif() -# Configure command based on the OS running -if (MSVC) - set(env_fast_command "fastdds.bat") # WINDOWS -else() - set(env_fast_command "fastdds") # POSIX -endif() + # Copy the examples validation files over to the build directory + file(GLOB_RECURSE XML_EXAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../../examples/*_profile.xml) + # for each xml file detected + foreach(XML_EXAMPLE_FILE_COMPLETE_PATH ${XML_EXAMPLE_FILES}) + # obtain the file name + get_filename_component(XML_EXAMPLE_FILE ${XML_EXAMPLE_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_EXAMPLE_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/examples/${XML_EXAMPLE_FILE}.xml # to relative build path + COPYONLY) + endforeach() -# Copy the examples validation files over to the build directory -file(GLOB_RECURSE XML_EXAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../../examples/*_profile.xml) -# for each xml file detected -foreach(XML_EXAMPLE_FILE_COMPLETE_PATH ${XML_EXAMPLE_FILES}) - # obtain the file name - get_filename_component(XML_EXAMPLE_FILE ${XML_EXAMPLE_FILE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${XML_EXAMPLE_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/examples/${XML_EXAMPLE_FILE}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the blackbox tests validation files over to the build directory -file(GLOB_RECURSE XML_BLACKBOX_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../blackbox/*_profile.xml) -# for each xml file detected -foreach(XML_BLACKBOX_FILE_COMPLETE_PATH ${XML_BLACKBOX_FILES}) - # obtain the file name - get_filename_component(XML_BLACKBOX_FILE ${XML_BLACKBOX_FILE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${XML_BLACKBOX_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/blackbox/${XML_BLACKBOX_FILE}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the unit tests validation files over to the build directory -file(GLOB_RECURSE XML_UNITTEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../unittest/*_profile.xml) -# for each xml file detected -foreach(XML_UNITTEST_FILE_COMPLETE_PATH ${XML_UNITTEST_FILES}) - # obtain the file name - get_filename_component(XML_UNITTEST_FILE ${XML_UNITTEST_FILE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${XML_UNITTEST_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/unittest/${XML_UNITTEST_FILE}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the system tests validation files over to the build directory -file(GLOB_RECURSE XML_SYSTEM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../*_profile.xml) -# for each xml file detected -foreach(XML_SYSTEM_FILE_COMPLETE_PATH ${XML_SYSTEM_FILES}) - # obtain the file name - get_filename_component(XML_SYSTEM_FILE ${XML_SYSTEM_FILE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${XML_SYSTEM_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/system/${XML_SYSTEM_FILE}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the comunication tests validation files over to the build directory -file(GLOB_RECURSE XML_COMMUNICATION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../communication/*_profile.xml) -# for each xml file detected -foreach(XML_COMMUNICATION_FILE_COMPLETE_PATH ${XML_COMMUNICATION_FILES}) - # obtain the file name - get_filename_component(XML_COMMUNICATION_FILE ${XML_COMMUNICATION_FILE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${XML_COMMUNICATION_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/communication/${XML_COMMUNICATION_FILE}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the dds tests validation files over to the build directory -file(GLOB_RECURSE XML_DDS_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../dds/*_profile.xml) -# for each xml file detected -foreach(XML_DDS_TEST_FILE_COMPLETE_PATH ${XML_DDS_TEST_FILES}) - # obtain the file name - get_filename_component(XML_DDS_TEST_FILE ${XML_DDS_TEST_FILE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${XML_DDS_TEST_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/dds/${XML_DDS_TEST_FILE}.xml # to relative build path - COPYONLY) -endforeach() - -if(PERFORMANCE_TESTS) - # Copy the performance tests validation files over to the build directory - file(GLOB_RECURSE XML_PERFORMANCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../performance/*_profile.xml) + # Copy the blackbox tests validation files over to the build directory + file(GLOB_RECURSE XML_BLACKBOX_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../blackbox/*_profile.xml) # for each xml file detected - foreach(XML_PERFORMANCE_FILE_COMPLETE_PATH ${XML_PERFORMANCE_FILES}) + foreach(XML_BLACKBOX_FILE_COMPLETE_PATH ${XML_BLACKBOX_FILES}) # obtain the file name - get_filename_component(XML_PERFORMANCE_FILE ${XML_PERFORMANCE_FILE_COMPLETE_PATH} NAME_WE) + get_filename_component(XML_BLACKBOX_FILE ${XML_BLACKBOX_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( - ${XML_PERFORMANCE_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/performance/${XML_PERFORMANCE_FILE}.xml # to relative build path + ${XML_BLACKBOX_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/blackbox/${XML_BLACKBOX_FILE}.xml # to relative build path COPYONLY) endforeach() -endif() -if(PROFILING_TESTS) - # Copy the profiling tests validation files over to the build directory - file(GLOB_RECURSE XML_PROFILING_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../profiling/*_profile.xml) + # Copy the unit tests validation files over to the build directory + file(GLOB_RECURSE XML_UNITTEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../unittest/*_profile.xml) # for each xml file detected - foreach(XML_PROFILING_FILE_COMPLETE_PATH ${XML_PROFILING_FILES}) + foreach(XML_UNITTEST_FILE_COMPLETE_PATH ${XML_UNITTEST_FILES}) # obtain the file name - get_filename_component(XML_PROFILING_FILE ${XML_PROFILING_FILE_COMPLETE_PATH} NAME_WE) + get_filename_component(XML_UNITTEST_FILE ${XML_UNITTEST_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( - ${XML_PROFILING_FILE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/profiling/${XML_PROFILING_FILE}.xml # to relative build path + ${XML_UNITTEST_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/unittest/${XML_UNITTEST_FILE}.xml # to relative build path COPYONLY) endforeach() -endif() -# Define test -add_test(NAME xml.validate COMMAND ${env_fast_command} xml validate xmldocuments) - -############################################################################### -# XML Static discovery validation -############################################################################### - -# Copy the examples validation files over to the build directory -file(GLOB_RECURSE STATIC_DISC_XML_EXAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../examples/*_static_disc.xml) - -# for each xml file detected in examples folder -foreach(STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH ${STATIC_DISC_XML_EXAMPLE}) - # obtain the file name - get_filename_component(STATIC_DISC_XML_EXAMPLE ${STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/examples/${STATIC_DISC_XML_EXAMPLE}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the test validation files over to the build directory -file(GLOB_RECURSE STATIC_DISC_XML_TEST ${CMAKE_CURRENT_SOURCE_DIR}/../*_static_disc.xml) - -# for each xml file detected in test folder -foreach(STATIC_DISC_XML_TEST_COMPLETE_PATH ${STATIC_DISC_XML_TEST}) - # obtain the file name - get_filename_component(STATIC_DISC_XML_TEST ${STATIC_DISC_XML_TEST_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${STATIC_DISC_XML_TEST_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/test/system/${STATIC_DISC_XML_TEST}.xml # to relative build path - COPYONLY) -endforeach() - -# Copy the sampled test files over to the build directory -file(GLOB_RECURSE STATIC_DISC_XML_SAMPLED_TEST ${CMAKE_CURRENT_SOURCE_DIR}/../../../blackbox/*_static_disc.xml.in) - -# set the expected CMake variables for the samples -set(TOPIC_RANDOM_NUMBER "123") -set(W_UNICAST_PORT_RANDOM_NUMBER "456") -set(R_UNICAST_PORT_RANDOM_NUMBER "654") -set(MULTICAST_PORT_RANDOM_NUMBER "789") - -# for each xml file detected in examples folder -foreach(STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH ${STATIC_DISC_XML_SAMPLED_TEST}) - # obtain the file name - get_filename_component(STATIC_DISC_XML_SAMPLED_TEST ${STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH} NAME_WE) - # copy the file from src to build folders - configure_file( - ${STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH} # from full src path - ${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/test/blackbox/${STATIC_DISC_XML_SAMPLED_TEST}.xml # to relative build path - ) -endforeach() + # Copy the system tests validation files over to the build directory + file(GLOB_RECURSE XML_SYSTEM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../*_profile.xml) + # for each xml file detected + foreach(XML_SYSTEM_FILE_COMPLETE_PATH ${XML_SYSTEM_FILES}) + # obtain the file name + get_filename_component(XML_SYSTEM_FILE ${XML_SYSTEM_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_SYSTEM_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/system/${XML_SYSTEM_FILE}.xml # to relative build path + COPYONLY) + endforeach() + + # Copy the comunication tests validation files over to the build directory + file(GLOB_RECURSE XML_COMMUNICATION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../communication/*_profile.xml) + # for each xml file detected + foreach(XML_COMMUNICATION_FILE_COMPLETE_PATH ${XML_COMMUNICATION_FILES}) + # obtain the file name + get_filename_component(XML_COMMUNICATION_FILE ${XML_COMMUNICATION_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_COMMUNICATION_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/communication/${XML_COMMUNICATION_FILE}.xml # to relative build path + COPYONLY) + endforeach() -# Define test -add_test(NAME xml.static_disc_validate COMMAND ${env_fast_command} xml validate xml_static_disc_docs -x ${CMAKE_SOURCE_DIR}/resources/xsd/fastdds_static_discovery.xsd) + # Copy the dds tests validation files over to the build directory + file(GLOB_RECURSE XML_DDS_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../dds/*_profile.xml) + # for each xml file detected + foreach(XML_DDS_TEST_FILE_COMPLETE_PATH ${XML_DDS_TEST_FILES}) + # obtain the file name + get_filename_component(XML_DDS_TEST_FILE ${XML_DDS_TEST_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_DDS_TEST_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/dds/${XML_DDS_TEST_FILE}.xml # to relative build path + COPYONLY) + endforeach() + + if(PERFORMANCE_TESTS) + # Copy the performance tests validation files over to the build directory + file(GLOB_RECURSE XML_PERFORMANCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../performance/*_profile.xml) + # for each xml file detected + foreach(XML_PERFORMANCE_FILE_COMPLETE_PATH ${XML_PERFORMANCE_FILES}) + # obtain the file name + get_filename_component(XML_PERFORMANCE_FILE ${XML_PERFORMANCE_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_PERFORMANCE_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/performance/${XML_PERFORMANCE_FILE}.xml # to relative build path + COPYONLY) + endforeach() + endif() + + if(PROFILING_TESTS) + # Copy the profiling tests validation files over to the build directory + file(GLOB_RECURSE XML_PROFILING_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../../profiling/*_profile.xml) + # for each xml file detected + foreach(XML_PROFILING_FILE_COMPLETE_PATH ${XML_PROFILING_FILES}) + # obtain the file name + get_filename_component(XML_PROFILING_FILE ${XML_PROFILING_FILE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${XML_PROFILING_FILE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xmldocuments/test/profiling/${XML_PROFILING_FILE}.xml # to relative build path + COPYONLY) + endforeach() + endif() + + # Define test + add_test(NAME xml.validate COMMAND ${env_fast_command} xml validate xmldocuments) + + set_property( + TEST xml.validate + PROPERTY ENVIRONMENT ${TEST_ENVIRONMENT} + ) + + ############################################################################### + # XML Static discovery validation + ############################################################################### + + # Copy the examples validation files over to the build directory + file(GLOB_RECURSE STATIC_DISC_XML_EXAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../examples/*_static_disc.xml) + + # for each xml file detected in examples folder + foreach(STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH ${STATIC_DISC_XML_EXAMPLE}) + # obtain the file name + get_filename_component(STATIC_DISC_XML_EXAMPLE ${STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${STATIC_DISC_XML_EXAMPLE_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/examples/${STATIC_DISC_XML_EXAMPLE}.xml # to relative build path + COPYONLY) + endforeach() + + # Copy the test validation files over to the build directory + file(GLOB_RECURSE STATIC_DISC_XML_TEST ${CMAKE_CURRENT_SOURCE_DIR}/../*_static_disc.xml) + + # for each xml file detected in test folder + foreach(STATIC_DISC_XML_TEST_COMPLETE_PATH ${STATIC_DISC_XML_TEST}) + # obtain the file name + get_filename_component(STATIC_DISC_XML_TEST ${STATIC_DISC_XML_TEST_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${STATIC_DISC_XML_TEST_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/test/system/${STATIC_DISC_XML_TEST}.xml # to relative build path + COPYONLY) + endforeach() + + # Copy the sampled test files over to the build directory + file(GLOB_RECURSE STATIC_DISC_XML_SAMPLED_TEST ${CMAKE_CURRENT_SOURCE_DIR}/../../../blackbox/*_static_disc.xml.in) + + # set the expected CMake variables for the samples + set(TOPIC_RANDOM_NUMBER "123") + set(W_UNICAST_PORT_RANDOM_NUMBER "456") + set(R_UNICAST_PORT_RANDOM_NUMBER "654") + set(MULTICAST_PORT_RANDOM_NUMBER "789") + + # for each xml file detected in examples folder + foreach(STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH ${STATIC_DISC_XML_SAMPLED_TEST}) + # obtain the file name + get_filename_component(STATIC_DISC_XML_SAMPLED_TEST ${STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH} NAME_WE) + # copy the file from src to build folders + configure_file( + ${STATIC_DISC_XML_SAMPLED_TEST_COMPLETE_PATH} # from full src path + ${CMAKE_CURRENT_BINARY_DIR}/xml_static_disc_docs/test/blackbox/${STATIC_DISC_XML_SAMPLED_TEST}.xml # to relative build path + ) + endforeach() + + # Define test + add_test(NAME xml.static_disc_validate COMMAND ${env_fast_command} xml validate xml_static_disc_docs -x ${CMAKE_SOURCE_DIR}/resources/xsd/fastdds_static_discovery.xsd) + + set_property( + TEST xml.static_disc_validate + PROPERTY ENVIRONMENT ${TEST_ENVIRONMENT} + ) + +endif() diff --git a/tools/fastdds/fastdds.bat b/tools/fastdds/fastdds.bat index 9bbcc0d6aa0..c6eeb708d5e 100644 --- a/tools/fastdds/fastdds.bat +++ b/tools/fastdds/fastdds.bat @@ -20,5 +20,12 @@ if not %ERRORLEVEL%==0 ( exit /B 65 ) ) + +if %PYTHON_VERSION%=="" ( + echo error retrieving python version. Please, make sure python is installed and accessible. + exit /B 65 + ) +) + :: Use launcher to profit from shebang hints on fastdds.py -py "%dir%\..\tools\fastdds\fastdds.py" %args% +py -%PYTHON_VERSION% "%dir%\..\tools\fastdds\fastdds.py" %args%