X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fcli%2Fquery%2Ftest_query;h=e44d67779b629417291dca8a403d833db0ed41c0;hb=HEAD;hp=803644ba462a942e6a7312c4f853d5c6788ea1e5;hpb=927c069356ec0754daf592601145313155e9ce94;p=babeltrace.git diff --git a/tests/cli/query/test_query b/tests/cli/query/test_query deleted file mode 100755 index 803644ba..00000000 --- a/tests/cli/query/test_query +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2019 Simon Marchi -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then - UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" -else - UTILSSH="$(dirname "$0")/../../utils/utils.sh" -fi - -# shellcheck source=../../utils/utils.sh -SH_TAP=1 source "$UTILSSH" - -NUM_TESTS=15 - -plan_tests $NUM_TESTS - -data_dir="${BT_TESTS_DATADIR}/cli/query" -plugin_dir="${data_dir}" - -stdout_expected_file=$(mktemp -t test_cli_query_stdout_xpected.XXXXXX) -stdout_file=$(mktemp -t test_cli_query_stdout.XXXXXX) -stderr_file=$(mktemp -t test_cli_query_stderr.XXXXXX) - -expect_success() { - local expected_str="$1" - shift 1 - local args=("$@") - - echo "$expected_str" > "$stdout_expected_file" - - bt_diff_cli "$stdout_expected_file" /dev/null \ - --plugin-path "$plugin_dir" \ - query "src.query.SourceWithQueryThatPrintsParams" \ - "${args[@]}" - ok "$?" "${args[*]}" -} - -expect_failure() { - local expected_str="$1" - shift 1 - local args=("$@") - local test_name="${args[*]}" - - echo -n > "$stdout_expected_file" - - bt_cli "$stdout_file" "$stderr_file" \ - --plugin-path "$plugin_dir" \ - query \ - "${args[@]}" - isnt "$?" 0 "${test_name}: exit code is not 0" - - bt_diff /dev/null "$stdout_file" - ok "$?" "${test_name}: nothing output on stout" - - # Ensure that a CLI error stack is printed (and that babeltrace doesn't - # abort before that). - grep --silent "^ERROR: " "${stderr_file}" - ok $? "${test_name}: babeltrace produces an error stack" - - grep --silent "${expected_str}" "${stderr_file}" - ok "$?" "${test_name}: expect \`${expected_str}\` error message on stderr" -} - -expect_success 'the-object:{}' \ - 'the-object' -expect_success "the-object:{a=2}" \ - 'the-object' -p 'a=2' - -# Check that -p parameters are processed in order. -expect_success "the-object:{a=3, ben=kin, voyons=donc}" \ - 'the-object' -p 'a=2,ben=kin' -p 'voyons=donc,a=3' - -# Failure inside the component class' query method. -expect_failure "ValueError: catastrophic failure" \ - 'src.query.SourceWithQueryThatPrintsParams' 'please-fail' '-p' 'a=2' - -# Non-existent component class. -expect_failure 'Cannot find component class: plugin-name="query", comp-cls-name="NonExistentSource", comp-cls-type=1' \ - 'src.query.NonExistentSource' 'the-object' '-p' 'a=2' - -# Wrong parameter syntax. -expect_failure "Invalid format for --params option's argument:" \ - 'src.query.SourceWithQueryThatPrintsParams' 'please-fail' '-p' 'a=3,' - -rm -f "$stdout_expected_file" -rm -f "$stdout_file" -rm -f "$stderr_file"