bt2: raise an exception if an AutoSourceComponentSpec produces no component
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 12 Aug 2019 18:37:58 +0000 (14:37 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Sep 2019 15:58:21 +0000 (11:58 -0400)
commit5f7f0be0dae6ea6c4d191db180d160eca150b53b
tree82d9c68e32b484a9bd36b60404e107a9b9921d0c
parent41a53734c8f92bb7ed02873e89441fedfd1683c1
bt2: raise an exception if an AutoSourceComponentSpec produces no component

We don't do anything special at the moment if an AutoSourceComponentSpec
passed to TraceCollectionMessageIterator produces no component.  The
created graph will have no source component and the message iterator
will produce no message:

    In [5]: list(bt2.TraceCollectionMessageIterator('/yomadame'))
    08-12 14:43:03.938 20284 20284 W CLI-CFG-SRC-AUTO-DISC auto_discover_source_components@autodisc.c:755 No trace was found based on input `/yomadame`.
    Out[5]: []

This patch changes the behavior to be a bit more strict.  If any
AutoSourceComponentSpec passed to TraceCollectionMessageIterator ends up
producing no component, an exception is raised.  In the following example, the
directory `/home/smarchi/lttng-traces` does contain some valid traces, and
therefore produces some components, whereas the string `/yomadame` does not
produce any.

    In [2]: bt2.TraceCollectionMessageIterator(['/home/smarchi/lttng-traces', '/yomadame'])
    08-12 14:45:06.433 24428 24428 W CLI-CFG-SRC-AUTO-DISC auto_discover_source_components@autodisc.c:755 No trace was found based on input `/yomadame`.
    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    <ipython-input-2-107461e1b36b> in <module>
    ----> 1 bt2.TraceCollectionMessageIterator(['/home/smarchi/lttng-traces', '/yomadame'])

    ~/build/babeltrace/src/bindings/python/bt2/build/build_lib/bt2/trace_collection_message_iterator.py in __init__(self, source_component_specs, filter_component_specs, stream_intersection_mode, begin, end, plugin_set)
        292         ]
        293         self._src_comp_specs += _auto_discover_source_component_specs(
    --> 294             auto_src_comp_specs, plugin_set
        295         )
        296

    ~/build/babeltrace/src/bindings/python/bt2/build/build_lib/bt2/trace_collection_message_iterator.py in _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set)
        194
        195         msg = 'Some auto source component specs did not produce any component: ' + ', '.join(unused_inputs)
    --> 196         raise RuntimeError(msg)
        197
        198     return comp_specs

    RuntimeError: Some auto source component specs did not produce any component: /yomadame

Change-Id: I6c6df9fad18915e294559948812a8213596affdf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1885
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/bindings/python/bt2/bt2/trace_collection_message_iterator.py
tests/bindings/python/bt2/test_trace_collection_message_iterator.py
This page took 0.026105 seconds and 4 git commands to generate.