From: Philippe Proulx Date: Fri, 5 May 2017 20:49:32 +0000 (-0400) Subject: Rename tests/bin -> tests/cli X-Git-Tag: v2.0.0-pre1~306 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=a8101b9166f96a7343965b6af219a848752869bd Rename tests/bin -> tests/cli Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/configure.ac b/configure.ac index 8dc537a3..b12fe3d2 100644 --- a/configure.ac +++ b/configure.ac @@ -479,8 +479,8 @@ AC_CONFIG_FILES([ bindings/python/bt2/Makefile bindings/python/bt2/__init__.py tests/Makefile - tests/bin/Makefile - tests/bin/intersection/Makefile + tests/cli/Makefile + tests/cli/intersection/Makefile tests/lib/Makefile tests/lib/writer/Makefile tests/lib/test-plugin-plugins/Makefile @@ -524,11 +524,11 @@ AC_CONFIG_FILES([tests/lib/test_bin_info_complete], [chmod +x tests/lib/test_bin AC_CONFIG_FILES([tests/plugins/test-utils-muxer-complete], [chmod +x tests/plugins/test-utils-muxer-complete]) -AC_CONFIG_FILES([tests/bin/test_trace_read], [chmod +x tests/bin/test_trace_read]) -AC_CONFIG_FILES([tests/bin/intersection/test_intersection], [chmod +x tests/bin/intersection/test_intersection]) -AC_CONFIG_FILES([tests/bin/intersection/bt_python_helper.py]) +AC_CONFIG_FILES([tests/cli/test_trace_read], [chmod +x tests/cli/test_trace_read]) +AC_CONFIG_FILES([tests/cli/intersection/test_intersection], [chmod +x tests/cli/intersection/test_intersection]) +AC_CONFIG_FILES([tests/cli/intersection/bt_python_helper.py]) AC_CONFIG_FILES([tests/lib/writer/bt_python_helper.py]) -AC_CONFIG_FILES([tests/bin/test_packet_seq_num], [chmod +x tests/bin/test_packet_seq_num]) +AC_CONFIG_FILES([tests/cli/test_packet_seq_num], [chmod +x tests/cli/test_packet_seq_num]) AS_IF([test "x$enable_python" = "xyes"], [ AC_CONFIG_FILES( diff --git a/tests/Makefile.am b/tests/Makefile.am index 6df77579..a9bd7991 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = utils bin lib bindings plugins +SUBDIRS = utils cli lib bindings plugins EXTRA_DIST = $(srcdir)/ctf-traces/** \ $(srcdir)/debug-info-data/** \ diff --git a/tests/bin/Makefile.am b/tests/bin/Makefile.am deleted file mode 100644 index 97d8eeba..00000000 --- a/tests/bin/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -SUBDIRS = intersection -check_SCRIPTS = test_trace_read test_packet_seq_num test_convert_args - -LOG_DRIVER_FLAGS='--merge' -LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh - -TESTS = test_trace_read \ - test_trace_read \ - test_packet_seq_num \ - test_convert_args \ - intersection/test_intersection - -if USE_PYTHON -TESTS += intersection/test_multi_trace_intersection.py -endif diff --git a/tests/bin/intersection/Makefile.am b/tests/bin/intersection/Makefile.am deleted file mode 100644 index 6c7330e5..00000000 --- a/tests/bin/intersection/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -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 - -all-local: - @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ - for script in $(EXTRA_DIST); do \ - cp -f $(srcdir)/$$script $(builddir); \ - done; \ - fi - -clean-local: - @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ - for script in $(EXTRA_DIST); do \ - rm -f $(builddir)/$$script; \ - done; \ - fi diff --git a/tests/bin/intersection/bt_python_helper.py.in b/tests/bin/intersection/bt_python_helper.py.in deleted file mode 100644 index 4b9fcaf7..00000000 --- a/tests/bin/intersection/bt_python_helper.py.in +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -# -# The MIT License (MIT) -# -# Copyright (C) 2016 - Jérémie Galarneau -# -# 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) diff --git a/tests/bin/intersection/test_intersection.in b/tests/bin/intersection/test_intersection.in deleted file mode 100644 index d70367f2..00000000 --- a/tests/bin/intersection/test_intersection.in +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2015 Julien Desfossez -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# 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., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TESTDIR=@abs_top_srcdir@/tests - -BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source $TESTDIR/utils/tap/tap.sh - -NUM_TESTS=10 - -plan_tests $NUM_TESTS - -test_intersect() { - trace=$1 - totalevents=$2 - intersect=$3 - - test $($BABELTRACE_BIN $trace | wc -l) = $totalevents - ok $? "$totalevents events in the whole trace" - test $($BABELTRACE_BIN --stream-intersection $trace 2>/dev/null| wc -l) = $intersect - ok $? "$intersect events in packets intersecting" -} - -diag "Test the stream intersection feature" - -diag "2 streams offsetted with 3 packets intersecting" -test_intersect ${CTF_TRACES}/intersection/3eventsintersect 8 3 - -diag "2 streams offsetted with 3 packets intersecting (exchanged file names)" -test_intersect ${CTF_TRACES}/intersection/3eventsintersectreverse 8 3 - -diag "No intersection between 2 streams" -test_intersect ${CTF_TRACES}/intersection/nointersect 6 0 - -diag "Only 1 stream" -test_intersect ${CTF_TRACES}/intersection/onestream 3 3 - -diag "No stream at all" -test_intersect ${CTF_TRACES}/intersection/nostream 0 0 diff --git a/tests/bin/intersection/test_multi_trace_intersection.py b/tests/bin/intersection/test_multi_trace_intersection.py deleted file mode 100755 index b4368a11..00000000 --- a/tests/bin/intersection/test_multi_trace_intersection.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env python3 -# -# The MIT License (MIT) -# -# Copyright (C) 2016 - Jérémie Galarneau -# -# 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) diff --git a/tests/bin/test_convert_args b/tests/bin/test_convert_args deleted file mode 100755 index 9ed64e25..00000000 --- a/tests/bin/test_convert_args +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) - 2017 Philippe Proulx -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# 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., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -curdir="$(dirname $0)" -testdir="$curdir/.." -babeltrace_bin="$curdir/../../cli/babeltrace" - -source $testdir/utils/tap/tap.sh - -test_bt_convert_run_args() { - local what="$1" - local convert_args="$2" - local expected_run_args="$3" - - # execute convert command - local run_args="$("$babeltrace_bin" convert --run-args $convert_args)" - - # check result - if [ "$test_head_comment" = 1 ]; then - comment "convert args: $convert_args" - fi - - if [ "$run_args" == "$expected_run_args" ]; then - pass "ARGS: $what" - else - fail "ARGS: $what" - diag "EXPECTED: $expected_run_args" - diag "GOT: $run_args" - fi -} - -test_bt_convert_fails() { - local what="$1" - local convert_args="$2" - - # execute convert command - "$babeltrace_bin" convert --run-args $convert_args &> /dev/null - - local status=$? - - # check result - if [ "$test_head_comment" = 1 ]; then - comment "convert args: $convert_args" - fi - - if [ $status == 0 ]; then - fail "SUCCEEDS (should fail): $what" - diag "ARGS: $convert_args" - else - pass "FAILS: $what" - fi -} - -comment() { - echo "### $1 ###" -} - -plan_tests 82 - -test_bt_convert_run_args 'path leftover' '/path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + named user source with --params' '/path/to/trace --source ZZ:another.source --params salut=yes' '--source ZZ:another.source --params salut=yes --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ZZ:muxer --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + named user source with --name --params' '/path/to/trace --source another.source --name HELLO --params salut=yes' '--source another.source --name HELLO --params salut=yes --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect HELLO:muxer --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + user source with --path --params' '/path/to/trace --source another.source --path some-path --params salut=yes' "--source another.source --key path --value some-path --params salut=yes --name another.source --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect 'another\\.source:muxer' --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty" -test_bt_convert_run_args 'user source with --url + -o dummy' '--source MY:my.source --url the-url -o dummy' '--source MY:my.source --key url --value the-url --sink utils.dummy --name dummy --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect MY:muxer --connect muxer:debug-info --connect debug-info:dummy' -test_bt_convert_run_args 'path leftover + --omit-home-plugin-path' '/path/to/trace --omit-home-plugin-path' '--omit-home-plugin-path --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --omit-system-plugin-path' '/path/to/trace --omit-system-plugin-path' '--omit-system-plugin-path --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --plugin-path' '--plugin-path=PATH1:PATH2 /path/to/trace' '--plugin-path PATH1:PATH2 --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'unnamed user source' '--source salut.com' "--source salut.com --name salut.com --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect 'salut\.com:muxer' --connect muxer:debug-info --connect debug-info:pretty" -test_bt_convert_run_args 'path leftover + user source named `ctf-fs`' '--source ctf-fs:salut.com /path/to/trace' "--source ctf-fs:salut.com --source ctf.fs --name ctf-fs-0 --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect ctf-fs-0:muxer --connect muxer:debug-info --connect debug-info:pretty" -test_bt_convert_run_args 'path leftover + user sink named `pretty`' '--sink pretty:my.sink /path/to/trace' '--sink pretty:my.sink --source ctf.fs --name ctf-fs --key path --value /path/to/trace --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-seconds + user sink named `pretty`' '--clock-seconds --sink pretty:my.sink /path/to/trace' '--sink pretty:my.sink --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty-0 --params clock-seconds=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty --connect debug-info:pretty-0' -test_bt_convert_run_args 'path leftover + user filter named `muxer`' '--filter muxer:salut.com /path/to/trace' '--filter muxer:salut.com --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer-0 --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer-0 --connect muxer-0:debug-info --connect debug-info:muxer --connect muxer:pretty' -test_bt_convert_run_args 'path leftover + --begin + user filter named `trimmer`' '/path/to/trace --filter trimmer:salut.com --begin=abc' '--filter trimmer:salut.com --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer-0 --key begin --value abc --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer-0 --connect trimmer-0:debug-info --connect debug-info:trimmer --connect trimmer:pretty' -test_bt_convert_run_args 'path leftover + --plugin-path' '/path/to/trace --plugin-path a:b:c' '--plugin-path a:b:c --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --omit-home-plugin-path --omit-system-plugin-path' '/path/to/trace --omit-home-plugin-path --omit-system-plugin-path' '--omit-home-plugin-path --omit-system-plugin-path --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --begin' '/path/to/trace --begin=123' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer --key begin --value 123 --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer --connect trimmer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --begin --end' '/path/to/trace --end=456 --begin 123' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer --key end --value 456 --key begin --value 123 --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer --connect trimmer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --timerange' '/path/to/trace --timerange=[abc,xyz]' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer --key begin --value abc --key end --value xyz --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer --connect trimmer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-cycles' '/path/to/trace --clock-cycles' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-cycles=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-date' '/path/to/trace --clock-date' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-date=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --force-correlate' '/path/to/trace --clock-force-correlate' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --params force-correlate=yes --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-gmt' '/path/to/trace --clock-gmt' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-gmt=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-offset' '/path/to/trace --clock-offset=15487' '--source ctf.fs --name ctf-fs --key clock-offset-cycles --value 15487 --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-offset-ns' '/path/to/trace --clock-offset-ns=326159487' '--source ctf.fs --name ctf-fs --key clock-offset-ns --value 326159487 --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --clock-seconds' '/path/to/trace --clock-seconds' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-seconds=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --color' '/path/to/trace --color=never' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --key color --value never --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --no-debug-info' '/path/to/trace --no-debug-info' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --connect ctf-fs:muxer --connect muxer:pretty' -test_bt_convert_run_args 'path leftover + --debug-info-dir' '/path/to/trace --debug-info-dir=/salut' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --key dir --value /salut --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --debug-info-target-prefix' '/path/to/trace --debug-info-target-prefix=/salut' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --key target-prefix --value /salut --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --debug-info-full-path' '/path/to/trace --debug-info-full-path' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --params full-path=yes --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --fields=trace:domain,loglevel' '--fields=trace:domain,loglevel /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params field-trace:domain=yes,field-loglevel=yes,field-default=hide --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --fields=all' '--fields=all /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params field-default=show --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --names=context,header' '--names=context,header /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params name-context=yes,name-header=yes,name-default=hide --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --names=all' '--names=all /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params name-default=show --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --no-delta' '/path/to/trace --no-delta' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params no-delta=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --output' '/path/to/trace --output /salut' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --key path --value /salut --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + --stream-intersection' '/path/to/trace --stream-intersection' '--source ctf.fs --name ctf-fs --params stream-intersection=yes --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + -i ctf' '/path/to/trace -i ctf' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'URL leftover + -i lttng-live' 'net://some-host/host/target/session -i lttng-live' '--source ctf.lttng-live --name lttng-live --key url --value net://some-host/host/target/session --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect lttng-live:muxer --connect muxer:debug-info --connect debug-info:pretty' -test_bt_convert_run_args 'path leftover + user sink + -o text' '/path/to/trace --sink=abc.def -o text' "--sink abc.def --name abc.def --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect 'debug-info:abc\.def' --connect debug-info:pretty" -test_bt_convert_run_args 'path leftover + -o dummy' '/path/to/trace -o dummy' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink utils.dummy --name dummy --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:dummy' -test_bt_convert_run_args 'path leftover + -o dummy + --clock-seconds' '/path/to/trace -o dummy --clock-seconds' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-seconds=yes --sink utils.dummy --name dummy --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty --connect debug-info:dummy' - -test_bt_convert_fails 'bad --source format (plugin only)' '--source salut' -test_bt_convert_fails 'bad --source format (name and plugin only)' '--source name:salut' -test_bt_convert_fails 'bad --source format (name only)' '--source name:' -test_bt_convert_fails 'bad --source format (extra dot found)' '--source name:plugin.comp.cls' -test_bt_convert_fails 'bad --filter format (plugin only)' '--filter salut' -test_bt_convert_fails 'bad --filter format (name and plugin only)' '--filter name:salut' -test_bt_convert_fails 'bad --filter format (name only)' '--filter name:' -test_bt_convert_fails 'bad --filter format (extra dot found)' '--filter name:plugin.comp.cls' -test_bt_convert_fails 'bad --sink format (plugin only)' '--sink salut' -test_bt_convert_fails 'bad --sink format (name and plugin only)' '--sink name:salut' -test_bt_convert_fails 'bad --sink format (name only)' '--sink name:' -test_bt_convert_fails 'bad --sink format (extra dot found)' '--sink name:plugin.comp.cls' -test_bt_convert_fails 'duplicate component name' '--sink hello:a.b --source hello:c.d' -test_bt_convert_fails 'unknown option' '--sink hello:a.b --salut' -test_bt_convert_fails '--params without current component' '--params lol=23' -test_bt_convert_fails '--path without current component' '--path /path/to/trace' -test_bt_convert_fails '--url without current component' '--url net://some-host/host/target/session' -test_bt_convert_fails '--nane without current component' '--name chapeau' -test_bt_convert_fails 'duplicate --begin' '--begin abc --clock-seconds --begin cde' -test_bt_convert_fails 'duplicate --end' '--begin abc --end xyz --clock-seconds --end cde' -test_bt_convert_fails '--begin and --timerange' '--begin abc --clock-seconds --timerange abc,def' -test_bt_convert_fails '--end and --timerange' '--end abc --clock-seconds --timerange abc,def' -test_bt_convert_fails 'bad --timerange format (1)' '--timerange abc' -test_bt_convert_fails 'bad --timerange format (2)' '--timerange abc,' -test_bt_convert_fails 'bad --timerange format (3)' '--timerange ,cde' -test_bt_convert_fails 'bad --fields format' '--fields salut' -test_bt_convert_fails 'bad --names format' '--names salut' -test_bt_convert_fails 'unknown -i' '-i lol' -test_bt_convert_fails 'duplicate -i' '-i lttng-live --clock-seconds --input-format=ctf' -test_bt_convert_fails 'unknown -o' '-o lol' -test_bt_convert_fails 'duplicate -o' '-o dummy --clock-seconds --output-format=text' -test_bt_convert_fails '--run-args and --run-args-0' '/path/to/trace --run-args --run-args-0' -test_bt_convert_fails 'duplicate -v' '/path/to/trace -vv' -test_bt_convert_fails 'two leftover arguments' '/path/to/trace /other/path' -test_bt_convert_fails '-o ctf-metadata without path' '-o ctf-metadata' -test_bt_convert_fails '-i lttng-live and implicit ctf.fs source' '-i lttng-live net://some-host/host/target/session --clock-offset=23' -test_bt_convert_fails 'implicit ctf.fs source without path' '--clock-offset=23' -test_bt_convert_fails 'implicit ctf.lttng-live source without URL' '-i lttng-live' -test_bt_convert_fails 'no source' '-o text' diff --git a/tests/bin/test_formats.in b/tests/bin/test_formats.in deleted file mode 100644 index 4bd32ea0..00000000 --- a/tests/bin/test_formats.in +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2016 Nathan Lynch -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# 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., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. - -BABELTRACE_BIN=$CURDIR/../../cli/babeltrace - -source $TESTDIR/utils/tap/tap.sh - -expected_formats=(text lttng-live dummy ctf-metadata ctf) - -plan_tests ${#expected_formats[*]} - -for format in "${expected_formats[@]}"; do - "$BABELTRACE_BIN" --list | @GREP@ -qw "$format" - ok $? "Detect support for format \"$format\"" -done diff --git a/tests/bin/test_packet_seq_num.in b/tests/bin/test_packet_seq_num.in deleted file mode 100644 index 640793b7..00000000 --- a/tests/bin/test_packet_seq_num.in +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2015 Julien Desfossez -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# 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., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. - -BABELTRACE_BIN=$CURDIR/../../cli/babeltrace -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source $TESTDIR/utils/tap/tap.sh - -NUM_TESTS=10 - -plan_tests $NUM_TESTS - -test_no_lost() { - trace=$1 - - $BABELTRACE_BIN $trace >/dev/null 2>&1 - ok $? "Trace parses" - $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" - if test $? = 0; then - fail 1 "Should not find any lost events" - else - ok 0 "No events lost" - fi -} - -test_lost() { - trace=$1 - expectedcountstr=$2 - - $BABELTRACE_BIN $trace >/dev/null 2>&1 - ok $? "Trace parses" - - # Convert warnings like: - # [warning] Tracer lost 2 trace packets between .... - # [warning] Tracer lost 3 trace packets between .... - # into "2,3" and make sure it matches the expected result - $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" \ - | cut -d" " -f4 | tr "\n" "," | @SED@ "s/.$//" | \ - @GREP@ "$expectedcountstr" >/dev/null - ok $? "Lost events string matches $expectedcountstr" - -} - -diag "Test the packet_seq_num validation" - -diag "No packet lost" -test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost - -diag "No packet lost, packet_seq_num not starting at 0" -test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0 - -diag "1 stream, 2 packets lost before the last packet" -test_lost ${CTF_TRACES}/packet_seq_num/2_lost_before_last "2" - -diag "2 streams, packets lost in one of them" -test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_1 "2" - -diag "2 streams, packets lost in both" -test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_2 "3,2,1" diff --git a/tests/bin/test_trace_read.in b/tests/bin/test_trace_read.in deleted file mode 100644 index 1325eb39..00000000 --- a/tests/bin/test_trace_read.in +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2013 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# 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., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. - -BABELTRACE_BIN=$CURDIR/../../cli/babeltrace - -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source $TESTDIR/utils/tap/tap.sh - -SUCCESS_TRACES=(${CTF_TRACES}/succeed/*) -FAIL_TRACES=(${CTF_TRACES}/fail/*) - -NUM_TESTS=$((${#SUCCESS_TRACES[@]} + ${#FAIL_TRACES[@]})) - -plan_tests $NUM_TESTS - -for path in ${SUCCESS_TRACES[@]}; do - trace=$(basename ${path}) - $BABELTRACE_BIN ${path} > /dev/null 2>&1 - ok $? "Run babeltrace with trace ${trace}" -done - -for path in ${FAIL_TRACES[@]}; do - trace=$(basename ${path}) - $BABELTRACE_BIN ${path} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - fail "Run babeltrace with invalid trace ${trace}" - else - pass "Run babeltrace with invalid trace ${trace}" - fi -done diff --git a/tests/cli/Makefile.am b/tests/cli/Makefile.am new file mode 100644 index 00000000..97d8eeba --- /dev/null +++ b/tests/cli/Makefile.am @@ -0,0 +1,15 @@ +SUBDIRS = intersection +check_SCRIPTS = test_trace_read test_packet_seq_num test_convert_args + +LOG_DRIVER_FLAGS='--merge' +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh + +TESTS = test_trace_read \ + test_trace_read \ + test_packet_seq_num \ + test_convert_args \ + intersection/test_intersection + +if USE_PYTHON +TESTS += intersection/test_multi_trace_intersection.py +endif diff --git a/tests/cli/intersection/Makefile.am b/tests/cli/intersection/Makefile.am new file mode 100644 index 00000000..6c7330e5 --- /dev/null +++ b/tests/cli/intersection/Makefile.am @@ -0,0 +1,20 @@ +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 + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi diff --git a/tests/cli/intersection/bt_python_helper.py.in b/tests/cli/intersection/bt_python_helper.py.in new file mode 100644 index 00000000..4b9fcaf7 --- /dev/null +++ b/tests/cli/intersection/bt_python_helper.py.in @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# +# The MIT License (MIT) +# +# Copyright (C) 2016 - Jérémie Galarneau +# +# 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) diff --git a/tests/cli/intersection/test_intersection.in b/tests/cli/intersection/test_intersection.in new file mode 100644 index 00000000..d70367f2 --- /dev/null +++ b/tests/cli/intersection/test_intersection.in @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright (C) - 2015 Julien Desfossez +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# 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., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TESTDIR=@abs_top_srcdir@/tests + +BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace +CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces + +source $TESTDIR/utils/tap/tap.sh + +NUM_TESTS=10 + +plan_tests $NUM_TESTS + +test_intersect() { + trace=$1 + totalevents=$2 + intersect=$3 + + test $($BABELTRACE_BIN $trace | wc -l) = $totalevents + ok $? "$totalevents events in the whole trace" + test $($BABELTRACE_BIN --stream-intersection $trace 2>/dev/null| wc -l) = $intersect + ok $? "$intersect events in packets intersecting" +} + +diag "Test the stream intersection feature" + +diag "2 streams offsetted with 3 packets intersecting" +test_intersect ${CTF_TRACES}/intersection/3eventsintersect 8 3 + +diag "2 streams offsetted with 3 packets intersecting (exchanged file names)" +test_intersect ${CTF_TRACES}/intersection/3eventsintersectreverse 8 3 + +diag "No intersection between 2 streams" +test_intersect ${CTF_TRACES}/intersection/nointersect 6 0 + +diag "Only 1 stream" +test_intersect ${CTF_TRACES}/intersection/onestream 3 3 + +diag "No stream at all" +test_intersect ${CTF_TRACES}/intersection/nostream 0 0 diff --git a/tests/cli/intersection/test_multi_trace_intersection.py b/tests/cli/intersection/test_multi_trace_intersection.py new file mode 100755 index 00000000..b4368a11 --- /dev/null +++ b/tests/cli/intersection/test_multi_trace_intersection.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python3 +# +# The MIT License (MIT) +# +# Copyright (C) 2016 - Jérémie Galarneau +# +# 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) diff --git a/tests/cli/test_convert_args b/tests/cli/test_convert_args new file mode 100755 index 00000000..9ed64e25 --- /dev/null +++ b/tests/cli/test_convert_args @@ -0,0 +1,156 @@ +#!/usr/bin/env bash +# +# Copyright (C) - 2017 Philippe Proulx +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# 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., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +curdir="$(dirname $0)" +testdir="$curdir/.." +babeltrace_bin="$curdir/../../cli/babeltrace" + +source $testdir/utils/tap/tap.sh + +test_bt_convert_run_args() { + local what="$1" + local convert_args="$2" + local expected_run_args="$3" + + # execute convert command + local run_args="$("$babeltrace_bin" convert --run-args $convert_args)" + + # check result + if [ "$test_head_comment" = 1 ]; then + comment "convert args: $convert_args" + fi + + if [ "$run_args" == "$expected_run_args" ]; then + pass "ARGS: $what" + else + fail "ARGS: $what" + diag "EXPECTED: $expected_run_args" + diag "GOT: $run_args" + fi +} + +test_bt_convert_fails() { + local what="$1" + local convert_args="$2" + + # execute convert command + "$babeltrace_bin" convert --run-args $convert_args &> /dev/null + + local status=$? + + # check result + if [ "$test_head_comment" = 1 ]; then + comment "convert args: $convert_args" + fi + + if [ $status == 0 ]; then + fail "SUCCEEDS (should fail): $what" + diag "ARGS: $convert_args" + else + pass "FAILS: $what" + fi +} + +comment() { + echo "### $1 ###" +} + +plan_tests 82 + +test_bt_convert_run_args 'path leftover' '/path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + named user source with --params' '/path/to/trace --source ZZ:another.source --params salut=yes' '--source ZZ:another.source --params salut=yes --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ZZ:muxer --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + named user source with --name --params' '/path/to/trace --source another.source --name HELLO --params salut=yes' '--source another.source --name HELLO --params salut=yes --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect HELLO:muxer --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + user source with --path --params' '/path/to/trace --source another.source --path some-path --params salut=yes' "--source another.source --key path --value some-path --params salut=yes --name another.source --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect 'another\\.source:muxer' --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty" +test_bt_convert_run_args 'user source with --url + -o dummy' '--source MY:my.source --url the-url -o dummy' '--source MY:my.source --key url --value the-url --sink utils.dummy --name dummy --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect MY:muxer --connect muxer:debug-info --connect debug-info:dummy' +test_bt_convert_run_args 'path leftover + --omit-home-plugin-path' '/path/to/trace --omit-home-plugin-path' '--omit-home-plugin-path --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --omit-system-plugin-path' '/path/to/trace --omit-system-plugin-path' '--omit-system-plugin-path --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --plugin-path' '--plugin-path=PATH1:PATH2 /path/to/trace' '--plugin-path PATH1:PATH2 --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'unnamed user source' '--source salut.com' "--source salut.com --name salut.com --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect 'salut\.com:muxer' --connect muxer:debug-info --connect debug-info:pretty" +test_bt_convert_run_args 'path leftover + user source named `ctf-fs`' '--source ctf-fs:salut.com /path/to/trace' "--source ctf-fs:salut.com --source ctf.fs --name ctf-fs-0 --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect ctf-fs-0:muxer --connect muxer:debug-info --connect debug-info:pretty" +test_bt_convert_run_args 'path leftover + user sink named `pretty`' '--sink pretty:my.sink /path/to/trace' '--sink pretty:my.sink --source ctf.fs --name ctf-fs --key path --value /path/to/trace --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-seconds + user sink named `pretty`' '--clock-seconds --sink pretty:my.sink /path/to/trace' '--sink pretty:my.sink --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty-0 --params clock-seconds=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty --connect debug-info:pretty-0' +test_bt_convert_run_args 'path leftover + user filter named `muxer`' '--filter muxer:salut.com /path/to/trace' '--filter muxer:salut.com --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer-0 --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer-0 --connect muxer-0:debug-info --connect debug-info:muxer --connect muxer:pretty' +test_bt_convert_run_args 'path leftover + --begin + user filter named `trimmer`' '/path/to/trace --filter trimmer:salut.com --begin=abc' '--filter trimmer:salut.com --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer-0 --key begin --value abc --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer-0 --connect trimmer-0:debug-info --connect debug-info:trimmer --connect trimmer:pretty' +test_bt_convert_run_args 'path leftover + --plugin-path' '/path/to/trace --plugin-path a:b:c' '--plugin-path a:b:c --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --omit-home-plugin-path --omit-system-plugin-path' '/path/to/trace --omit-home-plugin-path --omit-system-plugin-path' '--omit-home-plugin-path --omit-system-plugin-path --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --begin' '/path/to/trace --begin=123' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer --key begin --value 123 --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer --connect trimmer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --begin --end' '/path/to/trace --end=456 --begin 123' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer --key end --value 456 --key begin --value 123 --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer --connect trimmer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --timerange' '/path/to/trace --timerange=[abc,xyz]' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter utils.trimmer --name trimmer --key begin --value abc --key end --value xyz --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:trimmer --connect trimmer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-cycles' '/path/to/trace --clock-cycles' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-cycles=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-date' '/path/to/trace --clock-date' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-date=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --force-correlate' '/path/to/trace --clock-force-correlate' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --params force-correlate=yes --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-gmt' '/path/to/trace --clock-gmt' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-gmt=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-offset' '/path/to/trace --clock-offset=15487' '--source ctf.fs --name ctf-fs --key clock-offset-cycles --value 15487 --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-offset-ns' '/path/to/trace --clock-offset-ns=326159487' '--source ctf.fs --name ctf-fs --key clock-offset-ns --value 326159487 --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --clock-seconds' '/path/to/trace --clock-seconds' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-seconds=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --color' '/path/to/trace --color=never' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --key color --value never --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --no-debug-info' '/path/to/trace --no-debug-info' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --connect ctf-fs:muxer --connect muxer:pretty' +test_bt_convert_run_args 'path leftover + --debug-info-dir' '/path/to/trace --debug-info-dir=/salut' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --key dir --value /salut --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --debug-info-target-prefix' '/path/to/trace --debug-info-target-prefix=/salut' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --key target-prefix --value /salut --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --debug-info-full-path' '/path/to/trace --debug-info-full-path' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --params full-path=yes --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --fields=trace:domain,loglevel' '--fields=trace:domain,loglevel /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params field-trace:domain=yes,field-loglevel=yes,field-default=hide --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --fields=all' '--fields=all /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params field-default=show --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --names=context,header' '--names=context,header /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params name-context=yes,name-header=yes,name-default=hide --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --names=all' '--names=all /path/to/trace' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params name-default=show --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --no-delta' '/path/to/trace --no-delta' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params no-delta=yes --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --output' '/path/to/trace --output /salut' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --key path --value /salut --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + --stream-intersection' '/path/to/trace --stream-intersection' '--source ctf.fs --name ctf-fs --params stream-intersection=yes --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + -i ctf' '/path/to/trace -i ctf' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'URL leftover + -i lttng-live' 'net://some-host/host/target/session -i lttng-live' '--source ctf.lttng-live --name lttng-live --key url --value net://some-host/host/target/session --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect lttng-live:muxer --connect muxer:debug-info --connect debug-info:pretty' +test_bt_convert_run_args 'path leftover + user sink + -o text' '/path/to/trace --sink=abc.def -o text' "--sink abc.def --name abc.def --source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect 'debug-info:abc\.def' --connect debug-info:pretty" +test_bt_convert_run_args 'path leftover + -o dummy' '/path/to/trace -o dummy' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink utils.dummy --name dummy --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:dummy' +test_bt_convert_run_args 'path leftover + -o dummy + --clock-seconds' '/path/to/trace -o dummy --clock-seconds' '--source ctf.fs --name ctf-fs --key path --value /path/to/trace --sink text.pretty --name pretty --params clock-seconds=yes --sink utils.dummy --name dummy --filter utils.muxer --name muxer --filter lttng-utils.debug-info --name debug-info --connect ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty --connect debug-info:dummy' + +test_bt_convert_fails 'bad --source format (plugin only)' '--source salut' +test_bt_convert_fails 'bad --source format (name and plugin only)' '--source name:salut' +test_bt_convert_fails 'bad --source format (name only)' '--source name:' +test_bt_convert_fails 'bad --source format (extra dot found)' '--source name:plugin.comp.cls' +test_bt_convert_fails 'bad --filter format (plugin only)' '--filter salut' +test_bt_convert_fails 'bad --filter format (name and plugin only)' '--filter name:salut' +test_bt_convert_fails 'bad --filter format (name only)' '--filter name:' +test_bt_convert_fails 'bad --filter format (extra dot found)' '--filter name:plugin.comp.cls' +test_bt_convert_fails 'bad --sink format (plugin only)' '--sink salut' +test_bt_convert_fails 'bad --sink format (name and plugin only)' '--sink name:salut' +test_bt_convert_fails 'bad --sink format (name only)' '--sink name:' +test_bt_convert_fails 'bad --sink format (extra dot found)' '--sink name:plugin.comp.cls' +test_bt_convert_fails 'duplicate component name' '--sink hello:a.b --source hello:c.d' +test_bt_convert_fails 'unknown option' '--sink hello:a.b --salut' +test_bt_convert_fails '--params without current component' '--params lol=23' +test_bt_convert_fails '--path without current component' '--path /path/to/trace' +test_bt_convert_fails '--url without current component' '--url net://some-host/host/target/session' +test_bt_convert_fails '--nane without current component' '--name chapeau' +test_bt_convert_fails 'duplicate --begin' '--begin abc --clock-seconds --begin cde' +test_bt_convert_fails 'duplicate --end' '--begin abc --end xyz --clock-seconds --end cde' +test_bt_convert_fails '--begin and --timerange' '--begin abc --clock-seconds --timerange abc,def' +test_bt_convert_fails '--end and --timerange' '--end abc --clock-seconds --timerange abc,def' +test_bt_convert_fails 'bad --timerange format (1)' '--timerange abc' +test_bt_convert_fails 'bad --timerange format (2)' '--timerange abc,' +test_bt_convert_fails 'bad --timerange format (3)' '--timerange ,cde' +test_bt_convert_fails 'bad --fields format' '--fields salut' +test_bt_convert_fails 'bad --names format' '--names salut' +test_bt_convert_fails 'unknown -i' '-i lol' +test_bt_convert_fails 'duplicate -i' '-i lttng-live --clock-seconds --input-format=ctf' +test_bt_convert_fails 'unknown -o' '-o lol' +test_bt_convert_fails 'duplicate -o' '-o dummy --clock-seconds --output-format=text' +test_bt_convert_fails '--run-args and --run-args-0' '/path/to/trace --run-args --run-args-0' +test_bt_convert_fails 'duplicate -v' '/path/to/trace -vv' +test_bt_convert_fails 'two leftover arguments' '/path/to/trace /other/path' +test_bt_convert_fails '-o ctf-metadata without path' '-o ctf-metadata' +test_bt_convert_fails '-i lttng-live and implicit ctf.fs source' '-i lttng-live net://some-host/host/target/session --clock-offset=23' +test_bt_convert_fails 'implicit ctf.fs source without path' '--clock-offset=23' +test_bt_convert_fails 'implicit ctf.lttng-live source without URL' '-i lttng-live' +test_bt_convert_fails 'no source' '-o text' diff --git a/tests/cli/test_formats.in b/tests/cli/test_formats.in new file mode 100644 index 00000000..4bd32ea0 --- /dev/null +++ b/tests/cli/test_formats.in @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright (C) - 2016 Nathan Lynch +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# 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., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +CURDIR=$(dirname $0) +TESTDIR=$CURDIR/.. + +BABELTRACE_BIN=$CURDIR/../../cli/babeltrace + +source $TESTDIR/utils/tap/tap.sh + +expected_formats=(text lttng-live dummy ctf-metadata ctf) + +plan_tests ${#expected_formats[*]} + +for format in "${expected_formats[@]}"; do + "$BABELTRACE_BIN" --list | @GREP@ -qw "$format" + ok $? "Detect support for format \"$format\"" +done diff --git a/tests/cli/test_packet_seq_num.in b/tests/cli/test_packet_seq_num.in new file mode 100644 index 00000000..640793b7 --- /dev/null +++ b/tests/cli/test_packet_seq_num.in @@ -0,0 +1,76 @@ +#!/bin/bash +# +# Copyright (C) - 2015 Julien Desfossez +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# 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., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +CURDIR=$(dirname $0) +TESTDIR=$CURDIR/.. + +BABELTRACE_BIN=$CURDIR/../../cli/babeltrace +CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces + +source $TESTDIR/utils/tap/tap.sh + +NUM_TESTS=10 + +plan_tests $NUM_TESTS + +test_no_lost() { + trace=$1 + + $BABELTRACE_BIN $trace >/dev/null 2>&1 + ok $? "Trace parses" + $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" + if test $? = 0; then + fail 1 "Should not find any lost events" + else + ok 0 "No events lost" + fi +} + +test_lost() { + trace=$1 + expectedcountstr=$2 + + $BABELTRACE_BIN $trace >/dev/null 2>&1 + ok $? "Trace parses" + + # Convert warnings like: + # [warning] Tracer lost 2 trace packets between .... + # [warning] Tracer lost 3 trace packets between .... + # into "2,3" and make sure it matches the expected result + $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" \ + | cut -d" " -f4 | tr "\n" "," | @SED@ "s/.$//" | \ + @GREP@ "$expectedcountstr" >/dev/null + ok $? "Lost events string matches $expectedcountstr" + +} + +diag "Test the packet_seq_num validation" + +diag "No packet lost" +test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost + +diag "No packet lost, packet_seq_num not starting at 0" +test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0 + +diag "1 stream, 2 packets lost before the last packet" +test_lost ${CTF_TRACES}/packet_seq_num/2_lost_before_last "2" + +diag "2 streams, packets lost in one of them" +test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_1 "2" + +diag "2 streams, packets lost in both" +test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_2 "3,2,1" diff --git a/tests/cli/test_trace_read.in b/tests/cli/test_trace_read.in new file mode 100644 index 00000000..1325eb39 --- /dev/null +++ b/tests/cli/test_trace_read.in @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Copyright (C) - 2013 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# 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., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +CURDIR=$(dirname $0) +TESTDIR=$CURDIR/.. + +BABELTRACE_BIN=$CURDIR/../../cli/babeltrace + +CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces + +source $TESTDIR/utils/tap/tap.sh + +SUCCESS_TRACES=(${CTF_TRACES}/succeed/*) +FAIL_TRACES=(${CTF_TRACES}/fail/*) + +NUM_TESTS=$((${#SUCCESS_TRACES[@]} + ${#FAIL_TRACES[@]})) + +plan_tests $NUM_TESTS + +for path in ${SUCCESS_TRACES[@]}; do + trace=$(basename ${path}) + $BABELTRACE_BIN ${path} > /dev/null 2>&1 + ok $? "Run babeltrace with trace ${trace}" +done + +for path in ${FAIL_TRACES[@]}; do + trace=$(basename ${path}) + $BABELTRACE_BIN ${path} > /dev/null 2>&1 + if [ $? -eq 0 ]; then + fail "Run babeltrace with invalid trace ${trace}" + else + pass "Run babeltrace with invalid trace ${trace}" + fi +done