1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

ctdb-tests: Remove function iterate_test()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2015-06-17 17:26:21 +10:00 committed by Amitay Isaacs
parent a496c8bca6
commit 8b044d88fd
2 changed files with 4 additions and 101 deletions

View File

@ -11,11 +11,10 @@ Test case filenames look like:
<eventscript>.<event>.NNN.sh
The test helper functions will run <eventscript> with specified
options. If using the simple_test() or iterate_test() helper
functions then the 1st <event> argument is automatically passed. When
simple_test_event() is used the event name must be explicitly passed
as the 1st argument - this is more flexible and supports multiple
events per test.
options. If using the simple_test() helper function then the 1st
<event> argument is automatically passed. When simple_test_event() is
used the event name must be explicitly passed as the 1st argument -
this is more flexible and supports multiple events per test.
Examples:

View File

@ -1164,102 +1164,6 @@ simple_test_command ()
unit_test "$@"
}
# Run an eventscript iteratively.
# - 1st argument is the number of iterations.
# - 2nd argument is something to eval to do setup for every iteration.
# The easiest thing to do here is to define a function and pass it
# here.
# - Subsequent arguments come in pairs: an iteration number and
# something to eval for that iteration. Each time an iteration
# number is matched the associated argument is given to eval after
# the default setup is done. The iteration numbers need to be given
# in ascending order.
#
# Some optional args can be given *before* these, surrounded by extra
# "--" args. These args are passed to the eventscript. Quoting is
# lost.
#
# One use of the 2nd and further arguments is to call
# required_result() to change what is expected of a particular
# iteration.
iterate_test ()
{
[ -n "$event" ] || die 'simple_test: $event not set'
args=""
if [ "$1" = "--" ] ; then
shift
while [ "$1" != "--" ] ; do
args="${args}${args:+ }$1"
shift
done
shift
fi
_repeats="$1"
_setup_default="$2"
shift 2
echo "Running $_repeats iterations of \"$script $event\" $args"
_result=true
extra_footer ()
{
cat <<EOF
--------------------------------------------------
CTDB_BASE="$CTDB_BASE"
CTDB_ETCDIR="$CTDB_ETCDIR"
ctdb client is "$(which ctdb)"
ip command is "$(which ip)"
--------------------------------------------------
EOF
}
for iteration in $(seq 1 $_repeats) ; do
# This is inefficient because the iteration-specific setup
# might completely replace the default one. However, running
# the default is good because it allows you to revert to a
# particular result without needing to specify it explicitly.
eval $_setup_default
if [ $iteration = "$1" ] ; then
eval $2
shift 2
fi
extra_header ()
{
cat <<EOF
##################################################
Iteration $iteration
EOF
}
_shell=""
if $TEST_COMMAND_TRACE ; then
_shell="sh -x"
else
_shell="sh"
fi
_out=$($_shell "${script_dir}/${script}" "$event" $args 2>&1)
_rc=$?
_fout=$(echo "$_out" | result_filter)
if [ "$_fout" = "$required_output" -a $_rc = $required_rc ] ; then
_passed=true
else
_passed=false
_result=false
fi
result_print "$_passed" "$_out" "$_rc"
done
result_footer "$_result"
}
# Run an NFS eventscript iteratively.
#
# - 1st argument is the number of iterations.