From b9d103befd837c4411112257c2619ef8d68225dd Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 2 May 2017 13:14:20 -0400 Subject: [PATCH] Remove default port API MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit With the possibility of creating new ports for the whole lifetime of a component, default ports aren't so useful and their name is arbitrary. We don't need this for the 2.0 target. The existing component classes are changed like so: * debug-info.debug-info [filter]: one `in` input port and one `out` output port * text.pretty [sink]: one `in` input port * utils.dummy [sink]: one `in` input port * utils.trimmer [filter]: one `in` input port and one `out` output port * writer.writer [sink]: one `in` input port Tests are updated accordingly. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- cli/babeltrace.c | 4 ++ include/babeltrace/graph/component-filter.h | 4 -- include/babeltrace/graph/component-internal.h | 3 -- include/babeltrace/graph/component-sink.h | 2 - include/babeltrace/graph/component-source.h | 2 - include/babeltrace/graph/port.h | 2 - .../graph/private-component-filter.h | 8 --- .../babeltrace/graph/private-component-sink.h | 4 -- .../graph/private-component-source.h | 4 -- lib/graph/component.c | 28 ----------- lib/graph/filter.c | 32 ++++-------- lib/graph/sink.c | 17 +++---- lib/graph/source.c | 15 ------ plugins/ctf/fs/fs.c | 9 ---- plugins/debug-info/plugin.c | 3 +- plugins/text/pretty/pretty.c | 11 ++++ plugins/utils/dummy/dummy.c | 10 ++++ plugins/utils/muxer/muxer.c | 35 ------------- plugins/utils/trimmer/iterator.c | 4 +- plugins/utils/trimmer/trimmer.c | 18 +++++++ plugins/writer/writer.c | 10 ++++ tests/lib/test_bt_notification_iterator.c | 16 +++++- tests/lib/test_graph_topo.c | 50 +++++++++++++++---- tests/plugins/test-utils-muxer.c | 21 ++++---- 24 files changed, 136 insertions(+), 176 deletions(-) diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 0ef2491b..8391c4a9 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -554,6 +554,8 @@ int connect_source_sink(struct bt_graph *graph, struct bt_component *sink) { int ret = 0; + +#if 0 struct bt_connection *connection = NULL; struct bt_component *trimmer = NULL; struct bt_port *source_port = @@ -623,6 +625,8 @@ end: bt_put(sink_port); bt_put(to_sink_port); bt_put(connection); + +#endif return ret; } diff --git a/include/babeltrace/graph/component-filter.h b/include/babeltrace/graph/component-filter.h index 43da9db0..26ebf157 100644 --- a/include/babeltrace/graph/component-filter.h +++ b/include/babeltrace/graph/component-filter.h @@ -43,8 +43,6 @@ extern struct bt_port *bt_component_filter_get_input_port_by_name( struct bt_component *component, const char *name); extern struct bt_port *bt_component_filter_get_input_port_by_index( struct bt_component *component, uint64_t index); -extern struct bt_port *bt_component_filter_get_default_input_port( - struct bt_component *component); extern int64_t bt_component_filter_get_output_port_count( struct bt_component *component); @@ -52,8 +50,6 @@ extern struct bt_port *bt_component_filter_get_output_port_by_name( struct bt_component *component, const char *name); extern struct bt_port *bt_component_filter_get_output_port_by_index( struct bt_component *component, uint64_t index); -extern struct bt_port *bt_component_filter_get_default_output_port( - struct bt_component *component); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/component-internal.h b/include/babeltrace/graph/component-internal.h index 2308afdd..fe55a601 100644 --- a/include/babeltrace/graph/component-internal.h +++ b/include/babeltrace/graph/component-internal.h @@ -35,9 +35,6 @@ #include #include -#define DEFAULT_INPUT_PORT_NAME "default" -#define DEFAULT_OUTPUT_PORT_NAME "default" - typedef void (*bt_component_destroy_listener_func)( struct bt_component *class, void *data); diff --git a/include/babeltrace/graph/component-sink.h b/include/babeltrace/graph/component-sink.h index 96a935c5..e30e2648 100644 --- a/include/babeltrace/graph/component-sink.h +++ b/include/babeltrace/graph/component-sink.h @@ -43,8 +43,6 @@ extern struct bt_port *bt_component_sink_get_input_port_by_name( struct bt_component *component, const char *name); extern struct bt_port *bt_component_sink_get_input_port_by_index( struct bt_component *component, uint64_t index); -extern struct bt_port *bt_component_sink_get_default_input_port( - struct bt_component *component); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/component-source.h b/include/babeltrace/graph/component-source.h index 75cf0213..a1809a98 100644 --- a/include/babeltrace/graph/component-source.h +++ b/include/babeltrace/graph/component-source.h @@ -43,8 +43,6 @@ extern struct bt_port *bt_component_source_get_output_port_by_name( struct bt_component *component, const char *name); extern struct bt_port *bt_component_source_get_output_port_by_index( struct bt_component *component, uint64_t index); -extern struct bt_port *bt_component_source_get_default_output_port( - struct bt_component *component); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/port.h b/include/babeltrace/graph/port.h index af406341..b759b6ab 100644 --- a/include/babeltrace/graph/port.h +++ b/include/babeltrace/graph/port.h @@ -49,8 +49,6 @@ enum bt_port_type { BT_PORT_TYPE_UNKOWN = -1, }; -extern const char *BT_DEFAULT_PORT_NAME; - extern const char *bt_port_get_name(struct bt_port *port); extern enum bt_port_type bt_port_get_type(struct bt_port *port); extern struct bt_connection *bt_port_get_connection(struct bt_port *port); diff --git a/include/babeltrace/graph/private-component-filter.h b/include/babeltrace/graph/private-component-filter.h index bb3cfe75..ec19534e 100644 --- a/include/babeltrace/graph/private-component-filter.h +++ b/include/babeltrace/graph/private-component-filter.h @@ -42,10 +42,6 @@ extern struct bt_private_port * bt_private_component_filter_get_output_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * -bt_private_component_filter_get_default_output_private_port( - struct bt_private_component *private_component); - extern struct bt_private_port * bt_private_component_filter_add_output_private_port( struct bt_private_component *private_component, @@ -60,10 +56,6 @@ extern struct bt_private_port * bt_private_component_filter_get_input_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * -bt_private_component_filter_get_default_input_private_port( - struct bt_private_component *private_component); - extern struct bt_private_port * bt_private_component_filter_add_input_private_port( struct bt_private_component *private_component, diff --git a/include/babeltrace/graph/private-component-sink.h b/include/babeltrace/graph/private-component-sink.h index 9c473ccc..d05d22c2 100644 --- a/include/babeltrace/graph/private-component-sink.h +++ b/include/babeltrace/graph/private-component-sink.h @@ -42,10 +42,6 @@ extern struct bt_private_port * bt_private_component_sink_get_input_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * -bt_private_component_sink_get_default_input_private_port( - struct bt_private_component *private_component); - extern struct bt_private_port * bt_private_component_sink_add_input_private_port( struct bt_private_component *private_component, diff --git a/include/babeltrace/graph/private-component-source.h b/include/babeltrace/graph/private-component-source.h index da653203..086091a0 100644 --- a/include/babeltrace/graph/private-component-source.h +++ b/include/babeltrace/graph/private-component-source.h @@ -43,10 +43,6 @@ bt_private_component_source_get_output_private_port_by_index( struct bt_private_component *private_component, uint64_t index); -extern struct bt_private_port * -bt_private_component_source_get_default_output_private_port( - struct bt_private_component *private_component); - extern struct bt_private_port * bt_private_component_source_add_output_private_port( struct bt_private_component *private_component, diff --git a/lib/graph/component.c b/lib/graph/component.c index 7b433ea9..c4f26a89 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -209,7 +209,6 @@ struct bt_component *bt_component_create_with_init_method_data( int ret; struct bt_component *component = NULL; enum bt_component_class_type type; - struct bt_port *default_port = NULL; bt_get(params); @@ -273,32 +272,6 @@ struct bt_component *bt_component_create_with_init_method_data( goto end; } - if (type == BT_COMPONENT_CLASS_TYPE_SOURCE || - type == BT_COMPONENT_CLASS_TYPE_FILTER) { - default_port = bt_component_add_port(component, - component->output_ports, BT_PORT_TYPE_OUTPUT, - DEFAULT_OUTPUT_PORT_NAME, NULL); - if (!default_port) { - BT_PUT(component); - goto end; - } - - BT_PUT(default_port); - } - - if (type == BT_COMPONENT_CLASS_TYPE_FILTER || - type == BT_COMPONENT_CLASS_TYPE_SINK) { - default_port = bt_component_add_port(component, - component->input_ports, BT_PORT_TYPE_INPUT, - DEFAULT_INPUT_PORT_NAME, NULL); - if (!default_port) { - BT_PUT(component); - goto end; - } - - BT_PUT(default_port); - } - component->initializing = true; if (component_class->methods.init) { @@ -322,7 +295,6 @@ struct bt_component *bt_component_create_with_init_method_data( bt_component_class_freeze(component->class); end: bt_put(params); - bt_put(default_port); return component; } diff --git a/lib/graph/filter.c b/lib/graph/filter.c index e109e15e..aaab3b78 100644 --- a/lib/graph/filter.c +++ b/lib/graph/filter.c @@ -126,13 +126,6 @@ end: return port; } -struct bt_port *bt_component_filter_get_default_input_port( - struct bt_component *component) -{ - return bt_component_filter_get_input_port_by_name(component, - DEFAULT_INPUT_PORT_NAME); -} - int64_t bt_component_filter_get_output_port_count( struct bt_component *component) { @@ -179,13 +172,6 @@ end: return port; } -struct bt_port *bt_component_filter_get_default_output_port( - struct bt_component *component) -{ - return bt_component_filter_get_output_port_by_name(component, - DEFAULT_OUTPUT_PORT_NAME); -} - struct bt_private_port * bt_private_component_filter_get_input_private_port_by_index( struct bt_private_component *private_component, uint64_t index) @@ -196,12 +182,13 @@ bt_private_component_filter_get_input_private_port_by_index( } struct bt_private_port * -bt_private_component_filter_get_default_input_private_port( - struct bt_private_component *private_component) +bt_private_component_filter_get_input_private_port_by_name( + struct bt_private_component *private_component, + const char *name) { return bt_private_port_from_port( - bt_component_filter_get_default_input_port( - bt_component_from_private(private_component))); + bt_component_filter_get_input_port_by_name( + bt_component_from_private(private_component), name)); } struct bt_private_port *bt_private_component_filter_add_input_private_port( @@ -232,12 +219,13 @@ bt_private_component_filter_get_output_private_port_by_index( } struct bt_private_port * -bt_private_component_filter_get_default_output_private_port( - struct bt_private_component *private_component) +bt_private_component_filter_get_output_private_port_by_name( + struct bt_private_component *private_component, + const char *name) { return bt_private_port_from_port( - bt_component_filter_get_default_output_port( - bt_component_from_private(private_component))); + bt_component_filter_get_output_port_by_name( + bt_component_from_private(private_component), name)); } struct bt_private_port *bt_private_component_filter_add_output_private_port( diff --git a/lib/graph/sink.c b/lib/graph/sink.c index 1eedcf73..e99d111f 100644 --- a/lib/graph/sink.c +++ b/lib/graph/sink.c @@ -145,13 +145,6 @@ end: return port; } -struct bt_port *bt_component_sink_get_default_input_port( - struct bt_component *component) -{ - return bt_component_sink_get_input_port_by_name(component, - DEFAULT_INPUT_PORT_NAME); -} - struct bt_private_port * bt_private_component_sink_get_input_private_port_by_index( struct bt_private_component *private_component, uint64_t index) @@ -161,12 +154,14 @@ bt_private_component_sink_get_input_private_port_by_index( bt_component_from_private(private_component), index)); } -struct bt_private_port *bt_private_component_sink_get_default_input_private_port( - struct bt_private_component *private_component) +struct bt_private_port * +bt_private_component_sink_get_input_private_port_by_name( + struct bt_private_component *private_component, + const char *name) { return bt_private_port_from_port( - bt_component_sink_get_default_input_port( - bt_component_from_private(private_component))); + bt_component_sink_get_input_port_by_name( + bt_component_from_private(private_component), name)); } struct bt_private_port *bt_private_component_sink_add_input_private_port( diff --git a/lib/graph/source.c b/lib/graph/source.c index e76959b8..566d1c0e 100644 --- a/lib/graph/source.c +++ b/lib/graph/source.c @@ -125,13 +125,6 @@ end: return port; } -struct bt_port *bt_component_source_get_default_output_port( - struct bt_component *component) -{ - return bt_component_source_get_output_port_by_name(component, - DEFAULT_OUTPUT_PORT_NAME); -} - struct bt_private_port * bt_private_component_source_get_output_private_port_by_name( struct bt_private_component *private_component, @@ -151,14 +144,6 @@ bt_private_component_source_get_output_private_port_by_index( bt_component_from_private(private_component), index)); } -struct bt_private_port *bt_private_component_source_get_default_output_private_port( - struct bt_private_component *private_component) -{ - return bt_private_port_from_port( - bt_component_source_get_default_output_port( - bt_component_from_private(private_component))); -} - struct bt_private_port *bt_private_component_source_add_output_private_port( struct bt_private_component *private_component, const char *name, void *user_data) diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 669d2daa..2abd9b57 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -229,17 +229,8 @@ int create_ports(struct ctf_fs_component *ctf_fs) const char *basename; GError *error = NULL; GDir *dir = NULL; - struct bt_private_port *def_port; struct ctf_fs_file *file = NULL; - /* Remove default port if needed */ - def_port = bt_private_component_source_get_default_output_private_port( - ctf_fs->priv_comp); - if (def_port) { - bt_private_port_remove_from_component(def_port); - bt_put(def_port); - } - /* Create one output port for each stream file */ dir = g_dir_open(ctf_fs->trace_path->str, 0, &error); if (!dir) { diff --git a/plugins/debug-info/plugin.c b/plugins/debug-info/plugin.c index d0294c90..9795bcf3 100644 --- a/plugins/debug-info/plugin.c +++ b/plugins/debug-info/plugin.c @@ -318,7 +318,8 @@ enum bt_notification_iterator_status debug_info_iterator_init( } /* Create a new iterator on the upstream component. */ - input_port = bt_private_component_filter_get_default_input_private_port(component); + input_port = bt_private_component_filter_get_input_private_port_by_name( + component, "in"); assert(input_port); connection = bt_private_port_get_private_connection(input_port); assert(connection); diff --git a/plugins/text/pretty/pretty.c b/plugins/text/pretty/pretty.c index ea317cb3..cea5fe68 100644 --- a/plugins/text/pretty/pretty.c +++ b/plugins/text/pretty/pretty.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -705,12 +706,22 @@ enum bt_component_status pretty_init( { enum bt_component_status ret; struct pretty_component *pretty = create_pretty(); + void *priv_port; if (!pretty) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } + priv_port = bt_private_component_sink_add_input_private_port(component, + "in", NULL); + if (!priv_port) { + ret = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + bt_put(priv_port); + pretty->out = stdout; pretty->err = stderr; diff --git a/plugins/utils/dummy/dummy.c b/plugins/utils/dummy/dummy.c index 3d7de4d5..978ecdea 100644 --- a/plugins/utils/dummy/dummy.c +++ b/plugins/utils/dummy/dummy.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -58,12 +59,21 @@ enum bt_component_status dummy_init(struct bt_private_component *component, { enum bt_component_status ret; struct dummy *dummy = g_new0(struct dummy, 1); + void *priv_port; if (!dummy) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } + priv_port = bt_private_component_sink_add_input_private_port(component, + "in", NULL); + if (!priv_port) { + ret = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + bt_put(priv_port); dummy->iterators = g_ptr_array_new_with_free_func( (GDestroyNotify) bt_put); if (!dummy->iterators) { diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index e967093b..895be677 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -180,36 +180,6 @@ end: return ret; } -static -int remove_default_ports(struct bt_private_component *priv_comp) -{ - struct bt_private_port *priv_port; - int ret = 0; - - priv_port = bt_private_component_filter_get_default_input_private_port( - priv_comp); - if (priv_port) { - ret = bt_private_port_remove_from_component(priv_port); - if (ret) { - goto end; - } - } - - bt_put(priv_port); - priv_port = bt_private_component_filter_get_default_output_private_port( - priv_comp); - if (priv_port) { - ret = bt_private_port_remove_from_component(priv_port); - if (ret) { - goto end; - } - } - -end: - bt_put(priv_port); - return ret; -} - static int create_output_port(struct bt_private_component *priv_comp) { @@ -261,11 +231,6 @@ enum bt_component_status muxer_init( muxer_comp->priv_comp = priv_comp; ret = bt_private_component_set_user_data(priv_comp, muxer_comp); assert(ret == 0); - ret = remove_default_ports(priv_comp); - if (ret) { - goto error; - } - ret = ensure_available_input_port(priv_comp); if (ret) { goto error; diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 6043db92..e6427307 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -84,8 +84,8 @@ enum bt_notification_iterator_status trimmer_iterator_init( } /* Create a new iterator on the upstream component. */ - input_port = bt_private_component_filter_get_default_input_private_port( - component); + input_port = bt_private_component_filter_get_input_private_port_by_name( + component, "in"); assert(input_port); connection = bt_private_port_get_private_connection(input_port); assert(connection); diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index d3f907e1..8ec1332f 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include "trimmer.h" @@ -357,12 +358,27 @@ enum bt_component_status trimmer_component_init( { enum bt_component_status ret; struct trimmer *trimmer = create_trimmer_data(); + struct bt_private_port *priv_port = NULL; if (!trimmer) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } + /* Create input and output ports */ + priv_port = bt_private_component_filter_add_input_private_port( + component, "in", NULL); + if (!priv_port) { + goto error; + } + + bt_put(priv_port); + priv_port = bt_private_component_filter_add_output_private_port( + component, "out", NULL); + if (!priv_port) { + goto error; + } + ret = bt_private_component_set_user_data(component, trimmer); if (ret != BT_COMPONENT_STATUS_OK) { goto error; @@ -370,8 +386,10 @@ enum bt_component_status trimmer_component_init( ret = init_from_params(trimmer, params); end: + bt_put(priv_port); return ret; error: destroy_trimmer_data(trimmer); + ret = BT_COMPONENT_STATUS_ERROR; return ret; } diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index d50af13b..118210ab 100644 --- a/plugins/writer/writer.c +++ b/plugins/writer/writer.c @@ -265,12 +265,22 @@ enum bt_component_status writer_component_init( struct writer_component *writer_component = create_writer_component(); struct bt_value *value = NULL; const char *path; + void *priv_port; if (!writer_component) { ret = BT_COMPONENT_STATUS_NOMEM; goto end; } + priv_port = bt_private_component_sink_add_input_private_port(component, + "in", NULL); + if (!priv_port) { + ret = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + bt_put(priv_port); + value = bt_value_map_get(params, "path"); if (!value || bt_value_is_null(value) || !bt_value_is_string(value)) { fprintf(writer_component->err, diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_notification_iterator.c index 6b53c368..303c42bd 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_notification_iterator.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -701,6 +702,12 @@ enum bt_component_status src_init( struct bt_private_component *private_component, struct bt_value *params, void *init_method_data) { + void *priv_port; + + priv_port = bt_private_component_source_add_output_private_port( + private_component, "out", NULL); + assert(priv_port); + bt_put(priv_port); return BT_COMPONENT_STATUS_OK; } @@ -836,11 +843,16 @@ enum bt_component_status sink_init( { struct sink_user_data *user_data = g_new0(struct sink_user_data, 1); int ret; + void *priv_port; assert(user_data); ret = bt_private_component_set_user_data(private_component, user_data); assert(ret == 0); + priv_port = bt_private_component_sink_add_input_private_port( + private_component, "in", NULL); + assert(priv_port); + bt_put(priv_port); return BT_COMPONENT_STATUS_OK; } @@ -917,9 +929,9 @@ void do_std_test(enum test test, const char *name, assert(graph); /* Connect source to sink */ - upstream_port = bt_component_source_get_default_output_port(src_comp); + upstream_port = bt_component_source_get_output_port_by_name(src_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); diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index ccde32af..058da9e8 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -373,6 +373,19 @@ void src_port_disconnected(struct bt_private_component *private_component, } } +static +enum bt_component_status src_init(struct bt_private_component *priv_comp, + struct bt_value *params, void *init_method_data) +{ + void *priv_port; + + priv_port = bt_private_component_source_add_output_private_port( + priv_comp, "out", NULL); + assert(priv_port); + bt_put(priv_port); + return BT_COMPONENT_STATUS_OK; +} + static enum bt_component_status sink_consume( struct bt_private_component *priv_component) @@ -383,8 +396,8 @@ enum bt_component_status sink_consume( switch (current_test) { case TEST_SINK_REMOVES_PORT_IN_CONSUME: case TEST_SINK_REMOVES_PORT_IN_CONSUME_THEN_SRC_REMOVES_DISCONNECTED_PORT: - def_port = bt_private_component_sink_get_default_input_private_port( - priv_component); + def_port = bt_private_component_sink_get_input_private_port_by_name( + priv_component, "in"); assert(def_port); ret = bt_private_port_remove_from_component(def_port); assert(ret == 0); @@ -433,6 +446,19 @@ void sink_port_disconnected(struct bt_private_component *private_component, append_event(&event); } +static +enum bt_component_status sink_init(struct bt_private_component *priv_comp, + struct bt_value *params, void *init_method_data) +{ + void *priv_port; + + priv_port = bt_private_component_sink_add_input_private_port(priv_comp, + "in", NULL); + assert(priv_port); + bt_put(priv_port); + return BT_COMPONENT_STATUS_OK; +} + static void graph_port_added(struct bt_port *port, void *data) @@ -526,6 +552,8 @@ void init_test(void) src_comp_class = bt_component_class_source_create("src", src_iter_next); assert(src_comp_class); + ret = bt_component_class_set_init_method(src_comp_class, src_init); + assert(ret == 0); ret = bt_component_class_set_accept_port_connection_method( src_comp_class, accept_port_connection); assert(ret == 0); @@ -537,6 +565,8 @@ void init_test(void) assert(ret == 0); sink_comp_class = bt_component_class_sink_create("sink", sink_consume); assert(sink_comp_class); + ret = bt_component_class_set_init_method(sink_comp_class, sink_init); + assert(ret == 0); ret = bt_component_class_set_accept_port_connection_method( sink_comp_class, accept_port_connection); assert(ret == 0); @@ -636,9 +666,9 @@ void test_sink_removes_port_in_port_connected_then_src_removes_disconnected_port src = create_src(); sink = create_sink(); graph = create_graph(); - src_def_port = bt_component_source_get_default_output_port(src); + src_def_port = bt_component_source_get_output_port_by_name(src, "out"); assert(src_def_port); - sink_def_port = bt_component_sink_get_default_input_port(sink); + sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in"); assert(sink_def_port); conn = bt_graph_connect_ports(graph, src_def_port, sink_def_port); assert(conn); @@ -797,9 +827,9 @@ void test_sink_removes_port_in_port_connected(void) src = create_src(); sink = create_sink(); graph = create_graph(); - src_def_port = bt_component_source_get_default_output_port(src); + src_def_port = bt_component_source_get_output_port_by_name(src, "out"); assert(src_def_port); - sink_def_port = bt_component_sink_get_default_input_port(sink); + sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in"); assert(sink_def_port); conn = bt_graph_connect_ports(graph, src_def_port, sink_def_port); assert(conn); @@ -940,9 +970,9 @@ void test_src_adds_port_in_port_connected(void) src = create_src(); sink = create_sink(); graph = create_graph(); - src_def_port = bt_component_source_get_default_output_port(src); + src_def_port = bt_component_source_get_output_port_by_name(src, "out"); assert(src_def_port); - sink_def_port = bt_component_sink_get_default_input_port(sink); + sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in"); assert(sink_def_port); conn = bt_graph_connect_ports(graph, src_def_port, sink_def_port); assert(conn); @@ -1045,9 +1075,9 @@ void test_simple(void) src = create_src(); sink = create_sink(); graph = create_graph(); - src_def_port = bt_component_source_get_default_output_port(src); + src_def_port = bt_component_source_get_output_port_by_name(src, "out"); assert(src_def_port); - sink_def_port = bt_component_sink_get_default_input_port(sink); + sink_def_port = bt_component_sink_get_input_port_by_name(sink, "in"); assert(sink_def_port); conn = bt_graph_connect_ports(graph, src_def_port, sink_def_port); assert(conn); diff --git a/tests/plugins/test-utils-muxer.c b/tests/plugins/test-utils-muxer.c index 0f679628..1b4c94ec 100644 --- a/tests/plugins/test-utils-muxer.c +++ b/tests/plugins/test-utils-muxer.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -685,17 +686,8 @@ enum bt_component_status src_init( 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: nb_ports = 2; @@ -904,11 +896,16 @@ enum bt_component_status sink_init( { struct sink_user_data *user_data = g_new0(struct sink_user_data, 1); int ret; + void *priv_port; assert(user_data); ret = bt_private_component_set_user_data(private_component, user_data); assert(ret == 0); + priv_port = bt_private_component_sink_add_input_private_port( + private_component, "in", NULL); + assert(priv_port); + bt_put(priv_port); return BT_COMPONENT_STATUS_OK; } @@ -1023,7 +1020,7 @@ void do_std_test(enum test test, const char *name, 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); @@ -1499,7 +1496,7 @@ void test_single_end_then_multiple_full(void) 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); @@ -1628,7 +1625,7 @@ void test_single_again_end_then_multiple_full(void) 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); -- 2.34.1