X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_trace_collection_message_iterator.py;h=f2ddb6d03394976cd477c0510c0001d739133ec9;hp=7181a1e55eea979875827fc8d10c6adc52451ce6;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=5f2a1585bf407f3f3aa7e63d9041b75390cf8563 diff --git a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py index 7181a1e5..f2ddb6d0 100644 --- a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py +++ b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py @@ -1,20 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only # # Copyright (C) 2019 EfficiOS Inc. # -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# import unittest import datetime @@ -100,7 +87,8 @@ class ComponentSpecTestCase(unittest.TestCase): def test_create_sink_from_object(self): with self.assertRaisesRegex( - TypeError, "'_SinkComponentClass' is not a source or filter component class" + TypeError, + "'_SinkComponentClassConst' is not a source or filter component class", ): bt2.ComponentSpec(self._pretty_cc) @@ -258,7 +246,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): msgs = list(msg_iter) self.assertEqual(len(msgs), 28) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 8) + self.assertEqual(hist[bt2._EventMessageConst], 8) # Same as the above, but we pass a single spec instead of a spec list. def test_iter_specs_not_list(self): @@ -269,7 +257,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): msgs = list(msg_iter) self.assertEqual(len(msgs), 28) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 8) + self.assertEqual(hist[bt2._EventMessageConst], 8) def test_iter_custom_filter(self): src_spec = bt2.ComponentSpec.from_named_plugin_and_component_class( @@ -280,7 +268,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): ) msg_iter = bt2.TraceCollectionMessageIterator(src_spec, flt_spec) hist = _count_msgs_by_type(msg_iter) - self.assertEqual(hist[bt2._EventMessage], 5) + self.assertEqual(hist[bt2._EventMessageConst], 5) def test_iter_intersection(self): specs = [ @@ -294,7 +282,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): msgs = list(msg_iter) self.assertEqual(len(msgs), 15) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 3) + self.assertEqual(hist[bt2._EventMessageConst], 3) def test_iter_intersection_params(self): # Check that all params used to create the source component are passed @@ -314,7 +302,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): specs, stream_intersection_mode=True ) - event_msgs = [x for x in msg_iter if type(x) is bt2._EventMessage] + event_msgs = [x for x in msg_iter if type(x) is bt2._EventMessageConst] self.assertEqual(len(event_msgs), 3) self.assertEqual( event_msgs[0].default_clock_snapshot.ns_from_origin, 13516309000000071 @@ -335,7 +323,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): msgs = list(msg_iter) self.assertEqual(len(msgs), 56) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 16) + self.assertEqual(hist[bt2._EventMessageConst], 16) def test_iter_no_intersection_begin(self): specs = [ @@ -345,7 +333,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): ] msg_iter = bt2.TraceCollectionMessageIterator(specs, begin=13515309.000000023) hist = _count_msgs_by_type(msg_iter) - self.assertEqual(hist[bt2._EventMessage], 6) + self.assertEqual(hist[bt2._EventMessageConst], 6) def test_iter_no_intersection_end(self): specs = [ @@ -355,7 +343,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): ] msg_iter = bt2.TraceCollectionMessageIterator(specs, end=13515309.000000075) hist = _count_msgs_by_type(msg_iter) - self.assertEqual(hist[bt2._EventMessage], 5) + self.assertEqual(hist[bt2._EventMessageConst], 5) def test_iter_auto_source_component_spec(self): specs = [bt2.AutoSourceComponentSpec(_3EVENTS_INTERSECT_TRACE_PATH)] @@ -363,21 +351,21 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): msgs = list(msg_iter) self.assertEqual(len(msgs), 28) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 8) + self.assertEqual(hist[bt2._EventMessageConst], 8) def test_iter_auto_source_component_spec_list_of_strings(self): msg_iter = bt2.TraceCollectionMessageIterator([_3EVENTS_INTERSECT_TRACE_PATH]) msgs = list(msg_iter) self.assertEqual(len(msgs), 28) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 8) + self.assertEqual(hist[bt2._EventMessageConst], 8) def test_iter_auto_source_component_spec_string(self): msg_iter = bt2.TraceCollectionMessageIterator(_3EVENTS_INTERSECT_TRACE_PATH) msgs = list(msg_iter) self.assertEqual(len(msgs), 28) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 8) + self.assertEqual(hist[bt2._EventMessageConst], 8) def test_iter_mixed_inputs(self): msg_iter = bt2.TraceCollectionMessageIterator( @@ -392,7 +380,7 @@ class TraceCollectionMessageIteratorTestCase(unittest.TestCase): msgs = list(msg_iter) self.assertEqual(len(msgs), 76) hist = _count_msgs_by_type(msgs) - self.assertEqual(hist[bt2._EventMessage], 24) + self.assertEqual(hist[bt2._EventMessageConst], 24) def test_auto_source_component_non_existent(self): with self.assertRaisesRegex( @@ -426,7 +414,7 @@ class TestAutoDiscoverSourceComponentSpecsGrouping( bt2.AutoSourceComponentSpec(_AUTO_SOURCE_DISCOVERY_GROUPING_PATH), ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 8) @@ -456,7 +444,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( ) ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 2) @@ -508,7 +496,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( ), ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 2) @@ -572,7 +560,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( ), ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 2) @@ -639,7 +627,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( ), ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 2) @@ -700,7 +688,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( ), ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 2) self.assertEqual(msgs[0].stream.name, "TestSourceA: None") @@ -714,7 +702,7 @@ class TestAutoDiscoverSourceComponentSpecsParamsObjLogLevel( bt2.AutoSourceComponentSpec(self._dir_a, params={'what': 'python-obj'}), ] it = bt2.TraceCollectionMessageIterator(specs) - msgs = [x for x in it if type(x) is bt2._StreamBeginningMessage] + msgs = [x for x in it if type(x) is bt2._StreamBeginningMessageConst] self.assertEqual(len(msgs), 2) self.assertEqual(msgs[0].stream.name, "TestSourceA: deore")