cli: apply parameters (`--params` option) to leftovers
[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
34data_dir="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-params"
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)
41stderr_expected=/dev/null
42
43# Apply params to two components from one leftover.
44cat > "$expected_file" <<END
45TestSourceA: ('test-allo', 'madame')
46TestSourceB: ('test-allo', 'madame')
47END
48
49bt_diff_cli_sorted "$expected_file" "$stderr_expected" \
50 convert --plugin-path "${plugin_dir}" \
51 "${dir_ab}" --params 'test-allo="madame"'
52ok "$?" "apply params to two components from one leftover"
53
54# Apply params to two components from two distinct leftovers.
55cat > "$expected_file" <<END
56TestSourceA: ('test-allo', 'madame')
57TestSourceB: ('test-bonjour', 'monsieur')
58END
59
60bt_diff_cli_sorted "$expected_file" "$stderr_expected" \
61 convert --plugin-path "${plugin_dir}" \
62 "${dir_a}" --params 'test-allo="madame"' "${dir_b}" --params 'test-bonjour="monsieur"'
63ok "$?" "apply params to two leftovers"
64
65# Apply params to one component coming from one leftover and one component coming from two leftovers (1).
66cat > "$expected_file" <<END
67TestSourceA: ('test-allo', 'madame'), ('test-bonjour', 'monsieur')
68TestSourceB: ('test-bonjour', 'monsieur')
69END
70
71bt_diff_cli_sorted "$expected_file" "$stderr_expected" \
72 convert --plugin-path "${plugin_dir}" \
73 "${dir_a}" --params 'test-allo="madame"' "${dir_ab}" --params 'test-bonjour="monsieur"'
74ok "$?" "apply params to one component coming from one leftover and one component coming from two leftovers (1)"
75
76# Apply params to one component coming from one leftover and one component coming from two leftovers (2).
77cat > "$expected_file" <<END
78TestSourceA: ('test-bonjour', 'monsieur'), ('test-salut', 'les amis')
79TestSourceB: ('test-bonjour', 'madame'), ('test-salut', 'les amis')
80END
81
82bt_diff_cli_sorted "$expected_file" "$stderr_expected" \
83 convert --plugin-path "${plugin_dir}" \
84 "${dir_ab}" --params 'test-bonjour="madame",test-salut="les amis"' "${dir_a}" --params 'test-bonjour="monsieur"'
85ok "$?" "apply params to one component coming from one leftover and one component coming from two leftovers (2)"
86
87rm -f "$expected_file"
This page took 0.027417 seconds and 4 git commands to generate.