tests: use -z / -n to test for string empty / non-empty
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_log_level
CommitLineData
1b2b6649
SM
1#!/bin/bash
2#
0235b0db 3# SPDX-License-Identifier: GPL-2.0-only
1b2b6649 4#
0235b0db 5# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
1b2b6649 6#
1b2b6649 7
dc807017
SM
8# Test how log level options are applied to sources auto-discovered by the
9# convert command.
1b2b6649 10
75e396f6 11if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
1b2b6649
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"
1b2b6649
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)
1b2b6649 31
e511a264 32print_log_level=(--params 'what="log-level"')
dc807017 33details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
1b2b6649
SM
34
35debug=2
36trace=1
37
24594611 38# Apply log level to two components from one non-option argument.
1b2b6649 39cat > "$expected_file" <<END
dc807017
SM
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
1b2b6649
SM
57END
58
dc807017 59bt_diff_cli "$expected_file" "/dev/null" \
02510056 60 --plugin-path "${plugin_dir}" convert \
e511a264
SM
61 "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" \
62 "${details_sink[@]}"
24594611 63ok "$?" "apply log level to two components from one non-option argument"
1b2b6649 64
24594611 65# Apply log level to two components from two distinct non-option arguments.
1b2b6649 66cat > "$expected_file" <<END
dc807017
SM
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
1b2b6649
SM
84END
85
dc807017 86bt_diff_cli "$expected_file" "/dev/null" \
02510056 87 --plugin-path "${plugin_dir}" convert \
e511a264
SM
88 "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_b}" --log-level TRACE "${print_log_level[@]}" \
89 "${details_sink[@]}"
24594611 90ok "$?" "apply log level to two non-option arguments"
1b2b6649 91
24594611 92# Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1).
1b2b6649 93cat > "$expected_file" <<END
dc807017
SM
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
1b2b6649
SM
111END
112
dc807017 113bt_diff_cli "$expected_file" "/dev/null" \
02510056 114 --plugin-path "${plugin_dir}" convert \
e511a264
SM
115 "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_ab}" --log-level TRACE "${print_log_level[@]}" \
116 "${details_sink[@]}"
24594611 117ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
1b2b6649 118
24594611 119# Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2).
1b2b6649 120cat > "$expected_file" <<END
dc807017
SM
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
1b2b6649
SM
138END
139
dc807017 140bt_diff_cli "$expected_file" "/dev/null" \
02510056 141 --plugin-path "${plugin_dir}" convert \
e511a264
SM
142 "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" "${dir_a}" --log-level TRACE "${print_log_level[@]}" \
143 "${details_sink[@]}"
24594611 144ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
1b2b6649
SM
145
146rm -f "$expected_file"
This page took 0.048282 seconds and 4 git commands to generate.