| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (C) - 2017 Philippe Proulx <pproulx@efficios.com> |
| 4 | # |
| 5 | # This program is free software; you can redistribute it and/or modify it |
| 6 | # under the terms of the GNU General Public License, version 2 only, as |
| 7 | # published by the Free Software Foundation. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | # more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License along with |
| 15 | # this program; if not, write to the Free Software Foundation, Inc., 51 |
| 16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | |
| 18 | curdir="$(dirname $0)" |
| 19 | testdir="$curdir/.." |
| 20 | babeltrace_bin="$curdir/../../cli/babeltrace" |
| 21 | |
| 22 | source $testdir/utils/tap/tap.sh |
| 23 | |
| 24 | test_bt_convert_run_args() { |
| 25 | local what="$1" |
| 26 | local convert_args="$2" |
| 27 | local expected_run_args="$3" |
| 28 | |
| 29 | # execute convert command |
| 30 | local run_args="$("$babeltrace_bin" convert --run-args $convert_args)" |
| 31 | |
| 32 | # check result |
| 33 | if [ "$test_head_comment" = 1 ]; then |
| 34 | comment "convert args: $convert_args" |
| 35 | fi |
| 36 | |
| 37 | if [ "$run_args" == "$expected_run_args" ]; then |
| 38 | pass "ARGS: $what" |
| 39 | else |
| 40 | fail "ARGS: $what" |
| 41 | diag "EXPECTED: $expected_run_args" |
| 42 | diag "GOT: $run_args" |
| 43 | fi |
| 44 | } |
| 45 | |
| 46 | test_bt_convert_fails() { |
| 47 | local what="$1" |
| 48 | local convert_args="$2" |
| 49 | |
| 50 | # execute convert command |
| 51 | "$babeltrace_bin" convert --run-args $convert_args &> /dev/null |
| 52 | |
| 53 | local status=$? |
| 54 | |
| 55 | # check result |
| 56 | if [ "$test_head_comment" = 1 ]; then |
| 57 | comment "convert args: $convert_args" |
| 58 | fi |
| 59 | |
| 60 | if [ $status == 0 ]; then |
| 61 | fail "SUCCEEDS (should fail): $what" |
| 62 | diag "ARGS: $convert_args" |
| 63 | else |
| 64 | pass "FAILS: $what" |
| 65 | fi |
| 66 | } |
| 67 | |
| 68 | comment() { |
| 69 | echo "### $1 ###" |
| 70 | } |
| 71 | |
| 72 | plan_tests 82 |
| 73 | |
| 74 | test_bt_convert_run_args 'path leftover' '/path/to/trace' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 75 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ZZ:mux --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 76 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect HELLO:mux --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 77 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect 'another\\.source:mux' --connect ctf:mux --connect mux:debug-info --connect debug-info:text" |
| 78 | 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 mux --filter lttng-utils.debug-info --name debug-info --connect MY:mux --connect mux:debug-info --connect debug-info:dummy' |
| 79 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 80 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 81 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 82 | test_bt_convert_run_args 'unnamed user source' '--source salut.com' "--source salut.com --name salut.com --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect 'salut\.com:mux' --connect mux:debug-info --connect debug-info:text" |
| 83 | test_bt_convert_run_args 'path leftover + user source named `ctf`' '--source ctf:salut.com /path/to/trace' "--source ctf:salut.com --source ctf.fs --name ctf-0 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect ctf-0:mux --connect mux:debug-info --connect debug-info:text" |
| 84 | test_bt_convert_run_args 'path leftover + user sink named `text`' '--sink text:my.sink /path/to/trace' '--sink text:my.sink --source ctf.fs --name ctf --key path --value /path/to/trace --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 85 | test_bt_convert_run_args 'path leftover + --clock-seconds + user sink named `text`' '--clock-seconds --sink text:my.sink /path/to/trace' '--sink text:my.sink --source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text-0 --params clock-seconds=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text --connect debug-info:text-0' |
| 86 | test_bt_convert_run_args 'path leftover + user filter named `mux`' '--filter mux:salut.com /path/to/trace' '--filter mux:salut.com --source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux-0 --filter lttng-utils.debug-info --name debug-info --connect ctf:mux-0 --connect mux-0:debug-info --connect debug-info:mux --connect mux:text' |
| 87 | test_bt_convert_run_args 'path leftover + --begin + user filter named `trim`' '/path/to/trace --filter trim:salut.com --begin=abc' '--filter trim:salut.com --source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter utils.trimmer --name trim-0 --key begin --value abc --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:trim-0 --connect trim-0:debug-info --connect debug-info:trim --connect trim:text' |
| 88 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 89 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 90 | test_bt_convert_run_args 'path leftover + --begin' '/path/to/trace --begin=123' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter utils.trimmer --name trim --key begin --value 123 --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:trim --connect trim:debug-info --connect debug-info:text' |
| 91 | test_bt_convert_run_args 'path leftover + --begin --end' '/path/to/trace --end=456 --begin 123' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter utils.trimmer --name trim --key end --value 456 --key begin --value 123 --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:trim --connect trim:debug-info --connect debug-info:text' |
| 92 | test_bt_convert_run_args 'path leftover + --timerange' '/path/to/trace --timerange=[abc,xyz]' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter utils.trimmer --name trim --key begin --value abc --key end --value xyz --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:trim --connect trim:debug-info --connect debug-info:text' |
| 93 | test_bt_convert_run_args 'path leftover + --clock-cycles' '/path/to/trace --clock-cycles' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params clock-cycles=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 94 | test_bt_convert_run_args 'path leftover + --clock-date' '/path/to/trace --clock-date' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params clock-date=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 95 | test_bt_convert_run_args 'path leftover + --force-correlate' '/path/to/trace --clock-force-correlate' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --params force-correlate=yes --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 96 | test_bt_convert_run_args 'path leftover + --clock-gmt' '/path/to/trace --clock-gmt' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params clock-gmt=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 97 | test_bt_convert_run_args 'path leftover + --clock-offset' '/path/to/trace --clock-offset=15487' '--source ctf.fs --name ctf --key clock-offset-cycles --value 15487 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 98 | test_bt_convert_run_args 'path leftover + --clock-offset-ns' '/path/to/trace --clock-offset-ns=326159487' '--source ctf.fs --name ctf --key clock-offset-ns --value 326159487 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 99 | test_bt_convert_run_args 'path leftover + --clock-seconds' '/path/to/trace --clock-seconds' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params clock-seconds=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 100 | test_bt_convert_run_args 'path leftover + --color' '/path/to/trace --color=never' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --key color --value never --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 101 | test_bt_convert_run_args 'path leftover + --no-debug-info' '/path/to/trace --no-debug-info' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --connect ctf:mux --connect mux:text' |
| 102 | test_bt_convert_run_args 'path leftover + --debug-info-dir' '/path/to/trace --debug-info-dir=/salut' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --key dir --value /salut --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 103 | test_bt_convert_run_args 'path leftover + --debug-info-target-prefix' '/path/to/trace --debug-info-target-prefix=/salut' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --key target-prefix --value /salut --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 104 | test_bt_convert_run_args 'path leftover + --debug-info-full-path' '/path/to/trace --debug-info-full-path' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --params full-path=yes --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 105 | test_bt_convert_run_args 'path leftover + --fields=trace:domain,loglevel' '--fields=trace:domain,loglevel /path/to/trace' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params field-trace:domain=yes,field-loglevel=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 106 | test_bt_convert_run_args 'path leftover + --fields=all' '--fields=all /path/to/trace' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params field-default=show --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 107 | test_bt_convert_run_args 'path leftover + --names=context,header' '--names=context,header /path/to/trace' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params name-context=yes,name-header=yes,name-default=hide --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 108 | test_bt_convert_run_args 'path leftover + --names=all' '--names=all /path/to/trace' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params name-default=show --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 109 | test_bt_convert_run_args 'path leftover + --no-delta' '/path/to/trace --no-delta' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params no-delta=yes --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 110 | test_bt_convert_run_args 'path leftover + --output' '/path/to/trace --output /salut' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --key path --value /salut --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 111 | test_bt_convert_run_args 'path leftover + --stream-intersection' '/path/to/trace --stream-intersection' '--source ctf.fs --name ctf --params stream-intersection=yes --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 112 | test_bt_convert_run_args 'path leftover + -i ctf' '/path/to/trace -i ctf' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text' |
| 113 | test_bt_convert_run_args 'URL leftover + -i lttng-live' 'net://host/target/session -i lttng-live' '--source ctf.lttng-live --name lttng-live --key url --value net://host/target/session --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect lttng-live:mux --connect mux:debug-info --connect debug-info:text' |
| 114 | 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 --key path --value /path/to/trace --sink text.text --name text --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect 'debug-info:abc\.def' --connect debug-info:text" |
| 115 | test_bt_convert_run_args 'path leftover + -o dummy' '/path/to/trace -o dummy' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink utils.dummy --name dummy --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:dummy' |
| 116 | test_bt_convert_run_args 'path leftover + -o dummy + --clock-seconds' '/path/to/trace -o dummy --clock-seconds' '--source ctf.fs --name ctf --key path --value /path/to/trace --sink text.text --name text --params clock-seconds=yes --sink utils.dummy --name dummy --filter utils.muxer --name mux --filter lttng-utils.debug-info --name debug-info --connect ctf:mux --connect mux:debug-info --connect debug-info:text --connect debug-info:dummy' |
| 117 | |
| 118 | test_bt_convert_fails 'bad --source format (plugin only)' '--source salut' |
| 119 | test_bt_convert_fails 'bad --source format (name and plugin only)' '--source name:salut' |
| 120 | test_bt_convert_fails 'bad --source format (name only)' '--source name:' |
| 121 | test_bt_convert_fails 'bad --source format (extra dot found)' '--source name:plugin.comp.cls' |
| 122 | test_bt_convert_fails 'bad --filter format (plugin only)' '--filter salut' |
| 123 | test_bt_convert_fails 'bad --filter format (name and plugin only)' '--filter name:salut' |
| 124 | test_bt_convert_fails 'bad --filter format (name only)' '--filter name:' |
| 125 | test_bt_convert_fails 'bad --filter format (extra dot found)' '--filter name:plugin.comp.cls' |
| 126 | test_bt_convert_fails 'bad --sink format (plugin only)' '--sink salut' |
| 127 | test_bt_convert_fails 'bad --sink format (name and plugin only)' '--sink name:salut' |
| 128 | test_bt_convert_fails 'bad --sink format (name only)' '--sink name:' |
| 129 | test_bt_convert_fails 'bad --sink format (extra dot found)' '--sink name:plugin.comp.cls' |
| 130 | test_bt_convert_fails 'duplicate component name' '--sink hello:a.b --source hello:c.d' |
| 131 | test_bt_convert_fails 'unknown option' '--sink hello:a.b --salut' |
| 132 | test_bt_convert_fails '--params without current component' '--params lol=23' |
| 133 | test_bt_convert_fails '--path without current component' '--path /path/to/trace' |
| 134 | test_bt_convert_fails '--url without current component' '--url net://host/target/session' |
| 135 | test_bt_convert_fails '--nane without current component' '--name chapeau' |
| 136 | test_bt_convert_fails 'duplicate --begin' '--begin abc --clock-seconds --begin cde' |
| 137 | test_bt_convert_fails 'duplicate --end' '--begin abc --end xyz --clock-seconds --end cde' |
| 138 | test_bt_convert_fails '--begin and --timerange' '--begin abc --clock-seconds --timerange abc,def' |
| 139 | test_bt_convert_fails '--end and --timerange' '--end abc --clock-seconds --timerange abc,def' |
| 140 | test_bt_convert_fails 'bad --timerange format (1)' '--timerange abc' |
| 141 | test_bt_convert_fails 'bad --timerange format (2)' '--timerange abc,' |
| 142 | test_bt_convert_fails 'bad --timerange format (3)' '--timerange ,cde' |
| 143 | test_bt_convert_fails 'bad --fields format' '--fields salut' |
| 144 | test_bt_convert_fails 'bad --names format' '--names salut' |
| 145 | test_bt_convert_fails 'unknown -i' '-i lol' |
| 146 | test_bt_convert_fails 'duplicate -i' '-i lttng-live --clock-seconds --input-format=ctf' |
| 147 | test_bt_convert_fails 'unknown -o' '-o lol' |
| 148 | test_bt_convert_fails 'duplicate -o' '-o dummy --clock-seconds --output-format=text' |
| 149 | test_bt_convert_fails '--run-args and --run-args-0' '/path/to/trace --run-args --run-args-0' |
| 150 | test_bt_convert_fails 'duplicate -v' '/path/to/trace -vv' |
| 151 | test_bt_convert_fails 'two leftover arguments' '/path/to/trace /other/path' |
| 152 | test_bt_convert_fails '-o ctf-metadata without path' '-o ctf-metadata' |
| 153 | test_bt_convert_fails '-i lttng-live and implicit ctf.fs source' '-i lttng-live the-url --clock-offset=23' |
| 154 | test_bt_convert_fails 'implicit ctf.fs source without path' '--clock-offset=23' |
| 155 | test_bt_convert_fails 'implicit ctf.lttng-live source without URL' '-i lttng-live' |
| 156 | test_bt_convert_fails 'no source' '-o text' |