4 class TheIteratorOfAllEvil(bt2
._UserMessageIterator
):
5 def __init__(self
, config
, port
):
6 tc
, sc
, ec1
, ec2
, params
= port
.user_data
8 stream
= trace
.create_stream(sc
)
10 # Test with and without packets, once packets are optional.
11 packet
= stream
.create_packet()
13 if params
['with-stream-msgs-cs']:
14 sb_msg
= self
._create
_stream
_beginning
_message
(stream
, 100)
16 sb_msg
= self
._create
_stream
_beginning
_message
(stream
)
18 ev_msg1
= self
._create
_event
_message
(ec1
, packet
, 300)
19 ev_msg2
= self
._create
_event
_message
(ec2
, packet
, 400)
21 if params
['with-stream-msgs-cs']:
22 se_msg
= self
._create
_stream
_end
_message
(stream
, 1000)
24 se_msg
= self
._create
_stream
_end
_message
(stream
)
28 self
._create
_packet
_beginning
_message
(packet
, 200),
31 self
._create
_packet
_end
_message
(packet
, 900),
35 config
.can_seek_forward
= True
37 def _user_seek_beginning(self
):
41 if self
._at
< len(self
._msgs
):
42 msg
= self
._msgs
[self
._at
]
49 @bt2.plugin_component_class
50 class TheSourceOfAllEvil(
51 bt2
._UserSourceComponent
, message_iterator_class
=TheIteratorOfAllEvil
53 def __init__(self
, config
, params
, obj
):
54 tc
= self
._create
_trace
_class
()
56 # Use a clock class with an offset, so we can test with --begin or --end
57 # smaller than this offset (in other words, a time that it's not
58 # possible to represent with this clock class).
59 cc
= self
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(10000))
60 sc
= tc
.create_stream_class(
61 default_clock_class
=cc
,
62 supports_packets
=True,
63 packets_have_beginning_default_clock_snapshot
=True,
64 packets_have_end_default_clock_snapshot
=True,
66 ec1
= sc
.create_event_class(name
='event 1')
67 ec2
= sc
.create_event_class(name
='event 2')
68 self
._add
_output
_port
('out', (tc
, sc
, ec1
, ec2
, params
))
71 bt2
.register_plugin(__name__
, 'test-trimmer')