From ce0c39a24d8a8f9b3dc39a935baf811576588f53 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Tue, 12 Nov 2019 18:06:42 -0800 Subject: [PATCH] Update test_intra after new intraprocess communications --- tracetools_test/CMakeLists.txt | 2 +- tracetools_test/test/test_intra.py | 47 +++++++----------------------- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index 9de0467..e744477 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -141,7 +141,7 @@ if(BUILD_TESTING) # Run each test in its own pytest invocation set(_tracetools_test_pytest_tests - #test/test_intra.py + test/test_intra.py test/test_node.py test/test_publisher.py test/test_service.py diff --git a/tracetools_test/test/test_intra.py b/tracetools_test/test/test_intra.py index 413b5d3..4b4fedb 100644 --- a/tracetools_test/test/test_intra.py +++ b/tracetools_test/test/test_intra.py @@ -36,28 +36,19 @@ class TestIntra(TraceTestCase): # Check events order as set (e.g. node_init before pub_init) self.assertEventsOrderSet(self._events_ros) - # Check sub_init for normal and intraprocess events + # Check sub_init sub_init_events = self.get_events_with_name('ros2:rcl_subscription_init') sub_init_normal_events = self.get_events_with_field_value( 'topic_name', '/the_topic', sub_init_events) - sub_init_intra_events = self.get_events_with_field_value( - 'topic_name', - '/the_topic/_intra', - sub_init_events) self.assertNumEventsEqual( sub_init_normal_events, 1, - 'none or more than 1 sub init event for normal sub') - self.assertNumEventsEqual( - sub_init_intra_events, - 1, - 'none or more than 1 sub init event for intra sub') + 'none or more than 1 sub init event') - # Get subscription handles for normal & intra subscriptions + # Get subscription handle sub_init_normal_event = sub_init_normal_events[0] - # Note: sub handle linked to "normal" topic is the one actually linked to intra callback sub_handle_intra = self.get_field(sub_init_normal_event, 'subscription_handle') print(f'sub_handle_intra: {sub_handle_intra}') @@ -73,27 +64,27 @@ class TestIntra(TraceTestCase): 1, 'none or more than 1 callback added event') callback_added_event = callback_added_events[0] - callback_handle_intra = self.get_field(callback_added_event, 'callback') + callback_handle = self.get_field(callback_added_event, 'callback') # Get corresponding callback start/end pairs start_events = self.get_events_with_name('ros2:callback_start') end_events = self.get_events_with_name('ros2:callback_end') - # Should still have at least two start:end pairs (1 normal + 1 intra) + # Should have at least one start:end pair self.assertNumEventsGreaterEqual( start_events, - 2, - 'does not have at least 2 callback start events') + 1, + 'does not have at least 1 callback start event') self.assertNumEventsGreaterEqual( end_events, - 2, - 'does not have at least 2 callback end events') + 1, + 'does not have at least 1 callback end event') start_events_intra = self.get_events_with_field_value( 'callback', - callback_handle_intra, + callback_handle, start_events) end_events_intra = self.get_events_with_field_value( 'callback', - callback_handle_intra, + callback_handle, end_events) self.assertNumEventsGreaterEqual( start_events_intra, @@ -112,22 +103,6 @@ class TestIntra(TraceTestCase): 1, 'is_intra_process field value not valid for intra callback') - # Also check that the other callback_start event (normal one) has the right field value - start_events_not_intra = self.get_events_with_field_not_value( - 'callback', - callback_handle_intra, - start_events) - self.assertNumEventsGreaterEqual( - start_events_not_intra, - 1, - 'no normal start event') - start_event_not_intra = start_events_not_intra[0] - self.assertFieldEquals( - start_event_not_intra, - 'is_intra_process', - 0, - 'is_intra_process field value not valid for normal callback') - if __name__ == '__main__': unittest.main()