Skip to content

Commit 3d0fde9

Browse files
authored
Add tests isolation in test_rclcpp (#583)
* test_rclcpp: add test isolation Signed-off-by: Julien Enoch <julien.e@zettascale.tech> * test_rclcpp: add test isolation in test_sigterm.py.in and test_executable_output.py.in which are using a LaunchDescription Signed-off-by: Julien Enoch <julien.e@zettascale.tech> --------- Signed-off-by: Julien Enoch <julien.e@zettascale.tech>
1 parent 7b27452 commit 3d0fde9

4 files changed

Lines changed: 25 additions & 21 deletions

File tree

test_rclcpp/CMakeLists.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if(BUILD_TESTING)
2323
find_package(launch_testing_ament_cmake REQUIRED)
2424

2525
find_package(ament_cmake_gtest REQUIRED)
26+
find_package(ament_cmake_ros REQUIRED)
2627

2728
# finding gtest once in the highest scope
2829
# prevents finding it repeatedly in each local scope
@@ -319,46 +320,46 @@ if(BUILD_TESTING)
319320
function(test_target)
320321
set(rmw_implementation_env_var RMW_IMPLEMENTATION=${rmw_implementation})
321322

322-
ament_add_gtest_test(gtest_avoid_ros_namespace_conventions_qos
323+
ament_add_ros_isolated_gtest_test(gtest_avoid_ros_namespace_conventions_qos
323324
TEST_NAME gtest_avoid_ros_namespace_conventions_qos${target_suffix}
324325
APPEND_LIBRARY_DIRS "${append_library_dirs}"
325326
TIMEOUT 15
326327
ENV
327328
${rmw_implementation_env_var}
328329
)
329330

330-
ament_add_gtest_test(gtest_publisher
331+
ament_add_ros_isolated_gtest_test(gtest_publisher
331332
TEST_NAME gtest_publisher${target_suffix}
332333
APPEND_LIBRARY_DIRS "${append_library_dirs}"
333334
TIMEOUT 15
334335
ENV
335336
${rmw_implementation_env_var}
336337
)
337338

338-
ament_add_gtest_test(gtest_client_wait_for_service_shutdown
339+
ament_add_ros_isolated_gtest_test(gtest_client_wait_for_service_shutdown
339340
TEST_NAME gtest_client_wait_for_service_shutdown${target_suffix}
340341
APPEND_LIBRARY_DIRS "${append_library_dirs}"
341342
ENV
342343
${rmw_implementation_env_var}
343344
)
344345

345-
ament_add_gtest_test(gtest_executor
346+
ament_add_ros_isolated_gtest_test(gtest_executor
346347
TEST_NAME gtest_executor${target_suffix}
347348
APPEND_LIBRARY_DIRS "${append_library_dirs}"
348349
TIMEOUT 60
349350
ENV
350351
${rmw_implementation_env_var}
351352
)
352353

353-
ament_add_gtest_test(gtest_repeated_publisher_subscriber
354+
ament_add_ros_isolated_gtest_test(gtest_repeated_publisher_subscriber
354355
TEST_NAME gtest_repeated_publisher_subscriber${target_suffix}
355356
APPEND_LIBRARY_DIRS "${append_library_dirs}"
356357
TIMEOUT 15
357358
ENV
358359
${rmw_implementation_env_var}
359360
)
360361

361-
ament_add_gtest_test(gtest_spin
362+
ament_add_ros_isolated_gtest_test(gtest_spin
362363
TEST_NAME gtest_spin${target_suffix}
363364
APPEND_LIBRARY_DIRS "${append_library_dirs}"
364365
TIMEOUT 30
@@ -369,7 +370,7 @@ if(BUILD_TESTING)
369370
# TODO(clalancette): Under load, the gtest_subscription__rmw_connextdds test fails deep in the
370371
# bowels of Connext; see https://github.com/ros2/rmw_connextdds/issues/136 for details. Skip it
371372
# for now so we can keep CI green.
372-
ament_add_gtest_test(gtest_subscription
373+
ament_add_ros_isolated_gtest_test(gtest_subscription
373374
TEST_NAME gtest_subscription${target_suffix}
374375
APPEND_LIBRARY_DIRS "${append_library_dirs}"
375376
TIMEOUT 60
@@ -380,63 +381,63 @@ if(BUILD_TESTING)
380381
ament_add_test_label(gtest_subscription${target_suffix} xfail)
381382
endif()
382383

383-
ament_add_gtest_test(gtest_multiple_service_calls
384+
ament_add_ros_isolated_gtest_test(gtest_multiple_service_calls
384385
TEST_NAME gtest_multiple_service_calls${target_suffix}
385386
APPEND_LIBRARY_DIRS "${append_library_dirs}"
386387
TIMEOUT 60
387388
ENV
388389
${rmw_implementation_env_var}
389390
)
390391

391-
ament_add_gtest_test(gtest_timer
392+
ament_add_ros_isolated_gtest_test(gtest_timer
392393
TEST_NAME gtest_timer${target_suffix}
393394
APPEND_LIBRARY_DIRS "${append_library_dirs}"
394395
TIMEOUT 30
395396
ENV
396397
${rmw_implementation_env_var}
397398
)
398399

399-
ament_add_gtest_test(gtest_timeout_subscriber
400+
ament_add_ros_isolated_gtest_test(gtest_timeout_subscriber
400401
TEST_NAME gtest_timeout_subscriber${target_suffix}
401402
APPEND_LIBRARY_DIRS "${append_library_dirs}"
402403
TIMEOUT 30
403404
ENV
404405
${rmw_implementation_env_var}
405406
)
406407

407-
ament_add_gtest_test(gtest_intra_process
408+
ament_add_ros_isolated_gtest_test(gtest_intra_process
408409
TEST_NAME gtest_intra_process${target_suffix}
409410
APPEND_LIBRARY_DIRS "${append_library_dirs}"
410411
TIMEOUT 15
411412
ENV
412413
${rmw_implementation_env_var}
413414
)
414415

415-
ament_add_gtest_test(gtest_multithreaded
416+
ament_add_ros_isolated_gtest_test(gtest_multithreaded
416417
TEST_NAME gtest_multithreaded${target_suffix}
417418
APPEND_LIBRARY_DIRS "${append_library_dirs}"
418419
TIMEOUT 90
419420
ENV
420421
${rmw_implementation_env_var}
421422
)
422423

423-
ament_add_gtest_test(gtest_local_parameters
424+
ament_add_ros_isolated_gtest_test(gtest_local_parameters
424425
TEST_NAME gtest_local_parameters${target_suffix}
425426
APPEND_LIBRARY_DIRS "${append_library_dirs}"
426427
TIMEOUT 300
427428
ENV
428429
${rmw_implementation_env_var}
429430
)
430431

431-
ament_add_gtest_test(gtest_services_in_constructor
432+
ament_add_ros_isolated_gtest_test(gtest_services_in_constructor
432433
TEST_NAME gtest_services_in_constructor${target_suffix}
433434
APPEND_LIBRARY_DIRS "${append_library_dirs}"
434435
TIMEOUT 30
435436
ENV
436437
${rmw_implementation_env_var}
437438
)
438439

439-
ament_add_gtest_test(gtest_waitable
440+
ament_add_ros_isolated_gtest_test(gtest_waitable
440441
TEST_NAME gtest_waitable${target_suffix}
441442
APPEND_LIBRARY_DIRS "${append_library_dirs}"
442443
TIMEOUT 300

test_rclcpp/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<buildtool_depend>ament_cmake</buildtool_depend>
2222

2323
<test_depend>ament_cmake_gtest</test_depend>
24+
<test_depend>ament_cmake_ros</test_depend>
2425
<test_depend>ament_lint_auto</test_depend>
2526
<test_depend>ament_lint_common</test_depend>
2627
<test_depend>launch</test_depend>

test_rclcpp/test/test_executable_output.py.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ import launch_testing.actions
99
import launch_testing.asserts
1010
import launch_testing_ros
1111

12+
from launch_testing_ros.actions import EnableRmwIsolation
13+
1214
import os
1315
import unittest
1416

1517

1618
def generate_test_description():
17-
env = os.environ.copy()
18-
env['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '[{severity}] [{name}]: {message}'
1919
launch_description = LaunchDescription()
20+
launch_description.add_action(EnableRmwIsolation())
2021
proc_under_test = ExecuteProcess(
2122
cmd=['@TEST_EXECUTABLE@'],
2223
name='@TEST_EXECUTABLE_NAME@',
2324
sigterm_timeout='15',
2425
output='screen',
25-
env=env,
26+
additional_env={'RCUTILS_CONSOLE_OUTPUT_FORMAT': '[{severity}] [{name}]: {message}'},
2627
)
2728
launch_description.add_action(proc_under_test)
2829
launch_description.add_action(

test_rclcpp/test/test_sigterm.py.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ import launch_testing.actions
1010
import launch_testing.asserts
1111
import launch_testing_ros
1212

13+
from launch_testing_ros.actions import EnableRmwIsolation
14+
1315
import os
1416
import signal
1517
import sys
1618
import unittest
1719

1820

1921
def generate_test_description():
20-
env = os.environ.copy()
21-
env['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '[{severity}] [{name}]: {message}'
2222
launch_description = LaunchDescription()
23+
launch_description.add_action(EnableRmwIsolation())
2324
proc_under_test = ExecuteProcess(
2425
cmd=['@TEST_EXECUTABLE@'],
2526
name='@TEST_EXECUTABLE_NAME@',
2627
sigterm_timeout='15',
2728
output='screen',
28-
env=env,
29+
additional_env={'RCUTILS_CONSOLE_OUTPUT_FORMAT': '[{severity}] [{name}]: {message}'},
2930
)
3031
launch_description.add_action(proc_under_test)
3132
launch_description.add_action(launch_testing.util.KeepAliveProc())

0 commit comments

Comments
 (0)