From: Simon Marchi Date: Fri, 9 Aug 2019 21:57:56 +0000 (-0400) Subject: tests: move auto source discovery test artifacts X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=a83410cd12c9acfe79443782e7a5311a6dd6ca59 tests: move auto source discovery test artifacts These test artifacts will soon be used to test the auto source discovery feature in the Python bindings, so move them out of the `cli` directory. Change-Id: Ia6763a42657c988442436e088fbf0e96de5baf49 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1865 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/tests/cli/convert/test_auto_source_discovery_grouping b/tests/cli/convert/test_auto_source_discovery_grouping index 85f324d8..85e9f8fd 100755 --- a/tests/cli/convert/test_auto_source_discovery_grouping +++ b/tests/cli/convert/test_auto_source_discovery_grouping @@ -30,7 +30,7 @@ NUM_TESTS=3 plan_tests $NUM_TESTS -data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-grouping" +data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/grouping" plugin_dir="${data_dir}" trace_dir="${data_dir}/traces" @@ -44,7 +44,7 @@ else dir_sep='/' fi -stdout_expected_file="${data_dir}/stdout.expect" +stdout_expected_file="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-grouping.expect" stdout_actual_file=$(mktemp -t stdout-actual.XXXXXX) stderr_actual_file=$(mktemp -t actual-stderr.XXXXXX) diff --git a/tests/cli/convert/test_auto_source_discovery_log_level b/tests/cli/convert/test_auto_source_discovery_log_level index 5e79b013..2ffb4f8f 100755 --- a/tests/cli/convert/test_auto_source_discovery_log_level +++ b/tests/cli/convert/test_auto_source_discovery_log_level @@ -31,7 +31,7 @@ NUM_TESTS=4 plan_tests $NUM_TESTS -data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-params-log-level" +data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level" plugin_dir="${data_dir}" dir_a="${data_dir}/dir-a" dir_b="${data_dir}/dir-b" diff --git a/tests/cli/convert/test_auto_source_discovery_params b/tests/cli/convert/test_auto_source_discovery_params index 53a9ecbd..01123658 100755 --- a/tests/cli/convert/test_auto_source_discovery_params +++ b/tests/cli/convert/test_auto_source_discovery_params @@ -31,7 +31,7 @@ NUM_TESTS=4 plan_tests $NUM_TESTS -data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-params-log-level" +data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level" plugin_dir="${data_dir}" dir_a="${data_dir}/dir-a" dir_b="${data_dir}/dir-b" diff --git a/tests/data/auto-source-discovery/grouping/bt_plugin_test.py b/tests/data/auto-source-discovery/grouping/bt_plugin_test.py new file mode 100644 index 00000000..2495b502 --- /dev/null +++ b/tests/data/auto-source-discovery/grouping/bt_plugin_test.py @@ -0,0 +1,131 @@ +import bt2 +import os + +# Source component classes in this file recognize and group inputs in +# various ways. One stream is created by each component, with a name +# derived from the component class and the inputs. This is then checked +# using the `sink.text.details` sink. + + +class TestIter(bt2._UserMessageIterator): + def __init__(self, output_port): + inputs = output_port.user_data['inputs'] + sc = output_port.user_data['sc'] + tc = sc.trace_class + t = tc() + s = t.create_stream(sc, name=self._make_stream_name(inputs)) + + self._msgs = [ + self._create_stream_beginning_message(s), + self._create_stream_end_message(s), + ] + + def _make_stream_name(self, inputs): + comp_cls_name = self._component.__class__.__name__ + return ( + comp_cls_name + + ': ' + + ', '.join(sorted([os.path.basename(str(x)) for x in inputs])) + ) + + def __next__(self): + if len(self._msgs) == 0: + raise StopIteration + + return self._msgs.pop(0) + + +class Base: + def __init__(self, params): + tc = self._create_trace_class() + sc = tc.create_stream_class() + + self._add_output_port('out', {'inputs': params['inputs'], 'sc': sc}) + + +@bt2.plugin_component_class +class TestSourceExt(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): + """ + Recognize files whose name start with 'aaa', 'bbb' or 'ccc'. + + 'aaa' files are grouped together, 'bbb' files are grouped together, 'ccc' + files are not grouped. + """ + + def __init__(self, params, obj): + super().__init__(params) + + @staticmethod + def _user_query(priv_query_exec, obj, params, method_obj): + if obj == 'babeltrace.support-info': + if params['type'] == 'file': + name = os.path.basename(str(params['input'])) + + if name.startswith('aaa'): + return {'weight': 1, 'group': 'aaa'} + elif name.startswith('bbb'): + return {'weight': 0.5, 'group': 'bbb'} + elif name.startswith('ccc'): + # Try two different ways of returning "no group", and two + # different ways of returning 1 (an int and a float). + if name[3] == '1': + return {'weight': 1, 'group': None} + elif name[3] == '2': + return {'weight': 1.0, 'group': None} + elif name[3] == '3': + return 1 + else: + return 1.0 + else: + return 0 + else: + raise bt2.UnknownObject + + +@bt2.plugin_component_class +class TestSourceSomeDir( + Base, bt2._UserSourceComponent, message_iterator_class=TestIter +): + """Recognizes directories named "some-dir". The file "aaa10" in the + directory "some-dir" won't be found by TestSourceExt, because we won't + recurse in "some-dir".""" + + def __init__(self, params, obj): + super().__init__(params) + + @staticmethod + def _user_query(priv_query_exec, obj, params, method_obj): + if obj == 'babeltrace.support-info': + if params['type'] == 'directory': + name = os.path.basename(str(params['input'])) + return 1 if name == 'some-dir' else 0 + else: + return 0 + else: + raise bt2.UnknownObject + + +@bt2.plugin_component_class +class TestSourceABCDE(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): + """A source that recognizes the arbitrary string input "ABCDE".""" + + def __init__(self, params, obj): + super().__init__(params) + + @staticmethod + def _user_query(priv_query_exec, obj, params, method_obj): + if obj == 'babeltrace.support-info': + return ( + 1.0 + if params['type'] == 'string' and params['input'] == 'ABCDE' + else 0.0 + ) + else: + raise bt2.UnknownObject + + +class TestSourceNoQuery(bt2._UserSourceComponent, message_iterator_class=TestIter): + """A source that does not implement _query at all.""" + + +bt2.register_plugin(module_name=__name__, name="test") diff --git a/tests/data/auto-source-discovery/grouping/traces/aaa1 b/tests/data/auto-source-discovery/grouping/traces/aaa1 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/aaa2 b/tests/data/auto-source-discovery/grouping/traces/aaa2 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/aaa3 b/tests/data/auto-source-discovery/grouping/traces/aaa3 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/bbb1 b/tests/data/auto-source-discovery/grouping/traces/bbb1 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/bbb2 b/tests/data/auto-source-discovery/grouping/traces/bbb2 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/ccc1 b/tests/data/auto-source-discovery/grouping/traces/ccc1 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/ccc2 b/tests/data/auto-source-discovery/grouping/traces/ccc2 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/ccc3 b/tests/data/auto-source-discovery/grouping/traces/ccc3 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/ccc4 b/tests/data/auto-source-discovery/grouping/traces/ccc4 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/grouping/traces/some-dir/aaa10 b/tests/data/auto-source-discovery/grouping/traces/some-dir/aaa10 new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py b/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py new file mode 100644 index 00000000..a1ac6994 --- /dev/null +++ b/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py @@ -0,0 +1,100 @@ +import bt2 +import os + +# This file defines source component classes to help verify the parameters an +# log levels passed to components. Each component creates one stream, with a +# name derived from either: +# +# - the received params that start with `test-` +# - the received log level +# +# The `what` parameter determines what is used. + + +class TestIter(bt2._UserMessageIterator): + def __init__(self, output_port): + params = output_port.user_data['params'] + + comp_cls_name = self._component.__class__.__name__ + + if params['what'] == 'test-params': + items = sorted([str(x) for x in params.items() if x[0].startswith('test-')]) + stream_name = '{}: {}'.format(comp_cls_name, ', '.join(items)) + elif params['what'] == 'log-level': + log_level = self._component.logging_level + stream_name = '{}: {}'.format(comp_cls_name, log_level) + else: + assert False + + sc = output_port.user_data['sc'] + tc = sc.trace_class + t = tc() + s = t.create_stream(sc, name=stream_name) + + self._msgs = [ + self._create_stream_beginning_message(s), + self._create_stream_end_message(s), + ] + + def __next__(self): + if len(self._msgs) == 0: + raise StopIteration + + return self._msgs.pop(0) + + +class Base: + def __init__(self, params): + tc = self._create_trace_class() + sc = tc.create_stream_class() + + self._add_output_port('out', {'params': params, 'sc': sc}) + + +@bt2.plugin_component_class +class TestSourceA(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): + def __init__(self, params, obj): + super().__init__(params) + + @staticmethod + def _user_query(priv_query_exec, obj, params, method_obj): + # Match files starting with 'aaa'. + + if obj == 'babeltrace.support-info': + if params['type'] != 'file': + return 0 + + name = os.path.basename(str(params['input'])) + + if name.startswith('aaa'): + return {'weight': 1, 'group': 'aaa'} + else: + return 0 + else: + raise bt2.UnknownObject + + +@bt2.plugin_component_class +class TestSourceB(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): + def __init__(self, params, obj): + super().__init__(params) + + @staticmethod + def _user_query(priv_query_exec, obj, params, method_obj): + # Match files starting with 'bbb'. + + if obj == 'babeltrace.support-info': + if params['type'] != 'file': + return 0 + + name = os.path.basename(str(params['input'])) + + if name.startswith('bbb'): + return {'weight': 1, 'group': 'bbb'} + else: + return 0 + else: + raise bt2.UnknownObject + + +bt2.register_plugin(module_name=__name__, name="test") diff --git a/tests/data/auto-source-discovery/params-log-level/dir-a/aaa b/tests/data/auto-source-discovery/params-log-level/dir-a/aaa new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/params-log-level/dir-ab/aaa b/tests/data/auto-source-discovery/params-log-level/dir-ab/aaa new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/params-log-level/dir-ab/bbb b/tests/data/auto-source-discovery/params-log-level/dir-ab/bbb new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/auto-source-discovery/params-log-level/dir-b/bbb b/tests/data/auto-source-discovery/params-log-level/dir-b/bbb new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/cli/convert/auto-source-discovery-grouping.expect b/tests/data/cli/convert/auto-source-discovery-grouping.expect new file mode 100644 index 00000000..3cfa1987 --- /dev/null +++ b/tests/data/cli/convert/auto-source-discovery-grouping.expect @@ -0,0 +1,71 @@ +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceABCDE: ABCDE + Trace: + Stream (ID 0, Class ID 0) + +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceExt: aaa1, aaa2, aaa3 + Trace: + Stream (ID 0, Class ID 0) + +{Trace 2, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceExt: bbb1, bbb2 + Trace: + Stream (ID 0, Class ID 0) + +{Trace 3, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceExt: ccc1 + Trace: + Stream (ID 0, Class ID 0) + +{Trace 4, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceExt: ccc2 + Trace: + Stream (ID 0, Class ID 0) + +{Trace 5, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceExt: ccc3 + Trace: + Stream (ID 0, Class ID 0) + +{Trace 6, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceExt: ccc4 + Trace: + Stream (ID 0, Class ID 0) + +{Trace 7, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: TestSourceSomeDir: some-dir + Trace: + Stream (ID 0, Class ID 0) + +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 2, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 3, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 4, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 5, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 6, Stream class ID 0, Stream ID 0} +Stream end + +{Trace 7, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/bt_plugin_test.py b/tests/data/cli/convert/auto-source-discovery-grouping/bt_plugin_test.py deleted file mode 100644 index 2495b502..00000000 --- a/tests/data/cli/convert/auto-source-discovery-grouping/bt_plugin_test.py +++ /dev/null @@ -1,131 +0,0 @@ -import bt2 -import os - -# Source component classes in this file recognize and group inputs in -# various ways. One stream is created by each component, with a name -# derived from the component class and the inputs. This is then checked -# using the `sink.text.details` sink. - - -class TestIter(bt2._UserMessageIterator): - def __init__(self, output_port): - inputs = output_port.user_data['inputs'] - sc = output_port.user_data['sc'] - tc = sc.trace_class - t = tc() - s = t.create_stream(sc, name=self._make_stream_name(inputs)) - - self._msgs = [ - self._create_stream_beginning_message(s), - self._create_stream_end_message(s), - ] - - def _make_stream_name(self, inputs): - comp_cls_name = self._component.__class__.__name__ - return ( - comp_cls_name - + ': ' - + ', '.join(sorted([os.path.basename(str(x)) for x in inputs])) - ) - - def __next__(self): - if len(self._msgs) == 0: - raise StopIteration - - return self._msgs.pop(0) - - -class Base: - def __init__(self, params): - tc = self._create_trace_class() - sc = tc.create_stream_class() - - self._add_output_port('out', {'inputs': params['inputs'], 'sc': sc}) - - -@bt2.plugin_component_class -class TestSourceExt(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): - """ - Recognize files whose name start with 'aaa', 'bbb' or 'ccc'. - - 'aaa' files are grouped together, 'bbb' files are grouped together, 'ccc' - files are not grouped. - """ - - def __init__(self, params, obj): - super().__init__(params) - - @staticmethod - def _user_query(priv_query_exec, obj, params, method_obj): - if obj == 'babeltrace.support-info': - if params['type'] == 'file': - name = os.path.basename(str(params['input'])) - - if name.startswith('aaa'): - return {'weight': 1, 'group': 'aaa'} - elif name.startswith('bbb'): - return {'weight': 0.5, 'group': 'bbb'} - elif name.startswith('ccc'): - # Try two different ways of returning "no group", and two - # different ways of returning 1 (an int and a float). - if name[3] == '1': - return {'weight': 1, 'group': None} - elif name[3] == '2': - return {'weight': 1.0, 'group': None} - elif name[3] == '3': - return 1 - else: - return 1.0 - else: - return 0 - else: - raise bt2.UnknownObject - - -@bt2.plugin_component_class -class TestSourceSomeDir( - Base, bt2._UserSourceComponent, message_iterator_class=TestIter -): - """Recognizes directories named "some-dir". The file "aaa10" in the - directory "some-dir" won't be found by TestSourceExt, because we won't - recurse in "some-dir".""" - - def __init__(self, params, obj): - super().__init__(params) - - @staticmethod - def _user_query(priv_query_exec, obj, params, method_obj): - if obj == 'babeltrace.support-info': - if params['type'] == 'directory': - name = os.path.basename(str(params['input'])) - return 1 if name == 'some-dir' else 0 - else: - return 0 - else: - raise bt2.UnknownObject - - -@bt2.plugin_component_class -class TestSourceABCDE(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): - """A source that recognizes the arbitrary string input "ABCDE".""" - - def __init__(self, params, obj): - super().__init__(params) - - @staticmethod - def _user_query(priv_query_exec, obj, params, method_obj): - if obj == 'babeltrace.support-info': - return ( - 1.0 - if params['type'] == 'string' and params['input'] == 'ABCDE' - else 0.0 - ) - else: - raise bt2.UnknownObject - - -class TestSourceNoQuery(bt2._UserSourceComponent, message_iterator_class=TestIter): - """A source that does not implement _query at all.""" - - -bt2.register_plugin(module_name=__name__, name="test") diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/stdout.expect b/tests/data/cli/convert/auto-source-discovery-grouping/stdout.expect deleted file mode 100644 index 3cfa1987..00000000 --- a/tests/data/cli/convert/auto-source-discovery-grouping/stdout.expect +++ /dev/null @@ -1,71 +0,0 @@ -{Trace 0, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceABCDE: ABCDE - Trace: - Stream (ID 0, Class ID 0) - -{Trace 1, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceExt: aaa1, aaa2, aaa3 - Trace: - Stream (ID 0, Class ID 0) - -{Trace 2, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceExt: bbb1, bbb2 - Trace: - Stream (ID 0, Class ID 0) - -{Trace 3, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceExt: ccc1 - Trace: - Stream (ID 0, Class ID 0) - -{Trace 4, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceExt: ccc2 - Trace: - Stream (ID 0, Class ID 0) - -{Trace 5, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceExt: ccc3 - Trace: - Stream (ID 0, Class ID 0) - -{Trace 6, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceExt: ccc4 - Trace: - Stream (ID 0, Class ID 0) - -{Trace 7, Stream class ID 0, Stream ID 0} -Stream beginning: - Name: TestSourceSomeDir: some-dir - Trace: - Stream (ID 0, Class ID 0) - -{Trace 0, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 1, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 2, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 3, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 4, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 5, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 6, Stream class ID 0, Stream ID 0} -Stream end - -{Trace 7, Stream class ID 0, Stream ID 0} -Stream end diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/aaa1 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/aaa1 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/aaa2 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/aaa2 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/aaa3 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/aaa3 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/bbb1 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/bbb1 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/bbb2 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/bbb2 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc1 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc1 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc2 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc2 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc3 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc3 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc4 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/ccc4 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-grouping/traces/some-dir/aaa10 b/tests/data/cli/convert/auto-source-discovery-grouping/traces/some-dir/aaa10 deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-params-log-level/bt_plugin_test.py b/tests/data/cli/convert/auto-source-discovery-params-log-level/bt_plugin_test.py deleted file mode 100644 index a1ac6994..00000000 --- a/tests/data/cli/convert/auto-source-discovery-params-log-level/bt_plugin_test.py +++ /dev/null @@ -1,100 +0,0 @@ -import bt2 -import os - -# This file defines source component classes to help verify the parameters an -# log levels passed to components. Each component creates one stream, with a -# name derived from either: -# -# - the received params that start with `test-` -# - the received log level -# -# The `what` parameter determines what is used. - - -class TestIter(bt2._UserMessageIterator): - def __init__(self, output_port): - params = output_port.user_data['params'] - - comp_cls_name = self._component.__class__.__name__ - - if params['what'] == 'test-params': - items = sorted([str(x) for x in params.items() if x[0].startswith('test-')]) - stream_name = '{}: {}'.format(comp_cls_name, ', '.join(items)) - elif params['what'] == 'log-level': - log_level = self._component.logging_level - stream_name = '{}: {}'.format(comp_cls_name, log_level) - else: - assert False - - sc = output_port.user_data['sc'] - tc = sc.trace_class - t = tc() - s = t.create_stream(sc, name=stream_name) - - self._msgs = [ - self._create_stream_beginning_message(s), - self._create_stream_end_message(s), - ] - - def __next__(self): - if len(self._msgs) == 0: - raise StopIteration - - return self._msgs.pop(0) - - -class Base: - def __init__(self, params): - tc = self._create_trace_class() - sc = tc.create_stream_class() - - self._add_output_port('out', {'params': params, 'sc': sc}) - - -@bt2.plugin_component_class -class TestSourceA(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): - def __init__(self, params, obj): - super().__init__(params) - - @staticmethod - def _user_query(priv_query_exec, obj, params, method_obj): - # Match files starting with 'aaa'. - - if obj == 'babeltrace.support-info': - if params['type'] != 'file': - return 0 - - name = os.path.basename(str(params['input'])) - - if name.startswith('aaa'): - return {'weight': 1, 'group': 'aaa'} - else: - return 0 - else: - raise bt2.UnknownObject - - -@bt2.plugin_component_class -class TestSourceB(Base, bt2._UserSourceComponent, message_iterator_class=TestIter): - def __init__(self, params, obj): - super().__init__(params) - - @staticmethod - def _user_query(priv_query_exec, obj, params, method_obj): - # Match files starting with 'bbb'. - - if obj == 'babeltrace.support-info': - if params['type'] != 'file': - return 0 - - name = os.path.basename(str(params['input'])) - - if name.startswith('bbb'): - return {'weight': 1, 'group': 'bbb'} - else: - return 0 - else: - raise bt2.UnknownObject - - -bt2.register_plugin(module_name=__name__, name="test") diff --git a/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-a/aaa b/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-a/aaa deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-ab/aaa b/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-ab/aaa deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-ab/bbb b/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-ab/bbb deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-b/bbb b/tests/data/cli/convert/auto-source-discovery-params-log-level/dir-b/bbb deleted file mode 100644 index e69de29b..00000000