Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #22

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastddsspy_tool/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Add subdirectory with tests
add_subdirectory(integration)
110 changes: 110 additions & 0 deletions fastddsspy_tool/test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###########################################################################
# Create tests #
###########################################################################

find_package(PythonInterp 3 REQUIRED)

# Name of files to test
set(TEST_LIST
trivial
publisher_participant
)

# windows auxiliary script to fork test execution
set(PWS_LAUNCHER
${CMAKE_CURRENT_SOURCE_DIR}/launcher.ps1
)

# Calculate environment
set(TEST_ENVIRONMENT
"PATH=$ENV{PATH};$<TARGET_FILE_DIR:${PROJECT_NAME}>")

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};$<TARGET_FILE_DIR:${PROJECT_DEPENDENCY}>")

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};$<TARGET_FILE_DIR:${TINYXML2_LIBRARY}>")
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};$<TARGET_FILE_DIR:${YAMLCPP_LIBRARY}>")
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
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}/tests.py
"--exe" $<TARGET_FILE:fastddsspy_tool>
)

# Set test properties
set_tests_properties(
${TEST_NAME}
PROPERTIES
ENVIRONMENT "${TEST_ENVIRONMENT}"
)
endforeach()


unset(TEST_ENVIRONMENT)

add_subdirectory(dds/AdvancedConfigurationExample) # Source directory
Loading