tests: use -z / -n to test for string empty / non-empty
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_log_level
... / ...
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 log level options are applied to sources auto-discovered by the
9# convert 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_log_level=(--params 'what="log-level"')
33details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
34
35debug=2
36trace=1
37
38# Apply log level to two components from one non-option argument.
39cat > "$expected_file" <<END
40{Trace 0, Stream class ID 0, Stream ID 0}
41Stream beginning:
42 Name: TestSourceA: ${debug}
43 Trace:
44 Stream (ID 0, Class ID 0)
45
46{Trace 1, Stream class ID 0, Stream ID 0}
47Stream beginning:
48 Name: TestSourceB: ${debug}
49 Trace:
50 Stream (ID 0, Class ID 0)
51
52{Trace 0, Stream class ID 0, Stream ID 0}
53Stream end
54
55{Trace 1, Stream class ID 0, Stream ID 0}
56Stream end
57END
58
59bt_diff_cli "$expected_file" "/dev/null" \
60 --plugin-path "${plugin_dir}" convert \
61 "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" \
62 "${details_sink[@]}"
63ok "$?" "apply log level to two components from one non-option argument"
64
65# Apply log level to two components from two distinct non-option arguments.
66cat > "$expected_file" <<END
67{Trace 0, Stream class ID 0, Stream ID 0}
68Stream beginning:
69 Name: TestSourceA: ${debug}
70 Trace:
71 Stream (ID 0, Class ID 0)
72
73{Trace 1, Stream class ID 0, Stream ID 0}
74Stream beginning:
75 Name: TestSourceB: ${trace}
76 Trace:
77 Stream (ID 0, Class ID 0)
78
79{Trace 0, Stream class ID 0, Stream ID 0}
80Stream end
81
82{Trace 1, Stream class ID 0, Stream ID 0}
83Stream end
84END
85
86bt_diff_cli "$expected_file" "/dev/null" \
87 --plugin-path "${plugin_dir}" convert \
88 "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_b}" --log-level TRACE "${print_log_level[@]}" \
89 "${details_sink[@]}"
90ok "$?" "apply log level to two non-option arguments"
91
92# Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1).
93cat > "$expected_file" <<END
94{Trace 0, Stream class ID 0, Stream ID 0}
95Stream beginning:
96 Name: TestSourceA: ${trace}
97 Trace:
98 Stream (ID 0, Class ID 0)
99
100{Trace 1, Stream class ID 0, Stream ID 0}
101Stream beginning:
102 Name: TestSourceB: ${trace}
103 Trace:
104 Stream (ID 0, Class ID 0)
105
106{Trace 0, Stream class ID 0, Stream ID 0}
107Stream end
108
109{Trace 1, Stream class ID 0, Stream ID 0}
110Stream end
111END
112
113bt_diff_cli "$expected_file" "/dev/null" \
114 --plugin-path "${plugin_dir}" convert \
115 "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_ab}" --log-level TRACE "${print_log_level[@]}" \
116 "${details_sink[@]}"
117ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
118
119# Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2).
120cat > "$expected_file" <<END
121{Trace 0, Stream class ID 0, Stream ID 0}
122Stream beginning:
123 Name: TestSourceA: ${trace}
124 Trace:
125 Stream (ID 0, Class ID 0)
126
127{Trace 1, Stream class ID 0, Stream ID 0}
128Stream beginning:
129 Name: TestSourceB: ${debug}
130 Trace:
131 Stream (ID 0, Class ID 0)
132
133{Trace 0, Stream class ID 0, Stream ID 0}
134Stream end
135
136{Trace 1, Stream class ID 0, Stream ID 0}
137Stream end
138END
139
140bt_diff_cli "$expected_file" "/dev/null" \
141 --plugin-path "${plugin_dir}" convert \
142 "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" "${dir_a}" --log-level TRACE "${print_log_level[@]}" \
143 "${details_sink[@]}"
144ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
145
146rm -f "$expected_file"
This page took 0.023912 seconds and 4 git commands to generate.