2 * Copyright 2017 - Philippe Proulx <pproulx@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; under version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <babeltrace/ctf-ir/event-class.h>
26 #include <babeltrace/ctf-ir/event.h>
27 #include <babeltrace/ctf-ir/field-types.h>
28 #include <babeltrace/ctf-ir/fields.h>
29 #include <babeltrace/ctf-ir/packet.h>
30 #include <babeltrace/ctf-ir/stream-class.h>
31 #include <babeltrace/ctf-ir/stream.h>
32 #include <babeltrace/ctf-ir/trace.h>
33 #include <babeltrace/graph/clock-class-priority-map.h>
34 #include <babeltrace/graph/component-class-filter.h>
35 #include <babeltrace/graph/component-class-sink.h>
36 #include <babeltrace/graph/component-class-source.h>
37 #include <babeltrace/graph/component-class.h>
38 #include <babeltrace/graph/component-sink.h>
39 #include <babeltrace/graph/component-source.h>
40 #include <babeltrace/graph/component.h>
41 #include <babeltrace/graph/connection.h>
42 #include <babeltrace/graph/graph.h>
43 #include <babeltrace/graph/notification-event.h>
44 #include <babeltrace/graph/notification-inactivity.h>
45 #include <babeltrace/graph/notification-iterator.h>
46 #include <babeltrace/graph/notification-packet.h>
47 #include <babeltrace/graph/notification-stream.h>
48 #include <babeltrace/graph/port.h>
49 #include <babeltrace/graph/private-component-source.h>
50 #include <babeltrace/graph/private-component-sink.h>
51 #include <babeltrace/graph/private-component.h>
52 #include <babeltrace/graph/private-connection.h>
53 #include <babeltrace/graph/private-connection-private-notification-iterator.h>
54 #include <babeltrace/graph/private-port.h>
55 #include <babeltrace/plugin/plugin.h>
56 #include <babeltrace/ref.h>
65 TEST_AUTO_STREAM_BEGIN_FROM_PACKET_BEGIN
,
66 TEST_AUTO_STREAM_BEGIN_FROM_STREAM_END
,
67 TEST_AUTO_STREAM_END_FROM_END
,
68 TEST_AUTO_PACKET_BEGIN_FROM_PACKET_END
,
69 TEST_AUTO_PACKET_BEGIN_FROM_EVENT
,
70 TEST_AUTO_PACKET_END_FROM_PACKET_BEGIN
,
71 TEST_AUTO_PACKET_END_PACKET_BEGIN_FROM_EVENT
,
72 TEST_AUTO_PACKET_END_FROM_STREAM_END
,
73 TEST_AUTO_PACKET_END_STREAM_END_FROM_END
,
74 TEST_MULTIPLE_AUTO_STREAM_END_FROM_END
,
75 TEST_MULTIPLE_AUTO_PACKET_END_STREAM_END_FROM_END
,
78 enum test_event_type
{
79 TEST_EV_TYPE_NOTIF_UNEXPECTED
,
80 TEST_EV_TYPE_NOTIF_EVENT
,
81 TEST_EV_TYPE_NOTIF_INACTIVITY
,
82 TEST_EV_TYPE_NOTIF_STREAM_BEGIN
,
83 TEST_EV_TYPE_NOTIF_PACKET_BEGIN
,
84 TEST_EV_TYPE_NOTIF_PACKET_END
,
85 TEST_EV_TYPE_NOTIF_STREAM_END
,
87 TEST_EV_TYPE_SENTINEL
,
91 enum test_event_type type
;
92 struct bt_ctf_stream
*stream
;
93 struct bt_ctf_packet
*packet
;
96 struct source_muxer_sink
{
97 struct bt_component
*source
;
98 struct bt_component
*sink
;
101 static bool debug
= false;
102 static enum test current_test
;
103 static GArray
*test_events
;
104 static struct bt_clock_class_priority_map
*src_empty_cc_prio_map
;
105 static struct bt_ctf_stream_class
*src_stream_class
;
106 static struct bt_ctf_event_class
*src_event_class
;
107 static struct bt_ctf_stream
*src_stream1
;
108 static struct bt_ctf_stream
*src_stream2
;
109 static struct bt_ctf_packet
*src_stream1_packet1
;
110 static struct bt_ctf_packet
*src_stream1_packet2
;
111 static struct bt_ctf_packet
*src_stream2_packet1
;
112 static struct bt_ctf_packet
*src_stream2_packet2
;
116 SEQ_STREAM1_BEGIN
= -2,
117 SEQ_STREAM2_BEGIN
= -3,
118 SEQ_STREAM1_END
= -4,
119 SEQ_STREAM2_END
= -5,
120 SEQ_STREAM1_PACKET1_BEGIN
= -6,
121 SEQ_STREAM1_PACKET2_BEGIN
= -7,
122 SEQ_STREAM2_PACKET1_BEGIN
= -8,
123 SEQ_STREAM2_PACKET2_BEGIN
= -9,
124 SEQ_STREAM1_PACKET1_END
= -10,
125 SEQ_STREAM1_PACKET2_END
= -11,
126 SEQ_STREAM2_PACKET1_END
= -12,
127 SEQ_STREAM2_PACKET2_END
= -13,
128 SEQ_EVENT_STREAM1_PACKET1
= -14,
129 SEQ_EVENT_STREAM1_PACKET2
= -15,
130 SEQ_EVENT_STREAM2_PACKET1
= -16,
131 SEQ_EVENT_STREAM2_PACKET2
= -17,
132 SEQ_INACTIVITY
= -18,
135 struct src_iter_user_data
{
140 struct sink_user_data
{
141 struct bt_notification_iterator
*notif_iter
;
145 * No automatic notifications generated in this block.
146 * Stream 2 notifications are more indented.
148 static int64_t seq_no_auto_notifs
[] = {
150 SEQ_STREAM1_PACKET1_BEGIN
,
151 SEQ_EVENT_STREAM1_PACKET1
,
152 SEQ_EVENT_STREAM1_PACKET1
,
154 SEQ_EVENT_STREAM1_PACKET1
,
155 SEQ_STREAM2_PACKET2_BEGIN
,
156 SEQ_EVENT_STREAM2_PACKET2
,
157 SEQ_EVENT_STREAM1_PACKET1
,
158 SEQ_STREAM1_PACKET1_END
,
159 SEQ_STREAM2_PACKET2_END
,
160 SEQ_STREAM1_PACKET2_BEGIN
,
161 SEQ_EVENT_STREAM1_PACKET2
,
163 SEQ_STREAM1_PACKET2_END
,
168 /* Automatic "stream begin" from "packet begin" */
169 static int64_t seq_auto_stream_begin_from_packet_begin
[] = {
170 /* Automatic "stream begin" here */
171 SEQ_STREAM1_PACKET1_BEGIN
,
172 SEQ_STREAM1_PACKET1_END
,
177 /* Automatic "stream begin" from "stream end" */
178 static int64_t seq_auto_stream_begin_from_stream_end
[] = {
179 /* Automatic "stream begin" here */
184 /* Automatic "stream end" from END */
185 static int64_t seq_auto_stream_end_from_end
[] = {
187 /* Automatic "packet end" here */
191 /* Automatic "packet begin" from "packet end" */
192 static int64_t seq_auto_packet_begin_from_packet_end
[] = {
194 /* Automatic "packet begin" here */
195 SEQ_STREAM1_PACKET1_END
,
200 /* Automatic "packet begin" from event */
201 static int64_t seq_auto_packet_begin_from_event
[] = {
203 /* Automatic "packet begin" here */
204 SEQ_EVENT_STREAM1_PACKET1
,
205 SEQ_STREAM1_PACKET1_END
,
210 /* Automatic "packet end" from "packet begin" */
211 static int64_t seq_auto_packet_end_from_packet_begin
[] = {
213 SEQ_STREAM1_PACKET1_BEGIN
,
214 /* Automatic "packet end" here */
215 SEQ_STREAM1_PACKET2_BEGIN
,
216 SEQ_STREAM1_PACKET2_END
,
221 /* Automatic "packet end" and "packet begin" from event */
222 static int64_t seq_auto_packet_end_packet_begin_from_event
[] = {
224 SEQ_STREAM1_PACKET1_BEGIN
,
225 /* Automatic "packet end" here */
226 /* Automatic "packet begin" here */
227 SEQ_EVENT_STREAM1_PACKET2
,
228 SEQ_STREAM1_PACKET2_END
,
233 /* Automatic "packet end" from "stream end" */
234 static int64_t seq_auto_packet_end_from_stream_end
[] = {
236 SEQ_STREAM1_PACKET1_BEGIN
,
237 /* Automatic "packet end" here */
242 /* Automatic "packet end" and "stream end" from END */
243 static int64_t seq_auto_packet_end_stream_end_from_end
[] = {
245 SEQ_STREAM1_PACKET1_BEGIN
,
246 /* Automatic "packet end" here */
247 /* Automatic "stream end" here */
251 /* Multiple automatic "stream end" from END */
252 static int64_t seq_multiple_auto_stream_end_from_end
[] = {
255 /* Automatic "stream end" here */
256 /* Automatic "stream end" here */
260 /* Multiple automatic "packet end" and "stream end" from END */
261 static int64_t seq_multiple_auto_packet_end_stream_end_from_end
[] = {
264 SEQ_STREAM1_PACKET1_BEGIN
,
265 SEQ_STREAM2_PACKET1_BEGIN
,
266 /* Automatic "packet end" here */
267 /* Automatic "stream end" here */
268 /* Automatic "packet end" here */
269 /* Automatic "stream end" here */
274 void clear_test_events(void)
276 g_array_set_size(test_events
, 0);
280 void print_test_event(FILE *fp
, const struct test_event
*event
)
282 fprintf(fp
, "{ type = ");
284 switch (event
->type
) {
285 case TEST_EV_TYPE_NOTIF_UNEXPECTED
:
286 fprintf(fp
, "TEST_EV_TYPE_NOTIF_UNEXPECTED");
288 case TEST_EV_TYPE_NOTIF_EVENT
:
289 fprintf(fp
, "TEST_EV_TYPE_NOTIF_EVENT");
291 case TEST_EV_TYPE_NOTIF_INACTIVITY
:
292 fprintf(fp
, "TEST_EV_TYPE_NOTIF_INACTIVITY");
294 case TEST_EV_TYPE_NOTIF_STREAM_BEGIN
:
295 fprintf(fp
, "TEST_EV_TYPE_NOTIF_STREAM_BEGIN");
297 case TEST_EV_TYPE_NOTIF_STREAM_END
:
298 fprintf(fp
, "TEST_EV_TYPE_NOTIF_STREAM_END");
300 case TEST_EV_TYPE_NOTIF_PACKET_BEGIN
:
301 fprintf(fp
, "TEST_EV_TYPE_NOTIF_PACKET_BEGIN");
303 case TEST_EV_TYPE_NOTIF_PACKET_END
:
304 fprintf(fp
, "TEST_EV_TYPE_NOTIF_PACKET_END");
306 case TEST_EV_TYPE_END
:
307 fprintf(fp
, "TEST_EV_TYPE_END");
309 case TEST_EV_TYPE_SENTINEL
:
310 fprintf(fp
, "TEST_EV_TYPE_SENTINEL");
313 fprintf(fp
, "(UNKNOWN)");
317 fprintf(fp
, ", stream = %p, packet = %p }", event
->stream
,
322 void append_test_event(struct test_event
*event
)
324 g_array_append_val(test_events
, *event
);
328 bool compare_single_test_events(const struct test_event
*ev_a
,
329 const struct test_event
*ev_b
)
332 fprintf(stderr
, ":: Comparing test events: ");
333 print_test_event(stderr
, ev_a
);
334 fprintf(stderr
, " vs. ");
335 print_test_event(stderr
, ev_b
);
336 fprintf(stderr
, "\n");
339 if (ev_a
->type
!= ev_b
->type
) {
343 switch (ev_a
->type
) {
344 case TEST_EV_TYPE_END
:
345 case TEST_EV_TYPE_SENTINEL
:
348 if (ev_a
->stream
!= ev_b
->stream
) {
352 if (ev_a
->packet
!= ev_b
->packet
) {
362 bool compare_test_events(const struct test_event
*expected_events
)
364 const struct test_event
*expected_event
= expected_events
;
367 assert(expected_events
);
370 const struct test_event
*event
;
372 if (expected_event
->type
== TEST_EV_TYPE_SENTINEL
) {
376 if (i
>= test_events
->len
) {
380 event
= &g_array_index(test_events
, struct test_event
, i
);
382 if (!compare_single_test_events(event
, expected_event
)) {
390 if (i
!= test_events
->len
) {
398 void init_static_data(void)
401 struct bt_ctf_trace
*trace
;
402 struct bt_ctf_field_type
*empty_struct_ft
;
405 test_events
= g_array_new(FALSE
, TRUE
, sizeof(struct test_event
));
409 empty_struct_ft
= bt_ctf_field_type_structure_create();
410 assert(empty_struct_ft
);
411 trace
= bt_ctf_trace_create();
413 ret
= bt_ctf_trace_set_packet_header_type(trace
, empty_struct_ft
);
415 src_empty_cc_prio_map
= bt_clock_class_priority_map_create();
416 assert(src_empty_cc_prio_map
);
417 src_stream_class
= bt_ctf_stream_class_create("my-stream-class");
418 assert(src_stream_class
);
419 ret
= bt_ctf_stream_class_set_packet_context_type(src_stream_class
,
422 ret
= bt_ctf_stream_class_set_event_header_type(src_stream_class
,
425 ret
= bt_ctf_stream_class_set_event_context_type(src_stream_class
,
428 src_event_class
= bt_ctf_event_class_create("my-event-class");
429 ret
= bt_ctf_event_class_set_context_type(src_event_class
,
432 ret
= bt_ctf_event_class_set_context_type(src_event_class
,
435 ret
= bt_ctf_stream_class_add_event_class(src_stream_class
,
438 ret
= bt_ctf_trace_add_stream_class(trace
, src_stream_class
);
440 src_stream1
= bt_ctf_stream_create(src_stream_class
, "stream-1");
442 src_stream2
= bt_ctf_stream_create(src_stream_class
, "stream-2");
444 src_stream1_packet1
= bt_ctf_packet_create(src_stream1
);
445 assert(src_stream1_packet1
);
446 src_stream1_packet2
= bt_ctf_packet_create(src_stream1
);
447 assert(src_stream1_packet2
);
448 src_stream2_packet1
= bt_ctf_packet_create(src_stream2
);
449 assert(src_stream2_packet1
);
450 src_stream2_packet2
= bt_ctf_packet_create(src_stream2
);
451 assert(src_stream2_packet2
);
454 fprintf(stderr
, ":: stream 1: %p\n", src_stream1
);
455 fprintf(stderr
, ":: stream 2: %p\n", src_stream2
);
456 fprintf(stderr
, ":: stream 1, packet 1: %p\n", src_stream1_packet1
);
457 fprintf(stderr
, ":: stream 1, packet 2: %p\n", src_stream1_packet2
);
458 fprintf(stderr
, ":: stream 2, packet 1: %p\n", src_stream2_packet1
);
459 fprintf(stderr
, ":: stream 2, packet 2: %p\n", src_stream2_packet2
);
463 bt_put(empty_struct_ft
);
467 void fini_static_data(void)
470 g_array_free(test_events
, TRUE
);
473 bt_put(src_empty_cc_prio_map
);
474 bt_put(src_stream_class
);
475 bt_put(src_event_class
);
478 bt_put(src_stream1_packet1
);
479 bt_put(src_stream1_packet2
);
480 bt_put(src_stream2_packet1
);
481 bt_put(src_stream2_packet2
);
485 void src_iter_finalize(
486 struct bt_private_connection_private_notification_iterator
*private_notification_iterator
)
488 struct src_iter_user_data
*user_data
=
489 bt_private_connection_private_notification_iterator_get_user_data(
490 private_notification_iterator
);
498 enum bt_notification_iterator_status
src_iter_init(
499 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
,
500 struct bt_private_port
*private_port
)
502 struct src_iter_user_data
*user_data
=
503 g_new0(struct src_iter_user_data
, 1);
507 ret
= bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
511 switch (current_test
) {
512 case TEST_NO_AUTO_NOTIFS
:
513 user_data
->seq
= seq_no_auto_notifs
;
515 case TEST_AUTO_STREAM_BEGIN_FROM_PACKET_BEGIN
:
516 user_data
->seq
= seq_auto_stream_begin_from_packet_begin
;
518 case TEST_AUTO_STREAM_BEGIN_FROM_STREAM_END
:
519 user_data
->seq
= seq_auto_stream_begin_from_stream_end
;
521 case TEST_AUTO_STREAM_END_FROM_END
:
522 user_data
->seq
= seq_auto_stream_end_from_end
;
524 case TEST_AUTO_PACKET_BEGIN_FROM_PACKET_END
:
525 user_data
->seq
= seq_auto_packet_begin_from_packet_end
;
527 case TEST_AUTO_PACKET_BEGIN_FROM_EVENT
:
528 user_data
->seq
= seq_auto_packet_begin_from_event
;
530 case TEST_AUTO_PACKET_END_FROM_PACKET_BEGIN
:
531 user_data
->seq
= seq_auto_packet_end_from_packet_begin
;
533 case TEST_AUTO_PACKET_END_PACKET_BEGIN_FROM_EVENT
:
534 user_data
->seq
= seq_auto_packet_end_packet_begin_from_event
;
536 case TEST_AUTO_PACKET_END_FROM_STREAM_END
:
537 user_data
->seq
= seq_auto_packet_end_from_stream_end
;
539 case TEST_AUTO_PACKET_END_STREAM_END_FROM_END
:
540 user_data
->seq
= seq_auto_packet_end_stream_end_from_end
;
542 case TEST_MULTIPLE_AUTO_STREAM_END_FROM_END
:
543 user_data
->seq
= seq_multiple_auto_stream_end_from_end
;
545 case TEST_MULTIPLE_AUTO_PACKET_END_STREAM_END_FROM_END
:
546 user_data
->seq
= seq_multiple_auto_packet_end_stream_end_from_end
;
552 return BT_NOTIFICATION_ITERATOR_STATUS_OK
;
556 struct bt_ctf_event
*src_create_event(struct bt_ctf_packet
*packet
)
558 struct bt_ctf_event
*event
= bt_ctf_event_create(src_event_class
);
562 ret
= bt_ctf_event_set_packet(event
, packet
);
568 struct bt_notification_iterator_next_method_return
src_iter_next_seq(
569 struct src_iter_user_data
*user_data
)
571 struct bt_notification_iterator_next_method_return next_return
= {
572 .status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
,
575 struct bt_ctf_packet
*event_packet
= NULL
;
577 assert(user_data
->seq
);
578 cur_ts_ns
= user_data
->seq
[user_data
->at
];
583 BT_NOTIFICATION_ITERATOR_STATUS_END
;
586 next_return
.notification
=
587 bt_notification_inactivity_create(src_empty_cc_prio_map
);
588 assert(next_return
.notification
);
590 case SEQ_STREAM1_BEGIN
:
591 next_return
.notification
=
592 bt_notification_stream_begin_create(src_stream1
);
593 assert(next_return
.notification
);
595 case SEQ_STREAM2_BEGIN
:
596 next_return
.notification
=
597 bt_notification_stream_begin_create(src_stream2
);
598 assert(next_return
.notification
);
600 case SEQ_STREAM1_END
:
601 next_return
.notification
=
602 bt_notification_stream_end_create(src_stream1
);
603 assert(next_return
.notification
);
605 case SEQ_STREAM2_END
:
606 next_return
.notification
=
607 bt_notification_stream_end_create(src_stream2
);
608 assert(next_return
.notification
);
610 case SEQ_STREAM1_PACKET1_BEGIN
:
611 next_return
.notification
=
612 bt_notification_packet_begin_create(src_stream1_packet1
);
613 assert(next_return
.notification
);
615 case SEQ_STREAM1_PACKET2_BEGIN
:
616 next_return
.notification
=
617 bt_notification_packet_begin_create(src_stream1_packet2
);
618 assert(next_return
.notification
);
620 case SEQ_STREAM2_PACKET1_BEGIN
:
621 next_return
.notification
=
622 bt_notification_packet_begin_create(src_stream2_packet1
);
623 assert(next_return
.notification
);
625 case SEQ_STREAM2_PACKET2_BEGIN
:
626 next_return
.notification
=
627 bt_notification_packet_begin_create(src_stream2_packet2
);
628 assert(next_return
.notification
);
630 case SEQ_STREAM1_PACKET1_END
:
631 next_return
.notification
=
632 bt_notification_packet_end_create(src_stream1_packet1
);
633 assert(next_return
.notification
);
635 case SEQ_STREAM1_PACKET2_END
:
636 next_return
.notification
=
637 bt_notification_packet_end_create(src_stream1_packet2
);
638 assert(next_return
.notification
);
640 case SEQ_STREAM2_PACKET1_END
:
641 next_return
.notification
=
642 bt_notification_packet_end_create(src_stream2_packet1
);
643 assert(next_return
.notification
);
645 case SEQ_STREAM2_PACKET2_END
:
646 next_return
.notification
=
647 bt_notification_packet_end_create(src_stream2_packet2
);
648 assert(next_return
.notification
);
650 case SEQ_EVENT_STREAM1_PACKET1
:
651 event_packet
= src_stream1_packet1
;
653 case SEQ_EVENT_STREAM1_PACKET2
:
654 event_packet
= src_stream1_packet2
;
656 case SEQ_EVENT_STREAM2_PACKET1
:
657 event_packet
= src_stream2_packet1
;
659 case SEQ_EVENT_STREAM2_PACKET2
:
660 event_packet
= src_stream2_packet2
;
667 struct bt_ctf_event
*event
= src_create_event(event_packet
);
670 next_return
.notification
= bt_notification_event_create(event
,
671 src_empty_cc_prio_map
);
673 assert(next_return
.notification
);
676 if (next_return
.status
!= BT_NOTIFICATION_ITERATOR_STATUS_END
) {
684 struct bt_notification_iterator_next_method_return
src_iter_next(
685 struct bt_private_connection_private_notification_iterator
*priv_iterator
)
687 struct bt_notification_iterator_next_method_return next_return
= {
688 .status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
,
689 .notification
= NULL
,
691 struct src_iter_user_data
*user_data
=
692 bt_private_connection_private_notification_iterator_get_user_data(priv_iterator
);
695 next_return
= src_iter_next_seq(user_data
);
700 enum bt_component_status
src_init(
701 struct bt_private_component
*private_component
,
702 struct bt_value
*params
, void *init_method_data
)
706 ret
= bt_private_component_source_add_output_private_port(
707 private_component
, "out", NULL
, NULL
);
709 return BT_COMPONENT_STATUS_OK
;
713 void src_finalize(struct bt_private_component
*private_component
)
718 enum bt_component_status
sink_consume(
719 struct bt_private_component
*priv_component
)
721 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
722 struct bt_notification
*notification
= NULL
;
723 struct sink_user_data
*user_data
=
724 bt_private_component_get_user_data(priv_component
);
725 enum bt_notification_iterator_status it_ret
;
726 struct test_event test_event
= { 0 };
727 bool do_append_test_event
= true;
729 assert(user_data
&& user_data
->notif_iter
);
730 it_ret
= bt_notification_iterator_next(user_data
->notif_iter
);
733 ret
= BT_COMPONENT_STATUS_ERROR
;
734 do_append_test_event
= false;
739 case BT_NOTIFICATION_ITERATOR_STATUS_END
:
740 test_event
.type
= TEST_EV_TYPE_END
;
741 ret
= BT_COMPONENT_STATUS_END
;
742 BT_PUT(user_data
->notif_iter
);
744 case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN
:
750 notification
= bt_notification_iterator_get_notification(
751 user_data
->notif_iter
);
752 assert(notification
);
754 switch (bt_notification_get_type(notification
)) {
755 case BT_NOTIFICATION_TYPE_EVENT
:
757 struct bt_ctf_event
*event
;
759 test_event
.type
= TEST_EV_TYPE_NOTIF_EVENT
;
760 event
= bt_notification_event_get_event(notification
);
762 test_event
.packet
= bt_ctf_event_get_packet(event
);
764 assert(test_event
.packet
);
765 bt_put(test_event
.packet
);
768 case BT_NOTIFICATION_TYPE_INACTIVITY
:
769 test_event
.type
= TEST_EV_TYPE_NOTIF_INACTIVITY
;
771 case BT_NOTIFICATION_TYPE_STREAM_BEGIN
:
772 test_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
;
774 bt_notification_stream_begin_get_stream(notification
);
775 assert(test_event
.stream
);
776 bt_put(test_event
.stream
);
778 case BT_NOTIFICATION_TYPE_STREAM_END
:
779 test_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_END
;
781 bt_notification_stream_end_get_stream(notification
);
782 assert(test_event
.stream
);
783 bt_put(test_event
.stream
);
785 case BT_NOTIFICATION_TYPE_PACKET_BEGIN
:
786 test_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
;
788 bt_notification_packet_begin_get_packet(notification
);
789 assert(test_event
.packet
);
790 bt_put(test_event
.packet
);
792 case BT_NOTIFICATION_TYPE_PACKET_END
:
793 test_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_END
;
795 bt_notification_packet_end_get_packet(notification
);
796 assert(test_event
.packet
);
797 bt_put(test_event
.packet
);
800 test_event
.type
= TEST_EV_TYPE_NOTIF_UNEXPECTED
;
804 if (test_event
.packet
) {
805 test_event
.stream
= bt_ctf_packet_get_stream(test_event
.packet
);
806 assert(test_event
.stream
);
807 bt_put(test_event
.stream
);
811 if (do_append_test_event
) {
812 append_test_event(&test_event
);
815 bt_put(notification
);
820 void sink_port_connected(struct bt_private_component
*private_component
,
821 struct bt_private_port
*self_private_port
,
822 struct bt_port
*other_port
)
824 struct bt_private_connection
*priv_conn
=
825 bt_private_port_get_private_connection(self_private_port
);
826 struct sink_user_data
*user_data
= bt_private_component_get_user_data(
828 enum bt_connection_status conn_status
;
832 conn_status
= bt_private_connection_create_notification_iterator(
833 priv_conn
, NULL
, &user_data
->notif_iter
);
834 assert(conn_status
== 0);
839 enum bt_component_status
sink_init(
840 struct bt_private_component
*private_component
,
841 struct bt_value
*params
, void *init_method_data
)
843 struct sink_user_data
*user_data
= g_new0(struct sink_user_data
, 1);
847 ret
= bt_private_component_set_user_data(private_component
,
850 ret
= bt_private_component_sink_add_input_private_port(
851 private_component
, "in", NULL
, NULL
);
853 return BT_COMPONENT_STATUS_OK
;
857 void sink_finalize(struct bt_private_component
*private_component
)
859 struct sink_user_data
*user_data
= bt_private_component_get_user_data(
863 bt_put(user_data
->notif_iter
);
869 void create_source_sink(struct bt_graph
*graph
, struct bt_component
**source
,
870 struct bt_component
**sink
)
872 struct bt_component_class
*src_comp_class
;
873 struct bt_component_class
*sink_comp_class
;
876 /* Create source component */
877 src_comp_class
= bt_component_class_source_create("src", src_iter_next
);
878 assert(src_comp_class
);
879 ret
= bt_component_class_set_init_method(src_comp_class
, src_init
);
881 ret
= bt_component_class_set_finalize_method(src_comp_class
,
884 ret
= bt_component_class_source_set_notification_iterator_init_method(
885 src_comp_class
, src_iter_init
);
887 ret
= bt_component_class_source_set_notification_iterator_finalize_method(
888 src_comp_class
, src_iter_finalize
);
890 ret
= bt_graph_add_component(graph
, src_comp_class
, "source", NULL
,
894 /* Create sink component */
895 sink_comp_class
= bt_component_class_sink_create("sink", sink_consume
);
896 assert(sink_comp_class
);
897 ret
= bt_component_class_set_init_method(sink_comp_class
, sink_init
);
899 ret
= bt_component_class_set_finalize_method(sink_comp_class
,
901 ret
= bt_component_class_set_port_connected_method(sink_comp_class
,
902 sink_port_connected
);
904 ret
= bt_graph_add_component(graph
, sink_comp_class
, "sink", NULL
,
908 bt_put(src_comp_class
);
909 bt_put(sink_comp_class
);
913 void do_std_test(enum test test
, const char *name
,
914 const struct test_event
*expected_test_events
)
916 struct bt_component
*src_comp
;
917 struct bt_component
*sink_comp
;
918 struct bt_port
*upstream_port
;
919 struct bt_port
*downstream_port
;
920 struct bt_graph
*graph
;
921 enum bt_graph_status graph_status
= BT_GRAPH_STATUS_OK
;
925 diag("test: %s", name
);
926 graph
= bt_graph_create();
928 create_source_sink(graph
, &src_comp
, &sink_comp
);
930 /* Connect source to sink */
931 upstream_port
= bt_component_source_get_output_port_by_name(src_comp
, "out");
932 assert(upstream_port
);
933 downstream_port
= bt_component_sink_get_input_port_by_name(sink_comp
, "in");
934 assert(downstream_port
);
935 graph_status
= bt_graph_connect_ports(graph
, upstream_port
,
936 downstream_port
, NULL
);
937 bt_put(upstream_port
);
938 bt_put(downstream_port
);
940 /* Run the graph until the end */
941 while (graph_status
== BT_GRAPH_STATUS_OK
||
942 graph_status
== BT_GRAPH_STATUS_AGAIN
) {
943 graph_status
= bt_graph_run(graph
);
946 ok(graph_status
== BT_GRAPH_STATUS_END
, "graph finishes without any error");
948 /* Compare the resulting test events */
949 if (expected_test_events
) {
950 ok(compare_test_events(expected_test_events
),
951 "the produced sequence of test events is the expected one");
960 void test_no_auto_notifs(void)
962 const struct test_event expected_test_events
[] = {
963 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
964 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
965 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
966 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
967 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream2
, .packet
= NULL
, },
968 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
969 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream2
, .packet
= src_stream2_packet2
, },
970 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream2
, .packet
= src_stream2_packet2
, },
971 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
972 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
973 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream2
, .packet
= src_stream2_packet2
, },
974 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
975 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
976 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream2
, .packet
= NULL
, },
977 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
978 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
979 { .type
= TEST_EV_TYPE_END
, },
980 { .type
= TEST_EV_TYPE_SENTINEL
, },
983 do_std_test(TEST_NO_AUTO_NOTIFS
, "no automatic notifications",
984 expected_test_events
);
988 void test_auto_stream_begin_from_packet_begin(void)
990 const struct test_event expected_test_events
[] = {
991 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
992 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
993 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
994 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
995 { .type
= TEST_EV_TYPE_END
, },
996 { .type
= TEST_EV_TYPE_SENTINEL
, },
999 do_std_test(TEST_AUTO_STREAM_BEGIN_FROM_PACKET_BEGIN
,
1000 "automatic \"stream begin\" notif. caused by \"packet begin\" notif.",
1001 expected_test_events
);
1005 void test_auto_stream_begin_from_stream_end(void)
1007 const struct test_event expected_test_events
[] = {
1008 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1009 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1010 { .type
= TEST_EV_TYPE_END
, },
1011 { .type
= TEST_EV_TYPE_SENTINEL
, },
1014 do_std_test(TEST_AUTO_STREAM_BEGIN_FROM_STREAM_END
,
1015 "automatic \"stream begin\" notif. caused by \"stream end\" notif.",
1016 expected_test_events
);
1020 void test_auto_stream_end_from_end(void)
1022 const struct test_event expected_test_events
[] = {
1023 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1024 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1025 { .type
= TEST_EV_TYPE_END
, },
1026 { .type
= TEST_EV_TYPE_SENTINEL
, },
1029 do_std_test(TEST_AUTO_STREAM_END_FROM_END
,
1030 "automatic \"stream end\" notif. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
1031 expected_test_events
);
1035 void test_auto_packet_begin_from_packet_end(void)
1037 const struct test_event expected_test_events
[] = {
1038 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1039 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1040 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1041 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1042 { .type
= TEST_EV_TYPE_END
, },
1043 { .type
= TEST_EV_TYPE_SENTINEL
, },
1046 do_std_test(TEST_AUTO_PACKET_BEGIN_FROM_PACKET_END
,
1047 "automatic \"packet begin\" notif. caused by \"packet end\" notif.",
1048 expected_test_events
);
1052 void test_auto_packet_begin_from_event(void)
1054 const struct test_event expected_test_events
[] = {
1055 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1056 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1057 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1058 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1059 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1060 { .type
= TEST_EV_TYPE_END
, },
1061 { .type
= TEST_EV_TYPE_SENTINEL
, },
1064 do_std_test(TEST_AUTO_PACKET_BEGIN_FROM_EVENT
,
1065 "automatic \"packet begin\" notif. caused by event notif.",
1066 expected_test_events
);
1070 void test_auto_packet_end_from_packet_begin(void)
1072 const struct test_event expected_test_events
[] = {
1073 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1074 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1075 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1076 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
1077 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
1078 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1079 { .type
= TEST_EV_TYPE_END
, },
1080 { .type
= TEST_EV_TYPE_SENTINEL
, },
1083 do_std_test(TEST_AUTO_PACKET_END_FROM_PACKET_BEGIN
,
1084 "automatic \"packet end\" notif. caused by \"packet begin\" notif.",
1085 expected_test_events
);
1089 void test_auto_packet_end_packet_begin_from_event(void)
1091 const struct test_event expected_test_events
[] = {
1092 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1093 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1094 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1095 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
1096 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
1097 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet2
, },
1098 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1099 { .type
= TEST_EV_TYPE_END
, },
1100 { .type
= TEST_EV_TYPE_SENTINEL
, },
1103 do_std_test(TEST_AUTO_PACKET_END_PACKET_BEGIN_FROM_EVENT
,
1104 "automatic \"packet end\" and \"packet begin\" notifs. caused by event notif.",
1105 expected_test_events
);
1109 void test_auto_packet_end_from_stream_end(void)
1111 const struct test_event expected_test_events
[] = {
1112 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1113 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1114 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1115 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1116 { .type
= TEST_EV_TYPE_END
, },
1117 { .type
= TEST_EV_TYPE_SENTINEL
, },
1120 do_std_test(TEST_AUTO_PACKET_END_FROM_STREAM_END
,
1121 "automatic \"packet end\" notif. caused by \"stream end\" notif.",
1122 expected_test_events
);
1126 void test_auto_packet_end_stream_end_from_end(void)
1128 const struct test_event expected_test_events
[] = {
1129 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, .stream
= src_stream1
, .packet
= NULL
, },
1130 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1131 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, .stream
= src_stream1
, .packet
= src_stream1_packet1
, },
1132 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, .stream
= src_stream1
, .packet
= NULL
, },
1133 { .type
= TEST_EV_TYPE_END
, },
1134 { .type
= TEST_EV_TYPE_SENTINEL
, },
1137 do_std_test(TEST_AUTO_PACKET_END_STREAM_END_FROM_END
,
1138 "automatic \"packet end\" and \"stream end\" notifs. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
1139 expected_test_events
);
1143 void test_multiple_auto_stream_end_from_end(void)
1145 bool expected
= true;
1146 struct test_event expected_event
;
1147 struct test_event expected_event2
;
1148 struct test_event
*event
;
1149 struct test_event
*event2
;
1151 do_std_test(TEST_MULTIPLE_AUTO_STREAM_END_FROM_END
,
1152 "multiple automatic \"stream end\" notifs. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
1155 if (test_events
->len
!= 5) {
1160 expected_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
;
1161 expected_event
.stream
= src_stream1
;
1162 expected_event
.packet
= NULL
;
1163 event
= &g_array_index(test_events
, struct test_event
, 0);
1164 if (!compare_single_test_events(event
, &expected_event
)) {
1169 expected_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
;
1170 expected_event
.stream
= src_stream2
;
1171 expected_event
.packet
= NULL
;
1172 event
= &g_array_index(test_events
, struct test_event
, 1);
1173 if (!compare_single_test_events(event
, &expected_event
)) {
1178 expected_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_END
;
1179 expected_event
.stream
= src_stream1
;
1180 expected_event
.packet
= NULL
;
1181 expected_event2
.type
= TEST_EV_TYPE_NOTIF_STREAM_END
;
1182 expected_event2
.stream
= src_stream2
;
1183 expected_event2
.packet
= NULL
;
1184 event
= &g_array_index(test_events
, struct test_event
, 2);
1185 event2
= &g_array_index(test_events
, struct test_event
, 3);
1186 if (!(compare_single_test_events(event
, &expected_event
) &&
1187 compare_single_test_events(event2
, &expected_event2
)) &&
1188 !(compare_single_test_events(event2
, &expected_event
) &&
1189 compare_single_test_events(event
, &expected_event2
))) {
1194 expected_event
.type
= TEST_EV_TYPE_END
;
1195 expected_event
.stream
= NULL
;
1196 expected_event
.packet
= NULL
;
1197 event
= &g_array_index(test_events
, struct test_event
, 4);
1198 if (!compare_single_test_events(event
, &expected_event
)) {
1205 "the produced sequence of test events is the expected one");
1209 void test_multiple_auto_packet_end_stream_end_from_end(void)
1211 bool expected
= true;
1212 struct test_event expected_event
;
1213 struct test_event expected_event2
;
1214 struct test_event
*event
;
1215 struct test_event
*event2
;
1217 do_std_test(TEST_MULTIPLE_AUTO_PACKET_END_STREAM_END_FROM_END
,
1218 "multiple automatic \"packet end\" and \"stream end\" notifs. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
1221 if (test_events
->len
!= 9) {
1226 expected_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
;
1227 expected_event
.stream
= src_stream1
;
1228 expected_event
.packet
= NULL
;
1229 event
= &g_array_index(test_events
, struct test_event
, 0);
1230 if (!compare_single_test_events(event
, &expected_event
)) {
1235 expected_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
;
1236 expected_event
.stream
= src_stream2
;
1237 expected_event
.packet
= NULL
;
1238 event
= &g_array_index(test_events
, struct test_event
, 1);
1239 if (!compare_single_test_events(event
, &expected_event
)) {
1244 expected_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
;
1245 expected_event
.stream
= src_stream1
;
1246 expected_event
.packet
= src_stream1_packet1
;
1247 event
= &g_array_index(test_events
, struct test_event
, 2);
1248 if (!compare_single_test_events(event
, &expected_event
)) {
1253 expected_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
;
1254 expected_event
.stream
= src_stream2
;
1255 expected_event
.packet
= src_stream2_packet1
;
1256 event
= &g_array_index(test_events
, struct test_event
, 3);
1257 if (!compare_single_test_events(event
, &expected_event
)) {
1262 expected_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_END
;
1263 expected_event
.stream
= src_stream1
;
1264 expected_event
.packet
= src_stream1_packet1
;
1265 expected_event2
.type
= TEST_EV_TYPE_NOTIF_PACKET_END
;
1266 expected_event2
.stream
= src_stream2
;
1267 expected_event2
.packet
= src_stream2_packet1
;
1268 event
= &g_array_index(test_events
, struct test_event
, 4);
1269 event2
= &g_array_index(test_events
, struct test_event
, 6);
1270 if (!(compare_single_test_events(event
, &expected_event
) &&
1271 compare_single_test_events(event2
, &expected_event2
)) &&
1272 !(compare_single_test_events(event2
, &expected_event
) &&
1273 compare_single_test_events(event
, &expected_event2
))) {
1278 expected_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_END
;
1279 expected_event
.stream
= src_stream1
;
1280 expected_event
.packet
= NULL
;
1281 expected_event2
.type
= TEST_EV_TYPE_NOTIF_STREAM_END
;
1282 expected_event2
.stream
= src_stream2
;
1283 expected_event2
.packet
= NULL
;
1284 event
= &g_array_index(test_events
, struct test_event
, 5);
1285 event2
= &g_array_index(test_events
, struct test_event
, 7);
1286 if (!(compare_single_test_events(event
, &expected_event
) &&
1287 compare_single_test_events(event2
, &expected_event2
)) &&
1288 !(compare_single_test_events(event2
, &expected_event
) &&
1289 compare_single_test_events(event
, &expected_event2
))) {
1294 expected_event
.type
= TEST_EV_TYPE_END
;
1295 expected_event
.stream
= NULL
;
1296 expected_event
.packet
= NULL
;
1297 event
= &g_array_index(test_events
, struct test_event
, 8);
1298 if (!compare_single_test_events(event
, &expected_event
)) {
1305 "the produced sequence of test events is the expected one");
1308 #define DEBUG_ENV_VAR "TEST_BT_NOTIFICATION_ITERATOR_DEBUG"
1310 int main(int argc
, char **argv
)
1312 if (getenv(DEBUG_ENV_VAR
) && strcmp(getenv(DEBUG_ENV_VAR
), "1") == 0) {
1316 plan_tests(NR_TESTS
);
1318 test_no_auto_notifs();
1319 test_auto_stream_begin_from_packet_begin();
1320 test_auto_stream_begin_from_stream_end();
1321 test_auto_stream_end_from_end();
1322 test_auto_packet_begin_from_packet_end();
1323 test_auto_packet_begin_from_event();
1324 test_auto_packet_end_from_packet_begin();
1325 test_auto_packet_end_packet_begin_from_event();
1326 test_auto_packet_end_from_stream_end();
1327 test_auto_packet_end_stream_end_from_end();
1328 test_multiple_auto_stream_end_from_end();
1329 test_multiple_auto_packet_end_stream_end_from_end();
1331 return exit_status();