3 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
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.
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
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.
18 # Test how parameters are applied to sources auto-discovered by the convert
21 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
22 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
24 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
27 # shellcheck source=../../utils/utils.sh
28 SH_TAP
=1 source "$UTILSSH"
34 data_dir
="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level"
35 plugin_dir
="${data_dir}"
36 dir_a
="${data_dir}/dir-a"
37 dir_b
="${data_dir}/dir-b"
38 dir_ab
="${data_dir}/dir-ab"
40 expected_file
=$
(mktemp
-t expected.XXXXXX
)
42 print_test_params
="--params what=\"test-params\""
43 details_sink
=("-c" "sink.text.details" "--params=with-metadata=false")
45 # Apply params to two components from one non-option argument.
46 cat > "$expected_file" <<END
47 {Trace 0, Stream class ID 0, Stream ID 0}
49 Name: TestSourceA: ('test-allo', 'madame')
51 Stream (ID 0, Class ID 0)
53 {Trace 1, Stream class ID 0, Stream ID 0}
55 Name: TestSourceB: ('test-allo', 'madame')
57 Stream (ID 0, Class ID 0)
59 {Trace 0, Stream class ID 0, Stream ID 0}
62 {Trace 1, Stream class ID 0, Stream ID 0}
66 bt_diff_cli
"$expected_file" "/dev/null" \
67 --plugin-path "${plugin_dir}" convert \
68 "${dir_ab}" --params 'test-allo="madame"' ${print_test_params} \
70 ok
"$?" "apply params to two components from one non-option argument"
72 # Apply params to two components from two distinct non-option arguments.
73 cat > "$expected_file" <<END
74 {Trace 0, Stream class ID 0, Stream ID 0}
76 Name: TestSourceA: ('test-allo', 'madame')
78 Stream (ID 0, Class ID 0)
80 {Trace 1, Stream class ID 0, Stream ID 0}
82 Name: TestSourceB: ('test-bonjour', 'monsieur')
84 Stream (ID 0, Class ID 0)
86 {Trace 0, Stream class ID 0, Stream ID 0}
89 {Trace 1, Stream class ID 0, Stream ID 0}
93 bt_diff_cli
"$expected_file" "/dev/null" \
94 --plugin-path "${plugin_dir}" convert \
95 "${dir_a}" --params 'test-allo="madame"' ${print_test_params} "${dir_b}" --params 'test-bonjour="monsieur"' ${print_test_params} \
97 ok "$?
" "apply params to two non-option arguments
"
99 # Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1).
100 cat > "$expected_file" <<END
101 {Trace 0, Stream class ID 0, Stream ID 0}
103 Name: TestSourceA: ('test-allo', 'madame'), ('test-bonjour', 'monsieur')
105 Stream (ID 0, Class ID 0)
107 {Trace 1, Stream class ID 0, Stream ID 0}
109 Name: TestSourceB: ('test-bonjour', 'monsieur')
111 Stream (ID 0, Class ID 0)
113 {Trace 0, Stream class ID 0, Stream ID 0}
116 {Trace 1, Stream class ID 0, Stream ID 0}
120 bt_diff_cli "$expected_file" "/dev
/null
" \
121 --plugin-path "${plugin_dir}" convert \
122 "${dir_a}" --params 'test-allo="madame"' ${print_test_params} "${dir_ab}" --params 'test-bonjour="monsieur"' ${print_test_params} \
124 ok
"$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
126 # Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2).
127 cat > "$expected_file" <<END
128 {Trace 0, Stream class ID 0, Stream ID 0}
130 Name: TestSourceA: ('test-bonjour', 'monsieur'), ('test-salut', 'les amis')
132 Stream (ID 0, Class ID 0)
134 {Trace 1, Stream class ID 0, Stream ID 0}
136 Name: TestSourceB: ('test-bonjour', 'madame'), ('test-salut', 'les amis')
138 Stream (ID 0, Class ID 0)
140 {Trace 0, Stream class ID 0, Stream ID 0}
143 {Trace 1, Stream class ID 0, Stream ID 0}
147 bt_diff_cli
"$expected_file" "/dev/null" \
148 --plugin-path "${plugin_dir}" convert \
149 "${dir_ab}" --params 'test-bonjour="madame",test-salut="les amis"' ${print_test_params} "${dir_a}" --params 'test-bonjour="monsieur"' ${print_test_params} \
151 ok "$?
" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments
(2)"
153 rm -f "$expected_file"