static bool debug = false;
static enum test current_test;
static GArray *test_events;
+static struct bt_graph *graph;
static struct bt_clock_class_priority_map *src_empty_cc_prio_map;
static struct bt_stream_class *src_stream_class;
static struct bt_event_class *src_event_class;
assert(empty_struct_ft);
trace = bt_trace_create();
assert(trace);
- 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_empty_cc_prio_map = bt_clock_class_priority_map_create();
assert(src_empty_cc_prio_map);
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_payload_field_type(src_event_class,
empty_struct_ft);
assert(ret == 0);
ret = bt_stream_class_add_event_class(src_stream_class,
assert(ret == 0);
ret = bt_trace_add_stream_class(trace, src_stream_class);
assert(ret == 0);
- src_stream1 = bt_stream_create(src_stream_class, "stream-1");
+ src_stream1 = bt_stream_create(src_stream_class, "stream-1", 0);
assert(src_stream1);
- src_stream2 = bt_stream_create(src_stream_class, "stream-2");
+ src_stream2 = bt_stream_create(src_stream_class, "stream-2", 1);
assert(src_stream2);
src_stream1_packet1 = bt_packet_create(src_stream1);
assert(src_stream1_packet1);
return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
-static
-struct bt_event *src_create_event(struct bt_packet *packet)
-{
- struct bt_event *event = bt_event_create(src_event_class);
- int ret;
-
- assert(event);
- ret = bt_event_set_packet(event, packet);
- assert(ret == 0);
- return event;
-}
-
static
struct bt_notification_iterator_next_method_return src_iter_next_seq(
struct src_iter_user_data *user_data)
break;
case SEQ_INACTIVITY:
next_return.notification =
- bt_notification_inactivity_create(src_empty_cc_prio_map);
+ bt_notification_inactivity_create(graph,
+ src_empty_cc_prio_map);
assert(next_return.notification);
break;
case SEQ_STREAM1_BEGIN:
next_return.notification =
- bt_notification_stream_begin_create(src_stream1);
+ bt_notification_stream_begin_create(graph, src_stream1);
assert(next_return.notification);
break;
case SEQ_STREAM2_BEGIN:
next_return.notification =
- bt_notification_stream_begin_create(src_stream2);
+ bt_notification_stream_begin_create(graph, src_stream2);
assert(next_return.notification);
break;
case SEQ_STREAM1_END:
next_return.notification =
- bt_notification_stream_end_create(src_stream1);
+ bt_notification_stream_end_create(graph, src_stream1);
assert(next_return.notification);
break;
case SEQ_STREAM2_END:
next_return.notification =
- bt_notification_stream_end_create(src_stream2);
+ bt_notification_stream_end_create(graph, src_stream2);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET1_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream1_packet1);
+ bt_notification_packet_begin_create(graph,
+ src_stream1_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET2_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream1_packet2);
+ bt_notification_packet_begin_create(graph,
+ src_stream1_packet2);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET1_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream2_packet1);
+ bt_notification_packet_begin_create(graph,
+ src_stream2_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET2_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream2_packet2);
+ bt_notification_packet_begin_create(graph,
+ src_stream2_packet2);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET1_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream1_packet1);
+ bt_notification_packet_end_create(graph,
+ src_stream1_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET2_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream1_packet2);
+ bt_notification_packet_end_create(graph,
+ src_stream1_packet2);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET1_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream2_packet1);
+ bt_notification_packet_end_create(graph,
+ src_stream2_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET2_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream2_packet2);
+ bt_notification_packet_end_create(graph,
+ src_stream2_packet2);
assert(next_return.notification);
break;
case SEQ_EVENT_STREAM1_PACKET1:
}
if (event_packet) {
- struct bt_event *event = src_create_event(event_packet);
-
- assert(event);
- next_return.notification = bt_notification_event_create(event,
- src_empty_cc_prio_map);
- bt_put(event);
+ next_return.notification =
+ bt_notification_event_create(graph, src_event_class,
+ event_packet, src_empty_cc_prio_map);
assert(next_return.notification);
}
struct bt_event *event;
test_event.type = TEST_EV_TYPE_NOTIF_EVENT;
- event = bt_notification_event_get_event(notification);
+ event = bt_notification_event_borrow_event(notification);
assert(event);
- test_event.packet = bt_event_get_packet(event);
- bt_put(event);
+ test_event.packet = bt_event_borrow_packet(event);
assert(test_event.packet);
- bt_put(test_event.packet);
break;
}
case BT_NOTIFICATION_TYPE_INACTIVITY:
case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
test_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN;
test_event.stream =
- bt_notification_stream_begin_get_stream(notification);
+ bt_notification_stream_begin_borrow_stream(notification);
assert(test_event.stream);
- bt_put(test_event.stream);
break;
case BT_NOTIFICATION_TYPE_STREAM_END:
test_event.type = TEST_EV_TYPE_NOTIF_STREAM_END;
test_event.stream =
- bt_notification_stream_end_get_stream(notification);
+ bt_notification_stream_end_borrow_stream(notification);
assert(test_event.stream);
- bt_put(test_event.stream);
break;
case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
test_event.type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN;
test_event.packet =
- bt_notification_packet_begin_get_packet(notification);
+ bt_notification_packet_begin_borrow_packet(notification);
assert(test_event.packet);
- bt_put(test_event.packet);
break;
case BT_NOTIFICATION_TYPE_PACKET_END:
test_event.type = TEST_EV_TYPE_NOTIF_PACKET_END;
test_event.packet =
- bt_notification_packet_end_get_packet(notification);
+ bt_notification_packet_end_borrow_packet(notification);
assert(test_event.packet);
- bt_put(test_event.packet);
break;
default:
test_event.type = TEST_EV_TYPE_NOTIF_UNEXPECTED;
}
if (test_event.packet) {
- test_event.stream = bt_packet_get_stream(test_event.packet);
+ test_event.stream = bt_packet_borrow_stream(test_event.packet);
assert(test_event.stream);
- bt_put(test_event.stream);
}
end:
struct bt_component *sink_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- struct bt_graph *graph;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
clear_test_events();
current_test = test;
diag("test: %s", name);
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_sink(graph, &src_comp, &sink_comp);
bt_put(src_comp);
bt_put(sink_comp);
- bt_put(graph);
+ BT_PUT(graph);
}
static
enum bt_notification_iterator_status iter_status =
BT_NOTIFICATION_ITERATOR_STATUS_OK;
struct bt_port *upstream_port;
- struct bt_graph *graph;
clear_test_events();
current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR;
diag("test: output port notification iterator");
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_sink(graph, &src_comp, NULL);
"the produced sequence of test events is the expected one");
bt_put(src_comp);
- bt_put(graph);
+ BT_PUT(graph);
bt_put(notif_iter);
}
struct bt_component *src_comp;
struct bt_notification_iterator *notif_iter;
struct bt_port *upstream_port;
- struct bt_graph *graph;
clear_test_events();
current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR;
diag("test: cannot consume graph with existing output port notification iterator");
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_sink(graph, &src_comp, NULL);
"bt_graph_run() returns BT_GRAPH_STATUS_CANNOT_CONSUME when there's an output port notification iterator");
bt_put(src_comp);
- bt_put(graph);
+ BT_PUT(graph);
bt_put(notif_iter);
}