2 * Copyright 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #include <babeltrace2/babeltrace.h>
29 #include "common/assert.h"
30 #include "common/common.h"
31 #include "common/macros.h"
32 #include "common/uuid.h"
36 struct message_to_compare
{
37 const bt_message
*msg
;
38 const bt_trace
*trace
;
39 const bt_stream
*stream
;
42 struct messages_to_compare
{
43 struct message_to_compare left
;
44 struct message_to_compare right
;
48 int message_type_weight(const bt_message_type msg_type
)
53 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
56 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
59 case BT_MESSAGE_TYPE_EVENT
:
62 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
65 case BT_MESSAGE_TYPE_PACKET_END
:
68 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
:
71 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
74 case BT_MESSAGE_TYPE_STREAM_END
:
85 * Compare 2 messages to order them in a determinitic way based on their
87 * Returns -1 is left mesage must go first
88 * Returns 1 is right mesage must go first
91 int compare_messages_by_type(struct messages_to_compare
*msgs
)
93 bt_message_type left_msg_type
= bt_message_get_type(msgs
->left
.msg
);
94 bt_message_type right_msg_type
= bt_message_get_type(msgs
->right
.msg
);
96 return message_type_weight(right_msg_type
) -
97 message_type_weight(left_msg_type
);
101 int compare_events(const bt_event
*left_event
, const bt_event
*right_event
)
104 const bt_event_class
*left_event_class
, *right_event_class
;
105 uint64_t left_event_class_id
, right_event_class_id
;
106 const char *left_event_class_name
, *right_event_class_name
,
107 *left_event_class_emf_uri
, *right_event_class_emf_uri
;
108 bt_event_class_log_level left_event_class_log_level
, right_event_class_log_level
;
109 bt_property_availability left_log_level_avail
, right_log_level_avail
;
111 left_event_class
= bt_event_borrow_class_const(left_event
);
112 right_event_class
= bt_event_borrow_class_const(right_event
);
114 left_event_class_id
= bt_event_class_get_id(left_event_class
);
115 right_event_class_id
= bt_event_class_get_id(right_event_class
);
117 if (left_event_class_id
> right_event_class_id
) {
120 } else if (left_event_class_id
< right_event_class_id
) {
125 left_event_class_name
= bt_event_class_get_name(left_event_class
);
126 right_event_class_name
= bt_event_class_get_name(right_event_class
);
127 if (left_event_class_name
&& right_event_class_name
) {
128 ret
= strcmp(left_event_class_name
, right_event_class_name
);
132 } else if (!left_event_class_name
&& right_event_class_name
) {
135 } else if (left_event_class_name
&& !right_event_class_name
) {
140 left_log_level_avail
= bt_event_class_get_log_level(left_event_class
,
141 &left_event_class_log_level
);
142 right_log_level_avail
= bt_event_class_get_log_level(right_event_class
,
143 &right_event_class_log_level
);
145 if (left_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
146 right_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
147 ret
= left_event_class_log_level
- right_event_class_log_level
;
151 } else if (left_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
152 right_log_level_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
) {
155 } else if (left_log_level_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
&&
156 right_log_level_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
161 left_event_class_emf_uri
= bt_event_class_get_emf_uri(left_event_class
);
162 right_event_class_emf_uri
= bt_event_class_get_emf_uri(right_event_class
);
163 if (left_event_class_emf_uri
&& right_event_class_emf_uri
) {
164 ret
= strcmp(left_event_class_emf_uri
, right_event_class_emf_uri
);
168 } else if (!left_event_class_emf_uri
&& right_event_class_emf_uri
) {
171 } else if (left_event_class_emf_uri
&& !right_event_class_emf_uri
) {
181 int compare_streams(const bt_stream
*left_stream
, const bt_stream
*right_stream
)
184 const char *left_stream_name
, *right_stream_name
,
185 *left_stream_class_name
, *right_stream_class_name
;
186 const bt_stream_class
*left_stream_class
, *right_stream_class
;
189 * No need to compare stream id as it was checked earlier and if we are
190 * here it means they are identical or both absent.
192 BT_ASSERT(bt_stream_get_id(left_stream
) ==
193 bt_stream_get_id(right_stream
));
195 /* Compare stream name. */
196 left_stream_name
= bt_stream_get_name(left_stream
);
197 right_stream_name
= bt_stream_get_name(right_stream
);
199 if (left_stream_name
&& right_stream_name
) {
200 ret
= strcmp(left_stream_name
, right_stream_name
);
204 } else if (!left_stream_name
&& right_stream_name
) {
207 } else if (left_stream_name
&& !right_stream_name
) {
212 left_stream_class
= bt_stream_borrow_class_const(left_stream
);
213 right_stream_class
= bt_stream_borrow_class_const(right_stream
);
216 * No need to compare stream class id as it was checked earlier and if
217 * we are here it means they are identical.
219 BT_ASSERT(bt_stream_class_get_id(left_stream_class
) ==
220 bt_stream_class_get_id(right_stream_class
));
222 /* Compare stream class name. */
223 left_stream_class_name
= bt_stream_class_get_name(left_stream_class
);
224 right_stream_class_name
= bt_stream_class_get_name(right_stream_class
);
226 if (left_stream_class_name
&& right_stream_class_name
) {
227 ret
= strcmp(left_stream_class_name
, right_stream_class_name
);
231 } else if (!left_stream_class_name
&& right_stream_class_name
) {
234 } else if (left_stream_class_name
&& !right_stream_class_name
) {
239 /* Compare stream class automatic event class id assignment. */
240 if (bt_stream_class_assigns_automatic_event_class_id(left_stream_class
) &&
241 !bt_stream_class_assigns_automatic_event_class_id(right_stream_class
)) {
244 } else if (!bt_stream_class_assigns_automatic_event_class_id(left_stream_class
) &&
245 bt_stream_class_assigns_automatic_event_class_id(right_stream_class
)) {
250 /* Compare stream class automatic stream id assignment. */
251 if (bt_stream_class_assigns_automatic_stream_id(left_stream_class
) &&
252 !bt_stream_class_assigns_automatic_stream_id(right_stream_class
)) {
255 } else if (!bt_stream_class_assigns_automatic_stream_id(left_stream_class
) &&
256 bt_stream_class_assigns_automatic_stream_id(right_stream_class
)) {
261 /* Compare stream class support of discarded events. */
262 if (bt_stream_class_supports_discarded_events(left_stream_class
) &&
263 !bt_stream_class_supports_discarded_events(right_stream_class
)) {
266 } else if (!bt_stream_class_supports_discarded_events(left_stream_class
) &&
267 bt_stream_class_supports_discarded_events(right_stream_class
)) {
272 /* Compare stream class discarded events default clock snapshot. */
273 if (bt_stream_class_discarded_events_have_default_clock_snapshots(left_stream_class
) &&
274 !bt_stream_class_discarded_events_have_default_clock_snapshots(right_stream_class
)) {
277 } else if (!bt_stream_class_discarded_events_have_default_clock_snapshots(left_stream_class
) &&
278 bt_stream_class_discarded_events_have_default_clock_snapshots(right_stream_class
)) {
283 /* Compare stream class support of packets. */
284 if (bt_stream_class_supports_packets(left_stream_class
) &&
285 !bt_stream_class_supports_packets(right_stream_class
)) {
288 } else if (!bt_stream_class_supports_packets(left_stream_class
) &&
289 bt_stream_class_supports_packets(right_stream_class
)) {
294 if (!bt_stream_class_supports_packets(left_stream_class
)) {
295 /* Skip all packet related checks. */
300 * Compare stream class presence of discarded packets beginning default
303 if (bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class
) &&
304 !bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class
)) {
307 } else if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class
) &&
308 bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class
)) {
314 * Compare stream class presence of discarded packets end default clock
317 if (bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class
) &&
318 !bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class
)) {
321 } else if (!bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class
) &&
322 bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class
)) {
327 /* Compare stream class support of discarded packets. */
328 if (bt_stream_class_supports_discarded_packets(left_stream_class
) &&
329 !bt_stream_class_supports_discarded_packets(right_stream_class
)) {
332 } else if (!bt_stream_class_supports_discarded_packets(left_stream_class
) &&
333 bt_stream_class_supports_discarded_packets(right_stream_class
)) {
338 /* Compare stream class discarded packets default clock snapshot. */
339 if (bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class
) &&
340 !bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class
)) {
343 } else if (!bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class
) &&
344 bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class
)) {
354 int compare_clock_snapshots_and_clock_classes(const bt_clock_snapshot
*left_cs
,
355 const bt_clock_snapshot
*right_cs
)
358 uint64_t left_freq
, right_freq
, left_prec
, right_prec
;
359 uint64_t left_cs_value
, right_cs_value
;
360 const bt_clock_class
*left_clock_class
, *right_clock_class
;
361 const char *left_clock_class_name
, *right_clock_class_name
;
362 left_cs_value
= bt_clock_snapshot_get_value(left_cs
);
363 right_cs_value
= bt_clock_snapshot_get_value(right_cs
);
364 bt_uuid left_clock_class_uuid
, right_clock_class_uuid
;
366 ret
= left_cs_value
- right_cs_value
;
371 left_clock_class
= bt_clock_snapshot_borrow_clock_class_const(left_cs
);
372 right_clock_class
= bt_clock_snapshot_borrow_clock_class_const(right_cs
);
374 left_clock_class_uuid
= bt_clock_class_get_uuid(left_clock_class
);
375 right_clock_class_uuid
= bt_clock_class_get_uuid(right_clock_class
);
377 if (left_clock_class_uuid
&& !right_clock_class_uuid
) {
380 } else if (!left_clock_class_uuid
&& right_clock_class_uuid
) {
383 } else if (left_clock_class_uuid
&& right_clock_class_uuid
) {
384 ret
= bt_uuid_compare(left_clock_class_uuid
,
385 right_clock_class_uuid
);
392 left_clock_class_name
= bt_clock_class_get_name(left_clock_class
);
393 right_clock_class_name
= bt_clock_class_get_name(right_clock_class
);
395 if (left_clock_class_name
&& !right_clock_class_name
) {
398 } else if (!left_clock_class_name
&& right_clock_class_name
) {
401 } else if (left_clock_class_name
&& right_clock_class_name
) {
402 ret
= strcmp(left_clock_class_name
, right_clock_class_name
);
408 left_freq
= bt_clock_class_get_frequency(left_clock_class
);
409 right_freq
= bt_clock_class_get_frequency(right_clock_class
);
411 ret
= right_freq
- left_freq
;
416 left_prec
= bt_clock_class_get_precision(left_clock_class
);
417 right_prec
= bt_clock_class_get_precision(right_clock_class
);
419 ret
= right_prec
- left_prec
;
429 const bt_stream
*borrow_stream(const bt_message
*msg
)
431 bt_message_type msg_type
= bt_message_get_type(msg
);
432 const bt_stream
*stream
= NULL
;
433 const bt_packet
*packet
= NULL
;
434 const bt_event
*event
= NULL
;
437 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
438 stream
= bt_message_stream_beginning_borrow_stream_const(msg
);
440 case BT_MESSAGE_TYPE_STREAM_END
:
441 stream
= bt_message_stream_end_borrow_stream_const(msg
);
443 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
444 packet
= bt_message_packet_beginning_borrow_packet_const(msg
);
445 stream
= bt_packet_borrow_stream_const(packet
);
447 case BT_MESSAGE_TYPE_PACKET_END
:
448 packet
= bt_message_packet_end_borrow_packet_const(msg
);
449 stream
= bt_packet_borrow_stream_const(packet
);
451 case BT_MESSAGE_TYPE_EVENT
:
452 event
= bt_message_event_borrow_event_const(msg
);
453 stream
= bt_event_borrow_stream_const(event
);
455 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
456 stream
= bt_message_discarded_events_borrow_stream_const(msg
);
458 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
459 stream
= bt_message_discarded_packets_borrow_stream_const(msg
);
461 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
:
472 const bt_trace
*borrow_trace(const bt_message
*msg
)
474 const bt_trace
*trace
= NULL
;
475 const bt_stream
*stream
= NULL
;
477 stream
= borrow_stream(msg
);
479 trace
= bt_stream_borrow_trace_const(stream
);
486 int compare_messages_by_trace_name(struct messages_to_compare
*msgs
)
489 const char *left_trace_name
= NULL
, *right_trace_name
= NULL
;
491 if (msgs
->left
.trace
&& !msgs
->right
.trace
) {
496 if (!msgs
->left
.trace
&& msgs
->right
.trace
) {
501 if (!msgs
->left
.trace
&& !msgs
->right
.trace
) {
506 left_trace_name
= bt_trace_get_name(msgs
->left
.trace
);
507 right_trace_name
= bt_trace_get_name(msgs
->right
.trace
);
509 if (left_trace_name
&& !right_trace_name
) {
514 if (!left_trace_name
&& right_trace_name
) {
519 if (!left_trace_name
&& !right_trace_name
) {
524 ret
= strcmp(left_trace_name
, right_trace_name
);
530 int compare_messages_by_trace_uuid(struct messages_to_compare
*msgs
)
533 bt_uuid left_trace_uuid
= NULL
, right_trace_uuid
= NULL
;
535 if (msgs
->left
.trace
&& !msgs
->right
.trace
) {
540 if (!msgs
->left
.trace
&& msgs
->right
.trace
) {
545 if (!msgs
->left
.trace
&& !msgs
->right
.trace
) {
550 left_trace_uuid
= bt_trace_get_uuid(msgs
->left
.trace
);
551 right_trace_uuid
= bt_trace_get_uuid(msgs
->right
.trace
);
553 if (left_trace_uuid
&& !right_trace_uuid
) {
558 if (!left_trace_uuid
&& right_trace_uuid
) {
563 if (!left_trace_uuid
&& !right_trace_uuid
) {
568 ret
= bt_uuid_compare(left_trace_uuid
, right_trace_uuid
);
574 int compare_messages_by_stream_class_id(struct messages_to_compare
*msgs
)
577 uint64_t left_stream_class_id
= 0, right_stream_class_id
= 0;
579 if (msgs
->left
.stream
&& !msgs
->right
.stream
) {
584 if (!msgs
->left
.stream
&& msgs
->right
.stream
) {
589 if (!msgs
->left
.stream
&& !msgs
->right
.stream
) {
594 left_stream_class_id
= bt_stream_class_get_id(
595 bt_stream_borrow_class_const(msgs
->left
.stream
));
597 right_stream_class_id
= bt_stream_class_get_id(
598 bt_stream_borrow_class_const(msgs
->right
.stream
));
600 if (left_stream_class_id
== right_stream_class_id
) {
605 ret
= (left_stream_class_id
< right_stream_class_id
) ? -1 : 1;
612 int compare_messages_by_stream_id(struct messages_to_compare
*msgs
)
615 uint64_t left_stream_id
= 0, right_stream_id
= 0;
617 if (msgs
->left
.stream
&& !msgs
->right
.stream
) {
622 if (!msgs
->left
.stream
&& msgs
->right
.stream
) {
627 if (!msgs
->left
.stream
&& !msgs
->right
.stream
) {
632 left_stream_id
= bt_stream_get_id(msgs
->left
.stream
);
633 right_stream_id
= bt_stream_get_id(msgs
->right
.stream
);
635 if (left_stream_id
== right_stream_id
) {
640 ret
= (left_stream_id
< right_stream_id
) ? -1 : 1;
647 int compare_messages_same_type(struct messages_to_compare
*msgs
)
652 * Both messages are of the same type, we must compare characterics of
653 * the messages such as the attributes of the event in a event message.
655 BT_ASSERT(bt_message_get_type(msgs
->left
.msg
) ==
656 bt_message_get_type(msgs
->right
.msg
));
658 switch (bt_message_get_type(msgs
->left
.msg
)) {
659 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
661 case BT_MESSAGE_TYPE_STREAM_END
:
663 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
665 case BT_MESSAGE_TYPE_PACKET_END
:
666 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
672 case BT_MESSAGE_TYPE_EVENT
:
674 const bt_event
*left_event
, *right_event
;
675 left_event
= bt_message_event_borrow_event_const(msgs
->left
.msg
);
676 right_event
= bt_message_event_borrow_event_const(msgs
->right
.msg
);
678 ret
= compare_events(left_event
, right_event
);
683 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
689 case BT_MESSAGE_TYPE_DISCARDED_EVENTS
:
691 const bt_stream_class
*left_stream_class
;
692 bt_property_availability left_event_count_avail
,
693 right_event_count_avail
;
694 uint64_t left_event_count
, right_event_count
;
697 * Compare streams first to check if there is a
698 * mismatch about discarded event related configuration
699 * in the stream class.
701 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
706 left_stream_class
= bt_stream_borrow_class_const(msgs
->left
.stream
);
707 if (bt_stream_class_discarded_events_have_default_clock_snapshots(
708 left_stream_class
)) {
709 const bt_clock_snapshot
*left_beg_cs
=
710 bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(msgs
->left
.msg
);
711 const bt_clock_snapshot
*right_beg_cs
=
712 bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(msgs
->right
.msg
);
713 const bt_clock_snapshot
*left_end_cs
=
714 bt_message_discarded_events_borrow_end_default_clock_snapshot_const(msgs
->left
.msg
);
715 const bt_clock_snapshot
*right_end_cs
=
716 bt_message_discarded_events_borrow_end_default_clock_snapshot_const(msgs
->right
.msg
);
718 ret
= compare_clock_snapshots_and_clock_classes(
719 left_beg_cs
, right_beg_cs
);
724 ret
= compare_clock_snapshots_and_clock_classes(
725 left_end_cs
, right_end_cs
);
731 left_event_count_avail
=
732 bt_message_discarded_events_get_count(
733 msgs
->left
.msg
, &left_event_count
);
734 right_event_count_avail
=
735 bt_message_discarded_events_get_count(
736 msgs
->right
.msg
, &right_event_count
);
737 if (left_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
738 right_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
739 ret
= left_event_count
- right_event_count
;
743 } else if (left_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
744 right_event_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
) {
747 } else if (left_event_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
&&
748 right_event_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
755 case BT_MESSAGE_TYPE_DISCARDED_PACKETS
:
757 const bt_stream_class
*left_stream_class
;
758 bt_property_availability left_packet_count_avail
,
759 right_packet_count_avail
;
760 uint64_t left_packet_count
, right_packet_count
;
763 * Compare streams first to check if there is a
764 * mismatch about discarded packets related
765 * configuration in the stream class.
767 ret
= compare_streams(msgs
->left
.stream
, msgs
->right
.stream
);
772 left_stream_class
= bt_stream_borrow_class_const(msgs
->left
.stream
);
774 if (bt_stream_class_discarded_packets_have_default_clock_snapshots(
775 left_stream_class
)) {
776 const bt_clock_snapshot
*left_beg_cs
=
777 bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(msgs
->left
.msg
);
778 const bt_clock_snapshot
*right_beg_cs
=
779 bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(msgs
->right
.msg
);
780 const bt_clock_snapshot
*left_end_cs
=
781 bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(msgs
->left
.msg
);
782 const bt_clock_snapshot
*right_end_cs
=
783 bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(msgs
->right
.msg
);
785 ret
= compare_clock_snapshots_and_clock_classes(
786 left_beg_cs
, right_beg_cs
);
791 ret
= compare_clock_snapshots_and_clock_classes(
792 left_end_cs
, right_end_cs
);
798 left_packet_count_avail
= bt_message_discarded_packets_get_count(
799 msgs
->left
.msg
, &left_packet_count
);
800 right_packet_count_avail
= bt_message_discarded_packets_get_count(
801 msgs
->right
.msg
, &right_packet_count
);
802 if (left_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
803 right_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
804 ret
= left_packet_count
- right_packet_count
;
808 } else if (left_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
&&
809 right_packet_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
) {
812 } else if (left_packet_count_avail
== BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
&&
813 right_packet_count_avail
== BT_PROPERTY_AVAILABILITY_AVAILABLE
) {
820 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY
:
822 const bt_clock_snapshot
*left_cs
=
823 bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(msgs
->left
.msg
);
824 const bt_clock_snapshot
*right_cs
=
825 bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(msgs
->right
.msg
);
827 ret
= compare_clock_snapshots_and_clock_classes(
844 int common_muxing_compare_messages(const bt_message
*left_msg
,
845 const bt_message
*right_msg
)
848 struct messages_to_compare msgs
;
850 BT_ASSERT(left_msg
!= right_msg
);
852 msgs
.left
.msg
= left_msg
;
853 msgs
.left
.trace
= borrow_trace(left_msg
);
854 msgs
.left
.stream
= borrow_stream(left_msg
);
856 msgs
.right
.msg
= right_msg
;
857 msgs
.right
.trace
= borrow_trace(right_msg
);
858 msgs
.right
.stream
= borrow_stream(right_msg
);
860 /* Same timestamp: compare trace UUIDs. */
861 ret
= compare_messages_by_trace_uuid(&msgs
);
866 /* Same timestamp and trace UUID: compare trace names. */
867 ret
= compare_messages_by_trace_name(&msgs
);
873 * Same timestamp, trace name, and trace UUID: compare stream class
876 ret
= compare_messages_by_stream_class_id(&msgs
);
882 * Same timestamp, trace name, trace UUID, and stream class ID: compare
885 ret
= compare_messages_by_stream_id(&msgs
);
890 if (bt_message_get_type(msgs
.left
.msg
) !=
891 bt_message_get_type(msgs
.right
.msg
)) {
893 * The messages are of different type, we order (arbitrarily)
894 * in the following way:
895 * SB < PB < EV < DE < MI < PE < DP < SE
897 ret
= compare_messages_by_type(&msgs
);
902 /* The messages are of the same type. */
903 ret
= compare_messages_same_type(&msgs
);