# Augment PATH with stubs/ directory.
-if [ -d "${TEST_SUBDIR}/stubs" ] ; then
- PATH="${TEST_SUBDIR}/stubs:$PATH"
-fi
-
if "$TEST_VERBOSE" ; then
debug () { echo "$@" ; }
else
debug () { : ; }
fi
+ctdbd_socket="${TEST_VAR_DIR}/ctdbd.socket.$$"
+ctdbd_pidfile="${TEST_VAR_DIR}/ctdbd.pid.$$"
+
define_test ()
{
_f=$(basename "$0" ".sh")
stubby.*)
_cmd="${_f#stubby.}"
_cmd="${_cmd%.*}" # Strip test number
- export CTDB_TEST_PROG="ctdb_stubtest"
+ export CTDB="ctdb --socket $ctdbd_socket"
+ export CTDB_DEBUGLEVEL=3
test_args="$_cmd"
;;
*)
printf "%-28s - %s\n" "$_f" "$1"
}
+cleanup_ctdbd ()
+{
+ debug "Cleaning up fake ctdbd"
+
+ pid=$(cat "$ctdbd_pidfile" 2>/dev/null || echo)
+ if [ -n "$pid" ] ; then
+ kill $pid || true
+ rm -f "$ctdbd_pidfile"
+ fi
+ rm -f "$ctdbd_socket"
+}
+
+setup_ctdbd ()
+{
+ debug "Setting up fake ctdbd"
+
+ cat | fake_ctdbd -s "$ctdbd_socket" -p "$ctdbd_pidfile"
+ #test_cleanup cleanup_ctdbd
+}
+
setup_natgw ()
{
debug "Setting up NAT gateway"
simple_test ()
{
- : ${CTDB_DEBUGLEVEL:=3}
- export CTDB_DEBUGLEVEL
-
- unit_test ctdb $test_args "$@"
+ setup_ctdbd
+ (unit_test $CTDB -d $CTDB_DEBUGLEVEL $test_args "$@")
+ status=$?
+ cleanup_ctdbd
+ [ $status -eq 0 ] || exit $status
}
+++ /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