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