pass
-class NoSinkComponent(Exception):
- pass
-
-
class TryAgain(Exception):
pass
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:
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;
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:
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++) {
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);
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):