From: Martin Schwenke Date: Mon, 12 Aug 2019 11:01:20 +0000 (+1000) Subject: ctdb-tests: Add new test functions for running commands on nodes X-Git-Tag: talloc-2.3.1~490 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ec83f32faddf6ef9f5fdd11ecd6d651459dd650;p=thirdparty%2Fsamba.git ctdb-tests: Add new test functions for running commands on nodes * ctdb_onnode() * testprog_onnode() * function_onnode() These encapsulate familiar patterns found when running try_command_on_node(). The new function names are more concise and encourage more readable tests. Test writers can do less thinking about the subtleties of running different types of commands on nodes. For example, these functions ensure that $CTDB and $VALGRIND are used in the correct contexts. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index 52830ff9703..55b5deb7023 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -133,6 +133,46 @@ try_command_on_node () fi } +_run_onnode () +{ + local thing="$1" + shift + + local options nodespec + + while : ; do + case "$1" in + -*) + options="${options}${options:+ }${1}" + shift + ;; + *) + nodespec="$1" + shift + break + esac + done + + # shellcheck disable=SC2086 + # $options can be multi-word + try_command_on_node $options "$nodespec" "${thing} $*" +} + +ctdb_onnode () +{ + _run_onnode "$CTDB" "$@" +} + +testprog_onnode () +{ + _run_onnode "${CTDB_TEST_WRAPPER} ${VALGRIND}" "$@" +} + +function_onnode () +{ + _run_onnode "${CTDB_TEST_WRAPPER}" "$@" +} + sanity_check_output () { local min_lines="$1"