diff --git a/test/examples/CMakeLists.txt b/test/examples/CMakeLists.txt index 6116dbe936..b8f7099a6d 100644 --- a/test/examples/CMakeLists.txt +++ b/test/examples/CMakeLists.txt @@ -28,6 +28,21 @@ set(SHELL_EXECUTABLE "") set(TINYXML2_LIB_DIR_COMPOSE_VOLUME "") set(TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH "") +# Configure TinyXML2 library path if installed in user library path +if(NOT (TINYXML2_FROM_SOURCE OR TINYXML2_FROM_THIRDPARTY)) + message(STATUS "TINYXML2_LIBRARY " ${TINYXML2_LIBRARY}) + file(GLOB TINYXML2_LIBRARY_DIRS LIST_DIRECTORIES false ${TINYXML2_LIBRARY}) + if (TINYXML2_LIBRARY_DIRS) + list (GET TINYXML2_LIBRARY_DIRS 0 TINYXML2_LIBRARY_HEAD_DIR) + get_filename_component(TINYXML2_LIB_DIR ${TINYXML2_LIBRARY_HEAD_DIR} DIRECTORY) + message(STATUS "TINYXML2_LIB_DIR " ${TINYXML2_LIB_DIR}) + set(TINYXML2_LIB_DIR_COMPOSE_VOLUME "- ${TINYXML2_LIB_DIR}:${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/fastdds:ro") + set(TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/fastdds") + else() + message(FATAL_ERROR "Could not find a valid TinyXML 2 lirbary path.") + endif() +endif() + # Linux configurations if(UNIX AND NOT(APPLE) AND NOT(QNXNTO) AND NOT(ANDROID)) # Find bash @@ -39,6 +54,21 @@ if(UNIX AND NOT(APPLE) AND NOT(QNXNTO) AND NOT(ANDROID)) set(SHELL_EXECUTABLE ${BASH_EXECUTABLE}) set(DOCKER_IMAGE_NAME "ubuntu:22.04") + set(PROJECT_BINATY_DIR_COMPOSE_VOLUME "${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}") + set(fastcdr_LIB_DIR_COMPOSE_VOLUME "${fastcdr_LIB_DIR}:${fastcdr_LIB_DIR}") + set(CMAKE_INSTALL_PREFIX_COMPOSE_VOLUME "${CMAKE_INSTALL_PREFIX}:${CMAKE_INSTALL_PREFIX}") + + set(PATH_ENVIRONMENT_VARIABLE_COMPOSE "LD_LIBRARY_PATH: ${PROJECT_BINARY_DIR}/src/cpp:${fastcdr_LIB_DIR}") + if (TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH) + set(PATH_ENVIRONMENT_VARIABLE_COMPOSE "${PATH_ENVIRONMENT_VARIABLE_COMPOSE}:${TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH}") + endif() + set(EXAMPLE_PREFIX_DIR_COMPOSE "${PROJECT_BINARY_DIR}/examples/cpp") + set(EXAMPLE_SUFFIX_DIR_COMPOSE "") + set(FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE "${PROJECT_BINARY_DIR}/examples/cpp/") + set(COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE "$\${EXAMPLE_DIR}") + set(COMMAND_CONCATENATE_COMPOSE "&") + set(COMMAND_BACKGROUND_JOB_COMPOSE "") + # Windows configurations elseif(WIN32) # Find pwsh @@ -47,8 +77,8 @@ elseif(WIN32) message(FATAL_ERROR "pwsh not found") endif() - # Temporary, in the is installed here - set(SHELL_EXECUTABLE "C:/Program Files/PowerShell/latest/pwsh.exe") + set(PWSH_VERSION_DOCKER "latest") + set(SHELL_EXECUTABLE "C:/Program Files/PowerShell/${PWSH_VERSION_DOCKER}/pwsh.exe") set(FILE_EXTENSION ".exe") set(DOCKER_IMAGE_NAME "windows-testing") @@ -60,6 +90,18 @@ elseif(WIN32) string(REGEX REPLACE ".:" "C:" PROJECT_BINARY_DIR_C ${PROJECT_BINARY_DIR}) string(REGEX REPLACE ".:" "C:" fastcdr_INSTALL_DIR_C ${fastcdr_INSTALL_DIR}) + set(PROJECT_BINATY_DIR_COMPOSE_VOLUME "${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR_C}") + set(fastcdr_LIB_DIR_COMPOSE_VOLUME "${fastcdr_INSTALL_DIR}/bin:${fastcdr_INSTALL_DIR_C}/bin") + set(CMAKE_INSTALL_PREFIX_COMPOSE_VOLUME "${CMAKE_INSTALL_PREFIX}/bin:${CMAKE_INSTALL_PREFIX_C}/bin") + + set(PATH_ENVIRONMENT_VARIABLE_COMPOSE "PATH: C:/Program Files/OpenSSL-Win64;${CMAKE_INSTALL_PREFIX_C}/bin;${fastcdr_INSTALL_DIR_C}/bin;C:/Windows/System32;C:/Windows/System32/downlevel;") + set(EXAMPLE_PREFIX_DIR_COMPOSE "${PROJECT_BINARY_DIR_C}/examples/cpp") + set(EXAMPLE_SUFFIX_DIR_COMPOSE "RelWithDebInfo") + set(FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE "${PROJECT_BINARY_DIR_C}/examples/cpp") + set(COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE "& $\$Env:EXAMPLE_DIR") + set(COMMAND_CONCATENATE_COMPOSE "&\" \"&") + set(COMMAND_BACKGROUND_JOB_COMPOSE "; Receive-Job 1 -Wait") + set(WIN_DOCKERFILE ${CMAKE_CURRENT_LIST_DIR}/windows/Dockerfile) # Generate image for testing add_custom_target( @@ -77,21 +119,6 @@ else() message(FATAL_ERROR "Unsupported platform") endif() -# Configure TinyXML2 library path if installed in user library path -if(NOT (TINYXML2_FROM_SOURCE OR TINYXML2_FROM_THIRDPARTY)) - message(STATUS "TINYXML2_LIBRARY " ${TINYXML2_LIBRARY}) - file(GLOB TINYXML2_LIBRARY_DIRS LIST_DIRECTORIES false ${TINYXML2_LIBRARY}) - if (TINYXML2_LIBRARY_DIRS) - list (GET TINYXML2_LIBRARY_DIRS 0 TINYXML2_LIBRARY_HEAD_DIR) - get_filename_component(TINYXML2_LIB_DIR ${TINYXML2_LIBRARY_HEAD_DIR} DIRECTORY) - message(STATUS "TINYXML2_LIB_DIR " ${TINYXML2_LIB_DIR}) - set(TINYXML2_LIB_DIR_COMPOSE_VOLUME "- ${TINYXML2_LIB_DIR}:${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/fastdds:ro") - set(TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH ":${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/fastdds") - else() - message(FATAL_ERROR "Could not find a valid TinyXML 2 lirbary path.") - endif() -endif() - # Find all pytest files for testing file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*world.py) diff --git a/test/examples/hello_world.compose.yml b/test/examples/hello_world.compose.yml index 1a724dd0f6..be66e11d6b 100644 --- a/test/examples/hello_world.compose.yml +++ b/test/examples/hello_world.compose.yml @@ -16,27 +16,27 @@ services: waitset-subscriber: image: @DOCKER_IMAGE_NAME@ volumes: - - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR_C@ - - @fastcdr_INSTALL_DIR@/bin:@fastcdr_INSTALL_DIR_C@/bin - - @CMAKE_INSTALL_PREFIX@/bin:@CMAKE_INSTALL_PREFIX_C@/bin + - @PROJECT_BINATY_DIR_COMPOSE_VOLUME@ + - @fastcdr_LIB_DIR_COMPOSE_VOLUME@ + - @CMAKE_INSTALL_PREFIX_COMPOSE_VOLUME@ @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ environment: - PATH: C:/Program Files/OpenSSL-Win64;@CMAKE_INSTALL_PREFIX_C@/bin;@fastcdr_INSTALL_DIR_C@/bin;C:/Windows/System32;C:/Windows/System32/downlevel; - EXAMPLE_DIR: @PROJECT_BINARY_DIR_C@/examples/cpp/hello_world/RelWithDebInfo - FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR_C@/examples/cpp/hello_world/hello_world_profile.xml - command: @SHELL_EXECUTABLE@ -c "& $$Env:EXAMPLE_DIR/hello_world@FILE_EXTENSION@ subscriber --waitset --samples 30" + @PATH_ENVIRONMENT_VARIABLE_COMPOSE@ + EXAMPLE_DIR: @EXAMPLE_PREFIX_DIR_COMPOSE@/hello_world/@EXAMPLE_SUFFIX_DIR_COMPOSE@ + FASTDDS_DEFAULT_PROFILES_FILE: @FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE@/hello_world/hello_world_profile.xml + command: @SHELL_EXECUTABLE@ -c "@COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/hello_world@FILE_EXTENSION@ subscriber --waitset --samples 10" subscriber-publisher: image: @DOCKER_IMAGE_NAME@ volumes: - - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR_C@ - - @fastcdr_INSTALL_DIR@/bin:@fastcdr_INSTALL_DIR_C@/bin - - @CMAKE_INSTALL_PREFIX@/bin:@CMAKE_INSTALL_PREFIX_C@/bin + - @PROJECT_BINATY_DIR_COMPOSE_VOLUME@ + - @fastcdr_LIB_DIR_COMPOSE_VOLUME@ + - @CMAKE_INSTALL_PREFIX_COMPOSE_VOLUME@ @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ environment: - PATH: C:/Program Files/OpenSSL-Win64;@CMAKE_INSTALL_PREFIX_C@/bin;@fastcdr_INSTALL_DIR_C@/bin;C:/Windows/System32;C:/Windows/System32/downlevel; - EXAMPLE_DIR: @PROJECT_BINARY_DIR_C@/examples/cpp/hello_world/RelWithDebInfo - FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR_C@/examples/cpp/hello_world/hello_world_profile.xml - command: @SHELL_EXECUTABLE@ -c "& $$Env:EXAMPLE_DIR/hello_world@FILE_EXTENSION@ publisher --samples 30 &" "& $$Env:EXAMPLE_DIR/hello_world@FILE_EXTENSION@ subscriber --samples 30; Receive-Job 1 -Wait" + @PATH_ENVIRONMENT_VARIABLE_COMPOSE@ + EXAMPLE_DIR: @EXAMPLE_PREFIX_DIR_COMPOSE@/hello_world/@EXAMPLE_SUFFIX_DIR_COMPOSE@ + FASTDDS_DEFAULT_PROFILES_FILE: @FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE@/hello_world/hello_world_profile.xml + command: @SHELL_EXECUTABLE@ -c "@COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/hello_world@FILE_EXTENSION@ publisher --samples 10 --matched 2 @COMMAND_CONCATENATE_COMPOSE@ @COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/hello_world@FILE_EXTENSION@ subscriber --samples 10@COMMAND_BACKGROUND_JOB_COMPOSE@" depends_on: - waitset-subscriber