Tests: debug-info: compare output of `CompleteSrc`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 15 Oct 2019 20:10:55 +0000 (16:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Oct 2019 19:14:53 +0000 (15:14 -0400)
This source is intended to produce all type for fields and options so to
test that the `flt.lttng-utils.debug-info` copies them accurately.

On the long term, I see this CompleteSrc containing cases of all trace
IR options of all metadata objects (e.g. stream class, trace class,
etc.)

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie6a9bd71dfc978a739b0daca54b9c4ba736a11be
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2203
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
tests/Makefile.am
tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py [new file with mode: 0644]
tests/plugins/flt.lttng-utils.debug-info/test_succeed

index c4b0a0a507a4e2351e01d325d3cfd20a75b4f2b8..f8d0f788b42de34bd585847156329b8f86d90fa6 100644 (file)
@@ -103,11 +103,6 @@ TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query_support_info
 TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query_trace_info
 TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query_metadata_info
 endif
-
-if ENABLE_DEBUG_INFO
-TESTS_PLUGINS += \
-       plugins/flt.lttng-utils.debug-info/test_succeed
-endif
 endif
 
 if ENABLE_DEBUG_INFO
@@ -140,6 +135,10 @@ TESTS_PYTHON_PLUGIN_PROVIDER =
 
 if ENABLE_PYTHON_PLUGINS
 TESTS_PYTHON_PLUGIN_PROVIDER += python-plugin-provider/test_python_plugin_provider
+if ENABLE_DEBUG_INFO
+TESTS_PLUGINS += \
+       plugins/flt.lttng-utils.debug-info/test_succeed
+endif
 endif
 
 TESTS_PARAM_VALIDATION = \
diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py b/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py
new file mode 100644 (file)
index 0000000..c0a3691
--- /dev/null
@@ -0,0 +1,151 @@
+import bt2
+import math
+
+bt2.register_plugin(__name__, "test_debug_info")
+
+
+class CompleteIter(bt2._UserMessageIterator):
+    def __init__(self, config, output_port):
+        ec = output_port.user_data
+        sc = ec.stream_class
+        tc = sc.trace_class
+
+        trace = tc()
+        stream = trace.create_stream(sc)
+
+        ev = self._create_event_message(ec, stream, default_clock_snapshot=123)
+
+        ev.event.payload_field["bool"] = False
+        ev.event.payload_field["real_single"] = 2.0
+        ev.event.payload_field["real_double"] = math.pi
+        ev.event.payload_field["int32"] = 121
+        ev.event.payload_field["int3"] = -1
+        ev.event.payload_field["int9_hex"] = -92
+        ev.event.payload_field["uint32"] = 121
+        ev.event.payload_field["uint61"] = 299792458
+        ev.event.payload_field["uint5_oct"] = 29
+        ev.event.payload_field["struct"]['str'] = "Rotisserie St-Hubert"
+        ev.event.payload_field["struct"]['option_real'] = math.pi
+        ev.event.payload_field["string"] = "🎉"
+        ev.event.payload_field["dyn_array"] = [1.2, 2 / 3, 42.3, math.pi]
+        ev.event.payload_field["dyn_array_len"] = 4
+        ev.event.payload_field["dyn_array_with_len"] = [5.2, 5 / 3, 42.5, math.pi * 12]
+        ev.event.payload_field["sta_array"] = ['🕰', '🦴', ' 🎍']
+        ev.event.payload_field["option_none"]
+        ev.event.payload_field["option_some"] = "NORMANDIN"
+        ev.event.payload_field["option_bool_selector"] = True
+        ev.event.payload_field["option_bool"] = "Mike's"
+        ev.event.payload_field["option_int_selector"] = 1
+        ev.event.payload_field["option_int"] = "Barbies resto bar grill"
+        ev.event.payload_field['variant'].selected_option_index = 0
+        ev.event.payload_field["variant"] = "Couche-Tard"
+
+        self._msgs = [
+            self._create_stream_beginning_message(stream),
+            ev,
+            self._create_stream_end_message(stream),
+        ]
+
+    def __next__(self):
+        if len(self._msgs) > 0:
+            return self._msgs.pop(0)
+        else:
+            raise StopIteration
+
+
+@bt2.plugin_component_class
+class CompleteSrc(bt2._UserSourceComponent, message_iterator_class=CompleteIter):
+    def __init__(self, config, params, obj):
+        tc = self._create_trace_class()
+        cc = self._create_clock_class()
+        sc = tc.create_stream_class(default_clock_class=cc)
+
+        dyn_array_elem_fc = tc.create_double_precision_real_field_class()
+        dyn_array_with_len_elem_fc = tc.create_double_precision_real_field_class()
+        dyn_array_with_len_fc = tc.create_unsigned_integer_field_class(19)
+        sta_array_elem_fc = tc.create_string_field_class()
+        option_some_fc = tc.create_string_field_class()
+        variant_fc = tc.create_variant_field_class()
+        variant_fc.append_option(
+            name='var_str', field_class=tc.create_string_field_class()
+        )
+        option_none_fc = tc.create_double_precision_real_field_class()
+        struct_fc = tc.create_structure_field_class()
+        struct_option_fc = tc.create_double_precision_real_field_class()
+        struct_fc.append_member('str', tc.create_string_field_class())
+        struct_fc.append_member(
+            'option_real',
+            tc.create_option_without_selector_field_class(struct_option_fc),
+        )
+        option_bool_selector_fc = tc.create_bool_field_class()
+        option_int_selector_fc = tc.create_unsigned_integer_field_class(8)
+
+        payload = tc.create_structure_field_class()
+        payload += [
+            ("bool", tc.create_bool_field_class()),
+            ("real_single", tc.create_single_precision_real_field_class()),
+            ("real_double", tc.create_double_precision_real_field_class()),
+            ("int32", tc.create_signed_integer_field_class(32)),
+            ("int3", tc.create_signed_integer_field_class(3)),
+            (
+                "int9_hex",
+                tc.create_signed_integer_field_class(
+                    9, preferred_display_base=bt2.IntegerDisplayBase.HEXADECIMAL
+                ),
+            ),
+            ("uint32", tc.create_unsigned_integer_field_class(32)),
+            ("uint61", tc.create_unsigned_integer_field_class(61)),
+            (
+                "uint5_oct",
+                tc.create_unsigned_integer_field_class(
+                    5, preferred_display_base=bt2.IntegerDisplayBase.OCTAL
+                ),
+            ),
+            ("struct", struct_fc),
+            ("string", tc.create_string_field_class()),
+            ("dyn_array", tc.create_dynamic_array_field_class(dyn_array_elem_fc)),
+            ("dyn_array_len", dyn_array_with_len_fc),
+            (
+                "dyn_array_with_len",
+                tc.create_dynamic_array_field_class(
+                    dyn_array_with_len_elem_fc, length_fc=dyn_array_with_len_fc
+                ),
+            ),
+            ("sta_array", tc.create_dynamic_array_field_class(sta_array_elem_fc)),
+            (
+                "option_none",
+                tc.create_option_without_selector_field_class(option_none_fc),
+            ),
+            (
+                "option_some",
+                tc.create_option_without_selector_field_class(option_some_fc),
+            ),
+            ("option_bool_selector", option_bool_selector_fc),
+            (
+                "option_bool",
+                tc.create_option_with_bool_selector_field_class(
+                    tc.create_string_field_class(), option_bool_selector_fc
+                ),
+            ),
+            (
+                "option_bool_reversed",
+                tc.create_option_with_bool_selector_field_class(
+                    tc.create_string_field_class(),
+                    option_bool_selector_fc,
+                    selector_is_reversed=True,
+                ),
+            ),
+            ("option_int_selector", option_int_selector_fc),
+            (
+                "option_int",
+                tc.create_option_with_integer_selector_field_class(
+                    tc.create_string_field_class(),
+                    option_int_selector_fc,
+                    bt2.UnsignedIntegerRangeSet([(1, 3), (18, 44)]),
+                ),
+            ),
+            ("variant", variant_fc),
+        ]
+        ec = sc.create_event_class(name="my-event", payload_field_class=payload)
+
+        self._add_output_port("some-name", ec)
index 5338420cc12cd6c7434e6a603befe8c321c7460c..76b299feea1f1308dc76cb9a2e53665f043d1a5f 100755 (executable)
@@ -39,6 +39,7 @@ this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative"
 succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed"
 expect_dir="$BT_TESTS_DATADIR/$this_dir_relative"
 binary_artefact_dir="$BT_TESTS_DATADIR/$this_dir_relative"
+data_dir="$BT_TESTS_DATADIR/$this_dir_relative"
 
 test_debug_info() {
        local name="$1"
@@ -101,10 +102,19 @@ test_compare_ctf_src_trace() {
        test_compare_to_ctf_fs "src.ctf.fs with $trace_name trace" "${cli_args[@]}"
 }
 
-plan_tests 7
+test_compare_complete_src_trace() {
+
+       local source_name="src.test_debug_info.CompleteSrc"
+       local cli_args=("--plugin-path=$data_dir" "-c" "$source_name")
+       test_compare_to_ctf_fs "$source_name" "${cli_args[@]}"
+}
+
+plan_tests 9
 
 test_debug_info debug-info
 
 test_compare_ctf_src_trace smalltrace
 test_compare_ctf_src_trace 2packets
 test_compare_ctf_src_trace session-rotation
+
+test_compare_complete_src_trace
This page took 0.026538 seconds and 4 git commands to generate.