From 38403bf59288e53839f191f6da34792d9439528b Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 19 Jul 2019 17:46:35 -0400 Subject: [PATCH] Tests: flt.utils.muxer: add message ordering tests * Add a test that checks the basic ordering of messages based on timestamps. * Add a test that checks the basic ordering of messages with the same timestamps but different trace name, stream class id, or stream id. * Add tests that check the ordering of messages with the same timestamps and types. Signed-off-by: Francis Deslauriers Change-Id: I217119a00828288d0a2471c26b387a670e62608a Reviewed-on: https://review.lttng.org/c/babeltrace/+/1726 Tested-by: jenkins Reviewed-by: Philippe Proulx --- configure.ac | 2 + tests/Makefile.am | 3 +- .../flt.utils.muxer/bt_plugin_muxer_test.py | 446 ++++++++++++++++++ .../succeed/basic_timestamp_ordering.expect | 29 ++ .../succeed/diff_event_class_id.expect | 27 ++ .../succeed/diff_event_class_name.expect | 27 ++ .../succeed/diff_inactivity_msg_cs.expect | 19 + .../succeed/diff_stream_class_id.expect | 19 + .../succeed/diff_stream_class_name.expect | 21 + .../succeed/diff_stream_class_no_name.expect | 20 + .../succeed/diff_stream_id.expect | 19 + .../succeed/diff_stream_name.expect | 21 + .../succeed/diff_stream_no_name.expect | 20 + .../succeed/diff_trace_name.expect | 19 + .../succeed/multi_iter_ordering.expect | 55 +++ tests/plugins/Makefile.am | 1 + tests/plugins/flt.utils.muxer/Makefile.am | 1 + .../flt.utils.muxer/succeed/Makefile.am | 2 + .../flt.utils.muxer/succeed/test_succeed | 71 +++ 19 files changed, 821 insertions(+), 1 deletion(-) create mode 100644 tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/basic_timestamp_ordering.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_id.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_name.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_inactivity_msg_cs.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_id.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_name.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_no_name.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_stream_id.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_stream_name.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_stream_no_name.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/diff_trace_name.expect create mode 100644 tests/data/plugins/flt.utils.muxer/succeed/multi_iter_ordering.expect create mode 100644 tests/plugins/flt.utils.muxer/Makefile.am create mode 100644 tests/plugins/flt.utils.muxer/succeed/Makefile.am create mode 100755 tests/plugins/flt.utils.muxer/succeed/test_succeed diff --git a/configure.ac b/configure.ac index 30f72647..efa9c738 100644 --- a/configure.ac +++ b/configure.ac @@ -729,6 +729,8 @@ AC_CONFIG_FILES([ tests/plugins/sink.ctf.fs/Makefile tests/plugins/sink.ctf.fs/succeed/Makefile tests/plugins/flt.lttng-utils.debug-info/Makefile + tests/plugins/flt.utils.muxer/Makefile + tests/plugins/flt.utils.muxer/succeed/Makefile tests/plugins/flt.utils.trimmer/Makefile tests/utils/Makefile tests/utils/tap/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index aa48914a..346b4133 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -107,7 +107,8 @@ endif if ENABLE_PYTHON_PLUGINS if ENABLE_PYTHON_BINDINGS TESTS_CLI += cli/convert/test_auto_source_discovery_grouping -TESTS_PLUGINS += plugins/flt.utils.trimmer/test_trimming +TESTS_PLUGINS += plugins/flt.utils.trimmer/test_trimming \ + plugins/flt.utils.muxer/succeed/test_succeed endif endif diff --git a/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py b/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py new file mode 100644 index 00000000..ac2ee597 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/bt_plugin_muxer_test.py @@ -0,0 +1,446 @@ +import bt2 + + +class TheIteratorOfConfusion(bt2._UserMessageIterator): + def __init__(self, port): + self._at = 0 + test_name = port.user_data[0] + TEST_CASES[test_name].create_msgs(self, port.user_data[1:]) + + def __next__(self): + if self._at < len(self._msgs): + msg = self._msgs[self._at] + self._at += 1 + return msg + raise StopIteration + + +@bt2.plugin_component_class +class TheSourceOfConfusion( + bt2._UserSourceComponent, message_iterator_class=TheIteratorOfConfusion +): + def __init__(self, params, obj): + tc = self._create_trace_class() + + test_name = str(params['test-name']) + + TEST_CASES[test_name].source_setup(self, test_name) + + +class DiffTraceName: + def source_setup(src, test_name): + tc1 = src._create_trace_class() + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class() + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + trace_name1 = 'rouyn' + trace_name2 = 'noranda' + + src._add_output_port('out1', (test_name, 1, tc1, cc1, trace_name1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, trace_name2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, trace_name = params + trace = tc(name=trace_name) + sc = tc.create_stream_class( + default_clock_class=cc, assigns_automatic_stream_id=False + ) + stream = trace.create_stream(sc, 0) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class DiffStreamName: + def source_setup(src, test_name): + tc1 = src._create_trace_class() + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class() + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + stream_name1 = 'port-daniel' + stream_name2 = 'gascon' + + src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_name1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_name2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, stream_name = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, assigns_automatic_stream_id=False + ) + stream = trace.create_stream(sc, 0, stream_name) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class DiffStreamId: + def source_setup(src, test_name): + tc1 = src._create_trace_class() + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class() + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + stream_id1 = 18 + stream_id2 = 23 + + src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_id1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_id2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, stream_id = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, assigns_automatic_stream_id=False + ) + stream = trace.create_stream(sc, stream_id) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class DiffStreamNoName: + def source_setup(src, test_name): + tc1 = src._create_trace_class() + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class() + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + stream_name1 = "one" + stream_name2 = None + + src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_name1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_name2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, stream_no_name = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, assigns_automatic_stream_id=False + ) + stream = trace.create_stream(sc, 0, name=stream_no_name) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class DiffStreamClassId: + def source_setup(src, test_name): + tc1 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + stream_class_id1 = 18 + stream_class_id2 = 23 + + src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_class_id1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_class_id2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, stream_class_id = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, + id=stream_class_id, + assigns_automatic_stream_id=False, + ) + stream = trace.create_stream(sc, 0) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class DiffStreamClassName: + def source_setup(src, test_name): + tc1 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + stream_class_name1 = 'one' + stream_class_name2 = 'two' + + src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_class_name1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_class_name2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, stream_class_name = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, + id=0, + name=stream_class_name, + assigns_automatic_stream_id=False, + ) + stream = trace.create_stream(sc, 0) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class DiffStreamClassNoName: + def source_setup(src, test_name): + tc1 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + stream_class_name1 = 'one' + stream_class_name2 = None + + src._add_output_port('out1', (test_name, 1, tc1, cc1, stream_class_name1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, stream_class_name2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, stream_class_name = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, + id=0, + name=stream_class_name, + assigns_automatic_stream_id=False, + ) + stream = trace.create_stream(sc, 0) + + sb_msg = msg_iter._create_stream_beginning_message(stream, 0) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class BasicTimestampOrdering: + def source_setup(src, test_name): + tc = src._create_trace_class() + cc = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + timestamp1 = 0 + timestamp2 = 120 + timestamp3 = 4 + + src._add_output_port('out1', (test_name, 1, tc, cc, timestamp1)) + src._add_output_port('out2', (test_name, 2, tc, cc, timestamp2)) + src._add_output_port('out3', (test_name, 3, tc, cc, timestamp3)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, timestamp = params + trace = tc() + sc = tc.create_stream_class(default_clock_class=cc) + stream = trace.create_stream(sc) + + sb_msg = msg_iter._create_stream_beginning_message(stream, timestamp) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, se_msg] + + +class MultiIterOrdering: + def source_setup(src, test_name): + tc1 = src._create_trace_class(assigns_automatic_stream_class_id=False) + tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) + tc3 = src._create_trace_class(assigns_automatic_stream_class_id=False) + tc4 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + src._add_output_port('out1', (test_name, 1, tc1, cc)) + src._add_output_port('out2', (test_name, 2, tc2, cc)) + src._add_output_port('out3', (test_name, 3, tc3, cc)) + src._add_output_port('out4', (test_name, 4, tc4, cc)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc = params + trace_hello = tc(name='hello') + trace_meow = tc(name='meow') + + # Craft list of messages for each iterator so that the last messages of + # each iterator are all sharing the same timestamp. + clock_snapshot_value = 25 + + if iter_id == 1: + # Event, 2500 ns, trace "hello", stream class 0, stream 1 + stream_class0 = tc.create_stream_class( + id=0, default_clock_class=cc, assigns_automatic_stream_id=False + ) + sc_0_stream_1 = trace_hello.create_stream(stream_class0, id=1) + event_class = stream_class0.create_event_class(name='saumon atlantique') + + msg_iter._msgs = [ + msg_iter._create_stream_beginning_message(sc_0_stream_1, 0), + msg_iter._create_event_message( + event_class, sc_0_stream_1, clock_snapshot_value + ), + msg_iter._create_stream_end_message(sc_0_stream_1, iter_id*193) + ] + elif iter_id == 2: + # Packet beginning, 2500 ns, trace "meow", stream class 0, stream 1 + stream_class0 = tc.create_stream_class( + id=0, + default_clock_class=cc, + supports_packets=True, + packets_have_beginning_default_clock_snapshot=True, + packets_have_end_default_clock_snapshot=True, + assigns_automatic_stream_id=False, + ) + + sc_0_stream_1 = trace_meow.create_stream(stream_class0, id=1) + packet = sc_0_stream_1.create_packet() + + msg_iter._msgs = [ + msg_iter._create_stream_beginning_message(sc_0_stream_1, 1), + msg_iter._create_packet_beginning_message(packet, clock_snapshot_value), + msg_iter._create_packet_end_message(packet, iter_id*79), + msg_iter._create_stream_end_message(sc_0_stream_1, iter_id*193) + ] + elif iter_id == 3: + # Stream beginning, 2500 ns, trace "hello", stream class 0, stream 0 + stream_class0 = tc.create_stream_class( + id=0, default_clock_class=cc, assigns_automatic_stream_id=False + ) + + sc_0_stream_0 = trace_hello.create_stream(stream_class0, id=0) + + msg_iter._msgs = [ + msg_iter._create_stream_beginning_message( + sc_0_stream_0, clock_snapshot_value + ), + msg_iter._create_stream_end_message(sc_0_stream_0, iter_id*193) + ] + elif iter_id == 4: + # Event, 2500 ns, trace "meow", stream class 1, stream 1 + stream_class1 = tc.create_stream_class( + id=1, default_clock_class=cc, assigns_automatic_stream_id=False + ) + + sc_1_stream_1 = trace_meow.create_stream(stream_class1, id=1) + + event_class = stream_class1.create_event_class(name='bar rayé') + msg_iter._msgs = [ + msg_iter._create_stream_beginning_message(sc_1_stream_1, 3), + msg_iter._create_event_message( + event_class, sc_1_stream_1, clock_snapshot_value + ), + msg_iter._create_stream_end_message(sc_1_stream_1, iter_id*193) + ] + + +class DiffEventClassName: + def source_setup(src, test_name): + tc1 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + event_class_name1 = 'Hull' + event_class_name2 = 'Gatineau' + + src._add_output_port('out1', (test_name, 1, tc1, cc1, event_class_name1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, event_class_name2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, event_class_name = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, + id=0, + assigns_automatic_stream_id=False, + supports_packets=False, + ) + ec = sc.create_event_class(name=event_class_name) + + stream = trace.create_stream(sc, 0) + + # Use event class name length as timestamp so that both stream + # beginning message are not at the same time. This test is targetting + # event message. + sb_msg = msg_iter._create_stream_beginning_message(stream, len(ec.name)) + ev_msg = msg_iter._create_event_message(ec, stream, 50) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, ev_msg, se_msg] + + +class DiffEventClassId: + def source_setup(src, test_name): + tc1 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc1 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + tc2 = src._create_trace_class(assigns_automatic_stream_class_id=False) + cc2 = src._create_clock_class(frequency=1, offset=bt2.ClockClassOffset(0)) + + event_class_id1 = 1 + event_class_id2 = 2 + + src._add_output_port('out1', (test_name, 1, tc1, cc1, event_class_id1)) + src._add_output_port('out2', (test_name, 2, tc2, cc2, event_class_id2)) + + def create_msgs(msg_iter, params): + iter_id, tc, cc, event_class_id = params + trace = tc() + sc = tc.create_stream_class( + default_clock_class=cc, + id=0, + assigns_automatic_stream_id=False, + assigns_automatic_event_class_id=False, + supports_packets=False, + ) + ec = sc.create_event_class(id=event_class_id) + + stream = trace.create_stream(sc, 0) + + # Use event class id as timestamp so that both stream beginning message + # are not at the same time. This test is targetting event message. + sb_msg = msg_iter._create_stream_beginning_message(stream, ec.id) + ev_msg = msg_iter._create_event_message(ec, stream, 50) + se_msg = msg_iter._create_stream_end_message(stream, iter_id*193) + + msg_iter._msgs = [sb_msg, ev_msg, se_msg] + + +class DiffInactivityMsgCs: + def source_setup(src, test_name): + cc1 = src._create_clock_class( + frequency=1, name='La Baie', offset=bt2.ClockClassOffset(0) + ) + cc2 = src._create_clock_class( + frequency=1, name='Chicoutimi', offset=bt2.ClockClassOffset(0) + ) + + src._add_output_port('out1', (test_name, cc1)) + src._add_output_port('out2', (test_name, cc2)) + + def create_msgs(msg_iter, params): + cc, = params + sb_msg = msg_iter._create_message_iterator_inactivity_message(cc, 0) + msg_iter._msgs = [sb_msg] + + +TEST_CASES = { + 'diff_trace_name': DiffTraceName, + 'diff_event_class_name': DiffEventClassName, + 'diff_event_class_id': DiffEventClassId, + 'diff_stream_name': DiffStreamName, + 'diff_stream_no_name': DiffStreamNoName, + 'diff_stream_id': DiffStreamId, + 'diff_stream_class_id': DiffStreamClassId, + 'diff_stream_class_name': DiffStreamClassName, + 'diff_stream_class_no_name': DiffStreamClassNoName, + 'diff_inactivity_msg_cs': DiffInactivityMsgCs, + 'basic_timestamp_ordering': BasicTimestampOrdering, + 'multi_iter_ordering': MultiIterOrdering, +} + +bt2.register_plugin(__name__, 'test-muxer') diff --git a/tests/data/plugins/flt.utils.muxer/succeed/basic_timestamp_ordering.expect b/tests/data/plugins/flt.utils.muxer/succeed/basic_timestamp_ordering.expect new file mode 100644 index 00000000..e0cb89a9 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/basic_timestamp_ordering.expect @@ -0,0 +1,29 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[4 cycles, 4,000,000,000 ns from origin] +{Trace 1, Stream class ID 2, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 2) + +[120 cycles, 120,000,000,000 ns from origin] +{Trace 2, Stream class ID 1, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 1) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 2, Stream class ID 1, Stream ID 0} +Stream end + +[579 cycles, 579,000,000,000 ns from origin] +{Trace 1, Stream class ID 2, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_id.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_id.expect new file mode 100644 index 00000000..bff55c9b --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_id.expect @@ -0,0 +1,27 @@ +[1 cycles, 1,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[2 cycles, 2,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[50 cycles, 50,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Event (Class ID 1): + +[50 cycles, 50,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Event (Class ID 2): + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_name.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_name.expect new file mode 100644 index 00000000..3ea13407 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_event_class_name.expect @@ -0,0 +1,27 @@ +[4 cycles, 4,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[8 cycles, 8,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[50 cycles, 50,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Event `Gatineau` (Class ID 0): + +[50 cycles, 50,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Event `Hull` (Class ID 0): + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_inactivity_msg_cs.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_inactivity_msg_cs.expect new file mode 100644 index 00000000..c018a3e6 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_inactivity_msg_cs.expect @@ -0,0 +1,19 @@ +[0 cycles, 0 ns from origin] +Message iterator inactivity: + Clock class: + Name: Chicoutimi + Frequency (Hz): 1 + Precision (cycles): 0 + Offset (s): 0 + Offset (cycles): 0 + Origin is Unix epoch: Yes + +[0 cycles, 0 ns from origin] +Message iterator inactivity: + Clock class: + Name: La Baie + Frequency (Hz): 1 + Precision (cycles): 0 + Offset (s): 0 + Offset (cycles): 0 + Origin is Unix epoch: Yes diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_id.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_id.expect new file mode 100644 index 00000000..b96f250e --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_id.expect @@ -0,0 +1,19 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 18, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 18) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 23, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 23) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 18, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 1, Stream class ID 23, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_name.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_name.expect new file mode 100644 index 00000000..6e8e8577 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_name.expect @@ -0,0 +1,21 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Class name: one + Trace: + Stream (ID 0, Class ID 0) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Class name: two + Trace: + Stream (ID 0, Class ID 0) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_no_name.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_no_name.expect new file mode 100644 index 00000000..b87875d5 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_class_no_name.expect @@ -0,0 +1,20 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Class name: one + Trace: + Stream (ID 0, Class ID 0) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_id.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_id.expect new file mode 100644 index 00000000..46a69812 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_id.expect @@ -0,0 +1,19 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 18} +Stream beginning: + Trace: + Stream (ID 18, Class ID 0) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 23} +Stream beginning: + Trace: + Stream (ID 23, Class ID 0) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 18} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 23} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_name.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_name.expect new file mode 100644 index 00000000..86c025c6 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_name.expect @@ -0,0 +1,21 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: gascon + Trace: + Stream (ID 0, Class ID 0) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: port-daniel + Trace: + Stream (ID 0, Class ID 0) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_no_name.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_no_name.expect new file mode 100644 index 00000000..6e9e43df --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_stream_no_name.expect @@ -0,0 +1,20 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Stream (ID 0, Class ID 0) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Name: one + Trace: + Stream (ID 0, Class ID 0) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/diff_trace_name.expect b/tests/data/plugins/flt.utils.muxer/succeed/diff_trace_name.expect new file mode 100644 index 00000000..128ac958 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/diff_trace_name.expect @@ -0,0 +1,19 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace `noranda`: + Stream (ID 0, Class ID 0) + +[0 cycles, 0 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace `rouyn`: + Stream (ID 0, Class ID 0) + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 0} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.utils.muxer/succeed/multi_iter_ordering.expect b/tests/data/plugins/flt.utils.muxer/succeed/multi_iter_ordering.expect new file mode 100644 index 00000000..8059c779 --- /dev/null +++ b/tests/data/plugins/flt.utils.muxer/succeed/multi_iter_ordering.expect @@ -0,0 +1,55 @@ +[0 cycles, 0 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 1} +Stream beginning: + Trace `hello`: + Stream (ID 1, Class ID 0) + +[1 cycles, 1,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 1} +Stream beginning: + Trace `meow`: + Stream (ID 1, Class ID 0) + +[3 cycles, 3,000,000,000 ns from origin] +{Trace 2, Stream class ID 1, Stream ID 1} +Stream beginning: + Trace `meow`: + Stream (ID 1, Class ID 1) + +[25 cycles, 25,000,000,000 ns from origin] +{Trace 3, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace `hello`: + Stream (ID 0, Class ID 0) + +[25 cycles, 25,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 1} +Event `saumon atlantique` (Class ID 0): + +[25 cycles, 25,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 1} +Packet beginning: + +[25 cycles, 25,000,000,000 ns from origin] +{Trace 2, Stream class ID 1, Stream ID 1} +Event `bar rayé` (Class ID 0): + +[158 cycles, 158,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 1} +Packet end + +[193 cycles, 193,000,000,000 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 1} +Stream end + +[386 cycles, 386,000,000,000 ns from origin] +{Trace 1, Stream class ID 0, Stream ID 1} +Stream end + +[579 cycles, 579,000,000,000 ns from origin] +{Trace 3, Stream class ID 0, Stream ID 0} +Stream end + +[772 cycles, 772,000,000,000 ns from origin] +{Trace 2, Stream class ID 1, Stream ID 1} +Stream end diff --git a/tests/plugins/Makefile.am b/tests/plugins/Makefile.am index 998f57a5..b6e34644 100644 --- a/tests/plugins/Makefile.am +++ b/tests/plugins/Makefile.am @@ -2,4 +2,5 @@ SUBDIRS = \ sink.ctf.fs \ src.ctf.fs \ flt.lttng-utils.debug-info \ + flt.utils.muxer \ flt.utils.trimmer diff --git a/tests/plugins/flt.utils.muxer/Makefile.am b/tests/plugins/flt.utils.muxer/Makefile.am new file mode 100644 index 00000000..7daaeedb --- /dev/null +++ b/tests/plugins/flt.utils.muxer/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = succeed diff --git a/tests/plugins/flt.utils.muxer/succeed/Makefile.am b/tests/plugins/flt.utils.muxer/succeed/Makefile.am new file mode 100644 index 00000000..9681346f --- /dev/null +++ b/tests/plugins/flt.utils.muxer/succeed/Makefile.am @@ -0,0 +1,2 @@ +dist_check_SCRIPTS = \ + test_succeed diff --git a/tests/plugins/flt.utils.muxer/succeed/test_succeed b/tests/plugins/flt.utils.muxer/succeed/test_succeed new file mode 100755 index 00000000..15691b59 --- /dev/null +++ b/tests/plugins/flt.utils.muxer/succeed/test_succeed @@ -0,0 +1,71 @@ +#!/bin/bash +# +# Copyright (C) 2019 Francis Deslauriers +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; only version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file tests what happens when we mux messages. + +SH_TAP=1 + +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi + +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" + +data_dir="$BT_TESTS_DATADIR/plugins/flt.utils.muxer" + +plan_tests 12 + +function run_test +{ + local test_name="$1" + local local_args=( + "-c" "src.test-muxer.TheSourceOfConfusion" + "-p" "test-name=$test_name" + "-c" "sink.text.details" + "--params=compact=false,with-metadata=false" + "--plugin-path=$data_dir" + ) + + stdout_expected="$data_dir/succeed/$test_name.expect" + bt_diff_cli "$stdout_expected" /dev/null "${local_args[@]}" + ok $? "$test_name" +} + + +test_cases=( + basic_timestamp_ordering + diff_event_class_id + diff_event_class_name + diff_inactivity_msg_cs + diff_stream_class_id + diff_stream_class_name + diff_stream_class_no_name + diff_stream_id + diff_stream_name + diff_stream_no_name + diff_trace_name + multi_iter_ordering +) + +for i in "${test_cases[@]}" +do + run_test $i +done -- 2.34.1