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-filter.h>
39 #include <babeltrace/graph/component-sink.h>
40 #include <babeltrace/graph/component-source.h>
41 #include <babeltrace/graph/component.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/port.h>
48 #include <babeltrace/graph/private-component-source.h>
49 #include <babeltrace/graph/private-component-sink.h>
50 #include <babeltrace/graph/private-component.h>
51 #include <babeltrace/graph/private-connection.h>
52 #include <babeltrace/graph/private-notification-iterator.h>
53 #include <babeltrace/graph/private-port.h>
54 #include <babeltrace/plugin/plugin.h>
55 #include <babeltrace/ref.h>
64 TEST_NO_UPSTREAM_CONNECTION
,
66 TEST_4_PORTS_WITH_RETRIES
,
67 TEST_SINGLE_END_THEN_MULTIPLE_FULL
,
68 TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL
,
71 enum test_event_type
{
72 TEST_EV_TYPE_NOTIF_UNEXPECTED
,
73 TEST_EV_TYPE_NOTIF_EVENT
,
74 TEST_EV_TYPE_NOTIF_INACTIVITY
,
75 TEST_EV_TYPE_NOTIF_PACKET_BEGIN
,
76 TEST_EV_TYPE_NOTIF_PACKET_END
,
77 TEST_EV_TYPE_NOTIF_STREAM_BEGIN
,
78 TEST_EV_TYPE_NOTIF_STREAM_END
,
81 TEST_EV_TYPE_SENTINEL
,
85 enum test_event_type type
;
89 struct source_muxer_sink
{
90 struct bt_component
*source
;
91 struct bt_component
*muxer
;
92 struct bt_component
*sink
;
95 struct graph_listener_data
{
96 struct bt_graph
*graph
;
97 struct bt_component
*source
;
98 struct bt_component
*muxer
;
99 struct bt_component
*sink
;
102 static bool debug
= false;
103 static enum test current_test
;
104 static GArray
*test_events
;
105 static struct bt_clock_class_priority_map
*src_cc_prio_map
;
106 static struct bt_clock_class_priority_map
*src_empty_cc_prio_map
;
107 static struct bt_ctf_clock_class
*src_clock_class
;
108 static struct bt_ctf_stream_class
*src_stream_class
;
109 static struct bt_ctf_event_class
*src_event_class
;
110 static struct bt_ctf_packet
*src_packet0
;
111 static struct bt_ctf_packet
*src_packet1
;
112 static struct bt_ctf_packet
*src_packet2
;
113 static struct bt_ctf_packet
*src_packet3
;
118 SEQ_PACKET_BEGIN
= -3,
122 struct src_iter_user_data
{
126 struct bt_ctf_packet
*packet
;
129 struct sink_user_data
{
130 struct bt_notification_iterator
*notif_iter
;
133 static int64_t seq1
[] = {
134 24, 53, 97, 105, 119, 210, 222, 240, 292, 317, 353, 407, 433,
135 473, 487, 504, 572, 615, 708, 766, 850, 852, 931, 951, 956, 996,
139 static int64_t seq2
[] = {
140 51, 59, 68, 77, 91, 121, 139, 170, 179, 266, 352, 454, 478, 631,
141 644, 668, 714, 744, 750, 778, 790, 836, SEQ_END
,
144 static int64_t seq3
[] = {
145 8, 71, 209, 254, 298, 320, 350, 393, 419, 624, 651, 678, 717,
146 731, 733, 788, 819, 820, 857, 892, 903, 944, 998, SEQ_END
,
149 static int64_t seq4
[] = {
150 41, 56, 120, 138, 154, 228, 471, 479, 481, 525, 591, 605, 612,
151 618, 632, 670, 696, 825, 863, 867, 871, 884, 953, 985, 999,
155 static int64_t seq1_with_again
[] = {
156 24, 53, 97, 105, 119, 210, SEQ_AGAIN
, 222, 240, 292, 317, 353,
157 407, 433, 473, 487, 504, 572, 615, 708, 766, 850, 852, 931, 951,
161 static int64_t seq2_with_again
[] = {
162 51, 59, 68, 77, 91, 121, 139, 170, 179, 266, 352, 454, 478, 631,
163 644, 668, 714, 744, 750, 778, 790, 836, SEQ_AGAIN
, SEQ_END
,
166 static int64_t seq3_with_again
[] = {
167 8, 71, 209, 254, 298, 320, 350, 393, 419, 624, 651, SEQ_AGAIN
,
168 678, 717, 731, 733, 788, 819, 820, 857, 892, 903, 944, 998,
172 static int64_t seq4_with_again
[] = {
173 SEQ_AGAIN
, 41, 56, 120, 138, 154, 228, 471, 479, 481, 525, 591,
174 605, 612, 618, 632, 670, 696, 825, 863, 867, 871, 884, 953, 985,
178 static int64_t seq5
[] = {
179 1, 4, 189, 1001, SEQ_END
,
183 void clear_test_events(void)
185 g_array_set_size(test_events
, 0);
189 void print_test_event(FILE *fp
, const struct test_event
*event
)
191 fprintf(fp
, "{ type = ");
193 switch (event
->type
) {
194 case TEST_EV_TYPE_NOTIF_UNEXPECTED
:
195 fprintf(fp
, "TEST_EV_TYPE_NOTIF_UNEXPECTED");
197 case TEST_EV_TYPE_NOTIF_EVENT
:
198 fprintf(fp
, "TEST_EV_TYPE_NOTIF_EVENT");
200 case TEST_EV_TYPE_NOTIF_INACTIVITY
:
201 fprintf(fp
, "TEST_EV_TYPE_NOTIF_INACTIVITY");
203 case TEST_EV_TYPE_NOTIF_PACKET_BEGIN
:
204 fprintf(fp
, "TEST_EV_TYPE_NOTIF_PACKET_BEGIN");
206 case TEST_EV_TYPE_NOTIF_PACKET_END
:
207 fprintf(fp
, "TEST_EV_TYPE_NOTIF_PACKET_END");
209 case TEST_EV_TYPE_NOTIF_STREAM_BEGIN
:
210 fprintf(fp
, "TEST_EV_TYPE_NOTIF_STREAM_BEGIN");
212 case TEST_EV_TYPE_NOTIF_STREAM_END
:
213 fprintf(fp
, "TEST_EV_TYPE_NOTIF_STREAM_END");
215 case TEST_EV_TYPE_AGAIN
:
216 fprintf(fp
, "TEST_EV_TYPE_AGAIN");
218 case TEST_EV_TYPE_END
:
219 fprintf(fp
, "TEST_EV_TYPE_END");
221 case TEST_EV_TYPE_SENTINEL
:
222 fprintf(fp
, "TEST_EV_TYPE_SENTINEL");
225 fprintf(fp
, "(UNKNOWN)");
229 switch (event
->type
) {
230 case TEST_EV_TYPE_NOTIF_EVENT
:
231 case TEST_EV_TYPE_NOTIF_INACTIVITY
:
232 fprintf(fp
, ", ts-ns = %" PRId64
, event
->ts_ns
);
241 void append_test_event(struct test_event
*event
)
243 g_array_append_val(test_events
, *event
);
247 bool compare_single_test_events(const struct test_event
*ev_a
,
248 const struct test_event
*ev_b
)
251 fprintf(stderr
, ":: Comparing test events: ");
252 print_test_event(stderr
, ev_a
);
253 fprintf(stderr
, " vs. ");
254 print_test_event(stderr
, ev_b
);
255 fprintf(stderr
, "\n");
258 if (ev_a
->type
!= ev_b
->type
) {
262 switch (ev_a
->type
) {
263 case TEST_EV_TYPE_NOTIF_EVENT
:
264 case TEST_EV_TYPE_NOTIF_INACTIVITY
:
265 if (ev_a
->ts_ns
!= ev_b
->ts_ns
) {
277 bool compare_test_events(const struct test_event
*expected_events
)
279 const struct test_event
*expected_event
= expected_events
;
282 assert(expected_events
);
285 const struct test_event
*event
;
287 if (expected_event
->type
== TEST_EV_TYPE_SENTINEL
) {
291 if (i
>= test_events
->len
) {
295 event
= &g_array_index(test_events
, struct test_event
, i
);
297 if (!compare_single_test_events(event
, expected_event
)) {
305 if (i
!= test_events
->len
) {
307 fprintf(stderr
, ":: Length mismatch\n");
317 void init_static_data(void)
320 struct bt_ctf_trace
*trace
;
321 struct bt_ctf_stream
*stream
;
322 struct bt_ctf_field_type
*empty_struct_ft
;
325 test_events
= g_array_new(FALSE
, TRUE
, sizeof(struct test_event
));
329 empty_struct_ft
= bt_ctf_field_type_structure_create();
330 assert(empty_struct_ft
);
331 trace
= bt_ctf_trace_create();
333 ret
= bt_ctf_trace_set_native_byte_order(trace
,
334 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
336 ret
= bt_ctf_trace_set_packet_header_type(trace
, empty_struct_ft
);
338 src_clock_class
= bt_ctf_clock_class_create("my-clock");
339 assert(src_clock_class
);
340 ret
= bt_ctf_clock_class_set_is_absolute(src_clock_class
, 1);
342 ret
= bt_ctf_trace_add_clock_class(trace
, src_clock_class
);
344 src_empty_cc_prio_map
= bt_clock_class_priority_map_create();
345 assert(src_empty_cc_prio_map
);
346 src_cc_prio_map
= bt_clock_class_priority_map_create();
347 assert(src_cc_prio_map
);
348 ret
= bt_clock_class_priority_map_add_clock_class(src_cc_prio_map
,
351 src_stream_class
= bt_ctf_stream_class_create("my-stream-class");
352 assert(src_stream_class
);
353 ret
= bt_ctf_stream_class_set_packet_context_type(src_stream_class
,
356 ret
= bt_ctf_stream_class_set_event_header_type(src_stream_class
,
359 ret
= bt_ctf_stream_class_set_event_context_type(src_stream_class
,
362 src_event_class
= bt_ctf_event_class_create("my-event-class");
363 ret
= bt_ctf_event_class_set_context_type(src_event_class
,
366 ret
= bt_ctf_event_class_set_context_type(src_event_class
,
369 ret
= bt_ctf_stream_class_add_event_class(src_stream_class
,
372 ret
= bt_ctf_trace_add_stream_class(trace
, src_stream_class
);
374 stream
= bt_ctf_stream_create(src_stream_class
, "stream0");
376 src_packet0
= bt_ctf_packet_create(stream
);
379 stream
= bt_ctf_stream_create(src_stream_class
, "stream1");
381 src_packet1
= bt_ctf_packet_create(stream
);
384 stream
= bt_ctf_stream_create(src_stream_class
, "stream2");
386 src_packet2
= bt_ctf_packet_create(stream
);
389 stream
= bt_ctf_stream_create(src_stream_class
, "stream3");
391 src_packet3
= bt_ctf_packet_create(stream
);
396 bt_put(empty_struct_ft
);
400 void fini_static_data(void)
403 g_array_free(test_events
, TRUE
);
406 bt_put(src_empty_cc_prio_map
);
407 bt_put(src_cc_prio_map
);
408 bt_put(src_clock_class
);
409 bt_put(src_stream_class
);
410 bt_put(src_event_class
);
418 void src_iter_finalize(
419 struct bt_private_notification_iterator
*private_notification_iterator
)
421 struct src_iter_user_data
*user_data
=
422 bt_private_notification_iterator_get_user_data(
423 private_notification_iterator
);
431 enum bt_notification_iterator_status
src_iter_init(
432 struct bt_private_notification_iterator
*priv_notif_iter
,
433 struct bt_private_port
*private_port
)
435 struct src_iter_user_data
*user_data
=
436 g_new0(struct src_iter_user_data
, 1);
437 struct bt_port
*port
= bt_port_from_private_port(private_port
);
438 const char *port_name
;
443 ret
= bt_private_notification_iterator_set_user_data(priv_notif_iter
,
446 port_name
= bt_port_get_name(port
);
448 user_data
->iter_index
= port_name
[3] - '0';
451 switch (user_data
->iter_index
) {
453 user_data
->packet
= src_packet0
;
456 user_data
->packet
= src_packet1
;
459 user_data
->packet
= src_packet2
;
462 user_data
->packet
= src_packet3
;
468 switch (current_test
) {
470 if (user_data
->iter_index
== 1) {
471 user_data
->seq
= seq5
;
474 case TEST_SIMPLE_4_PORTS
:
475 if (user_data
->iter_index
== 0) {
476 user_data
->seq
= seq1
;
477 } else if (user_data
->iter_index
== 1) {
478 user_data
->seq
= seq2
;
479 } else if (user_data
->iter_index
== 2) {
480 user_data
->seq
= seq3
;
482 user_data
->seq
= seq4
;
485 case TEST_4_PORTS_WITH_RETRIES
:
486 if (user_data
->iter_index
== 0) {
487 user_data
->seq
= seq1_with_again
;
488 } else if (user_data
->iter_index
== 1) {
489 user_data
->seq
= seq2_with_again
;
490 } else if (user_data
->iter_index
== 2) {
491 user_data
->seq
= seq3_with_again
;
493 user_data
->seq
= seq4_with_again
;
496 case TEST_SINGLE_END_THEN_MULTIPLE_FULL
:
497 case TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL
:
498 if (user_data
->iter_index
== 0) {
499 /* Ignore: this iterator only returns END */
500 } else if (user_data
->iter_index
== 1) {
501 user_data
->seq
= seq2
;
503 user_data
->seq
= seq3
;
510 return BT_NOTIFICATION_ITERATOR_STATUS_OK
;
514 struct bt_ctf_event
*src_create_event(struct bt_ctf_packet
*packet
,
517 struct bt_ctf_event
*event
= bt_ctf_event_create(src_event_class
);
521 ret
= bt_ctf_event_set_packet(event
, packet
);
525 struct bt_ctf_clock_value
*clock_value
;
527 clock_value
= bt_ctf_clock_value_create(src_clock_class
,
530 ret
= bt_ctf_event_set_clock_value(event
, clock_value
);
539 struct bt_notification_iterator_next_return
src_iter_next_seq(
540 struct src_iter_user_data
*user_data
)
542 struct bt_notification_iterator_next_return next_return
= {
543 .status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
,
547 assert(user_data
->seq
);
548 cur_ts_ns
= user_data
->seq
[user_data
->at
];
553 BT_NOTIFICATION_ITERATOR_STATUS_END
;
557 BT_NOTIFICATION_ITERATOR_STATUS_AGAIN
;
559 case SEQ_PACKET_BEGIN
:
560 next_return
.notification
=
561 bt_notification_packet_begin_create(user_data
->packet
);
562 assert(next_return
.notification
);
565 next_return
.notification
=
566 bt_notification_packet_end_create(user_data
->packet
);
567 assert(next_return
.notification
);
571 struct bt_ctf_event
*event
= src_create_event(
572 user_data
->packet
, cur_ts_ns
);
575 next_return
.notification
= bt_notification_event_create(event
,
578 assert(next_return
.notification
);
583 if (next_return
.status
!= BT_NOTIFICATION_ITERATOR_STATUS_END
) {
591 struct bt_notification_iterator_next_return
src_iter_next(
592 struct bt_private_notification_iterator
*priv_iterator
)
594 struct bt_notification_iterator_next_return next_return
= {
595 .notification
= NULL
,
596 .status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
,
598 struct src_iter_user_data
*user_data
=
599 bt_private_notification_iterator_get_user_data(priv_iterator
);
600 struct bt_private_component
*private_component
=
601 bt_private_notification_iterator_get_private_component(priv_iterator
);
604 assert(private_component
);
606 switch (current_test
) {
608 if (user_data
->iter_index
== 0) {
609 if (user_data
->at
== 0) {
610 next_return
.notification
=
611 bt_notification_packet_begin_create(
613 assert(next_return
.notification
);
614 } else if (user_data
->at
< 6) {
615 struct bt_ctf_event
*event
= src_create_event(
616 user_data
->packet
, -1);
619 next_return
.notification
=
620 bt_notification_event_create(event
,
621 src_empty_cc_prio_map
);
622 assert(next_return
.notification
);
626 BT_NOTIFICATION_ITERATOR_STATUS_END
;
631 next_return
= src_iter_next_seq(user_data
);
634 case TEST_SIMPLE_4_PORTS
:
635 case TEST_4_PORTS_WITH_RETRIES
:
636 next_return
= src_iter_next_seq(user_data
);
638 case TEST_SINGLE_END_THEN_MULTIPLE_FULL
:
639 if (user_data
->iter_index
== 0) {
640 struct bt_private_port
*priv_port
;
642 priv_port
= bt_private_component_source_add_output_private_port(
643 private_component
, "out1", NULL
);
646 priv_port
= bt_private_component_source_add_output_private_port(
647 private_component
, "out2", NULL
);
650 next_return
.status
= BT_NOTIFICATION_ITERATOR_STATUS_END
;
652 next_return
= src_iter_next_seq(user_data
);
655 case TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL
:
656 if (user_data
->iter_index
== 0) {
657 if (user_data
->at
== 0) {
658 next_return
.status
= BT_NOTIFICATION_ITERATOR_STATUS_AGAIN
;
661 struct bt_private_port
*priv_port
;
663 priv_port
= bt_private_component_source_add_output_private_port(
664 private_component
, "out1", NULL
);
667 priv_port
= bt_private_component_source_add_output_private_port(
668 private_component
, "out2", NULL
);
671 next_return
.status
= BT_NOTIFICATION_ITERATOR_STATUS_END
;
674 next_return
= src_iter_next_seq(user_data
);
681 bt_put(private_component
);
686 enum bt_component_status
src_init(
687 struct bt_private_component
*private_component
,
688 struct bt_value
*params
, void *init_method_data
)
690 struct bt_private_port
*priv_port
;
693 switch (current_test
) {
697 case TEST_SINGLE_END_THEN_MULTIPLE_FULL
:
698 case TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL
:
707 priv_port
= bt_private_component_source_add_output_private_port(
708 private_component
, "out0", NULL
);
714 priv_port
= bt_private_component_source_add_output_private_port(
715 private_component
, "out1", NULL
);
721 priv_port
= bt_private_component_source_add_output_private_port(
722 private_component
, "out2", NULL
);
728 priv_port
= bt_private_component_source_add_output_private_port(
729 private_component
, "out3", NULL
);
734 return BT_COMPONENT_STATUS_OK
;
738 void src_finalize(struct bt_private_component
*private_component
)
743 enum bt_component_status
sink_consume(
744 struct bt_private_component
*priv_component
)
746 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
747 struct bt_notification
*notification
= NULL
;
748 struct sink_user_data
*user_data
=
749 bt_private_component_get_user_data(priv_component
);
750 enum bt_notification_iterator_status it_ret
;
751 struct test_event test_event
;
752 bool do_append_test_event
= true;
754 assert(user_data
&& user_data
->notif_iter
);
755 it_ret
= bt_notification_iterator_next(user_data
->notif_iter
);
758 ret
= BT_COMPONENT_STATUS_ERROR
;
759 do_append_test_event
= false;
764 case BT_NOTIFICATION_ITERATOR_STATUS_END
:
765 test_event
.type
= TEST_EV_TYPE_END
;
766 ret
= BT_COMPONENT_STATUS_END
;
767 BT_PUT(user_data
->notif_iter
);
769 case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN
:
770 test_event
.type
= TEST_EV_TYPE_AGAIN
;
771 ret
= BT_COMPONENT_STATUS_AGAIN
;
777 notification
= bt_notification_iterator_get_notification(
778 user_data
->notif_iter
);
779 assert(notification
);
781 switch (bt_notification_get_type(notification
)) {
782 case BT_NOTIFICATION_TYPE_EVENT
:
784 struct bt_ctf_event
*event
;
785 struct bt_clock_class_priority_map
*cc_prio_map
;
787 test_event
.type
= TEST_EV_TYPE_NOTIF_EVENT
;
789 bt_notification_event_get_clock_class_priority_map(
792 event
= bt_notification_event_get_event(notification
);
795 if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map
) > 0) {
796 struct bt_ctf_clock_value
*clock_value
;
797 struct bt_ctf_clock_class
*clock_class
=
798 bt_clock_class_priority_map_get_highest_priority_clock_class(
802 clock_value
= bt_ctf_event_get_clock_value(event
,
805 ret
= bt_ctf_clock_value_get_value_ns_from_epoch(
806 clock_value
, &test_event
.ts_ns
);
811 test_event
.ts_ns
= -1;
818 case BT_NOTIFICATION_TYPE_INACTIVITY
:
820 struct bt_clock_class_priority_map
*cc_prio_map
;
822 test_event
.type
= TEST_EV_TYPE_NOTIF_INACTIVITY
;
823 cc_prio_map
= bt_notification_event_get_clock_class_priority_map(
827 if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map
) > 0) {
828 struct bt_ctf_clock_value
*clock_value
;
829 struct bt_ctf_clock_class
*clock_class
=
830 bt_clock_class_priority_map_get_highest_priority_clock_class(
835 bt_notification_inactivity_get_clock_value(
836 notification
, clock_class
);
838 ret
= bt_ctf_clock_value_get_value_ns_from_epoch(
839 clock_value
, &test_event
.ts_ns
);
844 test_event
.ts_ns
= -1;
850 case BT_NOTIFICATION_TYPE_PACKET_BEGIN
:
851 test_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
;
853 case BT_NOTIFICATION_TYPE_PACKET_END
:
854 test_event
.type
= TEST_EV_TYPE_NOTIF_PACKET_END
;
856 case BT_NOTIFICATION_TYPE_STREAM_BEGIN
:
857 test_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
;
859 case BT_NOTIFICATION_TYPE_STREAM_END
:
860 test_event
.type
= TEST_EV_TYPE_NOTIF_STREAM_END
;
863 test_event
.type
= TEST_EV_TYPE_NOTIF_UNEXPECTED
;
868 if (do_append_test_event
) {
869 append_test_event(&test_event
);
872 bt_put(notification
);
877 void sink_port_connected(struct bt_private_component
*private_component
,
878 struct bt_private_port
*self_private_port
,
879 struct bt_port
*other_port
)
881 struct bt_private_connection
*priv_conn
=
882 bt_private_port_get_private_connection(self_private_port
);
883 struct sink_user_data
*user_data
= bt_private_component_get_user_data(
888 user_data
->notif_iter
=
889 bt_private_connection_create_notification_iterator(priv_conn
,
891 assert(user_data
->notif_iter
);
896 enum bt_component_status
sink_init(
897 struct bt_private_component
*private_component
,
898 struct bt_value
*params
, void *init_method_data
)
900 struct sink_user_data
*user_data
= g_new0(struct sink_user_data
, 1);
905 ret
= bt_private_component_set_user_data(private_component
,
908 priv_port
= bt_private_component_sink_add_input_private_port(
909 private_component
, "in", NULL
);
912 return BT_COMPONENT_STATUS_OK
;
916 void sink_finalize(struct bt_private_component
*private_component
)
918 struct sink_user_data
*user_data
= bt_private_component_get_user_data(
922 bt_put(user_data
->notif_iter
);
928 void create_source_muxer_sink(struct bt_component
**source
,
929 struct bt_component
**muxer
,
930 struct bt_component
**sink
)
932 struct bt_component_class
*src_comp_class
;
933 struct bt_component_class
*muxer_comp_class
;
934 struct bt_component_class
*sink_comp_class
;
937 /* Create source component */
938 src_comp_class
= bt_component_class_source_create("src", src_iter_next
);
939 assert(src_comp_class
);
940 ret
= bt_component_class_set_init_method(src_comp_class
, src_init
);
942 ret
= bt_component_class_set_finalize_method(src_comp_class
,
945 ret
= bt_component_class_source_set_notification_iterator_init_method(
946 src_comp_class
, src_iter_init
);
948 ret
= bt_component_class_source_set_notification_iterator_finalize_method(
949 src_comp_class
, src_iter_finalize
);
951 *source
= bt_component_create(src_comp_class
, "source", NULL
);
954 /* Create muxer component */
955 muxer_comp_class
= bt_plugin_find_component_class("utils", "muxer",
956 BT_COMPONENT_CLASS_TYPE_FILTER
);
957 assert(muxer_comp_class
);
958 *muxer
= bt_component_create(muxer_comp_class
, "muxer", NULL
);
961 /* Create sink component */
962 sink_comp_class
= bt_component_class_sink_create("sink", sink_consume
);
963 assert(sink_comp_class
);
964 ret
= bt_component_class_set_init_method(sink_comp_class
, sink_init
);
966 ret
= bt_component_class_set_finalize_method(sink_comp_class
,
968 ret
= bt_component_class_set_port_connected_method(sink_comp_class
,
969 sink_port_connected
);
971 *sink
= bt_component_create(sink_comp_class
, "sink", NULL
);
973 bt_put(src_comp_class
);
974 bt_put(muxer_comp_class
);
975 bt_put(sink_comp_class
);
979 void do_std_test(enum test test
, const char *name
,
980 const struct test_event
*expected_test_events
,
983 struct bt_component
*src_comp
;
984 struct bt_component
*muxer_comp
;
985 struct bt_component
*sink_comp
;
986 struct bt_port
*upstream_port
;
987 struct bt_port
*downstream_port
;
988 struct bt_graph
*graph
;
991 enum bt_graph_status graph_status
= BT_GRAPH_STATUS_OK
;
995 diag("test: %s", name
);
996 create_source_muxer_sink(&src_comp
, &muxer_comp
, &sink_comp
);
997 graph
= bt_graph_create();
1000 /* Connect source output ports to muxer input ports */
1001 if (with_upstream
) {
1002 count
= bt_component_source_get_output_port_count(src_comp
);
1005 for (i
= 0; i
< count
; i
++) {
1006 upstream_port
= bt_component_source_get_output_port_by_index(
1008 assert(upstream_port
);
1009 downstream_port
= bt_component_filter_get_input_port_by_index(
1011 assert(downstream_port
);
1012 graph_status
= bt_graph_connect_ports(graph
,
1013 upstream_port
, downstream_port
, NULL
);
1014 assert(graph_status
== 0);
1015 bt_put(upstream_port
);
1016 bt_put(downstream_port
);
1020 /* Connect muxer output port to sink input port */
1021 upstream_port
= bt_component_filter_get_output_port_by_name(muxer_comp
,
1023 assert(upstream_port
);
1024 downstream_port
= bt_component_sink_get_input_port_by_name(sink_comp
, "in");
1025 assert(downstream_port
);
1026 graph_status
= bt_graph_connect_ports(graph
, upstream_port
,
1027 downstream_port
, NULL
);
1028 assert(graph_status
== 0);
1029 bt_put(upstream_port
);
1030 bt_put(downstream_port
);
1032 while (graph_status
== BT_GRAPH_STATUS_OK
||
1033 graph_status
== BT_GRAPH_STATUS_AGAIN
) {
1034 graph_status
= bt_graph_run(graph
);
1037 ok(graph_status
== BT_GRAPH_STATUS_END
, "graph finishes without any error");
1038 ok(compare_test_events(expected_test_events
),
1039 "the produced sequence of test events is the expected one");
1048 void test_no_ts(void)
1050 const struct test_event expected_test_events
[] = {
1051 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1052 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1053 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1054 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1055 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= -1, },
1056 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= -1, },
1057 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= -1, },
1058 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= -1, },
1059 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= -1, },
1060 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1061 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1062 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 1, },
1063 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 4, },
1064 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 189, },
1065 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 1001, },
1066 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1067 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1068 { .type
= TEST_EV_TYPE_END
, },
1069 { .type
= TEST_EV_TYPE_SENTINEL
, },
1072 do_std_test(TEST_NO_TS
, "event notifications with no time",
1073 expected_test_events
, true);
1077 void test_no_upstream_connection(void)
1079 const struct test_event expected_test_events
[] = {
1080 { .type
= TEST_EV_TYPE_END
, },
1081 { .type
= TEST_EV_TYPE_SENTINEL
, },
1084 do_std_test(TEST_NO_UPSTREAM_CONNECTION
, "no upstream connection",
1085 expected_test_events
, false);
1089 void test_simple_4_ports(void)
1091 const struct test_event expected_test_events
[] = {
1092 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1093 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1094 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1095 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1096 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1097 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1098 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1099 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1100 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 8 },
1101 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 24 },
1102 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 41 },
1103 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 51 },
1104 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 53 },
1105 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 56 },
1106 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 59 },
1107 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 68 },
1108 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 71 },
1109 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 77 },
1110 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 91 },
1111 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 97 },
1112 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 105 },
1113 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 119 },
1114 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 120 },
1115 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 121 },
1116 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 138 },
1117 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 139 },
1118 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 154 },
1119 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 170 },
1120 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 179 },
1121 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 209 },
1122 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 210 },
1123 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 222 },
1124 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 228 },
1125 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 240 },
1126 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 254 },
1127 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 266 },
1128 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 292 },
1129 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 298 },
1130 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 317 },
1131 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 320 },
1132 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 350 },
1133 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 352 },
1134 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 353 },
1135 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 393 },
1136 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 407 },
1137 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 419 },
1138 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 433 },
1139 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 454 },
1140 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 471 },
1141 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 473 },
1142 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 478 },
1143 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 479 },
1144 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 481 },
1145 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 487 },
1146 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 504 },
1147 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 525 },
1148 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 572 },
1149 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 591 },
1150 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 605 },
1151 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 612 },
1152 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 615 },
1153 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 618 },
1154 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 624 },
1155 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 631 },
1156 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 632 },
1157 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 644 },
1158 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 651 },
1159 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 668 },
1160 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 670 },
1161 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 678 },
1162 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 696 },
1163 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 708 },
1164 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 714 },
1165 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 717 },
1166 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 731 },
1167 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 733 },
1168 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 744 },
1169 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 750 },
1170 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 766 },
1171 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 778 },
1172 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 788 },
1173 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 790 },
1174 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 819 },
1175 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 820 },
1176 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 825 },
1177 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 836 },
1178 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1179 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1180 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 850 },
1181 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 852 },
1182 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 857 },
1183 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 863 },
1184 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 867 },
1185 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 871 },
1186 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 884 },
1187 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 892 },
1188 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 903 },
1189 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 931 },
1190 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 944 },
1191 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 951 },
1192 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 953 },
1193 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 956 },
1194 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 985 },
1195 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 996 },
1196 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1197 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1198 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 998 },
1199 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1200 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1201 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 999 },
1202 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1203 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1204 { .type
= TEST_EV_TYPE_END
, },
1205 { .type
= TEST_EV_TYPE_SENTINEL
, },
1208 do_std_test(TEST_SIMPLE_4_PORTS
, "simple: 4 ports without retries",
1209 expected_test_events
, true);
1213 void test_4_ports_with_retries(void)
1215 const struct test_event expected_test_events
[] = {
1216 { .type
= TEST_EV_TYPE_AGAIN
, },
1217 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1218 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1219 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1220 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1221 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1222 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1223 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1224 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1225 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 8 },
1226 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 24 },
1227 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 41 },
1228 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 51 },
1229 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 53 },
1230 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 56 },
1231 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 59 },
1232 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 68 },
1233 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 71 },
1234 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 77 },
1235 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 91 },
1236 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 97 },
1237 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 105 },
1238 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 119 },
1239 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 120 },
1240 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 121 },
1241 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 138 },
1242 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 139 },
1243 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 154 },
1244 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 170 },
1245 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 179 },
1246 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 209 },
1247 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 210 },
1248 { .type
= TEST_EV_TYPE_AGAIN
, },
1249 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 222 },
1250 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 228 },
1251 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 240 },
1252 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 254 },
1253 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 266 },
1254 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 292 },
1255 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 298 },
1256 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 317 },
1257 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 320 },
1258 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 350 },
1259 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 352 },
1260 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 353 },
1261 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 393 },
1262 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 407 },
1263 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 419 },
1264 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 433 },
1265 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 454 },
1266 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 471 },
1267 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 473 },
1268 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 478 },
1269 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 479 },
1270 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 481 },
1271 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 487 },
1272 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 504 },
1273 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 525 },
1274 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 572 },
1275 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 591 },
1276 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 605 },
1277 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 612 },
1278 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 615 },
1279 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 618 },
1280 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 624 },
1281 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 631 },
1282 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 632 },
1283 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 644 },
1284 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 651 },
1285 { .type
= TEST_EV_TYPE_AGAIN
, },
1286 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 668 },
1287 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 670 },
1288 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 678 },
1289 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 696 },
1290 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 708 },
1291 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 714 },
1292 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 717 },
1293 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 731 },
1294 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 733 },
1295 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 744 },
1296 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 750 },
1297 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 766 },
1298 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 778 },
1299 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 788 },
1300 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 790 },
1301 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 819 },
1302 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 820 },
1303 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 825 },
1304 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 836 },
1305 { .type
= TEST_EV_TYPE_AGAIN
, },
1306 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1307 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1308 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 850 },
1309 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 852 },
1310 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 857 },
1311 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 863 },
1312 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 867 },
1313 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 871 },
1314 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 884 },
1315 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 892 },
1316 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 903 },
1317 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 931 },
1318 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 944 },
1319 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 951 },
1320 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 953 },
1321 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 956 },
1322 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 985 },
1323 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 996 },
1324 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1325 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1326 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 998 },
1327 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1328 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1329 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 999 },
1330 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1331 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1332 { .type
= TEST_EV_TYPE_END
, },
1333 { .type
= TEST_EV_TYPE_SENTINEL
, },
1336 do_std_test(TEST_4_PORTS_WITH_RETRIES
, "4 ports with retries",
1337 expected_test_events
, true);
1341 void connect_port_to_first_avail_muxer_port(struct bt_graph
*graph
,
1342 struct bt_port
*source_port
,
1343 struct bt_component
*muxer_comp
)
1345 struct bt_port
*avail_muxer_port
= NULL
;
1348 enum bt_graph_status graph_status
;
1350 count
= bt_component_filter_get_input_port_count(muxer_comp
);
1353 for (i
= 0; i
< count
; i
++) {
1354 struct bt_port
*muxer_port
=
1355 bt_component_filter_get_input_port_by_index(
1360 if (!bt_port_is_connected(muxer_port
)) {
1361 BT_MOVE(avail_muxer_port
, muxer_port
);
1368 graph_status
= bt_graph_connect_ports(graph
, source_port
,
1369 avail_muxer_port
, NULL
);
1370 assert(graph_status
== 0);
1371 bt_put(avail_muxer_port
);
1375 void graph_port_added_listener_connect_to_avail_muxer_port(struct bt_port
*port
,
1378 struct graph_listener_data
*graph_listener_data
= data
;
1379 struct bt_component
*comp
;
1381 comp
= bt_port_get_component(port
);
1384 if (comp
!= graph_listener_data
->source
) {
1388 connect_port_to_first_avail_muxer_port(graph_listener_data
->graph
,
1389 port
, graph_listener_data
->muxer
);
1396 void test_single_end_then_multiple_full(void)
1398 struct bt_component
*src_comp
;
1399 struct bt_component
*muxer_comp
;
1400 struct bt_component
*sink_comp
;
1401 struct bt_port
*upstream_port
;
1402 struct bt_port
*downstream_port
;
1403 struct bt_graph
*graph
;
1407 enum bt_graph_status graph_status
= BT_GRAPH_STATUS_OK
;
1408 struct graph_listener_data graph_listener_data
;
1409 const struct test_event expected_test_events
[] = {
1410 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1411 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1412 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1413 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1414 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 8 },
1415 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 51 },
1416 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 59 },
1417 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 68 },
1418 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 71 },
1419 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 77 },
1420 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 91 },
1421 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 121 },
1422 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 139 },
1423 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 170 },
1424 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 179 },
1425 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 209 },
1426 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 254 },
1427 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 266 },
1428 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 298 },
1429 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 320 },
1430 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 350 },
1431 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 352 },
1432 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 393 },
1433 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 419 },
1434 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 454 },
1435 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 478 },
1436 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 624 },
1437 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 631 },
1438 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 644 },
1439 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 651 },
1440 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 668 },
1441 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 678 },
1442 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 714 },
1443 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 717 },
1444 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 731 },
1445 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 733 },
1446 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 744 },
1447 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 750 },
1448 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 778 },
1449 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 788 },
1450 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 790 },
1451 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 819 },
1452 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 820 },
1453 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 836 },
1454 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1455 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1456 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 857 },
1457 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 892 },
1458 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 903 },
1459 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 944 },
1460 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 998 },
1461 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1462 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1463 { .type
= TEST_EV_TYPE_END
, },
1464 { .type
= TEST_EV_TYPE_SENTINEL
, },
1467 clear_test_events();
1468 current_test
= TEST_SINGLE_END_THEN_MULTIPLE_FULL
;
1469 diag("test: single end then multiple full");
1470 create_source_muxer_sink(&src_comp
, &muxer_comp
, &sink_comp
);
1471 graph
= bt_graph_create();
1473 graph_listener_data
.graph
= graph
;
1474 graph_listener_data
.source
= src_comp
;
1475 graph_listener_data
.muxer
= muxer_comp
;
1476 graph_listener_data
.sink
= sink_comp
;
1477 ret
= bt_graph_add_port_added_listener(graph
,
1478 graph_port_added_listener_connect_to_avail_muxer_port
,
1479 &graph_listener_data
);
1482 /* Connect source output ports to muxer input ports */
1483 count
= bt_component_source_get_output_port_count(src_comp
);
1486 for (i
= 0; i
< count
; i
++) {
1487 upstream_port
= bt_component_source_get_output_port_by_index(
1489 assert(upstream_port
);
1490 connect_port_to_first_avail_muxer_port(graph
,
1491 upstream_port
, muxer_comp
);
1492 bt_put(upstream_port
);
1495 /* Connect muxer output port to sink input port */
1496 upstream_port
= bt_component_filter_get_output_port_by_name(muxer_comp
,
1498 assert(upstream_port
);
1499 downstream_port
= bt_component_sink_get_input_port_by_name(sink_comp
, "in");
1500 assert(downstream_port
);
1501 graph_status
= bt_graph_connect_ports(graph
, upstream_port
,
1502 downstream_port
, NULL
);
1503 assert(graph_status
== 0);
1504 bt_put(upstream_port
);
1505 bt_put(downstream_port
);
1507 while (graph_status
== BT_GRAPH_STATUS_OK
||
1508 graph_status
== BT_GRAPH_STATUS_AGAIN
) {
1509 graph_status
= bt_graph_run(graph
);
1512 ok(graph_status
== BT_GRAPH_STATUS_END
, "graph finishes without any error");
1513 ok(compare_test_events(expected_test_events
),
1514 "the produced sequence of test events is the expected one");
1523 void test_single_again_end_then_multiple_full(void)
1525 struct bt_component
*src_comp
;
1526 struct bt_component
*muxer_comp
;
1527 struct bt_component
*sink_comp
;
1528 struct bt_port
*upstream_port
;
1529 struct bt_port
*downstream_port
;
1530 struct bt_graph
*graph
;
1534 enum bt_graph_status graph_status
= BT_GRAPH_STATUS_OK
;
1535 struct graph_listener_data graph_listener_data
;
1536 const struct test_event expected_test_events
[] = {
1537 { .type
= TEST_EV_TYPE_AGAIN
, },
1538 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1539 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1540 { .type
= TEST_EV_TYPE_NOTIF_STREAM_BEGIN
, },
1541 { .type
= TEST_EV_TYPE_NOTIF_PACKET_BEGIN
, },
1542 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 8 },
1543 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 51 },
1544 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 59 },
1545 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 68 },
1546 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 71 },
1547 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 77 },
1548 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 91 },
1549 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 121 },
1550 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 139 },
1551 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 170 },
1552 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 179 },
1553 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 209 },
1554 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 254 },
1555 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 266 },
1556 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 298 },
1557 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 320 },
1558 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 350 },
1559 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 352 },
1560 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 393 },
1561 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 419 },
1562 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 454 },
1563 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 478 },
1564 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 624 },
1565 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 631 },
1566 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 644 },
1567 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 651 },
1568 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 668 },
1569 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 678 },
1570 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 714 },
1571 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 717 },
1572 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 731 },
1573 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 733 },
1574 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 744 },
1575 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 750 },
1576 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 778 },
1577 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 788 },
1578 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 790 },
1579 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 819 },
1580 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 820 },
1581 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 836 },
1582 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1583 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1584 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 857 },
1585 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 892 },
1586 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 903 },
1587 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 944 },
1588 { .type
= TEST_EV_TYPE_NOTIF_EVENT
, .ts_ns
= 998 },
1589 { .type
= TEST_EV_TYPE_NOTIF_PACKET_END
, },
1590 { .type
= TEST_EV_TYPE_NOTIF_STREAM_END
, },
1591 { .type
= TEST_EV_TYPE_END
, },
1592 { .type
= TEST_EV_TYPE_SENTINEL
, },
1595 clear_test_events();
1596 current_test
= TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL
;
1597 diag("test: single again then end then multiple full");
1598 create_source_muxer_sink(&src_comp
, &muxer_comp
, &sink_comp
);
1599 graph
= bt_graph_create();
1601 graph_listener_data
.graph
= graph
;
1602 graph_listener_data
.source
= src_comp
;
1603 graph_listener_data
.muxer
= muxer_comp
;
1604 graph_listener_data
.sink
= sink_comp
;
1605 ret
= bt_graph_add_port_added_listener(graph
,
1606 graph_port_added_listener_connect_to_avail_muxer_port
,
1607 &graph_listener_data
);
1610 /* Connect source output ports to muxer input ports */
1611 count
= bt_component_source_get_output_port_count(src_comp
);
1614 for (i
= 0; i
< count
; i
++) {
1615 upstream_port
= bt_component_source_get_output_port_by_index(
1617 assert(upstream_port
);
1618 connect_port_to_first_avail_muxer_port(graph
,
1619 upstream_port
, muxer_comp
);
1620 bt_put(upstream_port
);
1623 /* Connect muxer output port to sink input port */
1624 upstream_port
= bt_component_filter_get_output_port_by_name(muxer_comp
,
1626 assert(upstream_port
);
1627 downstream_port
= bt_component_sink_get_input_port_by_name(sink_comp
, "in");
1628 assert(downstream_port
);
1629 graph_status
= bt_graph_connect_ports(graph
, upstream_port
,
1630 downstream_port
, NULL
);
1631 assert(graph_status
== 0);
1632 bt_put(upstream_port
);
1633 bt_put(downstream_port
);
1635 while (graph_status
== BT_GRAPH_STATUS_OK
||
1636 graph_status
== BT_GRAPH_STATUS_AGAIN
) {
1637 graph_status
= bt_graph_run(graph
);
1640 ok(graph_status
== BT_GRAPH_STATUS_END
, "graph finishes without any error");
1641 ok(compare_test_events(expected_test_events
),
1642 "the produced sequence of test events is the expected one");
1650 #define DEBUG_ENV_VAR "TEST_UTILS_MUXER_DEBUG"
1652 int main(int argc
, char **argv
)
1654 if (getenv(DEBUG_ENV_VAR
) && strcmp(getenv(DEBUG_ENV_VAR
), "1") == 0) {
1658 plan_tests(NR_TESTS
);
1661 test_no_upstream_connection();
1662 test_simple_4_ports();
1663 test_4_ports_with_retries();
1664 test_single_end_then_multiple_full();
1665 test_single_again_end_then_multiple_full();
1667 return exit_status();