From 3b85b3cbd815aa3a4e05d43a84e4cc08d901417f Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Mon, 3 Jun 2019 10:07:43 +0200 Subject: [PATCH] Add node creation test --- tracetools_test/CMakeLists.txt | 1 + tracetools_test/test/test_node.py | 33 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tracetools_test/test/test_node.py diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index a0ebd1a..b0ee45f 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -41,6 +41,7 @@ if(BUILD_TESTING) # Run each test in its own pytest invocation set(_tracetools_test_pytest_tests + test/test_node.py test/test_publisher.py test/test_subscription.py ) diff --git a/tracetools_test/test/test_node.py b/tracetools_test/test/test_node.py new file mode 100644 index 0000000..2757948 --- /dev/null +++ b/tracetools_test/test/test_node.py @@ -0,0 +1,33 @@ +import unittest +from tracetools_test.utils import ( + get_trace_event_names, + run_and_trace, + cleanup_trace, +) + +PKG = 'tracetools_test' + +node_creation_events = [ + 'ros2:rcl_init', + 'ros2:rcl_node_init', +] + +class TestNode(unittest.TestCase): + + def test_creation(self): + session_name_prefix = 'session-test-node-creation' + base_path = '/tmp' + test_node = 'test_publisher' + + exit_code, full_path = run_and_trace(base_path, session_name_prefix, node_creation_events, None, PKG, test_node) + self.assertEqual(exit_code, 0) + + trace_events = get_trace_event_names(full_path) + print(f'trace_events: {trace_events}') + self.assertSetEqual(set(node_creation_events), trace_events) + + cleanup_trace(full_path) + + +if __name__ == '__main__': + unittest.main()