Skip to content

Commit

Permalink
test_rclcpp in ci
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed May 6, 2024
1 parent c1c6f95 commit f23b7a9
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ jobs:
- name: Setup Rust
uses: dtolnay/[email protected]
- uses: actions/checkout@v2
- name: Clone system_tests
run: |
git clone https://github.com/ros2/system_tests.git
- name: rosdep
run: |
rosdep update
rosdep install --from-paths . -yir
- name: build
run: /ros_entrypoint.sh colcon build
- name: build_rmw
run: /ros_entrypoint.sh colcon build --packages-up-to rmw_zenoh_cpp
- name: build_tests
run: |
source install/setup.bash
/ros_entrypoint.sh colcon build --packages-up-to test_rclcpp
- name: test
run: |
source install/setup.bash
/ros_entrypoint.sh launch_test rmw_zenoh_cpp/test/test_rclcpp_launch.py
87 changes: 87 additions & 0 deletions rmw_zenoh_cpp/test/test_rclcpp_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright 2024 Open Source Robotics Foundation, Inc.
#
# 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 os
import sys
import signal
import subprocess
import time
import unittest

import launch
import launch.actions
import launch_ros.actions
import launch_testing.actions
import launch_testing.markers
import pytest


proc_env = os.environ.copy()
proc_env['PYTHONUNBUFFERED'] = '1'
proc_env['RMW_IMPLEMENTATION'] = 'rmw_zenoh_cpp'

@pytest.mark.launch_test
@launch_testing.markers.keep_alive
def generate_test_description():


dut_process = launch.actions.ExecuteProcess(
cmd=[
'colcon',
'test',
'--packages-select',
'test_rclcpp',
'--retest-until-pass',
'2',
],
shell=True,
env=proc_env,
)

return launch.LaunchDescription([
# rmw_zenohd,
dut_process,
# In tests where all of the procs under tests terminate themselves, it's necessary
# to add a dummy process not under test to keep the launch alive. launch_test
# provides a simple launch action that does this:
launch_testing.util.KeepAliveProc(),
launch_testing.actions.ReadyToTest()
]) , {'dut_process': dut_process}

class TestTerminatingProcessStops(unittest.TestCase):

def test_proc_terminates(self, proc_info, dut_process):
cmd=[
'ros2',
'run ',
'rmw_zenoh_cpp',
'rmw_zenohd',
]
process_group = subprocess.Popen(
cmd, stdout=subprocess.PIPE,
shell=True, env=proc_env, preexec_fn=os.setsid)
print(f'Started rmw_zenohd with pid [{process_group.pid}]')

proc_info.assertWaitForShutdown(process=dut_process, timeout=400)

os.killpg(os.getpgid(process_group.pid), signal.SIGTERM)


# These tests are run after the processes in generate_test_description() have shutdown.
@launch_testing.post_shutdown_test()
class TestShutdown(unittest.TestCase):

def test_exit_codes(self, proc_info):
"""Check if the processes exited normally."""
launch_testing.asserts.assertExitCodes(proc_info)

0 comments on commit f23b7a9

Please sign in to comment.