Move autodisc to its own convenience library
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_params
CommitLineData
1ead9076
SM
1#!/bin/bash
2#
3# Copyright (C) 2019 Simon Marchi <simon.marchi@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# Test how parameters are applied to sources auto-discovered by the convert
19# command.
20
21if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
22 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
23else
24 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
25fi
26
27# shellcheck source=../../utils/utils.sh
28SH_TAP=1 source "$UTILSSH"
29
30NUM_TESTS=4
31
32plan_tests $NUM_TESTS
33
1b2b6649 34data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-params-log-level"
1ead9076
SM
35plugin_dir="${data_dir}"
36dir_a="${data_dir}/dir-a"
37dir_b="${data_dir}/dir-b"
38dir_ab="${data_dir}/dir-ab"
39
40expected_file=$(mktemp -t expected.XXXXXX)
1ead9076 41
dc807017
SM
42print_test_params="--params what=\"test-params\""
43details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
1b2b6649 44
24594611 45# Apply params to two components from one non-option argument.
1ead9076 46cat > "$expected_file" <<END
dc807017
SM
47{Trace 0, Stream class ID 0, Stream ID 0}
48Stream beginning:
49 Name: TestSourceA: ('test-allo', 'madame')
50 Trace:
51 Stream (ID 0, Class ID 0)
52
53{Trace 1, Stream class ID 0, Stream ID 0}
54Stream beginning:
55 Name: TestSourceB: ('test-allo', 'madame')
56 Trace:
57 Stream (ID 0, Class ID 0)
58
59{Trace 0, Stream class ID 0, Stream ID 0}
60Stream end
61
62{Trace 1, Stream class ID 0, Stream ID 0}
63Stream end
1ead9076
SM
64END
65
dc807017 66bt_diff_cli "$expected_file" "/dev/null" \
1ead9076 67 convert --plugin-path "${plugin_dir}" \
dc807017
SM
68 "${dir_ab}" --params 'test-allo="madame"' ${print_test_params} \
69 ${details_sink[@]}
24594611 70ok "$?" "apply params to two components from one non-option argument"
1ead9076 71
24594611 72# Apply params to two components from two distinct non-option arguments.
1ead9076 73cat > "$expected_file" <<END
dc807017
SM
74{Trace 0, Stream class ID 0, Stream ID 0}
75Stream beginning:
76 Name: TestSourceA: ('test-allo', 'madame')
77 Trace:
78 Stream (ID 0, Class ID 0)
79
80{Trace 1, Stream class ID 0, Stream ID 0}
81Stream beginning:
82 Name: TestSourceB: ('test-bonjour', 'monsieur')
83 Trace:
84 Stream (ID 0, Class ID 0)
85
86{Trace 0, Stream class ID 0, Stream ID 0}
87Stream end
88
89{Trace 1, Stream class ID 0, Stream ID 0}
90Stream end
1ead9076
SM
91END
92
dc807017 93bt_diff_cli "$expected_file" "/dev/null" \
1ead9076 94 convert --plugin-path "${plugin_dir}" \
dc807017
SM
95 "${dir_a}" --params 'test-allo="madame"' ${print_test_params} "${dir_b}" --params 'test-bonjour="monsieur"' ${print_test_params} \
96 ${details_sink[@]}
24594611 97ok "$?" "apply params to two non-option arguments"
1ead9076 98
24594611 99# Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1).
1ead9076 100cat > "$expected_file" <<END
dc807017
SM
101{Trace 0, Stream class ID 0, Stream ID 0}
102Stream beginning:
103 Name: TestSourceA: ('test-allo', 'madame'), ('test-bonjour', 'monsieur')
104 Trace:
105 Stream (ID 0, Class ID 0)
106
107{Trace 1, Stream class ID 0, Stream ID 0}
108Stream beginning:
109 Name: TestSourceB: ('test-bonjour', 'monsieur')
110 Trace:
111 Stream (ID 0, Class ID 0)
112
113{Trace 0, Stream class ID 0, Stream ID 0}
114Stream end
115
116{Trace 1, Stream class ID 0, Stream ID 0}
117Stream end
1ead9076
SM
118END
119
dc807017 120bt_diff_cli "$expected_file" "/dev/null" \
1ead9076 121 convert --plugin-path "${plugin_dir}" \
dc807017
SM
122 "${dir_a}" --params 'test-allo="madame"' ${print_test_params} "${dir_ab}" --params 'test-bonjour="monsieur"' ${print_test_params} \
123 ${details_sink[@]}
24594611 124ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
1ead9076 125
24594611 126# Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2).
1ead9076 127cat > "$expected_file" <<END
dc807017
SM
128{Trace 0, Stream class ID 0, Stream ID 0}
129Stream beginning:
130 Name: TestSourceA: ('test-bonjour', 'monsieur'), ('test-salut', 'les amis')
131 Trace:
132 Stream (ID 0, Class ID 0)
133
134{Trace 1, Stream class ID 0, Stream ID 0}
135Stream beginning:
136 Name: TestSourceB: ('test-bonjour', 'madame'), ('test-salut', 'les amis')
137 Trace:
138 Stream (ID 0, Class ID 0)
139
140{Trace 0, Stream class ID 0, Stream ID 0}
141Stream end
142
143{Trace 1, Stream class ID 0, Stream ID 0}
144Stream end
1ead9076
SM
145END
146
dc807017 147bt_diff_cli "$expected_file" "/dev/null" \
1ead9076 148 convert --plugin-path "${plugin_dir}" \
dc807017
SM
149 "${dir_ab}" --params 'test-bonjour="madame",test-salut="les amis"' ${print_test_params} "${dir_a}" --params 'test-bonjour="monsieur"' ${print_test_params} \
150 ${details_sink[@]}
24594611 151ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
1ead9076
SM
152
153rm -f "$expected_file"
This page took 0.02906 seconds and 4 git commands to generate.