Add more tests and more test utils

This commit is contained in:
Christophe Bedard 2019-06-19 15:26:46 +02:00
parent 20cf197b87
commit eb8a7e2c26
10 changed files with 389 additions and 23 deletions

View file

@ -30,8 +30,32 @@ class TestServiceCallback(TraceTestCase):
nodes=['test_service_ping', 'test_service_pong']
)
def test_callback(self):
pass
def test_all(self):
# Check events order as set (e.g. start before end)
self.assertEventsOrderSet(self._events_ros)
# Check fields
start_events = self.get_events_with_name('ros2:callback_start')
for event in start_events:
self.assertValidHandle(event, 'callback')
is_intra_process_value = self.get_field(event, 'is_intra_process')
self.assertIsInstance(is_intra_process_value, int, 'is_intra_process not int')
# Should not be 1 for services (yet)
self.assertEqual(
is_intra_process_value,
0,
f'invalid value for is_intra_process: {is_intra_process_value}')
end_events = self.get_events_with_name('ros2:callback_end')
for event in end_events:
self.assertValidHandle(event, 'callback')
# Check that there is at least a start/end pair for each node
for node in self._nodes:
test_start_events = self.get_events_with_procname(node, start_events)
test_end_events = self.get_events_with_procname(node, end_events)
self.assertGreater(len(test_start_events), 0, f'no start_callback events for node: {node}')
self.assertGreater(len(test_end_events), 0, f'no end_callback events for node: {node}')
if __name__ == '__main__':