# 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
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\""
: ${CTDB_DEBUGLEVEL:=3}
export CTDB_DEBUGLEVEL
- unit_test $test_prog "$@"
+ unit_test ctdb $test_args "$@"
}
--- /dev/null
+#!/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