tests/cli/Makefile
tests/cli/intersection/Makefile
tests/lib/Makefile
- tests/lib/writer/Makefile
tests/lib/test-plugin-plugins/Makefile
tests/utils/common.sh
tests/utils/Makefile
babeltrace-ctf.pc
])
-AC_CONFIG_FILES([tests/cli/intersection/bt_python_helper.py])
AC_CONFIG_FILES([tests/cli/intersection/test_intersection], [chmod +x tests/cli/intersection/test_intersection])
AC_CONFIG_FILES([tests/cli/test_convert_args], [chmod +x tests/cli/test_convert_args])
AC_CONFIG_FILES([tests/cli/test_debug_info], [chmod +x tests/cli/test_debug_info])
AC_CONFIG_FILES([tests/cli/test_trimmer], [chmod +x tests/cli/test_trimmer])
AC_CONFIG_FILES([tests/lib/test_ctf_writer_complete], [chmod +x tests/lib/test_ctf_writer_complete])
AC_CONFIG_FILES([tests/lib/test_plugin_complete], [chmod +x tests/lib/test_plugin_complete])
-AC_CONFIG_FILES([tests/lib/writer/bt_python_helper.py])
-AC_CONFIG_FILES([tests/lib/writer/test_ctf_writer_empty_packet.py])
-AC_CONFIG_FILES([tests/lib/writer/test_ctf_writer_no_packet_context.py])
AC_CONFIG_FILES([tests/plugins/test-utils-muxer-complete], [chmod +x tests/plugins/test-utils-muxer-complete])
AC_CONFIG_FILES([tests/plugins/test_dwarf_complete], [chmod +x tests/plugins/test_dwarf_complete])
AC_CONFIG_FILES([tests/plugins/test_bin_info_complete], [chmod +x tests/plugins/test_bin_info_complete])
--- /dev/null
+htmlcov
+.coverage
+test_python_babeltrace
EXTRA_DIST = \
test_reader_event.py \
test_reader_event_declaration.py \
- test_reader_field_declaration.py
+ test_reader_field_declaration.py \
+ test_ctf_writer_empty_packet.py \
+ test_ctf_writer_no_packet_context.py \
+ test_reader_trace_intersection.py
--- /dev/null
+#!/usr/bin/env python3
+#
+# The MIT License (MIT)
+#
+# Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@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.
+
+import tempfile
+import babeltrace.writer as btw
+import babeltrace.reader as btr
+import shutil
+import uuid
+import unittest
+
+class CtfWriterEmptyPacketTestCase(unittest.TestCase):
+ def setUp(self):
+ self._expected_event_count = 100
+ self._trace_path = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self._trace_path)
+
+ def _create_trace(self):
+ trace = btw.Writer(self._trace_path)
+ clock = btw.Clock('test_clock')
+ trace.add_clock(clock)
+
+ integer_field_type = btw.IntegerFieldDeclaration(32)
+
+ event_class = btw.EventClass('simple_event')
+ event_class.add_field(integer_field_type, 'int_field')
+
+ stream_class = btw.StreamClass('empty_packet_stream')
+ stream_class.add_event_class(event_class)
+ stream_class.clock = clock
+
+ stream = trace.create_stream(stream_class)
+
+ for i in range(self._expected_event_count):
+ event = btw.Event(event_class)
+ event.payload('int_field').value = i
+ stream.append_event(event)
+ stream.flush()
+
+ # The CTF writer will not be able to populate the packet context's
+ # timestamp_begin and timestamp_end fields if it is asked to flush
+ # without any queued events.
+ with self.assertRaises(ValueError):
+ stream.flush()
+
+ packet_context = stream.packet_context
+ packet_context.field('timestamp_begin').value = 1
+ packet_context.field('timestamp_end').value = 123456
+
+ stream.flush()
+
+ def test_trace_empty_packet(self):
+ self._create_trace()
+
+ traces = btr.TraceCollection()
+ trace_handle = traces.add_trace(self._trace_path, 'ctf')
+ self.assertIsNotNone(trace_handle)
+
+ event_count = sum(1 for event in traces.events)
+ self.assertEqual(self._expected_event_count, event_count)
--- /dev/null
+#!/usr/bin/env python3
+#
+# The MIT License (MIT)
+#
+# Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@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.
+
+import tempfile
+import babeltrace.writer as btw
+import babeltrace.reader as btr
+import shutil
+import uuid
+import unittest
+
+class CtfWriterNoPacketContextTestCase(unittest.TestCase):
+ def setUp(self):
+ self._expected_event_count = 100
+ self._trace_path = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self._trace_path)
+
+ def _write_trace(self):
+ trace = btw.Writer(self._trace_path)
+ clock = btw.Clock('test_clock')
+ trace.add_clock(clock)
+
+ integer_field_type = btw.IntegerFieldDeclaration(32)
+
+ event_class = btw.EventClass('simple_event')
+ event_class.add_field(integer_field_type, 'int_field')
+
+ stream_class = btw.StreamClass('test_stream')
+ stream_class.add_event_class(event_class)
+ stream_class.clock = clock
+
+ stream_class.packet_context_type = None
+ stream = trace.create_stream(stream_class)
+
+ for i in range(self._expected_event_count):
+ event = btw.Event(event_class)
+ event.payload('int_field').value = i
+ stream.append_event(event)
+ stream.flush()
+
+ # It is not valid for a stream to contain more than one packet
+ # if it does not have content_size/packet_size info in its packet
+ # context
+ event = btw.Event(event_class)
+ event.payload('int_field').value = 42
+ stream.append_event(event)
+
+ flush_raises = False
+ try:
+ stream.flush()
+ except ValueError:
+ flush_raises = True
+ self.assertTrue(flush_raises)
+ trace.flush_metadata()
+
+ def test_trace_no_packet_context(self):
+ self._write_trace()
+ traces = btr.TraceCollection()
+ trace_handle = traces.add_trace(self._trace_path, 'ctf')
+ self.assertIsNotNone(trace_handle)
+
+ event_count = sum(1 for event in traces.events)
+ self.assertEqual(self._expected_event_count, event_count)
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) 2017 - Philippe Proulx <pproulx@efficios.com>
-# 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
-#
-# 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.
-#
-
-NO_SH_TAP=1
-. "/home/jgalar/EfficiOS/src/babeltrace/tests/utils/common.sh"
-
-check_coverage() {
- coverage run "$@"
-}
-
-export BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1
-export TEST_PLUGIN_PLUGINS_PATH="${BT_BUILD_PATH}/plugins"
-export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/plugins/ctf:${BT_BUILD_PATH}/plugins/utils:${BT_BUILD_PATH}/plugins/text"
-export LD_LIBRARY_PATH="${BT_BUILD_PATH}/lib/.libs"
-PYTHON_BUILD_DIR="${BT_BUILD_PATH}/bindings/python/bt2/build/build_lib:${BT_BUILD_PATH}/bindings/python/babeltrace/build/build_lib"
-TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python"
-TESTS_CTF_TRACES="${BT_SRC_PATH}/tests/ctf-traces"
-TESTRUNNER_PY="${BT_SRC_PATH}/tests/utils/python/testrunner.py"
-THIS_DIR="${BT_SRC_PATH}/tests/bindings/python/babeltrace"
-
-if test "x$TESTALL_COVERAGE" = "x1"; then
- EXEC=check_coverage
-else
- EXEC="/usr/bin/python"
-
-fi
-
-PYTHONPATH="$PYTHON_BUILD_DIR:$TESTS_UTILS_PYTHON_DIR" \
- "$EXEC" "$TESTRUNNER_PY" "$THIS_DIR"
-res=$?
-
-if test "x$TESTALL_COVERAGE_REPORT" = "x1"; then
- coverage report -m
-fi
-
-if test "x$TESTALL_COVERAGE_HTML" = "x1"; then
- coverage html
-fi
-
-exit $res
export TEST_PLUGIN_PLUGINS_PATH="${BT_BUILD_PATH}/plugins"
export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/plugins/ctf:${BT_BUILD_PATH}/plugins/utils:${BT_BUILD_PATH}/plugins/text"
export LD_LIBRARY_PATH="${BT_BUILD_PATH}/lib/.libs"
+export TEST_CTF_TRACES_PATH="${BT_BUILD_PATH}/tests/ctf-traces"
PYTHON_BUILD_DIR="${BT_BUILD_PATH}/bindings/python/bt2/build/build_lib:${BT_BUILD_PATH}/bindings/python/babeltrace/build/build_lib"
TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python"
TESTS_CTF_TRACES="${BT_SRC_PATH}/tests/ctf-traces"
--- /dev/null
+#!/usr/bin/env python3
+#
+# The MIT License (MIT)
+#
+# Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@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.
+
+import tempfile
+import babeltrace.writer as btw
+import babeltrace.reader as btr
+import uuid
+import shutil
+import unittest
+
+class Entry(object):
+ def __init__(self, stream_id, timestamp=None, end_of_packet=False):
+ self.stream_id = stream_id
+ self.timestamp = timestamp
+ self.end_of_packet = end_of_packet
+
+
+class Packet(object):
+ def __init__(self, timestamps):
+ self.timestamps = timestamps
+
+
+class TraceIntersectionTestCase(unittest.TestCase):
+ def _create_trace(self, stream_descriptions):
+ trace_path = tempfile.mkdtemp()
+ trace = btw.Writer(trace_path)
+ clock = btw.Clock('test_clock')
+ clock.uuid = self._clock_uuid
+ trace.add_clock(clock)
+
+ integer_field_type = btw.IntegerFieldDeclaration(32)
+
+ event_class = btw.EventClass('simple_event')
+ event_class.add_field(integer_field_type, 'int_field')
+
+ stream_class = btw.StreamClass('test_stream')
+ stream_class.add_event_class(event_class)
+ stream_class.clock = clock
+
+ streams = []
+ stream_entries = []
+ for stream_id, stream_packets in enumerate(stream_descriptions):
+ stream = trace.create_stream(stream_class)
+ streams.append(stream)
+
+ for packet in stream_packets:
+ for timestamp in packet.timestamps:
+ stream_entries.append(Entry(stream_id, timestamp))
+ # Mark the last inserted entry as the end of packet
+ stream_entries[len(stream_entries) - 1].end_of_packet = True
+
+ # Sort stream entries which will provide us with a time-ordered list of
+ # events to insert in the streams.
+ for entry in sorted(stream_entries, key=lambda entry: entry.timestamp):
+ clock.time = entry.timestamp
+ event = btw.Event(event_class)
+ event.payload('int_field').value = entry.stream_id
+ streams[entry.stream_id].append_event(event)
+ if entry.end_of_packet is True:
+ streams[entry.stream_id].flush()
+
+ return trace_path
+
+ def setUp(self):
+ self._clock_uuid = uuid.uuid4()
+ self._trace_path_early = self._create_trace(
+ [
+ [Packet(range(1, 7)), Packet(range(11, 18))],
+ [Packet(range(8, 15)), Packet(range(22, 24)), Packet(range(30, 60))],
+ [Packet(range(11, 14))]
+ ]
+ )
+ self._trace_path_late = self._create_trace(
+ [
+ [Packet(range(100, 105)), Packet(range(109, 120))],
+ [Packet(range(88, 95)), Packet(range(96, 110)), Packet(range(112, 140))],
+ [Packet(range(99, 105))]
+ ]
+ )
+
+ self._expected_timestamps_early = []
+ for ts in range(11, 14):
+ for stream in range(3):
+ self._expected_timestamps_early.append(ts)
+
+ self._expected_timestamps_late = []
+ for ts in range(100, 105):
+ for stream in range(3):
+ self._expected_timestamps_late.append(ts)
+
+ self._expected_timestamps_union = (self._expected_timestamps_early +
+ self._expected_timestamps_late)
+
+ def tearDown(self):
+ shutil.rmtree(self._trace_path_early)
+ shutil.rmtree(self._trace_path_late)
+ pass
+
+ @staticmethod
+ def _check_trace_expected_timestamps(trace_paths, expected_timestamps):
+ traces = btr.TraceCollection(intersect_mode=True)
+ for trace_path in trace_paths:
+ trace_handle = traces.add_trace(trace_path, 'ctf')
+ if trace_handle is None:
+ print('# Failed to open trace at {}'.format(trace_path))
+ return False
+ for event in traces.events:
+ expected_timestamp = expected_timestamps.pop(0)
+ if event.timestamp != expected_timestamp:
+ print('# Unexpected timestamp ({}), expected {}'.format(
+ event.timestamp, expected_timestamp))
+ return False
+ return True
+
+ def test_trace_early(self):
+ self._check_trace_expected_timestamps([self._trace_path_early],
+ self._expected_timestamps_early)
+
+ def test_trace_late(self):
+ self._check_trace_expected_timestamps([self._trace_path_late],
+ self._expected_timestamps_late)
+
+ def test_trace_intersection(self):
+ self._check_trace_expected_timestamps([self._trace_path_early,
+ self._trace_path_late],
+ self._expected_timestamps_union)
-check_SCRIPTS = test_intersection \
- bt_python_helper.py \
- test_multi_trace_intersection.py
-
-dist_noinst_SCRIPTS = test_multi_trace_intersection.py
-EXTRA_DIST=test_multi_trace_intersection.py
+check_SCRIPTS = test_intersection
all-local:
@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+++ /dev/null
-#!/usr/bin/env python3
-#
-# The MIT License (MIT)
-#
-# Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@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.
-
-import sys
-
-# Point the Python interpreter to the builddir's library and Babeltrace
-# bindings
-bt_module_path = '@abs_top_builddir@/bindings/python'
-bt_lib_py_path = '@abs_top_builddir@/bindings/python/babeltrace/.libs'
-bt_lib_bt_path = '@abs_top_builddir@/lib/.libs'
-bt_lib_ctf_path = '@abs_top_builddir@/format/ctf/.libs'
-
-sys.path.insert(0, bt_module_path)
-sys.path.insert(1, bt_lib_py_path)
-sys.path.insert(2, bt_lib_bt_path)
-sys.path.insert(3, bt_lib_ctf_path)
+++ /dev/null
-#!/usr/bin/env python3
-#
-# The MIT License (MIT)
-#
-# Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@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.
-
-import bt_python_helper
-import tempfile
-import babeltrace.writer as btw
-import babeltrace.reader as btr
-import uuid
-import shutil
-
-
-class Entry(object):
- def __init__(self, stream_id, timestamp=None, end_of_packet=False):
- self.stream_id = stream_id
- self.timestamp = timestamp
- self.end_of_packet = end_of_packet
-
-
-class Packet(object):
- def __init__(self, timestamps):
- self.timestamps = timestamps
-
-clock_uuid = uuid.uuid4()
-
-# stream_descriptions is a list of lists of Packets.
-# Each stream description list is mapped to a single stream instance.
-def create_trace(path, clock_uuid, stream_descriptions):
- trace = btw.Writer(path)
- clock = btw.Clock('test_clock')
- clock.uuid = clock_uuid
- trace.add_clock(clock)
-
- integer_field_type = btw.IntegerFieldDeclaration(32)
-
- event_class = btw.EventClass('simple_event')
- event_class.add_field(integer_field_type, 'int_field')
-
- stream_class = btw.StreamClass('test_stream')
- stream_class.add_event_class(event_class)
- stream_class.clock = clock
-
- streams = []
- stream_entries = []
- for stream_id, stream_packets in enumerate(stream_descriptions):
- stream = trace.create_stream(stream_class)
- streams.append(stream)
-
- for packet in stream_packets:
- for timestamp in packet.timestamps:
- stream_entries.append(Entry(stream_id, timestamp))
- # Mark the last inserted entry as the end of packet
- stream_entries[len(stream_entries) - 1].end_of_packet = True
-
- # Sort stream entries which will provide us with a time-ordered list of
- # events to insert in the streams.
- for entry in sorted(stream_entries, key=lambda entry: entry.timestamp):
- clock.time = entry.timestamp
- event = btw.Event(event_class)
- event.payload('int_field').value = entry.stream_id
- streams[entry.stream_id].append_event(event)
- if entry.end_of_packet is True:
- streams[entry.stream_id].flush()
-
-
-def check_trace_expected_timestamps(trace_paths, expected_timestamps):
- traces = btr.TraceCollection(intersect_mode=True)
- for trace_path in trace_paths:
- trace_handle = traces.add_trace(trace_path, 'ctf')
- if trace_handle is None:
- print('Failed to open trace at {}'.format(trace_path))
- return False
- for event in traces.events:
- expected_timestamp = expected_timestamps.pop(0)
- if event.timestamp != expected_timestamp:
- print('# Unexpected timestamp ({}), expected {}'.format(
- event.timestamp, expected_timestamp))
- return False
- return True
-
-
-def print_test_result(test_number, result, description):
- result_string = 'ok' if result else 'not ok'
- result_string += ' {} - {}'.format(test_number, description)
- print(result_string)
-
-TEST_COUNT = 3
-# TAP plan
-print('1..{}'.format(TEST_COUNT))
-
-trace_path_early = tempfile.mkdtemp()
-
-# The stream intersection of this trace is event timestamps 11, 12 and 13,
-# accounting for 9 events in stream-intersection mode
-print('# Creating early trace at {}'.format(trace_path_early))
-create_trace(trace_path_early, clock_uuid, [
- [Packet(range(1, 7)), Packet(range(11, 18))],
- [Packet(range(8, 15)), Packet(range(22, 24)), Packet(range(30, 60))],
- [Packet(range(11, 14))]
- ])
-
-trace_path_late = tempfile.mkdtemp()
-print('# Creating late trace at {}'.format(trace_path_late))
-# The stream intersection of this trace is event timestamps 100, 101, 102, 103
-# and 104 accounting for 15 events in stream-intersection mode
-create_trace(trace_path_late, clock_uuid, [
- [Packet(range(100, 105)), Packet(range(109, 120))],
- [Packet(range(88, 95)), Packet(range(96, 110)), Packet(range(112, 140))],
- [Packet(range(99, 105))]
- ])
-
-expected_timestamps_early = []
-for ts in range(11, 14):
- for stream in range(3):
- expected_timestamps_early.append(ts)
-
-expected_timestamps_late = []
-for ts in range(100, 105):
- for stream in range(3):
- expected_timestamps_late.append(ts)
-
-expected_timestamps_union = (expected_timestamps_early +
- expected_timestamps_late)
-
-# Validate that the stream-intersection mode on a single trace returns only
-# the events that are in overlapping packets across all of the trace's streams.
-result = check_trace_expected_timestamps([trace_path_early],
- expected_timestamps_early)
-print_test_result(1, result, 'Validating expected event timestamps of "early" trace')
-
-result = check_trace_expected_timestamps([trace_path_late],
- expected_timestamps_late)
-print_test_result(2, result, 'Validating expected event timestamps of "late" trace')
-
-result = check_trace_expected_timestamps([trace_path_early, trace_path_late],
- expected_timestamps_union)
-print_test_result(3, result, 'Validating expected event timestamps of the union of "early" and "late" traces')
-
-shutil.rmtree(trace_path_early)
-shutil.rmtree(trace_path_late)
-SUBDIRS = writer .
+SUBDIRS=
AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+++ /dev/null
-check_SCRIPTS = test_ctf_writer_no_packet_context.py \
- test_ctf_writer_empty_packet.py
+++ /dev/null
-#!/usr/bin/env python3
-#
-# The MIT License (MIT)
-#
-# Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@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.
-
-import sys
-
-# Point the Python interpreter to the builddir's library and Babeltrace
-# bindings
-bt_module_path = '@abs_top_builddir@/bindings/python'
-bt_lib_py_path = '@abs_top_builddir@/bindings/python/babeltrace/.libs'
-bt_lib_bt_path = '@abs_top_builddir@/lib/.libs'
-bt_lib_ctf_path = '@abs_top_builddir@/format/ctf/.libs'
-
-sys.path.insert(0, bt_module_path)
-sys.path.insert(1, bt_lib_py_path)
-sys.path.insert(2, bt_lib_bt_path)
-sys.path.insert(3, bt_lib_ctf_path)
+++ /dev/null
-#!/usr/bin/env python3
-#
-# The MIT License (MIT)
-#
-# Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@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.
-
-import bt_python_helper
-import tempfile
-import babeltrace.writer as btw
-import babeltrace.reader as btr
-import shutil
-import uuid
-
-TEST_COUNT = 4
-EXPECTED_EVENT_COUNT = 10
-trace_path = tempfile.mkdtemp()
-
-
-def print_test_result(test_number, result, description):
- result_string = 'ok' if result else 'not ok'
- result_string += ' {} - {}'.format(test_number, description)
- print(result_string)
-
-def create_trace(path):
- trace = btw.Writer(path)
- clock = btw.Clock('test_clock')
- trace.add_clock(clock)
-
- integer_field_type = btw.IntegerFieldDeclaration(32)
-
- event_class = btw.EventClass('simple_event')
- event_class.add_field(integer_field_type, 'int_field')
-
- stream_class = btw.StreamClass('empty_packet_stream')
- stream_class.add_event_class(event_class)
- stream_class.clock = clock
-
- stream = trace.create_stream(stream_class)
-
- for i in range(EXPECTED_EVENT_COUNT):
- event = btw.Event(event_class)
- event.payload('int_field').value = i
- stream.append_event(event)
- stream.flush()
- print_test_result(1, True,
- 'Flush a packet containing {} events'.format(EXPECTED_EVENT_COUNT))
-
- # The CTF writer will not be able to populate the packet context's
- # timestamp_begin and timestamp_end fields if it is asked to flush
- # without any queued events.
- try:
- stream.flush()
- empty_flush_succeeded = True
- except ValueError:
- empty_flush_succeeded = False
-
- print_test_result(2, not empty_flush_succeeded,
- 'Flushing an empty packet without explicitly setting packet time bounds should fail')
- packet_context = stream.packet_context
- packet_context.field('timestamp_begin').value = 1
- packet_context.field('timestamp_end').value = 123456
- try:
- stream.flush()
- empty_flush_succeeded = True
- except ValueError:
- empty_flush_succeeded = False
-
- print_test_result(3, empty_flush_succeeded,
- 'Flushing an empty packet after explicitly setting packet time bounds should succeed')
-
-
-# TAP plan
-print('1..{}'.format(TEST_COUNT))
-print('# Creating trace at {}'.format(trace_path))
-create_trace(trace_path)
-
-traces = btr.TraceCollection()
-trace_handle = traces.add_trace(trace_path, 'ctf')
-if trace_handle is None:
- print('Failed to open trace at {}'.format(trace_path))
-
-event_count = 0
-for event in traces.events:
- event_count += 1
-
-print_test_result(4, EXPECTED_EVENT_COUNT == event_count,
- 'Trace was found to contain {} events, expected {}'.format(
- event_count, EXPECTED_EVENT_COUNT))
-
-shutil.rmtree(trace_path)
+++ /dev/null
-#!/usr/bin/env python3
-#
-# The MIT License (MIT)
-#
-# Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@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.
-
-import bt_python_helper
-import tempfile
-import babeltrace.writer as btw
-import babeltrace.reader as btr
-import shutil
-import uuid
-
-TEST_COUNT = 4
-EXPECTED_EVENT_COUNT = 10
-trace_path = tempfile.mkdtemp()
-
-
-def print_test_result(test_number, result, description):
- result_string = 'ok' if result else 'not ok'
- result_string += ' {} - {}'.format(test_number, description)
- print(result_string)
-
-def create_trace(path):
- trace = btw.Writer(path)
- clock = btw.Clock('test_clock')
- trace.add_clock(clock)
-
- integer_field_type = btw.IntegerFieldDeclaration(32)
-
- event_class = btw.EventClass('simple_event')
- event_class.add_field(integer_field_type, 'int_field')
-
- stream_class = btw.StreamClass('test_stream')
- stream_class.add_event_class(event_class)
- stream_class.clock = clock
-
- stream_class.packet_context_type = None
- print_test_result(1, stream_class.packet_context_type is None,
- 'Set stream class packet context type to None')
-
- stream = trace.create_stream(stream_class)
-
- for i in range(EXPECTED_EVENT_COUNT):
- event = btw.Event(event_class)
- event.payload('int_field').value = i
- stream.append_event(event)
- stream.flush()
- print_test_result(2, True,
- 'Flush a packet')
-
- # It is not valid for a stream to contain more than one packet
- # if it does not have content_size/packet_size info in its packet
- # context
- event = btw.Event(event_class)
- event.payload('int_field').value = 42
- stream.append_event(event)
- try:
- stream.flush()
- second_flush_succeeded = True
- except ValueError:
- second_flush_succeeded = False
-
- print_test_result(3, not second_flush_succeeded,
- 'Flushing a second packet in a stream without a defined packet context fails')
-
-
-# TAP plan
-print('1..{}'.format(TEST_COUNT))
-print('# Creating trace at {}'.format(trace_path))
-create_trace(trace_path)
-
-traces = btr.TraceCollection()
-trace_handle = traces.add_trace(trace_path, 'ctf')
-if trace_handle is None:
- print('Failed to open trace at {}'.format(trace_path))
-
-event_count = 0
-for event in traces.events:
- event_count += 1
-
-print_test_result(4, EXPECTED_EVENT_COUNT == event_count,
- 'Trace was found to contain {} events, expected {}'.format(
- event_count, EXPECTED_EVENT_COUNT))
-
-shutil.rmtree(trace_path)