Split CTF IR and CTF writer APIs and implementations
[babeltrace.git] / tests / plugins / test-utils-muxer.c
index 292ee0fec6f4bc8432b985c4017438114ecc00d2..aa7f29809e3e2d2bc695ccf002baa7f06e041a18 100644 (file)
@@ -87,6 +87,8 @@ enum {
        SEQ_AGAIN = -2,
        SEQ_PACKET_BEGIN = -3,
        SEQ_PACKET_END = -4,
+       SEQ_STREAM_BEGIN = -5,
+       SEQ_STREAM_END = -6,
 };
 
 struct src_iter_user_data {
@@ -101,52 +103,62 @@ struct sink_user_data {
 };
 
 static int64_t seq1[] = {
-       24, 53, 97, 105, 119, 210, 222, 240, 292, 317, 353, 407, 433,
-       473, 487, 504, 572, 615, 708, 766, 850, 852, 931, 951, 956, 996,
-       SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 24, 53, 97, 105, 119, 210,
+       222, 240, 292, 317, 353, 407, 433, 473, 487, 504, 572, 615, 708,
+       766, 850, 852, 931, 951, 956, 996, SEQ_PACKET_END,
+       SEQ_STREAM_END, SEQ_END,
 };
 
 static int64_t seq2[] = {
-       51, 59, 68, 77, 91, 121, 139, 170, 179, 266, 352, 454, 478, 631,
-       644, 668, 714, 744, 750, 778, 790, 836, SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 51, 59, 68, 77, 91, 121,
+       139, 170, 179, 266, 352, 454, 478, 631, 644, 668, 714, 744, 750,
+       778, 790, 836, SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END,
 };
 
 static int64_t seq3[] = {
-       8, 71, 209, 254, 298, 320, 350, 393, 419, 624, 651, 678, 717,
-       731, 733, 788, 819, 820, 857, 892, 903, 944, 998, SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 8, 71, 209, 254, 298, 320,
+       350, 393, 419, 624, 651, 678, 717, 731, 733, 788, 819, 820, 857,
+       892, 903, 944, 998, SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END,
 };
 
 static int64_t seq4[] = {
-       41, 56, 120, 138, 154, 228, 471, 479, 481, 525, 591, 605, 612,
-       618, 632, 670, 696, 825, 863, 867, 871, 884, 953, 985, 999,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 41, 56, 120, 138, 154, 228,
+       471, 479, 481, 525, 591, 605, 612, 618, 632, 670, 696, 825, 863,
+       867, 871, 884, 953, 985, 999, SEQ_PACKET_END, SEQ_STREAM_END,
        SEQ_END,
 };
 
 static int64_t seq1_with_again[] = {
-       24, 53, 97, 105, 119, 210, SEQ_AGAIN, 222, 240, 292, 317, 353,
-       407, 433, 473, 487, 504, 572, 615, 708, 766, 850, 852, 931, 951,
-       956, 996, SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 24, 53, 97, 105, 119, 210,
+       SEQ_AGAIN, 222, 240, 292, 317, 353, 407, 433, 473, 487, 504,
+       572, 615, 708, 766, 850, 852, 931, 951, 956, 996,
+       SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END,
 };
 
 static int64_t seq2_with_again[] = {
-       51, 59, 68, 77, 91, 121, 139, 170, 179, 266, 352, 454, 478, 631,
-       644, 668, 714, 744, 750, 778, 790, 836, SEQ_AGAIN, SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 51, 59, 68, 77, 91, 121,
+       139, 170, 179, 266, 352, 454, 478, 631, 644, 668, 714, 744, 750,
+       778, 790, 836, SEQ_AGAIN, SEQ_PACKET_END, SEQ_STREAM_END,
+       SEQ_END,
 };
 
 static int64_t seq3_with_again[] = {
-       8, 71, 209, 254, 298, 320, 350, 393, 419, 624, 651, SEQ_AGAIN,
-       678, 717, 731, 733, 788, 819, 820, 857, 892, 903, 944, 998,
-       SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 8, 71, 209, 254, 298, 320,
+       350, 393, 419, 624, 651, SEQ_AGAIN, 678, 717, 731, 733, 788,
+       819, 820, 857, 892, 903, 944, 998, SEQ_PACKET_END,
+       SEQ_STREAM_END, SEQ_END,
 };
 
 static int64_t seq4_with_again[] = {
-       SEQ_AGAIN, 41, 56, 120, 138, 154, 228, 471, 479, 481, 525, 591,
-       605, 612, 618, 632, 670, 696, 825, 863, 867, 871, 884, 953, 985,
-       999, SEQ_END,
+       SEQ_AGAIN, SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 41, 56, 120, 138,
+       154, 228, 471, 479, 481, 525, 591, 605, 612, 618, 632, 670, 696,
+       825, 863, 867, 871, 884, 953, 985, 999, SEQ_PACKET_END,
+       SEQ_STREAM_END, SEQ_END,
 };
 
 static int64_t seq5[] = {
-       1, 4, 189, 1001, SEQ_END,
+       SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 1, 4, 189, 1001,
+       SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END,
 };
 
 static
@@ -303,7 +315,7 @@ void init_static_data(void)
        ret = bt_trace_set_native_byte_order(trace,
                BT_BYTE_ORDER_LITTLE_ENDIAN);
        assert(ret == 0);
-       ret = bt_trace_set_packet_header_type(trace, empty_struct_ft);
+       ret = bt_trace_set_packet_header_field_type(trace, empty_struct_ft);
        assert(ret == 0);
        src_clock_class = bt_clock_class_create("my-clock", 1000000000);
        assert(src_clock_class);
@@ -320,20 +332,20 @@ void init_static_data(void)
        assert(ret == 0);
        src_stream_class = bt_stream_class_create("my-stream-class");
        assert(src_stream_class);
-       ret = bt_stream_class_set_packet_context_type(src_stream_class,
+       ret = bt_stream_class_set_packet_context_field_type(src_stream_class,
                empty_struct_ft);
        assert(ret == 0);
-       ret = bt_stream_class_set_event_header_type(src_stream_class,
+       ret = bt_stream_class_set_event_header_field_type(src_stream_class,
                empty_struct_ft);
        assert(ret == 0);
-       ret = bt_stream_class_set_event_context_type(src_stream_class,
+       ret = bt_stream_class_set_event_context_field_type(src_stream_class,
                empty_struct_ft);
        assert(ret == 0);
        src_event_class = bt_event_class_create("my-event-class");
-       ret = bt_event_class_set_context_type(src_event_class,
+       ret = bt_event_class_set_context_field_type(src_event_class,
                empty_struct_ft);
        assert(ret == 0);
-       ret = bt_event_class_set_context_type(src_event_class,
+       ret = bt_event_class_set_context_field_type(src_event_class,
                empty_struct_ft);
        assert(ret == 0);
        ret = bt_stream_class_add_event_class(src_stream_class,
@@ -341,22 +353,22 @@ void init_static_data(void)
        assert(ret == 0);
        ret = bt_trace_add_stream_class(trace, src_stream_class);
        assert(ret == 0);
-       stream = bt_stream_create(src_stream_class, "stream0");
+       stream = bt_stream_create(src_stream_class, "stream0", 0);
        assert(stream);
        src_packet0 = bt_packet_create(stream);
        assert(src_packet0);
        bt_put(stream);
-       stream = bt_stream_create(src_stream_class, "stream1");
+       stream = bt_stream_create(src_stream_class, "stream1", 1);
        assert(stream);
        src_packet1 = bt_packet_create(stream);
        assert(src_packet0);
        bt_put(stream);
-       stream = bt_stream_create(src_stream_class, "stream2");
+       stream = bt_stream_create(src_stream_class, "stream2", 2);
        assert(stream);
        src_packet2 = bt_packet_create(stream);
        assert(src_packet0);
        bt_put(stream);
-       stream = bt_stream_create(src_stream_class, "stream3");
+       stream = bt_stream_create(src_stream_class, "stream3", 3);
        assert(stream);
        src_packet3 = bt_packet_create(stream);
        assert(src_packet0);
@@ -513,6 +525,7 @@ struct bt_notification_iterator_next_method_return src_iter_next_seq(
                .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
        };
        int64_t cur_ts_ns;
+       struct bt_stream *stream;
 
        assert(user_data->seq);
        cur_ts_ns = user_data->seq[user_data->at];
@@ -536,6 +549,20 @@ struct bt_notification_iterator_next_method_return src_iter_next_seq(
                        bt_notification_packet_end_create(user_data->packet);
                assert(next_return.notification);
                break;
+       case SEQ_STREAM_BEGIN:
+               stream = bt_packet_get_stream(user_data->packet);
+               next_return.notification =
+                       bt_notification_stream_begin_create(stream);
+               assert(next_return.notification);
+               bt_put(stream);
+               break;
+       case SEQ_STREAM_END:
+               stream = bt_packet_get_stream(user_data->packet);
+               next_return.notification =
+                       bt_notification_stream_end_create(stream);
+               assert(next_return.notification);
+               bt_put(stream);
+               break;
        default:
        {
                struct bt_event *event = src_create_event(
@@ -569,6 +596,7 @@ struct bt_notification_iterator_next_method_return src_iter_next(
                bt_private_connection_private_notification_iterator_get_user_data(priv_iterator);
        struct bt_private_component *private_component =
                bt_private_connection_private_notification_iterator_get_private_component(priv_iterator);
+       struct bt_stream *stream;
        int ret;
 
        assert(user_data);
@@ -578,11 +606,18 @@ struct bt_notification_iterator_next_method_return src_iter_next(
        case TEST_NO_TS:
                if (user_data->iter_index == 0) {
                        if (user_data->at == 0) {
+                               stream = bt_packet_get_stream(user_data->packet);
+                               next_return.notification =
+                                       bt_notification_stream_begin_create(
+                                               stream);
+                               bt_put(stream);
+                               assert(next_return.notification);
+                       } else if (user_data->at == 1) {
                                next_return.notification =
                                        bt_notification_packet_begin_create(
                                                user_data->packet);
                                assert(next_return.notification);
-                       } else if (user_data->at < 6) {
+                       } else if (user_data->at < 7) {
                                struct bt_event *event = src_create_event(
                                        user_data->packet, -1);
 
@@ -592,6 +627,18 @@ struct bt_notification_iterator_next_method_return src_iter_next(
                                                src_empty_cc_prio_map);
                                assert(next_return.notification);
                                bt_put(event);
+                       } else if (user_data->at == 7) {
+                               next_return.notification =
+                                       bt_notification_packet_end_create(
+                                               user_data->packet);
+                               assert(next_return.notification);
+                       } else if (user_data->at == 8) {
+                               stream = bt_packet_get_stream(user_data->packet);
+                               next_return.notification =
+                                       bt_notification_stream_end_create(
+                                               stream);
+                               bt_put(stream);
+                               assert(next_return.notification);
                        } else {
                                next_return.status =
                                        BT_NOTIFICATION_ITERATOR_STATUS_END;
@@ -846,7 +893,7 @@ void sink_port_connected(struct bt_private_component *private_component,
        assert(user_data);
        assert(priv_conn);
        conn_status = bt_private_connection_create_notification_iterator(
-               priv_conn, NULL, &user_data->notif_iter);
+               priv_conn, &user_data->notif_iter);
        assert(conn_status == 0);
        bt_put(priv_conn);
 }
This page took 0.02596 seconds and 4 git commands to generate.