mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ctdb-tests: Test ctdb CLI tool via a stub
Some features, such NAT gateway and LVS support, can be implemented without daemon and (internal) ctdb CLI tool support. These are non-core features that don't need incredible performance and they don't need to be in the core code. They can easily be reimplemented in scripts, along with some configuration changes. For continuity, the ctdb CLI tool code will call out to helper scripts so that the current status information can still be provided. Those helper scripts may then reinvoke the ctdb CLI tool to gather information. So, redo the tool testing using a "ctdb" stub command. This will swallow standard input and feed it to the test program each time the "ctdb" stub is called. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
1538fc4585
commit
3a2eebfe19
@ -1,5 +1,11 @@
|
||||
# Hey Emacs, this is a -*- shell-script -*- !!! :-)
|
||||
|
||||
# Augment PATH with stubs/ directory.
|
||||
|
||||
if [ -d "${TEST_SUBDIR}/stubs" ] ; then
|
||||
PATH="${TEST_SUBDIR}/stubs:$PATH"
|
||||
fi
|
||||
|
||||
if "$TEST_VERBOSE" ; then
|
||||
debug () { echo "$@" ; }
|
||||
else
|
||||
@ -14,12 +20,14 @@ define_test ()
|
||||
func.*)
|
||||
_func="${_f#func.}"
|
||||
_func="${_func%.*}" # Strip test number
|
||||
test_prog="ctdb_functest ${_func}"
|
||||
export CTDB_TEST_PROG="ctdb_functest"
|
||||
test_args="$_func"
|
||||
;;
|
||||
stubby.*)
|
||||
_cmd="${_f#stubby.}"
|
||||
_cmd="${_cmd%.*}" # Strip test number
|
||||
test_prog="ctdb_stubtest ${_cmd}"
|
||||
export CTDB_TEST_PROG="ctdb_stubtest"
|
||||
test_args="$_cmd"
|
||||
;;
|
||||
*)
|
||||
die "Unknown pattern for testcase \"$_f\""
|
||||
@ -71,5 +79,5 @@ simple_test ()
|
||||
: ${CTDB_DEBUGLEVEL:=3}
|
||||
export CTDB_DEBUGLEVEL
|
||||
|
||||
unit_test $test_prog "$@"
|
||||
unit_test ctdb $test_args "$@"
|
||||
}
|
||||
|
27
ctdb/tests/tool/stubs/ctdb
Executable file
27
ctdb/tests/tool/stubs/ctdb
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# If "ctdb" is called several time in a test then it must always get
|
||||
# the same input. So, it is read here the first time and then fed to
|
||||
# all future instances.
|
||||
if [ -z "$_CTDB_TOOL_STUB_INPUT" ] ; then
|
||||
if ! tty -s ; then
|
||||
_CTDB_TOOL_STUB_INPUT=$(cat)
|
||||
else
|
||||
_CTDB_TOOL_STUB_INPUT=""
|
||||
fi
|
||||
# Let's not try being subtle about whether this variable is unset
|
||||
# or empty. If we've been here then it is set, even if input was
|
||||
# empty.
|
||||
if [ -z "$_CTDB_TOOL_STUB_INPUT" ] ; then
|
||||
_CTDB_TOOL_STUB_INPUT="@@@EMPTY@@@"
|
||||
fi
|
||||
export _CTDB_TOOL_STUB_INPUT
|
||||
fi
|
||||
|
||||
if [ "$_CTDB_TOOL_STUB_INPUT" != "@@@EMPTY@@@" ] ; then
|
||||
exec "$CTDB_TEST_PROG" "$@" <<EOF
|
||||
$_CTDB_TOOL_STUB_INPUT
|
||||
EOF
|
||||
else
|
||||
exec "$CTDB_TEST_PROG" "$@" </dev/null
|
||||
fi
|
Loading…
Reference in New Issue
Block a user