| 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 the auto source disovery mechanism of the CLI. |
| 9 | |
| 10 | if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then |
| 11 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" |
| 12 | else |
| 13 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" |
| 14 | fi |
| 15 | |
| 16 | # shellcheck source=../../utils/utils.sh |
| 17 | SH_TAP=1 source "$UTILSSH" |
| 18 | |
| 19 | NUM_TESTS=3 |
| 20 | |
| 21 | plan_tests $NUM_TESTS |
| 22 | |
| 23 | data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/grouping" |
| 24 | plugin_dir="${data_dir}" |
| 25 | trace_dir="${data_dir}/traces" |
| 26 | |
| 27 | stdout_expected_file="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-grouping.expect" |
| 28 | stdout_actual_file=$(mktemp -t stdout-actual.XXXXXX) |
| 29 | stderr_actual_file=$(mktemp -t actual-stderr.XXXXXX) |
| 30 | |
| 31 | bt_cli "$stdout_actual_file" "$stderr_actual_file" \ |
| 32 | --plugin-path "${plugin_dir}" convert "ABCDE" "${trace_dir}" some_other_non_opt \ |
| 33 | -c sink.text.details --params='with-metadata=false' |
| 34 | ok "$?" "CLI runs successfully" |
| 35 | |
| 36 | # Check components and their inputs. |
| 37 | bt_diff "$stdout_expected_file" "$stdout_actual_file" |
| 38 | ok "$?" "expected components are instantiated with expected inputs" |
| 39 | |
| 40 | # Check that expected warning is printed. |
| 41 | # shellcheck disable=SC2016 |
| 42 | grep -q 'No trace was found based on input `some_other_non_opt`' "$stderr_actual_file" |
| 43 | ok "$?" "warning is printed" |
| 44 | |
| 45 | rm -f "$stdout_actual_file" |
| 46 | rm -f "$stderr_actual_file" |