Update test_intra test after new intra-process communications
This commit is contained in:
parent
fc1ce31504
commit
3c4a386003
1 changed files with 72 additions and 32 deletions
|
@ -25,45 +25,68 @@ class TestIntra(TraceTestCase):
|
||||||
session_name_prefix='session-test-intra',
|
session_name_prefix='session-test-intra',
|
||||||
events_ros=[
|
events_ros=[
|
||||||
'ros2:rcl_subscription_init',
|
'ros2:rcl_subscription_init',
|
||||||
|
'ros2:rclcpp_subscription_init',
|
||||||
'ros2:rclcpp_subscription_callback_added',
|
'ros2:rclcpp_subscription_callback_added',
|
||||||
'ros2:callback_start',
|
'ros2:callback_start',
|
||||||
'ros2:callback_end',
|
'ros2:callback_end',
|
||||||
],
|
],
|
||||||
nodes=['test_intra']
|
nodes=['test_intra'],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_all(self):
|
def test_all(self):
|
||||||
# Check events as set
|
# Check events as set
|
||||||
self.assertEventsSet(self._events_ros)
|
self.assertEventsSet(self._events_ros)
|
||||||
|
|
||||||
# Check sub_init
|
print('EVENTS: ', self._events)
|
||||||
sub_init_events = self.get_events_with_name('ros2:rcl_subscription_init')
|
|
||||||
sub_init_normal_events = self.get_events_with_field_value(
|
# Check rcl_subscription_init events
|
||||||
|
rcl_sub_init_events = self.get_events_with_name('ros2:rcl_subscription_init')
|
||||||
|
rcl_sub_init_topic_events = self.get_events_with_field_value(
|
||||||
'topic_name',
|
'topic_name',
|
||||||
'/the_topic',
|
'/the_topic',
|
||||||
sub_init_events)
|
rcl_sub_init_events,
|
||||||
|
)
|
||||||
|
# Only 1 for our given topic
|
||||||
self.assertNumEventsEqual(
|
self.assertNumEventsEqual(
|
||||||
sub_init_normal_events,
|
rcl_sub_init_topic_events,
|
||||||
1,
|
1,
|
||||||
'none or more than 1 sub init event')
|
'none or more than 1 rcl_sub_init event for the topic',
|
||||||
|
)
|
||||||
|
|
||||||
# Get subscription handle
|
# Get subscription handle
|
||||||
sub_init_normal_event = sub_init_normal_events[0]
|
rcl_sub_init_topic_event = rcl_sub_init_topic_events[0]
|
||||||
sub_handle_intra = self.get_field(sub_init_normal_event, 'subscription_handle')
|
sub_handle_intra = self.get_field(rcl_sub_init_topic_event, 'subscription_handle')
|
||||||
|
|
||||||
# Get corresponding callback handle
|
# Check rclcpp_subscription_init events
|
||||||
# Callback handle
|
rclcpp_sub_init_events = self.get_events_with_name('ros2:rclcpp_subscription_init')
|
||||||
callback_added_events = self.get_events_with_field_value(
|
rclcpp_sub_init_topic_events = self.get_events_with_field_value(
|
||||||
'subscription_handle',
|
'subscription_handle',
|
||||||
sub_handle_intra,
|
sub_handle_intra,
|
||||||
self.get_events_with_name(
|
rclcpp_sub_init_events,
|
||||||
'ros2:rclcpp_subscription_callback_added'))
|
)
|
||||||
|
# Should have 2 events for the given subscription handle
|
||||||
|
# (Subscription and SubscriptionIntraProcess)
|
||||||
self.assertNumEventsEqual(
|
self.assertNumEventsEqual(
|
||||||
callback_added_events,
|
rclcpp_sub_init_topic_events,
|
||||||
1,
|
2,
|
||||||
'none or more than 1 callback added event')
|
'number of rclcpp_sub_init events for the topic not equal to 2',
|
||||||
callback_added_event = callback_added_events[0]
|
)
|
||||||
callback_handle = self.get_field(callback_added_event, 'callback')
|
|
||||||
|
# Get the 2 subscription pointers
|
||||||
|
events = rclcpp_sub_init_topic_events
|
||||||
|
subscription_pointers = [self.get_field(e, 'subscription') for e in events]
|
||||||
|
|
||||||
|
# Get the corresponding callback pointers
|
||||||
|
rclcpp_sub_callback_added_events = self.get_events_with_name(
|
||||||
|
'ros2:rclcpp_subscription_callback_added',
|
||||||
|
)
|
||||||
|
rclcpp_sub_callback_added_topic_events = self.get_events_with_field_value(
|
||||||
|
'subscription',
|
||||||
|
subscription_pointers,
|
||||||
|
rclcpp_sub_callback_added_events,
|
||||||
|
)
|
||||||
|
events = rclcpp_sub_callback_added_topic_events
|
||||||
|
callback_pointers = [self.get_field(e, 'callback') for e in events]
|
||||||
|
|
||||||
# Get corresponding callback start/end pairs
|
# Get corresponding callback start/end pairs
|
||||||
start_events = self.get_events_with_name('ros2:callback_start')
|
start_events = self.get_events_with_name('ros2:callback_start')
|
||||||
|
@ -77,30 +100,47 @@ class TestIntra(TraceTestCase):
|
||||||
end_events,
|
end_events,
|
||||||
1,
|
1,
|
||||||
'does not have at least 1 callback end event')
|
'does not have at least 1 callback end event')
|
||||||
start_events_intra = self.get_events_with_field_value(
|
start_events_topic = self.get_events_with_field_value(
|
||||||
'callback',
|
'callback',
|
||||||
callback_handle,
|
callback_pointers,
|
||||||
start_events)
|
start_events)
|
||||||
end_events_intra = self.get_events_with_field_value(
|
end_events_topic = self.get_events_with_field_value(
|
||||||
'callback',
|
'callback',
|
||||||
callback_handle,
|
callback_pointers,
|
||||||
end_events)
|
end_events)
|
||||||
self.assertNumEventsGreaterEqual(
|
self.assertNumEventsGreaterEqual(
|
||||||
start_events_intra,
|
start_events_topic,
|
||||||
1,
|
1,
|
||||||
'no intra start event')
|
'no callback_start event found for topic')
|
||||||
self.assertNumEventsGreaterEqual(
|
self.assertNumEventsGreaterEqual(
|
||||||
end_events_intra,
|
end_events_topic,
|
||||||
1,
|
1,
|
||||||
'no intra end event')
|
'no callback_end found event for topic')
|
||||||
|
|
||||||
# Check is_intra_process field value
|
# Check for is_intra_process field value of 1/true
|
||||||
start_event_intra = start_events_intra[0]
|
start_events_intra = self.get_events_with_field_value(
|
||||||
self.assertFieldEquals(
|
|
||||||
start_event_intra,
|
|
||||||
'is_intra_process',
|
'is_intra_process',
|
||||||
1,
|
1,
|
||||||
'is_intra_process field value not valid for intra callback')
|
start_events_topic,
|
||||||
|
)
|
||||||
|
# Should have one event
|
||||||
|
self.assertNumEventsEqual(
|
||||||
|
start_events_intra,
|
||||||
|
1,
|
||||||
|
'none or more than 1 callback_start event for intra-process topic',
|
||||||
|
)
|
||||||
|
# As a sanity check, make sure its callback pointer has a corresponding callback_end event
|
||||||
|
callback_pointer_intra = self.get_field(start_events_intra[0], 'callback')
|
||||||
|
end_events_intra = self.get_events_with_field_value(
|
||||||
|
'callback',
|
||||||
|
callback_pointer_intra,
|
||||||
|
end_events_topic,
|
||||||
|
)
|
||||||
|
self.assertNumEventsEqual(
|
||||||
|
end_events_intra,
|
||||||
|
1,
|
||||||
|
'none or more than 1 callback_end event for intra-process topic',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue