1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
3 # Augment PATH with stubs/ directory.
5 if "$TEST_VERBOSE" ; then
6 debug () { echo "$@" ; }
11 ctdbd_socket="${TEST_VAR_DIR}/ctdbd.socket.$$"
12 ctdbd_pidfile="${TEST_VAR_DIR}/ctdbd.pid.$$"
16 _f=$(basename "$0" ".sh")
21 _cmd="${_cmd%.*}" # Strip test number
22 export CTDB="ctdb --socket $ctdbd_socket"
23 export CTDB_DEBUGLEVEL=2
27 die "Unknown pattern for testcase \"$_f\""
30 printf "%-28s - %s\n" "$_f" "$1"
35 debug "Cleaning up fake ctdbd"
37 pid=$(cat "$ctdbd_pidfile" 2>/dev/null || echo)
38 if [ -n "$pid" ] ; then
40 rm -f "$ctdbd_pidfile"
47 debug "Setting up fake ctdbd"
49 $VALGRIND fake_ctdbd -s "$ctdbd_socket" -p "$ctdbd_pidfile"
50 test_cleanup cleanup_ctdbd
60 debug "Setting up NAT gateway"
62 # Use in-tree binaries if running against local daemons.
63 # Otherwise CTDB need to be installed on all nodes.
64 if [ -n "$ctdb_dir" -a -d "${ctdb_dir}/bin" ] ; then
65 if [ -z "$CTDB_NATGW_HELPER" ] ; then
66 export CTDB_NATGW_HELPER="${ctdb_dir}/tools/ctdb_natgw"
68 # Only want to find functions file, so this is OK
69 export CTDB_BASE="${ctdb_dir}/config"
72 natgw_config_dir="${TEST_VAR_DIR}/natgw_config"
73 mkdir -p "$natgw_config_dir"
75 export CTDB_NATGW_NODES=$(mktemp --tmpdir="$natgw_config_dir")
76 test_cleanup "rm -f $CTDB_NATGW_NODES"
78 cat >"$CTDB_NATGW_NODES"
83 debug "Setting up LVS"
85 # Use in-tree binaries if running against local daemons.
86 # Otherwise CTDB need to be installed on all nodes.
87 if [ -n "$ctdb_dir" -a -d "${ctdb_dir}/bin" ] ; then
88 if [ -z "$CTDB_LVS_HELPER" ] ; then
89 export CTDB_LVS_HELPER="${ctdb_dir}/tools/ctdb_lvs"
91 # Only want to find functions file, so this is OK
92 export CTDB_BASE="${ctdb_dir}/config"
95 lvs_config_dir="${TEST_VAR_DIR}/lvs_config"
96 mkdir -p "$lvs_config_dir"
98 export CTDB_LVS_NODES=$(mktemp --tmpdir="$lvs_config_dir")
99 test_cleanup "rm -f ${CTDB_LVS_NODES}"
101 cat >"$CTDB_LVS_NODES"
108 _v="CTDB_NODES${_pnn:+_}${_pnn}"
109 debug "Setting up ${_v}"
111 eval export "${_v}"=$(mktemp --tmpdir="$TEST_VAR_DIR")
114 test_cleanup "rm -f ${_f}"
117 # You can't be too careful about what might be in the
118 # environment... so clean up when setting the default variable.
119 if [ -z "$_pnn" ] ; then
120 _n=$(wc -l "$CTDB_NODES" | awk '{ print $1 }')
121 for _i in $(seq 0 $_n) ; do
122 eval unset "CTDB_NODES_${_i}"
129 (unit_test $CTDB -d $CTDB_DEBUGLEVEL "$@")
131 [ $status -eq 0 ] || exit $status
136 simple_test_other $test_args "$@"