| 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=3 |
| 30 | |
| 31 | plan_tests $NUM_TESTS |
| 32 | |
| 33 | data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/grouping" |
| 34 | plugin_dir="${data_dir}" |
| 35 | trace_dir="${data_dir}/traces" |
| 36 | |
| 37 | stdout_expected_file="${BT_TESTS_DATADIR}/cli/convert/auto-source-discovery-grouping.expect" |
| 38 | stdout_actual_file=$(mktemp -t stdout-actual.XXXXXX) |
| 39 | stderr_actual_file=$(mktemp -t actual-stderr.XXXXXX) |
| 40 | |
| 41 | bt_cli "$stdout_actual_file" "$stderr_actual_file" \ |
| 42 | --plugin-path "${plugin_dir}" convert "ABCDE" "${trace_dir}" some_other_non_opt \ |
| 43 | -c sink.text.details --params='with-metadata=false' |
| 44 | ok "$?" "CLI runs successfully" |
| 45 | |
| 46 | # Check components and their inputs. |
| 47 | bt_diff "$stdout_expected_file" "$stdout_actual_file" |
| 48 | ok "$?" "expected components are instantiated with expected inputs" |
| 49 | |
| 50 | # Check that expected warning is printed. |
| 51 | # shellcheck disable=SC2016 |
| 52 | grep -q 'No trace was found based on input `some_other_non_opt`' "$stderr_actual_file" |
| 53 | ok "$?" "warning is printed" |
| 54 | |
| 55 | rm -f "$stdout_actual_file" |
| 56 | rm -f "$stderr_actual_file" |