+# 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
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)
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):
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(
)
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 = [
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_no_inputs_param(self):
+ def test_iter_intersection_params(self):
+ # Check that all params used to create the source component are passed
+ # to the `babeltrace.trace-infos` query.
specs = [
bt2.ComponentSpec.from_named_plugin_and_component_class(
- 'text', 'dmesg', {'read-from-stdin': True}
+ 'ctf',
+ 'fs',
+ {
+ 'inputs': [_3EVENTS_INTERSECT_TRACE_PATH],
+ 'clock-class-offset-s': 1000,
+ },
)
]
- with self.assertRaises(ValueError):
- bt2.TraceCollectionMessageIterator(specs, stream_intersection_mode=True)
+ msg_iter = bt2.TraceCollectionMessageIterator(
+ specs, stream_intersection_mode=True
+ )
+
+ 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
+ )
+ self.assertEqual(
+ event_msgs[1].default_clock_snapshot.ns_from_origin, 13516309000000072
+ )
+ self.assertEqual(
+ event_msgs[2].default_clock_snapshot.ns_from_origin, 13516309000000082
+ )
def test_iter_no_intersection_two_traces(self):
spec = bt2.ComponentSpec.from_named_plugin_and_component_class(
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 = [
]
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 = [
]
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)]
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(
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(
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)
)
]
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)
),
]
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)
),
]
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)
),
]
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)
),
]
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")
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")