Skip to content

Commit

Permalink
Refs #21886: Hello World Example Test
Browse files Browse the repository at this point in the history
Signed-off-by: Mario-DL <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL committed Oct 25, 2024
1 parent 9a5b57c commit 6f5301a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 22 deletions.
38 changes: 30 additions & 8 deletions test/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,48 @@ elseif(WIN32)
message(FATAL_ERROR "pwsh not found")
endif()

set(PWSH_EXECUTABLE ${BASH_EXECUTABLE})
# Temporary, in the is installed here
set(SHELL_EXECUTABLE "C:/Program Files/PowerShell/latest/pwsh.exe")

set(FILE_EXTENSION ".exe")
set(DOCKER_IMAGE_NAME "windows-testing")

cmake_path(GET fastcdr_LIB_DIR PARENT_PATH fastcdr_INSTALL_DIR)

# We don't know which docker image to use for Windows yet
message(FATAL_ERROR "Windows not supported yet")

set(WIN_DOCKERFILE ${CMAKE_CURRENT_LIST_DIR}/windows/Dockerfile)
# Generate image for testing
add_custom_target(
windows_docker_image_testing_generation
ALL
# Launch the docker build command using the build context.
COMMAND ${DOCKER_EXECUTABLE} build
--tag ${DOCKER_IMAGE_NAME}
--file ${WIN_DOCKERFILE}
${CMAKE_CURRENT_LIST_DIR}
COMMENT "Creating windows image for testing..." VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
# Unsupported platform
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))
get_filename_component(TINYXML2_LIB_DIR ${TINYXML2_LIBRARY} DIRECTORY)
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")
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}/*.py)
file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*world.py)

# Add security test only if security is enabled
if (NOT SECURITY)
Expand Down
21 changes: 10 additions & 11 deletions test/examples/hello_world.compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,32 @@
# 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.
version: "3"

services:
waitset-subscriber:
image: @DOCKER_IMAGE_NAME@
volumes:
- @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
- @fastcdr_INSTALL_DIR@/bin:@fastcdr_INSTALL_DIR@/bin
- @CMAKE_INSTALL_PREFIX@/bin:@CMAKE_INSTALL_PREFIX@/bin
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
environment:
# TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@
PATH: C:/Program Files/OpenSSL-Win64;@CMAKE_INSTALL_PREFIX@/bin;@fastcdr_INSTALL_DIR@/bin;C:/Windows/System32;C:/Windows/System32/downlevel;
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/Release
FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml
command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --waitset --samples 10"
command: @SHELL_EXECUTABLE@ -c "& $$Env:EXAMPLE_DIR/hello_world@FILE_EXTENSION@ subscriber --waitset --samples 30"

subscriber-publisher:
image: @DOCKER_IMAGE_NAME@
volumes:
- @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
- @fastcdr_INSTALL_DIR@/bin:@fastcdr_INSTALL_DIR@/bin
- @CMAKE_INSTALL_PREFIX@/bin:@CMAKE_INSTALL_PREFIX@/bin
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
environment:
# TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world
PATH: C:/Program Files/OpenSSL-Win64;@CMAKE_INSTALL_PREFIX@/bin;@fastcdr_INSTALL_DIR@/bin;C:/Windows/System32;C:/Windows/System32/downlevel;
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/Release
FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml
command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10"
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"
depends_on:
- waitset-subscriber
5 changes: 2 additions & 3 deletions test/examples/test_hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_hello_world():
out = ''
try:
out = subprocess.check_output(
'@DOCKER_EXECUTABLE@ compose -f hello_world.compose.yml up',
'"@DOCKER_EXECUTABLE@" compose -f hello_world.compose.yml up',
stderr=subprocess.STDOUT,
shell=True,
timeout=20
Expand All @@ -43,8 +43,7 @@ def test_hello_world():
raise subprocess.CalledProcessError(1, '')

except subprocess.CalledProcessError:
for l in out:
print(l)
print ('ERROR %s', e.output)
except subprocess.TimeoutExpired:
print('TIMEOUT')
print(out)
Expand Down
12 changes: 12 additions & 0 deletions test/examples/windows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM mcr.microsoft.com/powershell:windowsservercore-ltsc2022

SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install Chocolately
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# Install VC++ Redistributable 2022
RUN choco install -y vcredist140

# Install OpenSSL latest
RUN choco install -y openssl

0 comments on commit 6f5301a

Please sign in to comment.