1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

ctdb-tests: Reformat remaining test stubs with "shfmt -w -p -i 0 -fn"

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Sep 16 04:35:09 UTC 2022 on sn-devel-184
This commit is contained in:
Martin Schwenke 2022-08-26 09:16:49 +10:00 committed by Amitay Isaacs
parent 0e388a1994
commit 4f5b4bd9df
26 changed files with 660 additions and 586 deletions

View File

@ -3,28 +3,29 @@
prog="ctdb"
# Print a message and exit.
die ()
die()
{
echo "$1" >&2 ; exit "${2:-1}"
echo "$1" >&2
exit "${2:-1}"
}
not_implemented_exit_code=1
usage ()
usage()
{
cat >&2 <<EOF
cat >&2 <<EOF
Usage: $prog [-X] cmd
A fake CTDB stub that prints items depending on the variables
FAKE_CTDB_PNN (default 0) depending on command-line options.
EOF
exit 1
exit 1
}
not_implemented ()
not_implemented()
{
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
}
verbose=false
@ -36,19 +37,19 @@ args=""
# Options and command argument can appear in any order, so when
# getopts thinks it is done, process any non-option arguments and go
# around again.
while [ $# -gt 0 ] ; do
while getopts "Xvhn:?" opt ; do
while [ $# -gt 0 ]; do
while getopts "Xvhn:?" opt; do
case "$opt" in
X) machine_readable=true ;;
v) verbose=true ;;
n) nodespec="$OPTARG" ;;
\?|*) usage ;;
\? | *) usage ;;
esac
done
shift $((OPTIND - 1))
# Anything left over must be a non-option arg
if [ $# -gt 0 ] ; then
if [ $# -gt 0 ]; then
args="${args}${args:+ }${1}"
shift
fi
@ -59,85 +60,85 @@ done
# shellcheck disable=SC2086
set -- $args
setup_tickles ()
setup_tickles()
{
# Make sure tickles file exists.
tickles_file="${CTDB_TEST_TMP_DIR}/fake-ctdb/tickles"
mkdir -p "$(dirname "$tickles_file")"
touch "$tickles_file"
# Make sure tickles file exists.
tickles_file="${CTDB_TEST_TMP_DIR}/fake-ctdb/tickles"
mkdir -p "$(dirname "$tickles_file")"
touch "$tickles_file"
}
ctdb_gettickles ()
ctdb_gettickles()
{
_ip="$1"
_port="$2"
_ip="$1"
_port="$2"
setup_tickles
setup_tickles
echo "|source ip|port|destination ip|port|"
while read -r _src _dst ; do
if [ -z "$_ip" ] || [ "$_ip" = "${_dst%:*}" ] ; then
if [ -z "$_port" ] || [ "$_port" = "${_dst##*:}" ] ; then
echo "|${_src%:*}|${_src##*:}|${_dst%:*}|${_dst##*:}|"
fi
echo "|source ip|port|destination ip|port|"
while read -r _src _dst; do
if [ -z "$_ip" ] || [ "$_ip" = "${_dst%:*}" ]; then
if [ -z "$_port" ] || [ "$_port" = "${_dst##*:}" ]; then
echo "|${_src%:*}|${_src##*:}|${_dst%:*}|${_dst##*:}|"
fi
fi
done <"$tickles_file"
}
ctdb_addtickle()
{
_src="$1"
_dst="$2"
setup_tickles
if [ -n "$_dst" ]; then
echo "${_src} ${_dst}" >>"$tickles_file"
else
cat >>"$tickles_file"
fi
done <"$tickles_file"
}
ctdb_addtickle ()
ctdb_deltickle()
{
_src="$1"
_dst="$2"
_src="$1"
_dst="$2"
setup_tickles
setup_tickles
if [ -n "$_dst" ] ; then
echo "${_src} ${_dst}" >>"$tickles_file"
else
cat >>"$tickles_file"
fi
if [ -n "$_dst" ]; then
_t=$(grep -F -v "${_src} $${_dst}" "$tickles_file")
else
_t=$(cat "$tickles_file")
while read -r _src _dst; do
_t=$(echo "$_t" | grep -F -v "${_src} ${_dst}")
done
fi
echo "$_t" >"$tickles_file"
}
ctdb_deltickle ()
parse_nodespec()
{
_src="$1"
_dst="$2"
setup_tickles
if [ -n "$_dst" ] ; then
_t=$(grep -F -v "${_src} $${_dst}" "$tickles_file")
else
_t=$(cat "$tickles_file")
while read -r _src _dst ; do
_t=$(echo "$_t" | grep -F -v "${_src} ${_dst}")
done
fi
echo "$_t" >"$tickles_file"
}
parse_nodespec ()
{
if [ "$nodespec" = "all" ] ; then
nodes="$(seq 0 $((FAKE_CTDB_NUMNODES - 1)) )"
elif [ -n "$nodespec" ] ; then
nodes="$(echo "$nodespec" | sed -e 's@,@ @g')"
else
nodes=$(ctdb_pnn)
fi
if [ "$nodespec" = "all" ]; then
nodes="$(seq 0 $((FAKE_CTDB_NUMNODES - 1)))"
elif [ -n "$nodespec" ]; then
nodes="$(echo "$nodespec" | sed -e 's@,@ @g')"
else
nodes=$(ctdb_pnn)
fi
}
# For testing backward compatibility...
for i in $CTDB_NOT_IMPLEMENTED ; do
if [ "$i" = "$1" ] ; then
not_implemented "$i"
fi
for i in $CTDB_NOT_IMPLEMENTED; do
if [ "$i" = "$1" ]; then
not_implemented "$i"
fi
done
ctdb_pnn ()
ctdb_pnn()
{
# Defaults to 0
echo "${FAKE_CTDB_PNN:-0}"
# Defaults to 0
echo "${FAKE_CTDB_PNN:-0}"
}
######################################################################
@ -151,147 +152,147 @@ FAKE_CTDB_NODES_DISABLED="$FAKE_CTDB_NODE_STATE/0x4"
FAKE_CTDB_IP_LAYOUT="$FAKE_CTDB_STATE/ip-layout"
ip_reallocate ()
ip_reallocate()
{
touch "$FAKE_CTDB_IP_LAYOUT"
touch "$FAKE_CTDB_IP_LAYOUT"
# ShellCheck doesn't understand this flock pattern
# shellcheck disable=SC2094
(
flock 0
# ShellCheck doesn't understand this flock pattern
# shellcheck disable=SC2094
(
flock 0
_pa="${CTDB_BASE}/public_addresses"
_pa="${CTDB_BASE}/public_addresses"
if [ ! -s "$FAKE_CTDB_IP_LAYOUT" ] ; then
sed -n -e 's@^\([^#][^/]*\)/.*@\1 -1@p' \
"$_pa" >"$FAKE_CTDB_IP_LAYOUT"
fi
if [ ! -s "$FAKE_CTDB_IP_LAYOUT" ]; then
sed -n -e 's@^\([^#][^/]*\)/.*@\1 -1@p' \
"$_pa" >"$FAKE_CTDB_IP_LAYOUT"
fi
_t="${FAKE_CTDB_IP_LAYOUT}.new"
_t="${FAKE_CTDB_IP_LAYOUT}.new"
_flags=""
for _i in $(seq 0 $((FAKE_CTDB_NUMNODES - 1)) ) ; do
if ls "$FAKE_CTDB_STATE/node-state/"*"/$_i" >/dev/null 2>&1 ; then
# Have non-zero flags
_this=0
for _j in "$FAKE_CTDB_STATE/node-state/"*"/$_i" ; do
_tf="${_j%/*}" # dirname
_f="${_tf##*/}" # basename
_this=$(( _this | _f ))
_flags=""
for _i in $(seq 0 $((FAKE_CTDB_NUMNODES - 1))); do
if ls "$FAKE_CTDB_STATE/node-state/"*"/$_i" >/dev/null 2>&1; then
# Have non-zero flags
_this=0
for _j in "$FAKE_CTDB_STATE/node-state/"*"/$_i"; do
_tf="${_j%/*}" # dirname
_f="${_tf##*/}" # basename
_this=$((_this | _f))
done
else
_this="0"
fi
_flags="${_flags}${_flags:+,}${_this}"
done
else
_this="0"
fi
_flags="${_flags}${_flags:+,}${_this}"
CTDB_TEST_LOGLEVEL=NOTICE \
"ctdb_takeover_tests" \
"ipalloc" "$_flags" <"$FAKE_CTDB_IP_LAYOUT" |
sort >"$_t"
mv "$_t" "$FAKE_CTDB_IP_LAYOUT"
) <"$FAKE_CTDB_IP_LAYOUT"
}
ctdb_ip()
{
# If nobody has done any IP-fu then generate a layout.
[ -f "$FAKE_CTDB_IP_LAYOUT" ] || ip_reallocate
_mypnn=$(ctdb_pnn)
if $machine_readable; then
if $verbose; then
echo "|Public IP|Node|ActiveInterface|AvailableInterfaces|ConfiguredInterfaces|"
else
echo "|Public IP|Node|"
fi
else
echo "Public IPs on node ${_mypnn}"
fi
# Join public addresses file with $FAKE_CTDB_IP_LAYOUT, and
# process output line by line...
_pa="${CTDB_BASE}/public_addresses"
sed -e 's@/@ @' "$_pa" | sort | join - "$FAKE_CTDB_IP_LAYOUT" |
while read -r _ip _ _ifaces _pnn; do
if $verbose; then
# If more than 1 interface, assume all addresses are on the 1st.
_first_iface="${_ifaces%%,*}"
# Only show interface if address is on this node.
_my_iface=""
if [ "$_pnn" = "$_mypnn" ]; then
_my_iface="$_first_iface"
fi
if $machine_readable; then
echo "|${_ip}|${_pnn}|${_my_iface}|${_first_iface}|${_ifaces}|"
else
echo "${_ip} node[${_pnn}] active[${_my_iface}] available[${_first_iface}] configured[[${_ifaces}]"
fi
else
if $machine_readable; then
echo "|${_ip}|${_pnn}|"
else
echo "${_ip} ${_pnn}"
fi
fi
done
}
ctdb_moveip()
{
_ip="$1"
_target="$2"
ip_reallocate # should be harmless and ensures we have good state
# ShellCheck doesn't understand this flock pattern
# shellcheck disable=SC2094
(
flock 0
_t="${FAKE_CTDB_IP_LAYOUT}.new"
while read -r _i _pnn; do
if [ "$_ip" = "$_i" ]; then
echo "$_i $_target"
else
echo "$_i $_pnn"
fi
done | sort >"$_t"
mv "$_t" "$FAKE_CTDB_IP_LAYOUT"
) <"$FAKE_CTDB_IP_LAYOUT"
}
######################################################################
ctdb_enable()
{
parse_nodespec
for _i in $nodes; do
rm -f "${FAKE_CTDB_NODES_DISABLED}/${_i}"
done
CTDB_TEST_LOGLEVEL=NOTICE \
"ctdb_takeover_tests" \
"ipalloc" "$_flags" <"$FAKE_CTDB_IP_LAYOUT" |
sort >"$_t"
mv "$_t" "$FAKE_CTDB_IP_LAYOUT"
) <"$FAKE_CTDB_IP_LAYOUT"
ip_reallocate
}
ctdb_ip ()
ctdb_disable()
{
# If nobody has done any IP-fu then generate a layout.
[ -f "$FAKE_CTDB_IP_LAYOUT" ] || ip_reallocate
parse_nodespec
_mypnn=$(ctdb_pnn)
for _i in $nodes; do
mkdir -p "$FAKE_CTDB_NODES_DISABLED"
touch "${FAKE_CTDB_NODES_DISABLED}/${_i}"
done
if $machine_readable ; then
if $verbose ; then
echo "|Public IP|Node|ActiveInterface|AvailableInterfaces|ConfiguredInterfaces|"
else
echo "|Public IP|Node|"
fi
else
echo "Public IPs on node ${_mypnn}"
fi
# Join public addresses file with $FAKE_CTDB_IP_LAYOUT, and
# process output line by line...
_pa="${CTDB_BASE}/public_addresses"
sed -e 's@/@ @' "$_pa" | sort | join - "$FAKE_CTDB_IP_LAYOUT" |
while read -r _ip _ _ifaces _pnn ; do
if $verbose ; then
# If more than 1 interface, assume all addresses are on the 1st.
_first_iface="${_ifaces%%,*}"
# Only show interface if address is on this node.
_my_iface=""
if [ "$_pnn" = "$_mypnn" ]; then
_my_iface="$_first_iface"
fi
if $machine_readable ; then
echo "|${_ip}|${_pnn}|${_my_iface}|${_first_iface}|${_ifaces}|"
else
echo "${_ip} node[${_pnn}] active[${_my_iface}] available[${_first_iface}] configured[[${_ifaces}]"
fi
else
if $machine_readable ; then
echo "|${_ip}|${_pnn}|"
else
echo "${_ip} ${_pnn}"
fi
fi
done
}
ctdb_moveip ()
{
_ip="$1"
_target="$2"
ip_reallocate # should be harmless and ensures we have good state
# ShellCheck doesn't understand this flock pattern
# shellcheck disable=SC2094
(
flock 0
_t="${FAKE_CTDB_IP_LAYOUT}.new"
while read -r _i _pnn ; do
if [ "$_ip" = "$_i" ] ; then
echo "$_i $_target"
else
echo "$_i $_pnn"
fi
done | sort >"$_t"
mv "$_t" "$FAKE_CTDB_IP_LAYOUT"
) <"$FAKE_CTDB_IP_LAYOUT"
ip_reallocate
}
######################################################################
ctdb_enable ()
ctdb_shutdown()
{
parse_nodespec
for _i in $nodes ; do
rm -f "${FAKE_CTDB_NODES_DISABLED}/${_i}"
done
ip_reallocate
}
ctdb_disable ()
{
parse_nodespec
for _i in $nodes ; do
mkdir -p "$FAKE_CTDB_NODES_DISABLED"
touch "${FAKE_CTDB_NODES_DISABLED}/${_i}"
done
ip_reallocate
}
######################################################################
ctdb_shutdown ()
{
echo "CTDB says BYE!"
echo "CTDB says BYE!"
}
######################################################################
@ -301,118 +302,118 @@ ctdb_shutdown ()
# contains all nodes in the cluster (which is what current tests
# assume). Use the PNN to find the address from this file. The NAT
# gateway code only used the address, so just mark the node healthy.
ctdb_nodestatus ()
ctdb_nodestatus()
{
echo '|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|'
_line=$(( FAKE_CTDB_PNN + 1 ))
_ip=$(sed -e "${_line}p" "${CTDB_NATGW_NODES:-${CTDB_LVS_NODES}}")
echo "|${FAKE_CTDB_PNN}|${_ip}|0|0|0|0|0|0|0|Y|"
echo '|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|'
_line=$((FAKE_CTDB_PNN + 1))
_ip=$(sed -e "${_line}p" "${CTDB_NATGW_NODES:-${CTDB_LVS_NODES}}")
echo "|${FAKE_CTDB_PNN}|${_ip}|0|0|0|0|0|0|0|Y|"
}
######################################################################
ctdb_setvar ()
ctdb_setvar()
{
_var="$1"
_var="$1"
for _i in $FAKE_CTDB_TUNABLES_OK ; do
if [ "$_var" = "$_i" ] ; then
return 0
fi
done
for _i in $FAKE_CTDB_TUNABLES_OK; do
if [ "$_var" = "$_i" ]; then
return 0
fi
done
for _i in $FAKE_CTDB_TUNABLES_OBSOLETE ; do
if [ "$_var" = "$_i" ] ; then
echo "Setting obsolete tunable variable '${_var}'"
return 0
fi
done
for _i in $FAKE_CTDB_TUNABLES_OBSOLETE; do
if [ "$_var" = "$_i" ]; then
echo "Setting obsolete tunable variable '${_var}'"
return 0
fi
done
echo "Unable to set tunable variable '${_var}'"
return 1
echo "Unable to set tunable variable '${_var}'"
return 1
}
######################################################################
_t_setup ()
_t_setup()
{
_t_dir="${CTDB_TEST_TMP_DIR}/fake-ctdb/fake-tdb/$1"
mkdir -p "$_t_dir"
_t_dir="${CTDB_TEST_TMP_DIR}/fake-ctdb/fake-tdb/$1"
mkdir -p "$_t_dir"
}
_t_put ()
_t_put()
{
echo "$2" >"${_t_dir}/$1"
echo "$2" >"${_t_dir}/$1"
}
_t_get ()
_t_get()
{
cat "${_t_dir}/$1"
cat "${_t_dir}/$1"
}
_t_del ()
_t_del()
{
rm -f "${_t_dir}/$1"
rm -f "${_t_dir}/$1"
}
ctdb_pstore ()
ctdb_pstore()
{
_t_setup "$1"
_t_put "$2" "$3"
_t_setup "$1"
_t_put "$2" "$3"
}
ctdb_pdelete ()
ctdb_pdelete()
{
_t_setup "$1"
_t_del "$2"
_t_setup "$1"
_t_del "$2"
}
ctdb_pfetch ()
ctdb_pfetch()
{
_t_setup "$1"
_t_get "$2" >"$3" 2>/dev/null
_t_setup "$1"
_t_get "$2" >"$3" 2>/dev/null
}
ctdb_ptrans ()
ctdb_ptrans()
{
_t_setup "$1"
_t_setup "$1"
while IFS="" read -r _line ; do
_k=$(echo "$_line" | sed -n -e 's@^"\([^"]*\)" "[^"]*"$@\1@p')
_v=$(echo "$_line" | sed -e 's@^"[^"]*" "\([^"]*\)"$@\1@')
[ -n "$_k" ] || die "ctdb ptrans: bad line \"${_line}\""
if [ -n "$_v" ] ; then
_t_put "$_k" "$_v"
else
_t_del "$_k"
fi
done
while IFS="" read -r _line; do
_k=$(echo "$_line" | sed -n -e 's@^"\([^"]*\)" "[^"]*"$@\1@p')
_v=$(echo "$_line" | sed -e 's@^"[^"]*" "\([^"]*\)"$@\1@')
[ -n "$_k" ] || die "ctdb ptrans: bad line \"${_line}\""
if [ -n "$_v" ]; then
_t_put "$_k" "$_v"
else
_t_del "$_k"
fi
done
}
ctdb_catdb ()
ctdb_catdb()
{
_t_setup "$1"
_t_setup "$1"
# This will break on keys with spaces but we don't have any of
# those yet.
_count=0
for _i in "${_t_dir}/"* ; do
[ -r "$_i" ] || continue
_k="${_i##*/}" # basename
_v=$(_t_get "$_k")
_kn=$(printf '%s' "$_k" | wc -c)
_vn=$(printf '%s' "$_v" | wc -c)
cat <<EOF
# This will break on keys with spaces but we don't have any of
# those yet.
_count=0
for _i in "${_t_dir}/"*; do
[ -r "$_i" ] || continue
_k="${_i##*/}" # basename
_v=$(_t_get "$_k")
_kn=$(printf '%s' "$_k" | wc -c)
_vn=$(printf '%s' "$_v" | wc -c)
cat <<EOF
key(${_kn}) = "${_k}"
dmaster: 0
rsn: 1
data(${_vn}) = "${_v}"
EOF
_count=$((_count + 1))
done
_count=$((_count + 1))
done
echo "Dumped ${_count} records"
echo "Dumped ${_count} records"
}
######################################################################
@ -424,29 +425,30 @@ ctdb_ifaces()
{
_f="${CTDB_BASE}/public_addresses"
if [ ! -f "$_f" ] ; then
if [ ! -f "$_f" ]; then
die "Public addresses file \"${_f}\" not found"
fi
# Assume -Y.
echo "|Name|LinkStatus|References|"
while read -r _ip _iface ; do
while read -r _ip _iface; do
case "$_ip" in
\#*) : ;;
*)
_status=1
# For now assume _iface contains only 1.
if [ -f "{FAKE_CTDB_IFACES_DOWN}/${_iface}" ] ; then
if [ -f "{FAKE_CTDB_IFACES_DOWN}/${_iface}" ]; then
_status=0
fi
# Nobody looks at references
echo "|${_iface}|${_status}|0|"
;;
esac
done <"$_f" |
sort -u
sort -u
}
ctdb_setifacelink ()
ctdb_setifacelink()
{
_iface="$1"
_state="$2"
@ -457,7 +459,7 @@ ctdb_setifacelink ()
_f="${FAKE_CTDB_IFACES_DOWN}/${_iface}"
case "$_state" in
up) rm -f "$_f" ;;
up) rm -f "$_f" ;;
down) touch "$_f" ;;
*) die "ctdb setifacelink: unsupported interface status ${_state}" ;;
esac
@ -465,12 +467,12 @@ ctdb_setifacelink ()
######################################################################
ctdb_checktcpport ()
ctdb_checktcpport()
{
_port="$1"
for _i in $FAKE_TCP_LISTEN ; do
if [ "$_port" = "$_i" ] ; then
for _i in $FAKE_TCP_LISTEN; do
if [ "$_port" = "$_i" ]; then
exit 98
fi
done
@ -478,7 +480,7 @@ ctdb_checktcpport ()
exit 0
}
ctdb_gratarp ()
ctdb_gratarp()
{
# Do nothing for now
:
@ -495,7 +497,7 @@ func="ctdb_${cmd}"
# function. However, this can only happen if testing a script
# containing a new ctdb command that is not implemented, so this is
# unlikely to do harm.
if type "$func" >/dev/null 2>&1 ; then
if type "$func" >/dev/null 2>&1; then
"$func" "$@"
else
not_implemented "$cmd"

View File

@ -3,7 +3,7 @@
# Only supports reading from stdin
# shellcheck disable=SC2034
iface="$1" # ignored
iface="$1" # ignored
while read -r src dst; do
sed -i -e "/^${dst} ${src}\$/d" "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"

View File

@ -3,30 +3,31 @@
prog="ctdb_lvs"
# Print a message and exit.
die ()
die()
{
echo "$1" >&2 ; exit "${2:-1}"
echo "$1" >&2
exit "${2:-1}"
}
not_implemented_exit_code=1
usage ()
usage()
{
cat >&2 <<EOF
cat >&2 <<EOF
Usage: $prog { leader | list }
EOF
exit 1
exit 1
}
not_implemented ()
not_implemented()
{
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
}
ctdb_lvs_leader ()
ctdb_lvs_leader()
{
if [ -n "$FAKE_CTDB_LVS_LEADER" ] ; then
if [ -n "$FAKE_CTDB_LVS_LEADER" ]; then
echo "$FAKE_CTDB_LVS_LEADER"
return 0
else
@ -34,10 +35,10 @@ ctdb_lvs_leader ()
fi
}
ctdb_lvs_list ()
ctdb_lvs_list()
{
_pnn=0
while read -r _ip _ ; do
while read -r _ip _; do
echo "${_pnn} ${_ip}"
_pnn=$((_pnn + 1))
done <"$CTDB_LVS_NODES"
@ -46,7 +47,7 @@ ctdb_lvs_list ()
######################################################################
case "$1" in
leader) ctdb_lvs_leader "$@" ;;
list) ctdb_lvs_list "$@" ;;
*) not_implemented "$1" ;;
leader) ctdb_lvs_leader "$@" ;;
list) ctdb_lvs_list "$@" ;;
*) not_implemented "$1" ;;
esac

View File

@ -4,31 +4,31 @@ prog="ctdb_natgw"
not_implemented_exit_code=1
not_implemented ()
not_implemented()
{
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
echo "${prog}: command \"$1\" not implemented in stub" >&2
exit $not_implemented_exit_code
}
ctdb_natgw_leader ()
ctdb_natgw_leader()
{
[ -r "$CTDB_NATGW_NODES" ] || \
die "error: missing CTDB_NATGW_NODES=${CTDB_NATGW_NODES}"
[ -r "$CTDB_NATGW_NODES" ] ||
die "error: missing CTDB_NATGW_NODES=${CTDB_NATGW_NODES}"
# Determine the leader node
_leader="-1 0.0.0.0"
_pnn=0
while read -r _ip ; do
if [ "$FAKE_CTDB_NATGW_LEADER" = "$_ip" ] ; then
_leader="${_pnn} ${_ip}"
break
fi
_pnn=$((_pnn + 1))
done <"$CTDB_NATGW_NODES"
echo "$_leader"
# Determine the leader node
_leader="-1 0.0.0.0"
_pnn=0
while read -r _ip; do
if [ "$FAKE_CTDB_NATGW_LEADER" = "$_ip" ]; then
_leader="${_pnn} ${_ip}"
break
fi
_pnn=$((_pnn + 1))
done <"$CTDB_NATGW_NODES"
echo "$_leader"
}
case "$1" in
leader) ctdb_natgw_leader "$@" ;;
*) not_implemented "$1" ;;
leader) ctdb_natgw_leader "$@" ;;
*) not_implemented "$1" ;;
esac

View File

@ -1,7 +1,7 @@
#!/bin/sh
if [ "$FAKE_DATE_OUTPUT" ] ; then
echo "$FAKE_DATE_OUTPUT"
else
/bin/date "$@"
if [ "$FAKE_DATE_OUTPUT" ]; then
echo "$FAKE_DATE_OUTPUT"
else
/bin/date "$@"
fi

View File

@ -1,17 +1,17 @@
#!/bin/sh
usage ()
usage()
{
echo "usage: df [-kP] [<mount-point>]"
exit 1
echo "usage: df [-kP] [<mount-point>]"
exit 1
}
if [ "$1" = "-kP" ] ; then
shift
if [ "$1" = "-kP" ]; then
shift
fi
case "$1" in
-*) usage ;;
-*) usage ;;
esac
fs="${1:-/}"
@ -19,13 +19,13 @@ fs="${1:-/}"
# Anything starting with CTDB_DBDIR_BASE gets canonicalised to
# CTDB_DBDIR_BASE. This helps with the setting of defaults for the
# filesystem checks.
if [ "${fs#"${CTDB_DBDIR_BASE}"}" != "$fs" ] ; then
fs="$CTDB_DBDIR_BASE"
if [ "${fs#"${CTDB_DBDIR_BASE}"}" != "$fs" ]; then
fs="$CTDB_DBDIR_BASE"
fi
# A default, for tests that don't initialise this...
if [ -z "$FAKE_FS_USE" ] ; then
FAKE_FS_USE=10
if [ -z "$FAKE_FS_USE" ]; then
FAKE_FS_USE=10
fi
echo "Filesystem 1024-blocks Used Available Capacity Mounted on"
@ -35,4 +35,4 @@ used=$((blocks * FAKE_FS_USE / 100))
available=$((blocks - used))
printf "%-36s %10d %10d %10d %10d%% %s\n" \
"/dev/sda1" "$blocks" "$used" "$available" "$FAKE_FS_USE" "$fs"
"/dev/sda1" "$blocks" "$used" "$available" "$FAKE_FS_USE" "$fs"

View File

@ -2,8 +2,8 @@
link="yes"
if [ -f "${FAKE_ETHTOOL_LINK_DOWN}/${1}" ] ; then
link="no"
if [ -f "${FAKE_ETHTOOL_LINK_DOWN}/${1}" ]; then
link="no"
fi
# Expect to add more fields later.

View File

@ -2,12 +2,12 @@
opts="10.0.0.0/16(rw,async,insecure,no_root_squash,no_subtree_check)"
for i in $FAKE_SHARES ; do
# Directories longer than 15 characters are printed on their own
# line.
if [ ${#i} -ge 15 ] ; then
printf '%s\n\t\t%s\n' "$i" "$opts"
else
printf '%s\t%s\n' "$i" "$opts"
fi
for i in $FAKE_SHARES; do
# Directories longer than 15 characters are printed on their own
# line.
if [ ${#i} -ge 15 ]; then
printf '%s\n\t\t%s\n' "$i" "$opts"
else
printf '%s\t%s\n' "$i" "$opts"
fi
done

View File

@ -2,12 +2,12 @@
pid="$1"
if [ -n "$FAKE_PS_MAP" ] ; then
if [ -n "$FAKE_PS_MAP" ]; then
command=$(echo "$FAKE_PS_MAP" |
awk -v pid="$pid" '$1 == pid { print $2 }')
awk -v pid="$pid" '$1 == pid { print $2 }')
fi
if [ -z "$command" ] ; then
if [ -z "$command" ]; then
command="smbd"
fi

View File

@ -1,56 +1,66 @@
#!/bin/sh
die ()
die()
{
echo "$1" >&2
exit "${2:-1}"
}
[ -n "$FAKE_LVS_STATE_DIR" ] || die "FAKE_LVS_STATE_DIR not set"
service_address=""
scheduling_method="wlc"
persistent_timeout=""
real_server=""
forwarding_method="Route"
set_service_address ()
set_service_address()
{
[ -z "$service_address" ] ||
die "multiple 'service-address' options specified" 2
case "$2" in
*:*) service_address="${1} ${2}" ;;
*) service_address="${1} ${2}:0" ;;
*:*) service_address="${1} ${2}" ;;
*) service_address="${1} ${2}:0" ;;
esac
}
set_real_server ()
set_real_server()
{
[ -z "$real_server" ] ||
die "multiple 'real-server' options specified" 2
case "$1" in
*\]:*) real_server="${1}" ;;
*\]) real_server="${1}:0" ;;
*:*) real_server="${1}" ;;
*) real_server="${1}:0" ;;
*\]:*) real_server="${1}" ;;
*\]) real_server="${1}:0" ;;
*:*) real_server="${1}" ;;
*) real_server="${1}:0" ;;
esac
case "$real_server" in
127.0.0.1:*|\[::1\]:*) forwarding_method="Local" ;;
127.0.0.1:* | \[::1\]:*) forwarding_method="Local" ;;
esac
}
case "$1" in
-A)
shift
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case "$1" in
-t) set_service_address "TCP" "$2" ; shift 2 ;;
-u) set_service_address "UDP" "$2" ; shift 2 ;;
-s) scheduling_method="$2" ; shift 2 ;;
-p) persistent_timeout="persistent $2" ; shift 2 ;;
-t)
set_service_address "TCP" "$2"
shift 2
;;
-u)
set_service_address "UDP" "$2"
shift 2
;;
-s)
scheduling_method="$2"
shift 2
;;
-p)
persistent_timeout="persistent $2"
shift 2
;;
*) die "Unsupported -A option $1" ;;
esac
done
@ -63,10 +73,16 @@ case "$1" in
;;
-D)
shift
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case "$1" in
-t) set_service_address "TCP" "$2" ; shift 2 ;;
-u) set_service_address "UDP" "$2" ; shift 2 ;;
-t)
set_service_address "TCP" "$2"
shift 2
;;
-u)
set_service_address "UDP" "$2"
shift 2
;;
*) die "Unsupported -D option $1" ;;
esac
done
@ -79,12 +95,24 @@ case "$1" in
;;
-a)
shift
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case "$1" in
-t) set_service_address "TCP" "$2" ; shift 2 ;;
-u) set_service_address "UDP" "$2" ; shift 2 ;;
-r) set_real_server "$2" ; shift 2 ;;
-g) forwarding_method="Route" ; shift 1 ;;
-t)
set_service_address "TCP" "$2"
shift 2
;;
-u)
set_service_address "UDP" "$2"
shift 2
;;
-r)
set_real_server "$2"
shift 2
;;
-g)
forwarding_method="Route"
shift 1
;;
*) die "Unsupported -A option $1" ;;
esac
done
@ -109,17 +137,18 @@ EOF
[ -d "$d" ] || continue
printf '%s ' "$d"
cat "${d}/.info"
for f in "${d}/"* ; do
for f in "${d}/"*; do
[ -f "$f" ] || continue
read -r forwarding_method <"$f"
printf " -> %-28s %-7s %-6s %-10s %-10s\n" \
"${f##*/}" "$forwarding_method" 1 0 0
"${f##*/}" "$forwarding_method" 1 0 0
done
done
)
;;
*)
die "Unknown option $1"
;;
esac
exit 0

View File

@ -1,32 +1,32 @@
#!/bin/sh
usage ()
usage()
{
die "usage: ${0} -ll device"
die "usage: ${0} -ll device"
}
[ "$1" = "-ll" ] || usage
shift
[ $# -eq 1 ] || usage
device="$1"
if [ -n "$FAKE_MULTIPATH_HANG" ] ; then
FAKE_SLEEP_REALLY="yes" sleep 999
if [ -n "$FAKE_MULTIPATH_HANG" ]; then
FAKE_SLEEP_REALLY="yes" sleep 999
fi
path1_state="active"
path2_state="enabled"
for i in $FAKE_MULTIPATH_FAILURES ; do
if [ "$device" = "$i" ] ; then
path1_state="inactive"
path2_state="inactive"
break
fi
for i in $FAKE_MULTIPATH_FAILURES; do
if [ "$device" = "$i" ]; then
path1_state="inactive"
path2_state="inactive"
break
fi
done
cat <<EOF
cat <<EOF
${device} (AUTO-01234567) dm-0 ,
size=10G features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=1 status=${path1_state}

View File

@ -4,13 +4,14 @@ case "$1" in
nfsd)
echo "$FAKE_NFSD_THREAD_PIDS"
;;
rpc.statd|rpc.rquotad|rpc.mountd)
rpc.statd | rpc.rquotad | rpc.mountd)
echo "$FAKE_RPC_THREAD_PIDS"
;;
smbd)
echo "$FAKE_SMBD_THREAD_PIDS"
;;
*)
*)
echo "pidof: \"$1\" not implemented"
exit 1
;;
esac

View File

@ -1,37 +1,37 @@
#!/bin/sh
usage ()
usage()
{
echo "ps [ -p PID | -o FORMAT | aufxww ]"
exit 1
}
while getopts "o:p:h:?" opt ; do
while getopts "o:p:h:?" opt; do
case "$opt" in
o) format="$OPTARG" ;;
p) pid="$OPTARG" ;;
\?|h) usage ;;
\? | h) usage ;;
esac
done
shift $((OPTIND - 1))
if [ -n "$pid" ] && [ -n "$FAKE_PS_MAP" ] ; then
if [ -n "$pid" ] && [ -n "$FAKE_PS_MAP" ]; then
# shellcheck disable=SC1001
case "$format" in
comm\=)
echo "$FAKE_PS_MAP" |
awk -v pid="$pid" '$1 == pid { print $2 }'
awk -v pid="$pid" '$1 == pid { print $2 }'
;;
state\=)
echo "$FAKE_PS_MAP" |
awk -v pid="$pid" '$1 == pid { print $3 }'
awk -v pid="$pid" '$1 == pid { print $3 }'
;;
esac
exit
fi
if [ "$1" != "auxfww" ] ; then
if [ "$1" != "auxfww" ]; then
echo "option $1 not supported"
usage
fi

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Make statd-callout happy
case "$*" in
*/var/lib/nfs/statd/sm*) : ;;
*) exec /bin/rm "$@" ;;
*/var/lib/nfs/statd/sm*) : ;;
*) exec /bin/rm "$@" ;;
esac

View File

@ -2,31 +2,32 @@
prog="rpcinfo"
usage ()
usage()
{
cat >&2 <<EOF
cat >&2 <<EOF
Usage: $prog -T tcp host program [version]
A fake rpcinfo stub that succeeds for items in FAKE_RPCINFO_SERVICES,
depending on command-line options.
EOF
exit 1
exit 1
}
parse_options ()
parse_options()
{
while getopts "T:h?" opt ; do
while getopts "T:h?" opt; do
case "$opt" in
T) netid="$OPTARG" ;;
\?|h) usage ;;
\? | h) usage ;;
esac
done
shift $((OPTIND - 1))
[ "$netid" = "tcp" ] || usage
host="$1" ; shift
host="$1"
shift
[ "$host" = "localhost" ] || [ "$host" = "127.0.0.1" ] || usage
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
@ -39,39 +40,39 @@ parse_options ()
parse_options "$@"
for i in ${FAKE_RPCINFO_SERVICES} ; do
# This is stupidly cummulative, but needs to happen after the
# initial split of the list above.
IFS="${IFS}:"
# Want glob expansion
# shellcheck disable=SC2086
set -- $i
# $1 = program, $2 = low version, $3 = high version
for i in ${FAKE_RPCINFO_SERVICES}; do
# This is stupidly cummulative, but needs to happen after the
# initial split of the list above.
IFS="${IFS}:"
# Want glob expansion
# shellcheck disable=SC2086
set -- $i
# $1 = program, $2 = low version, $3 = high version
if [ "$1" = "$p" ] ; then
if [ -n "$v" ] ; then
if [ "$2" -le "$v" ] && [ "$v" -le "$3" ] ; then
echo "program ${p} version ${v} ready and waiting"
exit 0
else
echo "rpcinfo: RPC: Program/version mismatch; low version = ${2}, high version = ${3}" >&2
echo "program ${p} version ${v} is not available"
exit 1
fi
else
for j in $(seq "$2" "$3") ; do
echo "program ${p} version ${j} ready and waiting"
done
exit 0
if [ "$1" = "$p" ]; then
if [ -n "$v" ]; then
if [ "$2" -le "$v" ] && [ "$v" -le "$3" ]; then
echo "program ${p} version ${v} ready and waiting"
exit 0
else
echo "rpcinfo: RPC: Program/version mismatch; low version = ${2}, high version = ${3}" >&2
echo "program ${p} version ${v} is not available"
exit 1
fi
else
for j in $(seq "$2" "$3"); do
echo "program ${p} version ${j} ready and waiting"
done
exit 0
fi
fi
fi
done
echo "rpcinfo: RPC: Program not registered" >&2
if [ -n "$v" ] ; then
echo "program ${p} version ${v} is not available"
if [ -n "$v" ]; then
echo "program ${p} version ${v} is not available"
else
echo "program ${p} is not available"
echo "program ${p} is not available"
fi
exit 1

View File

@ -8,57 +8,58 @@ flag="${service_status_dir}/${service}"
start()
{
if [ -f "$flag" ] ; then
echo "service: can't start ${service} - already running"
exit 1
else
touch "$flag"
echo "Starting ${service}: OK"
fi
if [ -f "$flag" ]; then
echo "service: can't start ${service} - already running"
exit 1
else
touch "$flag"
echo "Starting ${service}: OK"
fi
}
stop ()
stop()
{
if [ -f "$flag" ] ; then
echo "Stopping ${service}: OK"
rm -f "$flag"
else
echo "service: can't stop ${service} - not running"
exit 1
fi
if [ -f "$flag" ]; then
echo "Stopping ${service}: OK"
rm -f "$flag"
else
echo "service: can't stop ${service} - not running"
exit 1
fi
}
case "$2" in
start)
start)
start
;;
stop)
stop)
stop
;;
restart|reload)
restart | reload)
stop
start
;;
status)
if [ -f "$flag" ] ; then
echo "$service running"
exit 0
status)
if [ -f "$flag" ]; then
echo "$service running"
exit 0
else
echo "$service not running"
exit 3
echo "$service not running"
exit 3
fi
;;
force-started)
force-started)
# For test setup...
touch "$flag"
;;
force-stopped)
force-stopped)
# For test setup...
rm -f "$flag"
;;
*)
*)
echo "service $service $2 not supported"
exit 1
;;
esac
exit 0

View File

@ -1,9 +1,9 @@
#!/bin/sh
if [ "$FAKE_SLEEP_REALLY" = "yes" ] ; then
/bin/sleep "$@"
elif [ -n "$FAKE_SLEEP_FORCE" ] ; then
/bin/sleep "$FAKE_SLEEP_FORCE"
if [ "$FAKE_SLEEP_REALLY" = "yes" ]; then
/bin/sleep "$@"
elif [ -n "$FAKE_SLEEP_FORCE" ]; then
/bin/sleep "$FAKE_SLEEP_FORCE"
else
:
:
fi

View File

@ -14,17 +14,44 @@ sip=""
mon_name=""
state=""
while [ $# -gt 0 ] ; do
while [ $# -gt 0 ]; do
case "$1" in
--client) cip="$2" ; shift 2 ;;
--client=*) cip="${1#*=}" ; shift ;;
--ip) sip="$2" ; shift 2 ;;
--ip=*) sip="${1#*=}" ; shift ;;
--server) mon_name="$2" ; shift 2 ;;
--server=*) mon_name="${1#*=}" ; shift ;;
--stateval) state="$2" ; shift 2 ;;
--stateval=*) state="${1#*=}" ; shift ;;
--) shift ; break ;;
--client)
cip="$2"
shift 2
;;
--client=*)
cip="${1#*=}"
shift
;;
--ip)
sip="$2"
shift 2
;;
--ip=*)
sip="${1#*=}"
shift
;;
--server)
mon_name="$2"
shift 2
;;
--server=*)
mon_name="${1#*=}"
shift
;;
--stateval)
state="$2"
shift 2
;;
--stateval=*)
state="${1#*=}"
shift
;;
--)
shift
break
;;
-*) usage ;;
*) break ;;
esac

View File

@ -2,7 +2,7 @@
prog="ss"
usage ()
usage()
{
cat >&2 <<EOF
Usage: $prog { -t|--tcp | -x|--unix } [options] [ FILTER ]
@ -17,7 +17,7 @@ EOF
exit 1
}
not_supported ()
not_supported()
{
echo "Options not supported in stub: $*" >&2
usage
@ -26,7 +26,7 @@ not_supported ()
############################################################
#
parse_filter ()
parse_filter()
{
# Very limited implementation:
# We only expect to find || inside parentheses
@ -41,7 +41,7 @@ parse_filter ()
sports="|"
srcs="|"
while [ -n "$1" ] ; do
while [ -n "$1" ]; do
case "$1" in
\()
in_parens=true
@ -52,17 +52,20 @@ parse_filter ()
shift
;;
\|\|)
if ! $in_parens ; then
if ! $in_parens; then
not_supported "|| in parentheses"
fi
shift
;;
sport)
p="${3#:}" ; sports="${sports}${p}|"
p="${3#:}"
sports="${sports}${p}|"
shift 3
;;
src)
ip="${2#\[}" ; ip="${ip%\]}" ; srcs="${srcs}${ip}|"
ip="${2#\[}"
ip="${ip%\]}"
srcs="${srcs}${ip}|"
shift 2
;;
*)
@ -73,59 +76,59 @@ parse_filter ()
}
# Check if socket has matches in both ok_ips and ok_ports
filter_socket ()
filter_socket()
{
ok_ips="$1"
ok_ports="$2"
socket="$3"
ok_ips="$1"
ok_ports="$2"
socket="$3"
ip="${socket%:*}"
port="${socket##*:}"
ip="${socket%:*}"
port="${socket##*:}"
if [ "$ok_ports" != "|" ] &&
[ "${ok_ports#*|"${port}"|}" = "$ok_ports" ]; then
return 1
fi
if [ "$ok_ips" != "|" ] && [ "${ok_ips#*|"${ip}"|}" = "$ok_ips" ]; then
return 1
fi
if [ "$ok_ports" != "|" ] &&
[ "${ok_ports#*|"${port}"|}" = "$ok_ports" ]; then
return 1
fi
if [ "$ok_ips" != "|" ] && [ "${ok_ips#*|"${ip}"|}" = "$ok_ips" ]; then
return 1
fi
return 0
return 0
}
ss_tcp_established ()
ss_tcp_established()
{
if $header ; then
echo "Recv-Q Send-Q Local Address:Port Peer Address:Port"
fi
# Yes, lose the quoting so we can do a hacky parsing job
# shellcheck disable=SC2048,SC2086
parse_filter $*
for i in $FAKE_NETSTAT_TCP_ESTABLISHED ; do
src="${i%|*}"
dst="${i#*|}"
if filter_socket "$srcs" "$sports" "$src" ; then
echo 0 0 "$src" "$dst"
if $header; then
echo "Recv-Q Send-Q Local Address:Port Peer Address:Port"
fi
done
if [ -z "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" ] ; then
return
fi
while read -r src dst ; do
if filter_socket "$srcs" "$sports" "$src" ; then
echo 0 0 "$src" "$dst"
# Yes, lose the quoting so we can do a hacky parsing job
# shellcheck disable=SC2048,SC2086
parse_filter $*
for i in $FAKE_NETSTAT_TCP_ESTABLISHED; do
src="${i%|*}"
dst="${i#*|}"
if filter_socket "$srcs" "$sports" "$src"; then
echo 0 0 "$src" "$dst"
fi
done
if [ -z "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" ]; then
return
fi
done <"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
while read -r src dst; do
if filter_socket "$srcs" "$sports" "$src"; then
echo 0 0 "$src" "$dst"
fi
done <"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
}
############################################################
unix_listen ()
unix_listen()
{
if $header ; then
if $header; then
cat <<EOF
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port"
EOF
@ -136,11 +139,11 @@ EOF
parse_filter $*
_n=12345
for _s in $FAKE_NETSTAT_UNIX_LISTEN ; do
for _s in $FAKE_NETSTAT_UNIX_LISTEN; do
# ss matches Unix domain sockets as either src or
# sport.
if filter_socket "$srcs" "$sports" "${_s}:" || \
filter_socket "$srcs" "$sports" ":${_s}" ; then
if filter_socket "$srcs" "$sports" "${_s}:" ||
filter_socket "$srcs" "$sports" ":${_s}"; then
printf "u_str LISTEN 0 128 %s %d * 0\n" "$_s" "$_n"
_n=$((_n + 1))
fi
@ -158,7 +161,7 @@ header=true
orig="$*"
while getopts "txnalHh?" opt ; do
while getopts "txnalHh?" opt; do
case "$opt" in
t) tcp=true ;;
x) unix=true ;;
@ -166,7 +169,7 @@ while getopts "txnalHh?" opt ; do
a) all=true ;;
H) header=false ;;
n) : ;;
\?|h) usage ;;
\? | h) usage ;;
esac
done
shift $((OPTIND - 1))
@ -176,7 +179,7 @@ if [ -z "$all" ]; then
nosupported "$*"
fi
if $tcp ; then
if $tcp; then
if [ "$1" != "state" ] || [ "$2" != "established" ] || $listen; then
usage
fi
@ -190,8 +193,8 @@ if $tcp ; then
exit
fi
if $unix ; then
if ! $listen ; then
if $unix; then
if ! $listen; then
not_supported "$orig"
fi

View File

@ -1,6 +1,6 @@
#!/bin/sh
usage ()
usage()
{
echo "stat -c FMT FILE ..."
exit 1
@ -8,20 +8,20 @@ usage ()
format=""
while getopts "c:h:?" opt ; do
while getopts "c:h:?" opt; do
case "$opt" in
c) format="$OPTARG" ;;
\?|h) usage ;;
\? | h) usage ;;
esac
done
shift $((OPTIND - 1))
fake_device_id ()
fake_device_id()
{
_path="$1"
_t=$(echo "$FAKE_FILE_ID_MAP" |
awk -v path="${_path}" '$1 == path { print $2 }')
awk -v path="${_path}" '$1 == path { print $2 }')
_major_minor="${_t%:*}"
_major="0x${_major_minor%:*}"
_minor="0x${_major_minor#*:}"
@ -29,18 +29,18 @@ fake_device_id ()
echo "$_device_id"
}
fake_inode ()
fake_inode()
{
_path="$1"
_t=$(echo "$FAKE_FILE_ID_MAP" |
awk -v path="${_path}" '$1 == path { print $2 }')
awk -v path="${_path}" '$1 == path { print $2 }')
echo "${_t##*:}"
}
if [ -n "$format" ] ; then
for f ; do
if [ ! -e "$f" ] ; then
if [ -n "$format" ]; then
for f; do
if [ ! -e "$f" ]; then
continue
fi
case "$f" in

View File

@ -1,10 +1,10 @@
#!/bin/sh
if [ -z "$FAKE_TDB_MUTEX_CHECK" ] ; then
if [ -z "$FAKE_TDB_MUTEX_CHECK" ]; then
exit
fi
echo "$FAKE_TDB_MUTEX_CHECK" |
while read -r pid chain ; do
echo "[${chain}] pid=${pid}"
done
while read -r pid chain; do
echo "[${chain}] pid=${pid}"
done

View File

@ -1,9 +1,9 @@
#!/bin/sh
if [ "$FAKE_TDB_IS_OK" = "yes" ] ; then
echo "TDB good"
exit 0
if [ "$FAKE_TDB_IS_OK" = "yes" ]; then
echo "TDB good"
exit 0
else
echo "TDB busted"
exit 1
echo "TDB busted"
exit 1
fi

View File

@ -1,31 +1,34 @@
#!/bin/sh
do_help ()
do_help()
{
if [ "$FAKE_TDBTOOL_SUPPORTS_CHECK" = "yes" ] ; then
echo "check"
fi
exit 0
if [ "$FAKE_TDBTOOL_SUPPORTS_CHECK" = "yes" ]; then
echo "check"
fi
exit 0
}
do_check ()
do_check()
{
if [ "$FAKE_TDB_IS_OK" = "yes" ] ; then
echo "Database integrity is OK"
else
echo "Database is busted"
fi
exit 0
if [ "$FAKE_TDB_IS_OK" = "yes" ]; then
echo "Database integrity is OK"
else
echo "Database is busted"
fi
exit 0
}
do_cmd ()
do_cmd()
{
case "$*" in
case "$*" in
*check) do_check ;;
help) do_help ;;
"") read -r tdb_cmd && [ -n "$tdb_cmd" ] && do_cmd "$tdb_cmd" ;;
*) echo "$0: Not implemented: $*" ; exit 1 ;;
esac
*)
echo "$0: Not implemented: $*"
exit 1
;;
esac
}
do_cmd "$@"

View File

@ -1,43 +1,43 @@
#!/bin/sh
not_implemented ()
not_implemented()
{
echo "testparm: option \"$1\" not implemented in stub" >&2
exit 2
echo "testparm: option \"$1\" not implemented in stub" >&2
exit 2
}
error ()
error()
{
cat >&2 <<EOF
cat >&2 <<EOF
Load smb config files from ${CTDB_SYS_ETCDIR}/samba/smb.conf
rlimit_max: increasing rlimit_max (2048) to minimum Windows limit (16384)
EOF
for i in $FAKE_SHARES ; do
bi=$(basename "$i")
echo "Processing section \"[${bi}]\""
done >&2
for i in $FAKE_SHARES; do
bi=$(basename "$i")
echo "Processing section \"[${bi}]\""
done >&2
cat >&2 <<EOF
cat >&2 <<EOF
Loaded services file OK.
WARNING: 'workgroup' and 'netbios name' must differ.
EOF
exit 1
exit 1
}
timeout ()
timeout()
{
echo "$0: INTERNAL ERROR - timeout stub should avoid this" >&2
echo "$0: INTERNAL ERROR - timeout stub should avoid this" >&2
}
if [ -n "$FAKE_TESTPARM_FAIL" ] ; then
error
if [ -n "$FAKE_TESTPARM_FAIL" ]; then
error
fi
if [ -n "$FAKE_TIMEOUT" ] ; then
timeout
if [ -n "$FAKE_TIMEOUT" ]; then
timeout
fi
# Ensure that testparm always uses our canned configuration instead of
@ -45,34 +45,40 @@ fi
file=""
parameter=""
for i ; do
case "$i" in
for i; do
case "$i" in
--parameter-name=*) parameter="${i#--parameter-name=}" ;;
-*) : ;;
*) file="$i" ;;
esac
esac
done
# Just hard-code parameter requests for now. Later on they could be
# parsed out of the file.
case "$parameter" in
security) echo "ADS" ; exit 0 ;;
smb*ports) echo "445, 139" ; exit 0 ;;
?*) not_implemented "--parameter-name=$parameter" ;;
# Fall through if $parameter not set
security)
echo "ADS"
exit 0
;;
smb*ports)
echo "445, 139"
exit 0
;;
?*) not_implemented "--parameter-name=$parameter" ;;
# Fall through if $parameter not set
esac
if [ -n "$file" ] ; then
# This should include the shares, since this is used when the
# samba eventscript caches the output.
cat "$file"
if [ -n "$file" ]; then
# This should include the shares, since this is used when the
# samba eventscript caches the output.
cat "$file"
else
# We force our own smb.conf and add the shares.
cat "${CTDB_SYS_ETCDIR}/samba/smb.conf"
# We force our own smb.conf and add the shares.
cat "${CTDB_SYS_ETCDIR}/samba/smb.conf"
for i in $FAKE_SHARES ; do
bi=$(basename "$i")
cat <<EOF
for i in $FAKE_SHARES; do
bi=$(basename "$i")
cat <<EOF
[${bi}]
path = $i
@ -81,5 +87,5 @@ cat <<EOF
read only = no
browseable = yes
EOF
done
done
fi

View File

@ -1,8 +1,8 @@
#!/bin/sh
if [ -n "$FAKE_TIMEOUT" ] ; then
exit 124
if [ -n "$FAKE_TIMEOUT" ]; then
exit 124
else
shift 1
exec "$@"
shift 1
exec "$@"
fi

View File

@ -1,7 +1,7 @@
#!/bin/sh
if [ "$FAKE_WBINFO_FAIL" = "yes" ] ; then
exit 1
if [ "$FAKE_WBINFO_FAIL" = "yes" ]; then
exit 1
fi
exit 0