Skip to content

Commit f13c380

Browse files
Merge branch 'use-rmw-cyclonedds-cpp-for-rmw-related-test-tracetools' into 'master'
Run rmw-related test_tracetools tests with rmw_cyclonedds_cpp See merge request ros-tracing/ros2_tracing!284
2 parents 4701ae6 + 4df177b commit f13c380

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

test_tracetools/test/test_pub_sub.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import unittest
1616

17+
from launch.actions import SetEnvironmentVariable
1718
from tracetools_test.case import TraceTestCase
1819
from tracetools_trace.tools import tracepoints as tp
1920

@@ -39,6 +40,8 @@ def __init__(self, *args) -> None:
3940
],
4041
package='test_tracetools',
4142
nodes=['test_ping', 'test_pong'],
43+
# Need rmw_cyclonedds_cpp for the rmw instrumentation
44+
additional_actions=SetEnvironmentVariable('RMW_IMPLEMENTATION', 'rmw_cyclonedds_cpp'),
4245
)
4346

4447
def test_all(self):

test_tracetools/test/test_publisher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import unittest
1717

18+
from launch.actions import SetEnvironmentVariable
1819
from tracetools_test.case import TraceTestCase
1920
from tracetools_trace.tools import tracepoints as tp
2021

@@ -35,6 +36,8 @@ def __init__(self, *args) -> None:
3536
],
3637
package='test_tracetools',
3738
nodes=['test_publisher'],
39+
# Need rmw_cyclonedds_cpp for the rmw instrumentation
40+
additional_actions=SetEnvironmentVariable('RMW_IMPLEMENTATION', 'rmw_cyclonedds_cpp'),
3841
)
3942

4043
def test_all(self):

test_tracetools/test/test_subscription.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import unittest
1818

19+
from launch.actions import SetEnvironmentVariable
1920
from tracetools_test.case import TraceTestCase
2021
from tracetools_trace.tools import tracepoints as tp
2122

@@ -41,6 +42,8 @@ def __init__(self, *args) -> None:
4142
],
4243
package='test_tracetools',
4344
nodes=['test_ping', 'test_pong'],
45+
# Need rmw_cyclonedds_cpp for the rmw instrumentation
46+
additional_actions=SetEnvironmentVariable('RMW_IMPLEMENTATION', 'rmw_cyclonedds_cpp'),
4447
)
4548

4649
def test_all(self):

tracetools_test/tracetools_test/case.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from typing import Union
2525
import unittest
2626

27+
from launch import Action
2728
from tracetools_read import DictEvent
2829
from tracetools_read import get_event_name
2930
from tracetools_read import get_event_timestamp
@@ -59,6 +60,7 @@ def __init__(
5960
nodes: List[str],
6061
base_path: str = '/tmp',
6162
events_kernel: List[str] = [],
63+
additional_actions: Union[List[Action], Action] = [],
6264
) -> None:
6365
"""Create a TraceTestCase."""
6466
super().__init__(methodName=args[0])
@@ -68,6 +70,7 @@ def __init__(
6870
self._events_kernel = events_kernel
6971
self._package = package
7072
self._nodes = nodes
73+
self._additional_actions = additional_actions
7174

7275
def setUp(self):
7376
# Get timestamp before trace (ns)
@@ -80,6 +83,7 @@ def setUp(self):
8083
self._events_kernel,
8184
self._package,
8285
self._nodes,
86+
self._additional_actions,
8387
)
8488

8589
print(f'TRACE DIRECTORY: {full_path}')

tracetools_test/tracetools_test/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import shutil
1919
from typing import List
2020
from typing import Tuple
21+
from typing import Union
2122

23+
from launch import Action
2224
from launch import LaunchDescription
2325
from launch import LaunchService
2426
from launch_ros.actions import Node
@@ -35,6 +37,7 @@ def run_and_trace(
3537
kernel_events: List[str],
3638
package_name: str,
3739
node_names: List[str],
40+
additional_actions: Union[List[Action], Action] = [],
3841
) -> Tuple[int, str]:
3942
"""
4043
Run a node while tracing.
@@ -45,12 +48,15 @@ def run_and_trace(
4548
:param kernel_events: the list of kernel events to enable
4649
:param package_name: the name of the package to use
4750
:param node_names: the names of the nodes to execute
51+
:param additional_actions: the list of additional actions to prepend
4852
:return: exit code, full generated path
4953
"""
5054
session_name = append_timestamp(session_name_prefix)
5155
full_path = os.path.join(base_path, session_name)
56+
if not isinstance(additional_actions, list):
57+
additional_actions = [additional_actions]
5258

53-
launch_actions = []
59+
launch_actions = additional_actions
5460
# Add trace action
5561
launch_actions.append(
5662
Trace(

0 commit comments

Comments
 (0)