4 class TheIteratorOfConfusion(bt2
._UserMessageIterator
):
5 def __init__(self
, config
, port
):
7 test_name
= port
.user_data
[0]
8 TEST_CASES
[test_name
].create_msgs(self
, port
.user_data
[1:])
11 if self
._at
< len(self
._msgs
):
12 msg
= self
._msgs
[self
._at
]
18 @bt2.plugin_component_class
19 class TheSourceOfConfusion(
20 bt2
._UserSourceComponent
, message_iterator_class
=TheIteratorOfConfusion
22 def __init__(self
, config
, params
, obj
):
23 test_name
= str(params
['test-name'])
25 TEST_CASES
[test_name
].source_setup(self
, test_name
)
29 def source_setup(src
, test_name
):
30 tc1
= src
._create
_trace
_class
()
31 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
32 tc2
= src
._create
_trace
_class
()
33 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
36 trace_name2
= 'noranda'
38 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, trace_name1
))
39 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, trace_name2
))
41 def create_msgs(msg_iter
, params
):
42 iter_id
, tc
, cc
, trace_name
= params
43 trace
= tc(name
=trace_name
)
44 sc
= tc
.create_stream_class(
45 default_clock_class
=cc
, assigns_automatic_stream_id
=False
47 stream
= trace
.create_stream(sc
, 0)
49 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
50 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
52 msg_iter
._msgs
= [sb_msg
, se_msg
]
56 def source_setup(src
, test_name
):
57 tc1
= src
._create
_trace
_class
()
58 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
59 tc2
= src
._create
_trace
_class
()
60 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
62 stream_name1
= 'port-daniel'
63 stream_name2
= 'gascon'
65 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_name1
))
66 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_name2
))
68 def create_msgs(msg_iter
, params
):
69 iter_id
, tc
, cc
, stream_name
= params
71 sc
= tc
.create_stream_class(
72 default_clock_class
=cc
, assigns_automatic_stream_id
=False
74 stream
= trace
.create_stream(sc
, 0, stream_name
)
76 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
77 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
79 msg_iter
._msgs
= [sb_msg
, se_msg
]
83 def source_setup(src
, test_name
):
84 tc1
= src
._create
_trace
_class
()
85 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
86 tc2
= src
._create
_trace
_class
()
87 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
92 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_id1
))
93 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_id2
))
95 def create_msgs(msg_iter
, params
):
96 iter_id
, tc
, cc
, stream_id
= params
98 sc
= tc
.create_stream_class(
99 default_clock_class
=cc
, assigns_automatic_stream_id
=False
101 stream
= trace
.create_stream(sc
, stream_id
)
103 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
104 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
106 msg_iter
._msgs
= [sb_msg
, se_msg
]
109 class DiffStreamNoName
:
110 def source_setup(src
, test_name
):
111 tc1
= src
._create
_trace
_class
()
112 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
113 tc2
= src
._create
_trace
_class
()
114 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
119 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_name1
))
120 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_name2
))
122 def create_msgs(msg_iter
, params
):
123 iter_id
, tc
, cc
, stream_no_name
= params
125 sc
= tc
.create_stream_class(
126 default_clock_class
=cc
, assigns_automatic_stream_id
=False
128 stream
= trace
.create_stream(sc
, 0, name
=stream_no_name
)
130 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
131 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
133 msg_iter
._msgs
= [sb_msg
, se_msg
]
136 class DiffStreamClassId
:
137 def source_setup(src
, test_name
):
138 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
139 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
140 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
141 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
143 stream_class_id1
= 18
144 stream_class_id2
= 23
146 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_class_id1
))
147 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_class_id2
))
149 def create_msgs(msg_iter
, params
):
150 iter_id
, tc
, cc
, stream_class_id
= params
152 sc
= tc
.create_stream_class(
153 default_clock_class
=cc
,
155 assigns_automatic_stream_id
=False,
157 stream
= trace
.create_stream(sc
, 0)
159 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
160 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
162 msg_iter
._msgs
= [sb_msg
, se_msg
]
165 class DiffStreamClassName
:
166 def source_setup(src
, test_name
):
167 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
168 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
169 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
170 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
172 stream_class_name1
= 'one'
173 stream_class_name2
= 'two'
175 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_class_name1
))
176 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_class_name2
))
178 def create_msgs(msg_iter
, params
):
179 iter_id
, tc
, cc
, stream_class_name
= params
181 sc
= tc
.create_stream_class(
182 default_clock_class
=cc
,
184 name
=stream_class_name
,
185 assigns_automatic_stream_id
=False,
187 stream
= trace
.create_stream(sc
, 0)
189 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
190 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
192 msg_iter
._msgs
= [sb_msg
, se_msg
]
195 class DiffStreamClassNoName
:
196 def source_setup(src
, test_name
):
197 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
198 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
199 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
200 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
202 stream_class_name1
= 'one'
203 stream_class_name2
= None
205 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_class_name1
))
206 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_class_name2
))
208 def create_msgs(msg_iter
, params
):
209 iter_id
, tc
, cc
, stream_class_name
= params
211 sc
= tc
.create_stream_class(
212 default_clock_class
=cc
,
214 name
=stream_class_name
,
215 assigns_automatic_stream_id
=False,
217 stream
= trace
.create_stream(sc
, 0)
219 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
220 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
222 msg_iter
._msgs
= [sb_msg
, se_msg
]
225 class BasicTimestampOrdering
:
226 def source_setup(src
, test_name
):
227 tc
= src
._create
_trace
_class
()
228 cc
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
234 src
._add
_output
_port
('out1', (test_name
, 1, tc
, cc
, timestamp1
))
235 src
._add
_output
_port
('out2', (test_name
, 2, tc
, cc
, timestamp2
))
236 src
._add
_output
_port
('out3', (test_name
, 3, tc
, cc
, timestamp3
))
238 def create_msgs(msg_iter
, params
):
239 iter_id
, tc
, cc
, timestamp
= params
241 sc
= tc
.create_stream_class(default_clock_class
=cc
)
242 stream
= trace
.create_stream(sc
)
244 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, timestamp
)
245 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
247 msg_iter
._msgs
= [sb_msg
, se_msg
]
250 class MultiIterOrdering
:
251 def source_setup(src
, test_name
):
252 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
253 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
254 tc3
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
255 tc4
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
256 cc
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
258 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc
))
259 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc
))
260 src
._add
_output
_port
('out3', (test_name
, 3, tc3
, cc
))
261 src
._add
_output
_port
('out4', (test_name
, 4, tc4
, cc
))
263 def create_msgs(msg_iter
, params
):
264 iter_id
, tc
, cc
= params
265 trace_hello
= tc(name
='hello')
266 trace_meow
= tc(name
='meow')
268 # Craft list of messages for each iterator so that the last messages of
269 # each iterator are all sharing the same timestamp.
270 clock_snapshot_value
= 25
273 # Event, 2500 ns, trace "hello", stream class 0, stream 1
274 stream_class0
= tc
.create_stream_class(
275 id=0, default_clock_class
=cc
, assigns_automatic_stream_id
=False
277 sc_0_stream_1
= trace_hello
.create_stream(stream_class0
, id=1)
278 event_class
= stream_class0
.create_event_class(name
='saumon atlantique')
281 msg_iter
._create
_stream
_beginning
_message
(sc_0_stream_1
, 0),
282 msg_iter
._create
_event
_message
(
283 event_class
, sc_0_stream_1
, clock_snapshot_value
285 msg_iter
._create
_stream
_end
_message
(sc_0_stream_1
, iter_id
* 193),
288 # Packet beginning, 2500 ns, trace "meow", stream class 0, stream 1
289 stream_class0
= tc
.create_stream_class(
291 default_clock_class
=cc
,
292 supports_packets
=True,
293 packets_have_beginning_default_clock_snapshot
=True,
294 packets_have_end_default_clock_snapshot
=True,
295 assigns_automatic_stream_id
=False,
298 sc_0_stream_1
= trace_meow
.create_stream(stream_class0
, id=1)
299 packet
= sc_0_stream_1
.create_packet()
302 msg_iter
._create
_stream
_beginning
_message
(sc_0_stream_1
, 1),
303 msg_iter
._create
_packet
_beginning
_message
(packet
, clock_snapshot_value
),
304 msg_iter
._create
_packet
_end
_message
(packet
, iter_id
* 79),
305 msg_iter
._create
_stream
_end
_message
(sc_0_stream_1
, iter_id
* 193),
308 # Stream beginning, 2500 ns, trace "hello", stream class 0, stream 0
309 stream_class0
= tc
.create_stream_class(
310 id=0, default_clock_class
=cc
, assigns_automatic_stream_id
=False
313 sc_0_stream_0
= trace_hello
.create_stream(stream_class0
, id=0)
316 msg_iter
._create
_stream
_beginning
_message
(
317 sc_0_stream_0
, clock_snapshot_value
319 msg_iter
._create
_stream
_end
_message
(sc_0_stream_0
, iter_id
* 193),
322 # Event, 2500 ns, trace "meow", stream class 1, stream 1
323 stream_class1
= tc
.create_stream_class(
324 id=1, default_clock_class
=cc
, assigns_automatic_stream_id
=False
327 sc_1_stream_1
= trace_meow
.create_stream(stream_class1
, id=1)
329 event_class
= stream_class1
.create_event_class(name
='bar rayƩ')
331 msg_iter
._create
_stream
_beginning
_message
(sc_1_stream_1
, 3),
332 msg_iter
._create
_event
_message
(
333 event_class
, sc_1_stream_1
, clock_snapshot_value
335 msg_iter
._create
_stream
_end
_message
(sc_1_stream_1
, iter_id
* 193),
339 class DiffEventClassName
:
340 def source_setup(src
, test_name
):
341 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
342 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
343 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
344 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
346 event_class_name1
= 'Hull'
347 event_class_name2
= 'Gatineau'
349 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, event_class_name1
))
350 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, event_class_name2
))
352 def create_msgs(msg_iter
, params
):
353 iter_id
, tc
, cc
, event_class_name
= params
355 sc
= tc
.create_stream_class(
356 default_clock_class
=cc
,
358 assigns_automatic_stream_id
=False,
359 supports_packets
=False,
361 ec
= sc
.create_event_class(name
=event_class_name
)
363 stream
= trace
.create_stream(sc
, 0)
365 # Use event class name length as timestamp so that both stream
366 # beginning message are not at the same time. This test is targetting
368 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, len(ec
.name
))
369 ev_msg
= msg_iter
._create
_event
_message
(ec
, stream
, 50)
370 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
372 msg_iter
._msgs
= [sb_msg
, ev_msg
, se_msg
]
375 class DiffEventClassId
:
376 def source_setup(src
, test_name
):
377 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
378 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
379 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
380 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
385 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, event_class_id1
))
386 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, event_class_id2
))
388 def create_msgs(msg_iter
, params
):
389 iter_id
, tc
, cc
, event_class_id
= params
391 sc
= tc
.create_stream_class(
392 default_clock_class
=cc
,
394 assigns_automatic_stream_id
=False,
395 assigns_automatic_event_class_id
=False,
396 supports_packets
=False,
398 ec
= sc
.create_event_class(id=event_class_id
)
400 stream
= trace
.create_stream(sc
, 0)
402 # Use event class id as timestamp so that both stream beginning message
403 # are not at the same time. This test is targetting event message.
404 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, ec
.id)
405 ev_msg
= msg_iter
._create
_event
_message
(ec
, stream
, 50)
406 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
408 msg_iter
._msgs
= [sb_msg
, ev_msg
, se_msg
]
411 class DiffInactivityMsgCs
:
412 def source_setup(src
, test_name
):
413 cc1
= src
._create
_clock
_class
(
414 frequency
=1, name
='La Baie', offset
=bt2
.ClockClassOffset(0)
416 cc2
= src
._create
_clock
_class
(
417 frequency
=1, name
='Chicoutimi', offset
=bt2
.ClockClassOffset(0)
420 src
._add
_output
_port
('out1', (test_name
, cc1
))
421 src
._add
_output
_port
('out2', (test_name
, cc2
))
423 def create_msgs(msg_iter
, params
):
425 sb_msg
= msg_iter
._create
_message
_iterator
_inactivity
_message
(cc
, 0)
426 msg_iter
._msgs
= [sb_msg
]
430 'diff_trace_name': DiffTraceName
,
431 'diff_event_class_name': DiffEventClassName
,
432 'diff_event_class_id': DiffEventClassId
,
433 'diff_stream_name': DiffStreamName
,
434 'diff_stream_no_name': DiffStreamNoName
,
435 'diff_stream_id': DiffStreamId
,
436 'diff_stream_class_id': DiffStreamClassId
,
437 'diff_stream_class_name': DiffStreamClassName
,
438 'diff_stream_class_no_name': DiffStreamClassNoName
,
439 'diff_inactivity_msg_cs': DiffInactivityMsgCs
,
440 'basic_timestamp_ordering': BasicTimestampOrdering
,
441 'multi_iter_ordering': MultiIterOrdering
,
444 bt2
.register_plugin(__name__
, 'test-muxer')