4 class TheIteratorOfAllEvil(bt2
._UserMessageIterator
):
5 def __init__(self
, 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),
36 def _seek_beginning(self
):
40 if self
._at
< len(self
._msgs
):
41 msg
= self
._msgs
[self
._at
]
47 @bt2.plugin_component_class
48 class TheSourceOfAllEvil(bt2
._UserSourceComponent
,
49 message_iterator_class
=TheIteratorOfAllEvil
):
50 def __init__(self
, params
):
51 tc
= self
._create
_trace
_class
()
53 # Use a clock class with an offset, so we can test with --begin or --end
54 # smaller than this offset (in other words, a time that it's not
55 # possible to represent with this clock class).
56 cc
= self
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(10000))
57 sc
= tc
.create_stream_class(default_clock_class
=cc
,
58 packets_have_beginning_default_clock_snapshot
=True,
59 packets_have_end_default_clock_snapshot
=True)
60 ec1
= sc
.create_event_class(name
='event 1')
61 ec2
= sc
.create_event_class(name
='event 2')
62 self
._add
_output
_port
('out', (tc
, sc
, ec1
, ec2
, params
))
65 bt2
.register_plugin(__name__
, 'test-trimmer')