1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2019 EfficiOS Inc.
9 class TheIteratorOfConfusion(bt2
._UserMessageIterator
):
10 def __init__(self
, config
, port
):
12 test_name
= port
.user_data
[0]
13 TEST_CASES
[test_name
].create_msgs(self
, port
.user_data
[1:])
16 if self
._at
< len(self
._msgs
):
17 msg
= self
._msgs
[self
._at
]
23 @bt2.plugin_component_class
24 class TheSourceOfConfusion(
25 bt2
._UserSourceComponent
, message_iterator_class
=TheIteratorOfConfusion
27 def __init__(self
, config
, params
, obj
):
28 test_name
= str(params
['test-name'])
30 TEST_CASES
[test_name
].source_setup(self
, test_name
)
34 def source_setup(src
, test_name
):
35 tc1
= src
._create
_trace
_class
()
36 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
37 tc2
= src
._create
_trace
_class
()
38 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
41 trace_name2
= 'noranda'
43 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, trace_name1
))
44 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, trace_name2
))
46 def create_msgs(msg_iter
, params
):
47 iter_id
, tc
, cc
, trace_name
= params
48 trace
= tc(name
=trace_name
)
49 sc
= tc
.create_stream_class(
50 default_clock_class
=cc
, assigns_automatic_stream_id
=False
52 stream
= trace
.create_stream(sc
, 0)
54 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
55 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
57 msg_iter
._msgs
= [sb_msg
, se_msg
]
61 def source_setup(src
, test_name
):
62 tc1
= src
._create
_trace
_class
()
63 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
64 tc2
= src
._create
_trace
_class
()
65 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
67 stream_name1
= 'port-daniel'
68 stream_name2
= 'gascon'
70 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_name1
))
71 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_name2
))
73 def create_msgs(msg_iter
, params
):
74 iter_id
, tc
, cc
, stream_name
= params
76 sc
= tc
.create_stream_class(
77 default_clock_class
=cc
, assigns_automatic_stream_id
=False
79 stream
= trace
.create_stream(sc
, 0, stream_name
)
81 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
82 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
84 msg_iter
._msgs
= [sb_msg
, se_msg
]
88 def source_setup(src
, test_name
):
89 tc1
= src
._create
_trace
_class
()
90 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
91 tc2
= src
._create
_trace
_class
()
92 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
97 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_id1
))
98 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_id2
))
100 def create_msgs(msg_iter
, params
):
101 iter_id
, tc
, cc
, stream_id
= params
103 sc
= tc
.create_stream_class(
104 default_clock_class
=cc
, assigns_automatic_stream_id
=False
106 stream
= trace
.create_stream(sc
, stream_id
)
108 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
109 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
111 msg_iter
._msgs
= [sb_msg
, se_msg
]
114 class DiffStreamNoName
:
115 def source_setup(src
, test_name
):
116 tc1
= src
._create
_trace
_class
()
117 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
118 tc2
= src
._create
_trace
_class
()
119 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
124 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_name1
))
125 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_name2
))
127 def create_msgs(msg_iter
, params
):
128 iter_id
, tc
, cc
, stream_no_name
= params
130 sc
= tc
.create_stream_class(
131 default_clock_class
=cc
, assigns_automatic_stream_id
=False
133 stream
= trace
.create_stream(sc
, 0, name
=stream_no_name
)
135 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
136 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
138 msg_iter
._msgs
= [sb_msg
, se_msg
]
141 class DiffStreamClassId
:
142 def source_setup(src
, test_name
):
143 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
144 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
145 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
146 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
148 stream_class_id1
= 18
149 stream_class_id2
= 23
151 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_class_id1
))
152 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_class_id2
))
154 def create_msgs(msg_iter
, params
):
155 iter_id
, tc
, cc
, stream_class_id
= params
157 sc
= tc
.create_stream_class(
158 default_clock_class
=cc
,
160 assigns_automatic_stream_id
=False,
162 stream
= trace
.create_stream(sc
, 0)
164 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
165 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
167 msg_iter
._msgs
= [sb_msg
, se_msg
]
170 class DiffStreamClassName
:
171 def source_setup(src
, test_name
):
172 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
173 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
174 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
175 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
177 stream_class_name1
= 'one'
178 stream_class_name2
= 'two'
180 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_class_name1
))
181 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_class_name2
))
183 def create_msgs(msg_iter
, params
):
184 iter_id
, tc
, cc
, stream_class_name
= params
186 sc
= tc
.create_stream_class(
187 default_clock_class
=cc
,
189 name
=stream_class_name
,
190 assigns_automatic_stream_id
=False,
192 stream
= trace
.create_stream(sc
, 0)
194 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
195 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
197 msg_iter
._msgs
= [sb_msg
, se_msg
]
200 class DiffStreamClassNoName
:
201 def source_setup(src
, test_name
):
202 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
203 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
204 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
205 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
207 stream_class_name1
= 'one'
208 stream_class_name2
= None
210 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, stream_class_name1
))
211 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, stream_class_name2
))
213 def create_msgs(msg_iter
, params
):
214 iter_id
, tc
, cc
, stream_class_name
= params
216 sc
= tc
.create_stream_class(
217 default_clock_class
=cc
,
219 name
=stream_class_name
,
220 assigns_automatic_stream_id
=False,
222 stream
= trace
.create_stream(sc
, 0)
224 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, 0)
225 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
227 msg_iter
._msgs
= [sb_msg
, se_msg
]
230 class BasicTimestampOrdering
:
231 def source_setup(src
, test_name
):
232 tc
= src
._create
_trace
_class
()
233 cc
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
239 src
._add
_output
_port
('out1', (test_name
, 1, tc
, cc
, timestamp1
))
240 src
._add
_output
_port
('out2', (test_name
, 2, tc
, cc
, timestamp2
))
241 src
._add
_output
_port
('out3', (test_name
, 3, tc
, cc
, timestamp3
))
243 def create_msgs(msg_iter
, params
):
244 iter_id
, tc
, cc
, timestamp
= params
246 sc
= tc
.create_stream_class(default_clock_class
=cc
)
247 stream
= trace
.create_stream(sc
)
249 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, timestamp
)
250 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
252 msg_iter
._msgs
= [sb_msg
, se_msg
]
255 class MultiIterOrdering
:
256 def source_setup(src
, test_name
):
257 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
258 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
259 tc3
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
260 tc4
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
261 cc
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
263 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc
))
264 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc
))
265 src
._add
_output
_port
('out3', (test_name
, 3, tc3
, cc
))
266 src
._add
_output
_port
('out4', (test_name
, 4, tc4
, cc
))
268 def create_msgs(msg_iter
, params
):
269 iter_id
, tc
, cc
= params
270 trace_hello
= tc(name
='hello')
271 trace_meow
= tc(name
='meow')
273 # Craft list of messages for each iterator so that the last messages of
274 # each iterator are all sharing the same timestamp.
275 clock_snapshot_value
= 25
278 # Event, 2500 ns, trace "hello", stream class 0, stream 1
279 stream_class0
= tc
.create_stream_class(
280 id=0, default_clock_class
=cc
, assigns_automatic_stream_id
=False
282 sc_0_stream_1
= trace_hello
.create_stream(stream_class0
, id=1)
283 event_class
= stream_class0
.create_event_class(name
='saumon atlantique')
286 msg_iter
._create
_stream
_beginning
_message
(sc_0_stream_1
, 0),
287 msg_iter
._create
_event
_message
(
288 event_class
, sc_0_stream_1
, clock_snapshot_value
290 msg_iter
._create
_stream
_end
_message
(sc_0_stream_1
, iter_id
* 193),
293 # Packet beginning, 2500 ns, trace "meow", stream class 0, stream 1
294 stream_class0
= tc
.create_stream_class(
296 default_clock_class
=cc
,
297 supports_packets
=True,
298 packets_have_beginning_default_clock_snapshot
=True,
299 packets_have_end_default_clock_snapshot
=True,
300 assigns_automatic_stream_id
=False,
303 sc_0_stream_1
= trace_meow
.create_stream(stream_class0
, id=1)
304 packet
= sc_0_stream_1
.create_packet()
307 msg_iter
._create
_stream
_beginning
_message
(sc_0_stream_1
, 1),
308 msg_iter
._create
_packet
_beginning
_message
(packet
, clock_snapshot_value
),
309 msg_iter
._create
_packet
_end
_message
(packet
, iter_id
* 79),
310 msg_iter
._create
_stream
_end
_message
(sc_0_stream_1
, iter_id
* 193),
313 # Stream beginning, 2500 ns, trace "hello", stream class 0, stream 0
314 stream_class0
= tc
.create_stream_class(
315 id=0, default_clock_class
=cc
, assigns_automatic_stream_id
=False
318 sc_0_stream_0
= trace_hello
.create_stream(stream_class0
, id=0)
321 msg_iter
._create
_stream
_beginning
_message
(
322 sc_0_stream_0
, clock_snapshot_value
324 msg_iter
._create
_stream
_end
_message
(sc_0_stream_0
, iter_id
* 193),
327 # Event, 2500 ns, trace "meow", stream class 1, stream 1
328 stream_class1
= tc
.create_stream_class(
329 id=1, default_clock_class
=cc
, assigns_automatic_stream_id
=False
332 sc_1_stream_1
= trace_meow
.create_stream(stream_class1
, id=1)
334 event_class
= stream_class1
.create_event_class(name
='bar rayƩ')
336 msg_iter
._create
_stream
_beginning
_message
(sc_1_stream_1
, 3),
337 msg_iter
._create
_event
_message
(
338 event_class
, sc_1_stream_1
, clock_snapshot_value
340 msg_iter
._create
_stream
_end
_message
(sc_1_stream_1
, iter_id
* 193),
344 class DiffEventClassName
:
345 def source_setup(src
, test_name
):
346 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
347 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
348 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
349 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
351 event_class_name1
= 'Hull'
352 event_class_name2
= 'Gatineau'
354 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, event_class_name1
))
355 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, event_class_name2
))
357 def create_msgs(msg_iter
, params
):
358 iter_id
, tc
, cc
, event_class_name
= params
360 sc
= tc
.create_stream_class(
361 default_clock_class
=cc
,
363 assigns_automatic_stream_id
=False,
364 supports_packets
=False,
366 ec
= sc
.create_event_class(name
=event_class_name
)
368 stream
= trace
.create_stream(sc
, 0)
370 # Use event class name length as timestamp so that both stream
371 # beginning message are not at the same time. This test is targetting
373 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, len(ec
.name
))
374 ev_msg
= msg_iter
._create
_event
_message
(ec
, stream
, 50)
375 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
377 msg_iter
._msgs
= [sb_msg
, ev_msg
, se_msg
]
380 class DiffEventClassId
:
381 def source_setup(src
, test_name
):
382 tc1
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
383 cc1
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
384 tc2
= src
._create
_trace
_class
(assigns_automatic_stream_class_id
=False)
385 cc2
= src
._create
_clock
_class
(frequency
=1, offset
=bt2
.ClockClassOffset(0))
390 src
._add
_output
_port
('out1', (test_name
, 1, tc1
, cc1
, event_class_id1
))
391 src
._add
_output
_port
('out2', (test_name
, 2, tc2
, cc2
, event_class_id2
))
393 def create_msgs(msg_iter
, params
):
394 iter_id
, tc
, cc
, event_class_id
= params
396 sc
= tc
.create_stream_class(
397 default_clock_class
=cc
,
399 assigns_automatic_stream_id
=False,
400 assigns_automatic_event_class_id
=False,
401 supports_packets
=False,
403 ec
= sc
.create_event_class(id=event_class_id
)
405 stream
= trace
.create_stream(sc
, 0)
407 # Use event class id as timestamp so that both stream beginning message
408 # are not at the same time. This test is targetting event message.
409 sb_msg
= msg_iter
._create
_stream
_beginning
_message
(stream
, ec
.id)
410 ev_msg
= msg_iter
._create
_event
_message
(ec
, stream
, 50)
411 se_msg
= msg_iter
._create
_stream
_end
_message
(stream
, iter_id
* 193)
413 msg_iter
._msgs
= [sb_msg
, ev_msg
, se_msg
]
416 class DiffInactivityMsgCs
:
417 def source_setup(src
, test_name
):
418 cc1
= src
._create
_clock
_class
(
419 frequency
=1, name
='La Baie', offset
=bt2
.ClockClassOffset(0)
421 cc2
= src
._create
_clock
_class
(
422 frequency
=1, name
='Chicoutimi', offset
=bt2
.ClockClassOffset(0)
425 src
._add
_output
_port
('out1', (test_name
, cc1
))
426 src
._add
_output
_port
('out2', (test_name
, cc2
))
428 def create_msgs(msg_iter
, params
):
430 sb_msg
= msg_iter
._create
_message
_iterator
_inactivity
_message
(cc
, 0)
431 msg_iter
._msgs
= [sb_msg
]
435 'diff_trace_name': DiffTraceName
,
436 'diff_event_class_name': DiffEventClassName
,
437 'diff_event_class_id': DiffEventClassId
,
438 'diff_stream_name': DiffStreamName
,
439 'diff_stream_no_name': DiffStreamNoName
,
440 'diff_stream_id': DiffStreamId
,
441 'diff_stream_class_id': DiffStreamClassId
,
442 'diff_stream_class_name': DiffStreamClassName
,
443 'diff_stream_class_no_name': DiffStreamClassNoName
,
444 'diff_inactivity_msg_cs': DiffInactivityMsgCs
,
445 'basic_timestamp_ordering': BasicTimestampOrdering
,
446 'multi_iter_ordering': MultiIterOrdering
,
449 bt2
.register_plugin(__name__
, 'test-muxer')