--- /dev/null
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2015-2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ * The following TSDL code was generated by barectf v2.3.0
+ * on 2019-06-21 11:00:09.758512.
+ *
+ * For more details, see <http://barectf.org>.
+ */
+
+trace {
+ major = 1;
+ minor = 8;
+ byte_order = le;
+ uuid = "437748de-9435-11e9-8353-5254007c6857";
+ packet.header := struct {
+ integer {
+ size = 32;
+ align = 32;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } magic;
+ integer {
+ size = 8;
+ align = 8;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } uuid[16];
+ integer {
+ size = 8;
+ align = 8;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } stream_id;
+ } align(1);
+};
+
+env {
+ domain = "bare";
+ tracer_name = "barectf";
+ tracer_major = 2;
+ tracer_minor = 3;
+ tracer_patch = 0;
+ barectf_gen_date = "2019-06-21T11:00:09.758481";
+};
+
+clock {
+ name = default;
+ freq = 1000000000;
+ offset_s = 1434072888;
+ offset = 0;
+ precision = 0;
+ absolute = false;
+};
+
+/* default */
+stream {
+ id = 0;
+ packet.context := struct {
+ integer {
+ size = 64;
+ align = 64;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ map = clock.default.value;
+ } timestamp_begin;
+ integer {
+ size = 64;
+ align = 64;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ map = clock.default.value;
+ } timestamp_end;
+ integer {
+ size = 32;
+ align = 32;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } packet_size;
+ integer {
+ size = 32;
+ align = 32;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } content_size;
+ integer {
+ size = 32;
+ align = 32;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } events_discarded;
+ } align(1);
+ event.header := struct {
+ integer {
+ size = 64;
+ align = 64;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ map = clock.default.value;
+ } timestamp;
+ integer {
+ size = 16;
+ align = 16;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } id;
+ } align(1);
+};
+
+event {
+ name = "simple_uint32";
+ id = 0;
+ stream_id = 0; /* default */
+ loglevel = 2; /* CRIT */
+ fields := struct {
+ integer {
+ size = 32;
+ align = 32;
+ signed = false;
+ byte_order = le;
+ base = 10;
+ encoding = none;
+ } value;
+ } align(1);
+};
--- /dev/null
+/* CTF 1.8 */
+
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+typealias integer { size = 16; align = 8; signed = false; } := uint16_t;
+typealias integer { size = 32; align = 8; signed = false; } := uint32_t;
+typealias integer { size = 64; align = 8; signed = false; } := uint64_t;
+typealias integer { size = 64; align = 8; signed = false; } := unsigned long;
+typealias integer { size = 5; align = 1; signed = false; } := uint5_t;
+typealias integer { size = 27; align = 1; signed = false; } := uint27_t;
+
+trace {
+ major = 1;
+ minor = 8;
+ uuid = "a7055065-938f-439c-818e-975c13b30be2";
+ byte_order = le;
+ packet.header := struct {
+ uint32_t magic;
+ uint8_t uuid[16];
+ uint32_t stream_id;
+ uint64_t stream_instance_id;
+ };
+};
+
+env {
+ hostname = "raton";
+ domain = "ust";
+ tracer_name = "lttng-ust";
+ tracer_major = 2;
+ tracer_minor = 11;
+};
+
+clock {
+ name = "monotonic";
+ uuid = "4d76db72-e40f-409e-ba30-532d309d5048";
+ description = "Monotonic Clock";
+ freq = 1000000000; /* Frequency, in Hz */
+ /* clock value offset from Epoch is: offset * (1/freq) */
+ offset = 1565056443054742594;
+};
+
+typealias integer {
+ size = 27; align = 1; signed = false;
+ map = clock.monotonic.value;
+} := uint27_clock_monotonic_t;
+
+typealias integer {
+ size = 32; align = 8; signed = false;
+ map = clock.monotonic.value;
+} := uint32_clock_monotonic_t;
+
+typealias integer {
+ size = 64; align = 8; signed = false;
+ map = clock.monotonic.value;
+} := uint64_clock_monotonic_t;
+
+struct packet_context {
+ uint64_clock_monotonic_t timestamp_begin;
+ uint64_clock_monotonic_t timestamp_end;
+ uint64_t content_size;
+ uint64_t packet_size;
+ uint64_t packet_seq_num;
+ unsigned long events_discarded;
+ uint32_t cpu_id;
+};
+
+struct event_header_compact {
+ enum : uint5_t { compact = 0 ... 30, extended = 31 } id;
+ variant <id> {
+ struct {
+ uint27_clock_monotonic_t timestamp;
+ } compact;
+ struct {
+ uint32_t id;
+ uint64_clock_monotonic_t timestamp;
+ } extended;
+ } v;
+} align(8);
+
+struct event_header_large {
+ enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;
+ variant <id> {
+ struct {
+ uint32_clock_monotonic_t timestamp;
+ } compact;
+ struct {
+ uint32_t id;
+ uint64_clock_monotonic_t timestamp;
+ } extended;
+ } v;
+} align(8);
+
+stream {
+ id = 0;
+ event.header := struct event_header_large;
+ packet.context := struct packet_context;
+};
+
+event {
+ name = "my_app:current_temp";
+ id = 0;
+ stream_id = 0;
+ loglevel = 13;
+ fields := struct {
+ integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _temp;
+ string _status;
+ };
+};
+
--- /dev/null
+/* CTF 1.8 */
+
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+typealias integer { size = 16; align = 8; signed = false; } := uint16_t;
+typealias integer { size = 32; align = 8; signed = false; } := uint32_t;
+typealias integer { size = 64; align = 8; signed = false; } := uint64_t;
+typealias integer { size = 64; align = 8; signed = false; } := unsigned long;
+typealias integer { size = 5; align = 1; signed = false; } := uint5_t;
+typealias integer { size = 27; align = 1; signed = false; } := uint27_t;
+
+trace {
+ major = 1;
+ minor = 8;
+ uuid = "e8680f63-336b-4999-9b6b-080f1c1b9f7b";
+ byte_order = le;
+ packet.header := struct {
+ uint32_t magic;
+ uint8_t uuid[16];
+ uint32_t stream_id;
+ uint64_t stream_instance_id;
+ };
+};
+
+env {
+ hostname = "raton";
+ domain = "ust";
+ tracer_name = "lttng-ust";
+ tracer_major = 2;
+ tracer_minor = 10;
+};
+
+clock {
+ name = "monotonic";
+ uuid = "4d76db72-e40f-409e-ba30-532d309d5048";
+ description = "Monotonic Clock";
+ freq = 1000000000; /* Frequency, in Hz */
+ /* clock value offset from Epoch is: offset * (1/freq) */
+ offset = 1565056443054742596;
+};
+
+typealias integer {
+ size = 27; align = 1; signed = false;
+ map = clock.monotonic.value;
+} := uint27_clock_monotonic_t;
+
+typealias integer {
+ size = 32; align = 8; signed = false;
+ map = clock.monotonic.value;
+} := uint32_clock_monotonic_t;
+
+typealias integer {
+ size = 64; align = 8; signed = false;
+ map = clock.monotonic.value;
+} := uint64_clock_monotonic_t;
+
+struct packet_context {
+ uint64_clock_monotonic_t timestamp_begin;
+ uint64_clock_monotonic_t timestamp_end;
+ uint64_t content_size;
+ uint64_t packet_size;
+ uint64_t packet_seq_num;
+ unsigned long events_discarded;
+ uint32_t cpu_id;
+};
+
+struct event_header_compact {
+ enum : uint5_t { compact = 0 ... 30, extended = 31 } id;
+ variant <id> {
+ struct {
+ uint27_clock_monotonic_t timestamp;
+ } compact;
+ struct {
+ uint32_t id;
+ uint64_clock_monotonic_t timestamp;
+ } extended;
+ } v;
+} align(8);
+
+struct event_header_large {
+ enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;
+ variant <id> {
+ struct {
+ uint32_clock_monotonic_t timestamp;
+ } compact;
+ struct {
+ uint32_t id;
+ uint64_clock_monotonic_t timestamp;
+ } extended;
+ } v;
+} align(8);
+
+stream {
+ id = 0;
+ event.header := struct event_header_large;
+ packet.context := struct packet_context;
+};
+
+event {
+ name = "my_app:current_temp";
+ id = 0;
+ stream_id = 0;
+ loglevel = 13;
+ fields := struct {
+ integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _temp;
+ string _status;
+ };
+};
+
--- /dev/null
+Trace class:
+ Stream class (ID 0):
+ Supports packets: Yes
+ Packets have beginning default clock snapshot: Yes
+ Packets have end default clock snapshot: Yes
+ Supports discarded events: Yes
+ Discarded events have default clock snapshots: Yes
+ Supports discarded packets: No
+ Default clock class:
+ Name: default
+ Frequency (Hz): 1,000,000,000
+ Precision (cycles): 0
+ Offset (s): 1,434,072,888
+ Offset (cycles): 0
+ Origin is Unix epoch: No
+ Event class `simple_uint32` (ID 0):
+ Log level: Critical
+ Payload field class: Structure (1 member):
+ value: Unsigned integer (32-bit, Base 10)
+
+[Unknown]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Stream beginning:
+ Trace:
+ UUID: 437748de-9435-11e9-8353-5254007c6857
+ Environment (6 entries):
+ barectf_gen_date: 2019-06-21T11:00:09.758481
+ domain: bare
+ tracer_major: 2
+ tracer_minor: 3
+ tracer_name: barectf
+ tracer_patch: 0
+ Stream (ID 0, Class ID 0)
+
+[1,048,932,916,574,076 cycles, 1,435,121,820,916,574,076 ns from origin]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Packet beginning:
+
+[1,048,932,916,580,091 cycles, 1,435,121,820,916,580,091 ns from origin]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Event `simple_uint32` (Class ID 0):
+ Payload:
+ value: 0
+
+[1,048,932,916,584,407 cycles, 1,435,121,820,916,584,407 ns from origin]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Packet end
+
+[1,048,932,916,605,259 cycles, 1,435,121,820,916,605,259 ns from origin]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Packet beginning:
+
+[1,048,932,916,605,259 cycles, 1,435,121,820,916,605,259 ns from origin]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Event `simple_uint32` (Class ID 0):
+ Payload:
+ value: 1500
+
+[1,048,932,916,609,657 cycles, 1,435,121,820,916,609,657 ns from origin]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Packet end
+
+[Unknown]
+{Trace 0, Stream class ID 0, Stream ID 0}
+Stream end
--- /dev/null
+[835,286,238,469,473 1,565,891,729,293,212,067] {0 0 0} Packet end
+[835,286,238,584,858 1,565,891,729,293,327,452] {0 0 0} Packet end
+[835,286,238,743,462 1,565,891,729,293,486,056] {0 0 0} Packet end
+[835,286,238,783,931 1,565,891,729,293,526,525] {0 0 0} Packet end
--- /dev/null
+[900,859,125,273,445 1,565,957,302,180,016,041] {0 0 0} Packet end
+[900,859,125,273,473 1,565,957,302,180,016,069] {0 0 0} Packet end
self.assertRaises(KeyError, lambda: streams[0]['range-ns'])
+class QueryTraceInfoPacketTimestampQuirksTestCase(unittest.TestCase):
+ def setUp(self):
+ ctf = bt2.find_plugin('ctf')
+ self._fs = ctf.source_component_classes['fs']
+ self._path = os.path.join(test_ctf_traces_path, 'succeed')
+
+ def _test_lttng_quirks(self, trace_name):
+ res = bt2.QueryExecutor(
+ self._fs,
+ "babeltrace.trace-info",
+ {"inputs": [os.path.join(self._path, trace_name)]},
+ ).query()
+
+ self.assertEqual(len(res), 1)
+ return res[0]
+
+ def test_event_after_packet(self):
+ trace = self._test_lttng_quirks("lttng-event-after-packet")
+ streams = trace["streams"]
+ self.assertEqual(len(streams), 1)
+
+ self.assertEqual(streams[0]['range-ns']['begin'], 1565957300948091100)
+ self.assertEqual(streams[0]['range-ns']['end'], 1565957302180016069)
+
+ def test_lttng_crash(self):
+ trace = self._test_lttng_quirks("lttng-crash")
+ streams = trace["streams"]
+ self.assertEqual(len(streams), 1)
+
+ self.assertEqual(streams[0]['range-ns']['begin'], 1565891729288866738)
+ self.assertEqual(streams[0]['range-ns']['end'], 1565891729293526525)
+
+
if __name__ == '__main__':
unittest.main()
ok $? "Trace '$name' gives the expected output"
}
-plan_tests 3
+test_packet_end() {
+ local name="$1"
+ local expected_stdout="$expect_dir/trace-$name.expect"
+ local ret=0
+ local ret_stdout
+ local ret_stderr
+ local details_comp=("-c" "sink.text.details")
+ local details_args=("-p" "with-trace-name=no,with-stream-name=no,with-metadata=no,compact=yes")
+ local temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)"
+ local temp_greped_stdout_output_file="$(mktemp -t greped_stdout.XXXXXX)"
+ local temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
+
+ bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \
+ "$succeed_trace_dir/$name" "${details_comp[@]}" \
+ "${details_args[@]}"
+
+ "$BT_TESTS_GREP_BIN" "Packet end" "$temp_stdout_output_file" > "$temp_greped_stdout_output_file"
+
+ bt_diff "$expected_stdout" "$temp_greped_stdout_output_file"
+ ret_stdout=$?
+
+ bt_diff /dev/null "$temp_stderr_output_file"
+ ret_stderr=$?
+
+ if ((ret_stdout != 0 || ret_stderr != 0)); then
+ ret=1
+ fi
+
+ ok $ret "Trace '$name' gives the expected output"
+ rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" "$temp_greped_stdout_output_file"
+}
+
+plan_tests 6
test_ctf_gen_single simple
test_ctf_single smalltrace
test_ctf_single 2packets
+test_ctf_single barectf-event-before-packet
+test_packet_end lttng-event-after-packet
+test_packet_end lttng-crash