tests: use -z / -n to test for string empty / non-empty
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_params
... / ...
CommitLineData
1#!/bin/bash
2#
3# SPDX-License-Identifier: GPL-2.0-only
4#
5# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
6#
7
8# Test how parameters are applied to sources auto-discovered by the convert
9# command.
10
11if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
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
24data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level"
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)
31
32print_test_params=("--params" 'what="test-params"')
33details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
34
35# Apply params to two components from one non-option argument.
36cat > "$expected_file" <<END
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
54END
55
56bt_diff_cli "$expected_file" "/dev/null" \
57 --plugin-path "${plugin_dir}" convert \
58 "${dir_ab}" --params 'test-allo="madame"' "${print_test_params[@]}" \
59 "${details_sink[@]}"
60ok "$?" "apply params to two components from one non-option argument"
61
62# Apply params to two components from two distinct non-option arguments.
63cat > "$expected_file" <<END
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
81END
82
83bt_diff_cli "$expected_file" "/dev/null" \
84 --plugin-path "${plugin_dir}" convert \
85 "${dir_a}" --params 'test-allo="madame"' "${print_test_params[@]}" "${dir_b}" --params 'test-bonjour="monsieur"' "${print_test_params[@]}" \
86 "${details_sink[@]}"
87ok "$?" "apply params to two non-option arguments"
88
89# Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1).
90cat > "$expected_file" <<END
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
108END
109
110bt_diff_cli "$expected_file" "/dev/null" \
111 --plugin-path "${plugin_dir}" convert \
112 "${dir_a}" --params 'test-allo="madame"' "${print_test_params[@]}" "${dir_ab}" --params 'test-bonjour="monsieur"' "${print_test_params[@]}" \
113 "${details_sink[@]}"
114ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
115
116# Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2).
117cat > "$expected_file" <<END
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
135END
136
137bt_diff_cli "$expected_file" "/dev/null" \
138 --plugin-path "${plugin_dir}" convert \
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[@]}"
141ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
142
143rm -f "$expected_file"
This page took 0.022756 seconds and 4 git commands to generate.