#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <stdbool.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
-#include <babeltrace/ctf-ir/event-class.h>
-#include <babeltrace/ctf-ir/event.h>
-#include <babeltrace/ctf-ir/field-types.h>
-#include <babeltrace/ctf-ir/fields.h>
-#include <babeltrace/ctf-ir/packet.h>
-#include <babeltrace/ctf-ir/stream-class.h>
-#include <babeltrace/ctf-ir/stream.h>
-#include <babeltrace/ctf-ir/trace.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-filter.h>
-#include <babeltrace/graph/component-sink.h>
-#include <babeltrace/graph/component-source.h>
-#include <babeltrace/graph/component.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/notification-event.h>
-#include <babeltrace/graph/notification-inactivity.h>
-#include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/notification-packet.h>
-#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-component-source.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-connection.h>
-#include <babeltrace/graph/private-notification-iterator.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/plugin/plugin.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/babeltrace.h>
#include <glib.h>
#include "tap/tap.h"
-#define NR_TESTS 14
+#define NR_TESTS 12
enum test {
TEST_NO_TS,
TEST_NO_UPSTREAM_CONNECTION,
- TEST_EVENT_NOTIF_VS_THE_REST,
TEST_SIMPLE_4_PORTS,
TEST_4_PORTS_WITH_RETRIES,
TEST_SINGLE_END_THEN_MULTIPLE_FULL,
TEST_EV_TYPE_NOTIF_INACTIVITY,
TEST_EV_TYPE_NOTIF_PACKET_BEGIN,
TEST_EV_TYPE_NOTIF_PACKET_END,
+ TEST_EV_TYPE_NOTIF_STREAM_BEGIN,
+ TEST_EV_TYPE_NOTIF_STREAM_END,
TEST_EV_TYPE_AGAIN,
TEST_EV_TYPE_END,
TEST_EV_TYPE_SENTINEL,
static GArray *test_events;
static struct bt_clock_class_priority_map *src_cc_prio_map;
static struct bt_clock_class_priority_map *src_empty_cc_prio_map;
-static struct bt_ctf_clock_class *src_clock_class;
-static struct bt_ctf_stream_class *src_stream_class;
-static struct bt_ctf_event_class *src_event_class;
-static struct bt_ctf_packet *src_packet;
+static struct bt_clock_class *src_clock_class;
+static struct bt_stream_class *src_stream_class;
+static struct bt_event_class *src_event_class;
+static struct bt_packet *src_packet0;
+static struct bt_packet *src_packet1;
+static struct bt_packet *src_packet2;
+static struct bt_packet *src_packet3;
enum {
SEQ_END = -1,
SEQ_AGAIN = -2,
SEQ_PACKET_BEGIN = -3,
SEQ_PACKET_END = -4,
+ SEQ_STREAM_BEGIN = -5,
+ SEQ_STREAM_END = -6,
};
struct src_iter_user_data {
size_t iter_index;
int64_t *seq;
size_t at;
+ struct bt_packet *packet;
};
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, 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_AGAIN,
+ 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,
- 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,
-};
-
-static int64_t seq6[] = {
- 1, 2, 12, SEQ_PACKET_BEGIN, 14, 19, SEQ_END,
-};
-
-static int64_t seq7[] = {
- 8, 9, SEQ_PACKET_BEGIN, 10, 13, SEQ_PACKET_END, 22, SEQ_END,
+ SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 1, 4, 189, 1001,
+ SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END,
};
static
case TEST_EV_TYPE_NOTIF_PACKET_END:
fprintf(fp, "TEST_EV_TYPE_NOTIF_PACKET_END");
break;
+ case TEST_EV_TYPE_NOTIF_STREAM_BEGIN:
+ fprintf(fp, "TEST_EV_TYPE_NOTIF_STREAM_BEGIN");
+ break;
+ case TEST_EV_TYPE_NOTIF_STREAM_END:
+ fprintf(fp, "TEST_EV_TYPE_NOTIF_STREAM_END");
+ break;
case TEST_EV_TYPE_AGAIN:
fprintf(fp, "TEST_EV_TYPE_AGAIN");
break;
}
if (i != test_events->len) {
+ if (debug) {
+ fprintf(stderr, ":: Length mismatch\n");
+ }
+
return false;
}
void init_static_data(void)
{
int ret;
- struct bt_ctf_trace *trace;
- struct bt_ctf_stream *stream;
- struct bt_ctf_field_type *empty_struct_ft;
+ struct bt_trace *trace;
+ struct bt_stream *stream;
+ struct bt_field_type *empty_struct_ft;
+ struct bt_field_type *eh_ft;
+ struct bt_field_type *eh_ts_ft;
/* Test events */
test_events = g_array_new(FALSE, TRUE, sizeof(struct test_event));
assert(test_events);
/* Metadata */
- empty_struct_ft = bt_ctf_field_type_structure_create();
+ empty_struct_ft = bt_field_type_structure_create();
assert(empty_struct_ft);
- trace = bt_ctf_trace_create();
+ src_clock_class = bt_clock_class_create("my-clock", 1000000000);
+ assert(src_clock_class);
+ trace = bt_trace_create();
assert(trace);
- ret = bt_ctf_trace_set_native_byte_order(trace,
- BT_CTF_BYTE_ORDER_LITTLE_ENDIAN);
+ ret = bt_trace_set_native_byte_order(trace,
+ BT_BYTE_ORDER_LITTLE_ENDIAN);
assert(ret == 0);
- ret = bt_ctf_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_ctf_clock_class_create("my-clock");
- assert(src_clock_class);
- ret = bt_ctf_clock_class_set_is_absolute(src_clock_class, 1);
+ ret = bt_clock_class_set_is_absolute(src_clock_class, 1);
assert(ret == 0);
- ret = bt_ctf_trace_add_clock_class(trace, src_clock_class);
+ ret = bt_trace_add_clock_class(trace, src_clock_class);
assert(ret == 0);
src_empty_cc_prio_map = bt_clock_class_priority_map_create();
assert(src_empty_cc_prio_map);
ret = bt_clock_class_priority_map_add_clock_class(src_cc_prio_map,
src_clock_class, 0);
assert(ret == 0);
- src_stream_class = bt_ctf_stream_class_create("my-stream-class");
+ src_stream_class = bt_stream_class_create("my-stream-class");
assert(src_stream_class);
- ret = bt_ctf_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_ctf_stream_class_set_event_header_type(src_stream_class,
- empty_struct_ft);
+ eh_ft = bt_field_type_structure_create();
+ assert(eh_ft);
+ eh_ts_ft = bt_field_type_integer_create(64);
+ assert(eh_ts_ft);
+ ret = bt_field_type_structure_add_field(eh_ft, eh_ts_ft, "ts");
assert(ret == 0);
- ret = bt_ctf_stream_class_set_event_context_type(src_stream_class,
+ ret = bt_field_type_integer_set_mapped_clock_class(eh_ts_ft,
+ src_clock_class);
+ assert(ret == 0);
+ ret = bt_stream_class_set_event_header_field_type(src_stream_class,
+ eh_ft);
+ assert(ret == 0);
+ ret = bt_stream_class_set_event_context_field_type(src_stream_class,
empty_struct_ft);
assert(ret == 0);
- src_event_class = bt_ctf_event_class_create("my-event-class");
- ret = bt_ctf_event_class_set_context_type(src_event_class,
+ src_event_class = bt_event_class_create("my-event-class");
+ ret = bt_event_class_set_context_field_type(src_event_class,
empty_struct_ft);
assert(ret == 0);
- ret = bt_ctf_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_ctf_stream_class_add_event_class(src_stream_class,
+ ret = bt_stream_class_add_event_class(src_stream_class,
src_event_class);
assert(ret == 0);
- ret = bt_ctf_trace_add_stream_class(trace, src_stream_class);
+ ret = bt_trace_add_stream_class(trace, src_stream_class);
assert(ret == 0);
- stream = bt_ctf_stream_create(src_stream_class, "my-stream");
+ 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", 1);
+ assert(stream);
+ src_packet1 = bt_packet_create(stream);
+ assert(src_packet0);
+ bt_put(stream);
+ 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", 3);
assert(stream);
- src_packet = bt_ctf_packet_create(stream);
- assert(src_packet);
+ src_packet3 = bt_packet_create(stream);
+ assert(src_packet0);
+ bt_put(stream);
bt_put(trace);
- bt_put(stream);
bt_put(empty_struct_ft);
+ bt_put(eh_ft);
+ bt_put(eh_ts_ft);
}
static
bt_put(src_clock_class);
bt_put(src_stream_class);
bt_put(src_event_class);
+ bt_put(src_packet0);
+ bt_put(src_packet1);
+ bt_put(src_packet2);
+ bt_put(src_packet3);
}
static
void src_iter_finalize(
- struct bt_private_notification_iterator *private_notification_iterator)
+ struct bt_private_connection_private_notification_iterator *private_notification_iterator)
{
struct src_iter_user_data *user_data =
- bt_private_notification_iterator_get_user_data(
+ bt_private_connection_private_notification_iterator_get_user_data(
private_notification_iterator);
if (user_data) {
static
enum bt_notification_iterator_status src_iter_init(
- struct bt_private_notification_iterator *priv_notif_iter,
+ struct bt_private_connection_private_notification_iterator *priv_notif_iter,
struct bt_private_port *private_port)
{
struct src_iter_user_data *user_data =
g_new0(struct src_iter_user_data, 1);
- struct bt_port *port = bt_port_from_private_port(private_port);
+ struct bt_port *port = bt_port_from_private(private_port);
const char *port_name;
int ret;
assert(user_data);
assert(port);
- ret = bt_private_notification_iterator_set_user_data(priv_notif_iter,
+ ret = bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
user_data);
assert(ret == 0);
port_name = bt_port_get_name(port);
user_data->iter_index = port_name[3] - '0';
bt_put(port);
+ switch (user_data->iter_index) {
+ case 0:
+ user_data->packet = src_packet0;
+ break;
+ case 1:
+ user_data->packet = src_packet1;
+ break;
+ case 2:
+ user_data->packet = src_packet2;
+ break;
+ case 3:
+ user_data->packet = src_packet3;
+ break;
+ default:
+ abort();
+ }
+
switch (current_test) {
case TEST_NO_TS:
if (user_data->iter_index == 1) {
user_data->seq = seq5;
}
break;
- case TEST_EVENT_NOTIF_VS_THE_REST:
- if (user_data->iter_index == 0) {
- user_data->seq = seq6;
- } else {
- user_data->seq = seq7;
- }
- break;
case TEST_SIMPLE_4_PORTS:
if (user_data->iter_index == 0) {
user_data->seq = seq1;
}
break;
default:
- assert(false);
+ abort();
}
return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
static
-struct bt_ctf_event *src_create_event(int64_t ts_ns)
+struct bt_notification *src_create_event_notif(struct bt_packet *packet,
+ struct bt_clock_class_priority_map *cc_prio_map, int64_t ts_ns)
{
- struct bt_ctf_event *event = bt_ctf_event_create(src_event_class);
int ret;
-
+ struct bt_event *event;
+ struct bt_notification *notif;
+ struct bt_clock_value *clock_value;
+ struct bt_field *field;
+
+ notif = bt_notification_event_create(src_event_class,
+ packet, cc_prio_map);
+ assert(notif);
+ event = bt_notification_event_borrow_event(notif);
assert(event);
- ret = bt_ctf_event_set_packet(event, src_packet);
+ field = bt_event_borrow_header(event);
+ assert(field);
+ field = bt_field_structure_borrow_field_by_name(field, "ts");
+ assert(field);
+ ret = bt_field_integer_unsigned_set_value(field, (uint64_t) ts_ns);
assert(ret == 0);
-
- if (ts_ns != -1) {
- struct bt_ctf_clock_value *clock_value;
-
- clock_value = bt_ctf_clock_value_create(src_clock_class,
- (uint64_t) ts_ns);
- assert(clock_value);
- ret = bt_ctf_event_set_clock_value(event, clock_value);
- bt_put(clock_value);
- }
-
- return event;
+ clock_value = bt_event_borrow_clock_value(event, src_clock_class);
+ assert(clock_value);
+ ret = bt_clock_value_set_value(clock_value, (uint64_t) ts_ns);
+ assert(ret == 0);
+ return notif;
}
static
-struct bt_notification_iterator_next_return src_iter_next_seq(
+struct bt_notification_iterator_next_method_return src_iter_next_seq(
struct src_iter_user_data *user_data)
{
- struct bt_notification_iterator_next_return next_return = {
+ struct bt_notification_iterator_next_method_return next_return = {
.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];
break;
case SEQ_PACKET_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_packet);
+ bt_notification_packet_begin_create(user_data->packet);
assert(next_return.notification);
break;
case SEQ_PACKET_END:
next_return.notification =
- bt_notification_packet_end_create(src_packet);
+ 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_ctf_event *event = src_create_event(cur_ts_ns);
-
- assert(event);
- next_return.notification = bt_notification_event_create(event,
- src_cc_prio_map);
- bt_put(event);
+ next_return.notification = src_create_event_notif(
+ user_data->packet, src_cc_prio_map, cur_ts_ns);
assert(next_return.notification);
break;
}
}
static
-struct bt_notification_iterator_next_return src_iter_next(
- struct bt_private_notification_iterator *priv_iterator)
+struct bt_notification_iterator_next_method_return src_iter_next(
+ struct bt_private_connection_private_notification_iterator *priv_iterator)
{
- struct bt_notification_iterator_next_return next_return = {
- .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
+ struct bt_notification_iterator_next_method_return next_return = {
.notification = NULL,
+ .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
};
struct src_iter_user_data *user_data =
- bt_private_notification_iterator_get_user_data(priv_iterator);
+ bt_private_connection_private_notification_iterator_get_user_data(priv_iterator);
struct bt_private_component *private_component =
- bt_private_notification_iterator_get_private_component(priv_iterator);
+ bt_private_connection_private_notification_iterator_get_private_component(priv_iterator);
+ struct bt_stream *stream;
+ int ret;
assert(user_data);
assert(private_component);
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_packet_begin_create(src_packet);
+ bt_notification_stream_begin_create(
+ stream);
+ bt_put(stream);
assert(next_return.notification);
- } else if (user_data->at < 6) {
- struct bt_ctf_event *event = src_create_event(-1);
-
- assert(event);
+ } 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 < 7) {
next_return.notification =
- bt_notification_event_create(event,
- src_empty_cc_prio_map);
+ src_create_event_notif(
+ user_data->packet,
+ src_empty_cc_prio_map, 0);
+ assert(next_return.notification);
+ } 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);
- bt_put(event);
} else {
next_return.status =
BT_NOTIFICATION_ITERATOR_STATUS_END;
next_return = src_iter_next_seq(user_data);
}
break;
- case TEST_EVENT_NOTIF_VS_THE_REST:
case TEST_SIMPLE_4_PORTS:
case TEST_4_PORTS_WITH_RETRIES:
next_return = src_iter_next_seq(user_data);
break;
case TEST_SINGLE_END_THEN_MULTIPLE_FULL:
if (user_data->iter_index == 0) {
- struct bt_private_port *priv_port;
-
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out1");
- assert(priv_port);
- bt_put(priv_port);
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out2");
- assert(priv_port);
- bt_put(priv_port);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out1", NULL, NULL);
+ assert(ret == 0);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out2", NULL, NULL);
+ assert(ret == 0);
next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END;
} else {
next_return = src_iter_next_seq(user_data);
next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN;
user_data->at++;
} else {
- struct bt_private_port *priv_port;
-
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out1");
- assert(priv_port);
- bt_put(priv_port);
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out2");
- assert(priv_port);
- bt_put(priv_port);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out1", NULL, NULL);
+ assert(ret == 0);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out2", NULL, NULL);
+ assert(ret == 0);
next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END;
}
} else {
}
break;
default:
- assert(false);
+ abort();
}
bt_put(private_component);
struct bt_private_component *private_component,
struct bt_value *params, void *init_method_data)
{
- struct bt_private_port *priv_port;
int ret;
size_t nb_ports;
- priv_port = bt_private_component_source_get_default_output_private_port(
- private_component);
- if (priv_port) {
- ret = bt_private_port_remove_from_component(priv_port);
- assert(ret == 0);
- bt_put(priv_port);
- }
-
switch (current_test) {
case TEST_NO_TS:
- case TEST_EVENT_NOTIF_VS_THE_REST:
nb_ports = 2;
break;
case TEST_SINGLE_END_THEN_MULTIPLE_FULL:
}
if (nb_ports >= 1) {
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out0");
- assert(priv_port);
- bt_put(priv_port);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out0", NULL, NULL);
+ assert(ret == 0);
}
if (nb_ports >= 2) {
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out1");
- assert(priv_port);
- bt_put(priv_port);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out1", NULL, NULL);
+ assert(ret == 0);
}
if (nb_ports >= 3) {
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out2");
- assert(priv_port);
- bt_put(priv_port);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out2", NULL, NULL);
+ assert(ret == 0);
}
if (nb_ports >= 4) {
- priv_port = bt_private_component_source_add_output_private_port(
- private_component, "out3");
- assert(priv_port);
- bt_put(priv_port);
+ ret = bt_private_component_source_add_output_private_port(
+ private_component, "out3", NULL, NULL);
+ assert(ret == 0);
}
return BT_COMPONENT_STATUS_OK;
switch (bt_notification_get_type(notification)) {
case BT_NOTIFICATION_TYPE_EVENT:
{
- struct bt_ctf_event *event;
+ struct bt_event *event;
struct bt_clock_class_priority_map *cc_prio_map;
test_event.type = TEST_EV_TYPE_NOTIF_EVENT;
cc_prio_map =
- bt_notification_event_get_clock_class_priority_map(
+ bt_notification_event_borrow_clock_class_priority_map(
notification);
assert(cc_prio_map);
- event = bt_notification_event_get_event(notification);
+ event = bt_notification_event_borrow_event(notification);
assert(event);
if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) > 0) {
- struct bt_ctf_clock_value *clock_value;
- struct bt_ctf_clock_class *clock_class =
- bt_clock_class_priority_map_get_highest_priority_clock_class(
+ struct bt_clock_value *clock_value;
+ struct bt_clock_class *clock_class =
+ bt_clock_class_priority_map_borrow_highest_priority_clock_class(
cc_prio_map);
assert(clock_class);
- clock_value = bt_ctf_event_get_clock_value(event,
+ clock_value = bt_event_borrow_clock_value(event,
clock_class);
assert(clock_value);
- ret = bt_ctf_clock_value_get_value_ns_from_epoch(
+ ret = bt_clock_value_get_value_ns_from_epoch(
clock_value, &test_event.ts_ns);
assert(ret == 0);
- bt_put(clock_value);
- bt_put(clock_class);
} else {
test_event.ts_ns = -1;
}
- bt_put(cc_prio_map);
- bt_put(event);
break;
}
case BT_NOTIFICATION_TYPE_INACTIVITY:
struct bt_clock_class_priority_map *cc_prio_map;
test_event.type = TEST_EV_TYPE_NOTIF_INACTIVITY;
- cc_prio_map = bt_notification_event_get_clock_class_priority_map(
+ cc_prio_map = bt_notification_inactivity_borrow_clock_class_priority_map(
notification);
assert(cc_prio_map);
if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) > 0) {
- struct bt_ctf_clock_value *clock_value;
- struct bt_ctf_clock_class *clock_class =
- bt_clock_class_priority_map_get_highest_priority_clock_class(
+ struct bt_clock_value *clock_value;
+ struct bt_clock_class *clock_class =
+ bt_clock_class_priority_map_borrow_highest_priority_clock_class(
cc_prio_map);
assert(clock_class);
clock_value =
- bt_notification_inactivity_get_clock_value(
+ bt_notification_inactivity_borrow_clock_value(
notification, clock_class);
assert(clock_value);
- ret = bt_ctf_clock_value_get_value_ns_from_epoch(
+ ret = bt_clock_value_get_value_ns_from_epoch(
clock_value, &test_event.ts_ns);
assert(ret == 0);
- bt_put(clock_value);
- bt_put(clock_class);
} else {
test_event.ts_ns = -1;
}
- bt_put(cc_prio_map);
break;
}
case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
case BT_NOTIFICATION_TYPE_PACKET_END:
test_event.type = TEST_EV_TYPE_NOTIF_PACKET_END;
break;
+ case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
+ test_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN;
+ break;
+ case BT_NOTIFICATION_TYPE_STREAM_END:
+ test_event.type = TEST_EV_TYPE_NOTIF_STREAM_END;
+ break;
default:
test_event.type = TEST_EV_TYPE_NOTIF_UNEXPECTED;
break;
bt_private_port_get_private_connection(self_private_port);
struct sink_user_data *user_data = bt_private_component_get_user_data(
private_component);
+ enum bt_connection_status conn_status;
assert(user_data);
assert(priv_conn);
- user_data->notif_iter =
- bt_private_connection_create_notification_iterator(priv_conn);
- assert(user_data->notif_iter);
+ conn_status = bt_private_connection_create_notification_iterator(
+ priv_conn, &user_data->notif_iter);
+ assert(conn_status == 0);
bt_put(priv_conn);
}
ret = bt_private_component_set_user_data(private_component,
user_data);
assert(ret == 0);
+ ret = bt_private_component_sink_add_input_private_port(
+ private_component, "in", NULL, NULL);
+ assert(ret == 0);
return BT_COMPONENT_STATUS_OK;
}
}
static
-void create_source_muxer_sink(struct bt_component **source,
+void create_source_muxer_sink(struct bt_graph *graph,
+ struct bt_component **source,
struct bt_component **muxer,
struct bt_component **sink)
{
ret = bt_component_class_source_set_notification_iterator_finalize_method(
src_comp_class, src_iter_finalize);
assert(ret == 0);
- *source = bt_component_create(src_comp_class, "source", NULL);
- assert(*source);
+ ret = bt_graph_add_component(graph, src_comp_class, "source", NULL, source);
+ assert(ret == 0);
/* Create muxer component */
muxer_comp_class = bt_plugin_find_component_class("utils", "muxer",
BT_COMPONENT_CLASS_TYPE_FILTER);
assert(muxer_comp_class);
- *muxer = bt_component_create(muxer_comp_class, "muxer", NULL);
- assert(*muxer);
+ ret = bt_graph_add_component(graph, muxer_comp_class, "muxer", NULL, muxer);
+ assert(ret == 0);
/* Create sink component */
sink_comp_class = bt_component_class_sink_create("sink", sink_consume);
ret = bt_component_class_set_port_connected_method(sink_comp_class,
sink_port_connected);
assert(ret == 0);
- *sink = bt_component_create(sink_comp_class, "sink", NULL);
+ ret = bt_graph_add_component(graph, sink_comp_class, "sink", NULL, sink);
+ assert(ret == 0);
bt_put(src_comp_class);
bt_put(muxer_comp_class);
struct bt_port *upstream_port;
struct bt_port *downstream_port;
struct bt_graph *graph;
- size_t i;
- uint64_t count;
- void *conn;
- int ret;
+ int64_t i;
+ int64_t count;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
clear_test_events();
current_test = test;
diag("test: %s", name);
- create_source_muxer_sink(&src_comp, &muxer_comp, &sink_comp);
graph = bt_graph_create();
assert(graph);
+ create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp);
/* Connect source output ports to muxer input ports */
if (with_upstream) {
- ret = bt_component_source_get_output_port_count(src_comp, &count);
- assert(ret == 0);
+ count = bt_component_source_get_output_port_count(src_comp);
+ assert(count >= 0);
for (i = 0; i < count; i++) {
- upstream_port = bt_component_source_get_output_port_at_index(
+ upstream_port = bt_component_source_get_output_port_by_index(
src_comp, i);
assert(upstream_port);
- downstream_port = bt_component_filter_get_input_port_at_index(
+ downstream_port = bt_component_filter_get_input_port_by_index(
muxer_comp, i);
assert(downstream_port);
- conn = bt_graph_connect_ports(graph,
- upstream_port, downstream_port);
- assert(conn);
- bt_put(conn);
+ graph_status = bt_graph_connect_ports(graph,
+ upstream_port, downstream_port, NULL);
+ assert(graph_status == 0);
bt_put(upstream_port);
bt_put(downstream_port);
}
}
/* Connect muxer output port to sink input port */
- upstream_port = bt_component_filter_get_output_port(muxer_comp,
+ upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp,
"out");
assert(upstream_port);
- downstream_port = bt_component_sink_get_default_input_port(sink_comp);
+ downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in");
assert(downstream_port);
- conn = bt_graph_connect_ports(graph, upstream_port, downstream_port);
- assert(conn);
- bt_put(conn);
+ graph_status = bt_graph_connect_ports(graph, upstream_port,
+ downstream_port, NULL);
+ assert(graph_status == 0);
bt_put(upstream_port);
bt_put(downstream_port);
void test_no_ts(void)
{
const struct test_event expected_test_events[] = {
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 1, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 4, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 189, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 1001, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
}
static
-void test_event_notif_vs_the_rest(void)
+void test_simple_4_ports(void)
{
const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 1, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 9, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 10, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 12, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 13, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 14, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 19, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 22, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_EVENT_NOTIF_VS_THE_REST, "event notifications vs. the rest",
- expected_test_events, true);
-}
-
-
-static
-void test_simple_4_ports(void)
-{
- const struct test_event expected_test_events[] = {
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 24 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 41 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 825 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 850 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 852 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 956 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 985 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 996 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 999 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
{
const struct test_event expected_test_events[] = {
{ .type = TEST_EV_TYPE_AGAIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 24 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 41 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 825 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 },
{ .type = TEST_EV_TYPE_AGAIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 850 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 852 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 956 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 985 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 996 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 999 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
struct bt_component *muxer_comp)
{
struct bt_port *avail_muxer_port = NULL;
- void *conn;
- uint64_t i;
- uint64_t count;
- int ret;
+ int64_t i;
+ int64_t count;
+ enum bt_graph_status graph_status;
- ret = bt_component_filter_get_input_port_count(muxer_comp, &count);
- assert(ret == 0);
+ count = bt_component_filter_get_input_port_count(muxer_comp);
+ assert(count >= 0);
for (i = 0; i < count; i++) {
struct bt_port *muxer_port =
- bt_component_filter_get_input_port_at_index(
+ bt_component_filter_get_input_port_by_index(
muxer_comp, i);
assert(muxer_port);
}
}
- conn = bt_graph_connect_ports(graph, source_port, avail_muxer_port);
- assert(conn);
- bt_put(conn);
+ graph_status = bt_graph_connect_ports(graph, source_port,
+ avail_muxer_port, NULL);
+ assert(graph_status == 0);
bt_put(avail_muxer_port);
}
struct bt_port *upstream_port;
struct bt_port *downstream_port;
struct bt_graph *graph;
- size_t i;
- uint64_t count;
- void *conn;
+ int64_t i;
+ int64_t count;
int ret;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
struct graph_listener_data graph_listener_data;
const struct test_event expected_test_events[] = {
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 51 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 59 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 819 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 892 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 903 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 944 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
clear_test_events();
current_test = TEST_SINGLE_END_THEN_MULTIPLE_FULL;
diag("test: single end then multiple full");
- create_source_muxer_sink(&src_comp, &muxer_comp, &sink_comp);
graph = bt_graph_create();
assert(graph);
+ create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp);
graph_listener_data.graph = graph;
graph_listener_data.source = src_comp;
graph_listener_data.muxer = muxer_comp;
graph_listener_data.sink = sink_comp;
ret = bt_graph_add_port_added_listener(graph,
- graph_port_added_listener_connect_to_avail_muxer_port,
+ graph_port_added_listener_connect_to_avail_muxer_port, NULL,
&graph_listener_data);
- assert(ret == 0);
+ assert(ret >= 0);
/* Connect source output ports to muxer input ports */
- ret = bt_component_source_get_output_port_count(src_comp, &count);
+ count = bt_component_source_get_output_port_count(src_comp);
assert(ret == 0);
for (i = 0; i < count; i++) {
- upstream_port = bt_component_source_get_output_port_at_index(
+ upstream_port = bt_component_source_get_output_port_by_index(
src_comp, i);
assert(upstream_port);
connect_port_to_first_avail_muxer_port(graph,
}
/* Connect muxer output port to sink input port */
- upstream_port = bt_component_filter_get_output_port(muxer_comp,
+ upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp,
"out");
assert(upstream_port);
- downstream_port = bt_component_sink_get_default_input_port(sink_comp);
+ downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in");
assert(downstream_port);
- conn = bt_graph_connect_ports(graph, upstream_port, downstream_port);
- assert(conn);
- bt_put(conn);
+ graph_status = bt_graph_connect_ports(graph, upstream_port,
+ downstream_port, NULL);
+ assert(graph_status == 0);
bt_put(upstream_port);
bt_put(downstream_port);
struct bt_port *upstream_port;
struct bt_port *downstream_port;
struct bt_graph *graph;
- size_t i;
- uint64_t count;
- void *conn;
+ int64_t i;
+ int64_t count;
int ret;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
struct graph_listener_data graph_listener_data;
const struct test_event expected_test_events[] = {
{ .type = TEST_EV_TYPE_AGAIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 51 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 59 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 819 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 892 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 903 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 944 },
{ .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 },
+ { .type = TEST_EV_TYPE_NOTIF_PACKET_END, },
+ { .type = TEST_EV_TYPE_NOTIF_STREAM_END, },
{ .type = TEST_EV_TYPE_END, },
{ .type = TEST_EV_TYPE_SENTINEL, },
};
clear_test_events();
current_test = TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL;
diag("test: single again then end then multiple full");
- create_source_muxer_sink(&src_comp, &muxer_comp, &sink_comp);
graph = bt_graph_create();
assert(graph);
+ create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp);
graph_listener_data.graph = graph;
graph_listener_data.source = src_comp;
graph_listener_data.muxer = muxer_comp;
graph_listener_data.sink = sink_comp;
ret = bt_graph_add_port_added_listener(graph,
- graph_port_added_listener_connect_to_avail_muxer_port,
+ graph_port_added_listener_connect_to_avail_muxer_port, NULL,
&graph_listener_data);
- assert(ret == 0);
+ assert(ret >= 0);
/* Connect source output ports to muxer input ports */
- ret = bt_component_source_get_output_port_count(src_comp, &count);
+ count = bt_component_source_get_output_port_count(src_comp);
assert(ret == 0);
for (i = 0; i < count; i++) {
- upstream_port = bt_component_source_get_output_port_at_index(
+ upstream_port = bt_component_source_get_output_port_by_index(
src_comp, i);
assert(upstream_port);
connect_port_to_first_avail_muxer_port(graph,
}
/* Connect muxer output port to sink input port */
- upstream_port = bt_component_filter_get_output_port(muxer_comp,
+ upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp,
"out");
assert(upstream_port);
- downstream_port = bt_component_sink_get_default_input_port(sink_comp);
+ downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in");
assert(downstream_port);
- conn = bt_graph_connect_ports(graph, upstream_port, downstream_port);
- assert(conn);
- bt_put(conn);
+ graph_status = bt_graph_connect_ports(graph, upstream_port,
+ downstream_port, NULL);
+ assert(graph_status == 0);
bt_put(upstream_port);
bt_put(downstream_port);
init_static_data();
test_no_ts();
test_no_upstream_connection();
- test_event_notif_vs_the_rest();
test_simple_4_ports();
test_4_ports_with_retries();
test_single_end_then_multiple_full();