Commit | Line | Data |
---|---|---|
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 | 11 | if [ -n "${BT_TESTS_SRCDIR:-}" ]; then |
1ead9076 SM |
12 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" |
13 | else | |
14 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" | |
15 | fi | |
16 | ||
17 | # shellcheck source=../../utils/utils.sh | |
18 | SH_TAP=1 source "$UTILSSH" | |
19 | ||
20 | NUM_TESTS=4 | |
21 | ||
22 | plan_tests $NUM_TESTS | |
23 | ||
a83410cd | 24 | data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level" |
1ead9076 SM |
25 | plugin_dir="${data_dir}" |
26 | dir_a="${data_dir}/dir-a" | |
27 | dir_b="${data_dir}/dir-b" | |
28 | dir_ab="${data_dir}/dir-ab" | |
29 | ||
30 | expected_file=$(mktemp -t expected.XXXXXX) | |
1ead9076 | 31 | |
e511a264 | 32 | print_test_params=("--params" 'what="test-params"') |
dc807017 | 33 | details_sink=("-c" "sink.text.details" "--params=with-metadata=false") |
1b2b6649 | 34 | |
24594611 | 35 | # Apply params to two components from one non-option argument. |
1ead9076 | 36 | cat > "$expected_file" <<END |
dc807017 SM |
37 | {Trace 0, Stream class ID 0, Stream ID 0} |
38 | Stream 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} | |
44 | Stream 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} | |
50 | Stream end | |
51 | ||
52 | {Trace 1, Stream class ID 0, Stream ID 0} | |
53 | Stream end | |
1ead9076 SM |
54 | END |
55 | ||
dc807017 | 56 | bt_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 | 60 | ok "$?" "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 | 63 | cat > "$expected_file" <<END |
dc807017 SM |
64 | {Trace 0, Stream class ID 0, Stream ID 0} |
65 | Stream 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} | |
71 | Stream 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} | |
77 | Stream end | |
78 | ||
79 | {Trace 1, Stream class ID 0, Stream ID 0} | |
80 | Stream end | |
1ead9076 SM |
81 | END |
82 | ||
dc807017 | 83 | bt_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 | 87 | ok "$?" "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 | 90 | cat > "$expected_file" <<END |
dc807017 SM |
91 | {Trace 0, Stream class ID 0, Stream ID 0} |
92 | Stream 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} | |
98 | Stream 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} | |
104 | Stream end | |
105 | ||
106 | {Trace 1, Stream class ID 0, Stream ID 0} | |
107 | Stream end | |
1ead9076 SM |
108 | END |
109 | ||
dc807017 | 110 | bt_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 | 114 | ok "$?" "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 | 117 | cat > "$expected_file" <<END |
dc807017 SM |
118 | {Trace 0, Stream class ID 0, Stream ID 0} |
119 | Stream 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} | |
125 | Stream 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} | |
131 | Stream end | |
132 | ||
133 | {Trace 1, Stream class ID 0, Stream ID 0} | |
134 | Stream end | |
1ead9076 SM |
135 | END |
136 | ||
dc807017 | 137 | bt_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 | 141 | ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2)" |
1ead9076 SM |
142 | |
143 | rm -f "$expected_file" |