208928dc5f5166cd2b924efae3fd122f4a37139e
[babeltrace.git] / tests / cli / auto-source-discovery / test_auto_source_discovery
1 #!/bin/bash
2 #
3 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
4 #
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License, version 2 only, as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 # Test the auto source disovery mechanism of the CLI.
19
20 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
22 else
23 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
24 fi
25
26 # shellcheck source=../../utils/utils.sh
27 SH_TAP=1 source "$UTILSSH"
28
29 NUM_TESTS=2
30
31 plan_tests $NUM_TESTS
32
33 data_dir=$(readlink -f "${BT_TESTS_DATADIR}/cli/auto-source-discovery")
34 plugin_dir="${data_dir}"
35 trace_dir="${data_dir}/traces"
36
37 expected_file=$(mktemp expected.XXXXXX)
38 actual_file=$(mktemp actual.XXXXXX)
39
40 run_python_bt2 "$BT_TESTS_BT2_BIN" convert --plugin-path "${plugin_dir}" "ABCDE" "${trace_dir}" some_other_leftover | sort > "$actual_file"
41 ok "${PIPESTATUS[0]}" "successful execution"
42
43 cat > "$expected_file" <<END
44 TestSourceABCDE: ABCDE
45 TestSourceExt: ${trace_dir}/aaa1, ${trace_dir}/aaa2, ${trace_dir}/aaa3
46 TestSourceExt: ${trace_dir}/bbb1, ${trace_dir}/bbb2
47 TestSourceExt: ${trace_dir}/ccc1
48 TestSourceExt: ${trace_dir}/ccc2
49 TestSourceExt: ${trace_dir}/ccc3
50 TestSourceExt: ${trace_dir}/ccc4
51 TestSourceSomeDir: ${trace_dir}/some-dir
52 END
53
54 diff -u "$expected_file" "$actual_file"
55 ok "$?" "sources are auto-discovered"
56
57 rm -f "$expected_file" "$actual_file"
This page took 0.030728 seconds and 3 git commands to generate.