From cd6128ca5412c3b9cb40afe2580008329f612930 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Thu, 11 Apr 2019 17:09:32 -0400 Subject: [PATCH] lib: remove unused _NO_SINK graph status Also: - Add an assert to verify that there is at least a sink component in the graph when it's configured. - Remove the equivalent in the Python bindings, including the test in test_graph.py, even though test_graph.py is not functional at the moment. Signed-off-by: Francis Deslauriers Change-Id: I8d6ce79a2c77527908f500017bb346b2c2d94c63 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1315 CI-Build: Simon Marchi Tested-by: jenkins Reviewed-by: Philippe Proulx --- bindings/python/bt2/bt2/__init__.py.in | 4 ---- cli/babeltrace.c | 2 -- include/babeltrace/graph/graph-const.h | 1 - include/babeltrace/graph/graph-internal.h | 6 ++++-- lib/graph/graph.c | 2 -- tests/bindings/python/bt2/test_graph.py | 23 ----------------------- 6 files changed, 4 insertions(+), 34 deletions(-) diff --git a/bindings/python/bt2/bt2/__init__.py.in b/bindings/python/bt2/bt2/__init__.py.in index e1058890..f8fd8482 100644 --- a/bindings/python/bt2/bt2/__init__.py.in +++ b/bindings/python/bt2/bt2/__init__.py.in @@ -99,10 +99,6 @@ class UnsupportedFeature(Exception): pass -class NoSinkComponent(Exception): - pass - - class TryAgain(Exception): pass diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 934f9f85..791c6c8e 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -2614,8 +2614,6 @@ const char *bt_graph_status_str(bt_graph_status status) return "BT_GRAPH_STATUS_CANCELED"; case BT_GRAPH_STATUS_ERROR: return "BT_GRAPH_STATUS_ERROR"; - case BT_GRAPH_STATUS_NO_SINK: - return "BT_GRAPH_STATUS_NO_SINK"; case BT_GRAPH_STATUS_NOMEM: return "BT_GRAPH_STATUS_NOMEM"; default: diff --git a/include/babeltrace/graph/graph-const.h b/include/babeltrace/graph/graph-const.h index a8c5a514..9cb12acf 100644 --- a/include/babeltrace/graph/graph-const.h +++ b/include/babeltrace/graph/graph-const.h @@ -38,7 +38,6 @@ typedef enum bt_graph_status { BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111, BT_GRAPH_STATUS_CANCELED = 125, BT_GRAPH_STATUS_ERROR = -1, - BT_GRAPH_STATUS_NO_SINK = -6, BT_GRAPH_STATUS_NOMEM = -12, } bt_graph_status; diff --git a/include/babeltrace/graph/graph-internal.h b/include/babeltrace/graph/graph-internal.h index ec2f65ec..d9ae46f6 100644 --- a/include/babeltrace/graph/graph-internal.h +++ b/include/babeltrace/graph/graph-internal.h @@ -177,8 +177,6 @@ const char *bt_graph_status_string(enum bt_graph_status status) return "BT_GRAPH_STATUS_END"; case BT_GRAPH_STATUS_OK: return "BT_GRAPH_STATUS_OK"; - case BT_GRAPH_STATUS_NO_SINK: - return "BT_GRAPH_STATUS_NO_SINK"; case BT_GRAPH_STATUS_ERROR: return "BT_GRAPH_STATUS_ERROR"; case BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION: @@ -219,6 +217,10 @@ enum bt_graph_status bt_graph_configure(struct bt_graph *graph) goto end; } +#ifdef BT_ASSERT_PRE + BT_ASSERT_PRE(graph->has_sink, "Graph has no sink component: %!+g", graph); +#endif + graph->config_state = BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED; for (i = 0; i < graph->components->len; i++) { diff --git a/lib/graph/graph.c b/lib/graph/graph.c index 2940355f..219ca277 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -752,8 +752,6 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph) if (graph->sinks_to_consume->length > 1) { status = BT_GRAPH_STATUS_OK; } - } else if (status == BT_GRAPH_STATUS_NO_SINK) { - goto end; } } while (status == BT_GRAPH_STATUS_OK); diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index 1d37e225..73788b48 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -370,29 +370,6 @@ class GraphTestCase(unittest.TestCase): with self.assertRaises(bt2.TryAgain): self._graph.run() - def test_run_no_sink(self): - class MyIter(bt2._UserMessageIterator): - pass - - class MySource(bt2._UserSourceComponent, - message_iterator_class=MyIter): - def __init__(self, params): - self._add_output_port('out') - - class MyFilter(bt2._UserFilterComponent, - message_iterator_class=MyIter): - def __init__(self, params): - self._add_output_port('out') - self._add_input_port('in') - - src = self._graph.add_component(MySource, 'src') - flt = self._graph.add_component(MyFilter, 'flt') - conn = self._graph.connect_ports(src.output_ports['out'], - flt.input_ports['in']) - - with self.assertRaises(bt2.NoSinkComponent): - self._graph.run() - def test_run_error(self): class MyIter(bt2._UserMessageIterator): def __init__(self): -- 2.34.1