blob: 716e4d5fc72670e694ac28cf73c66a6ea58ec180 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# Hey Emacs, this is a -*- shell-script -*- !!! :-)
# Print a message and exit.
die () { echo "$@" >&2 ; exit 1 ; }
test_prog="$(dirname ${TAKEOVER_TESTS_DIR})/bin/ctdb_takeover_tests ctdb_takeover_run_core"
define_test ()
{
_f="$0"
_f="${_f#./}" # strip leading ./
_f="${_f#testcases/}" # strip leading testcases/
_f="${_f%.sh}" # strip off .sh suffix if any
case "$_f" in
nondet.*)
algorithm="nondet"
export CTDB_LCP2="no"
;;
lcp2.*)
algorithm="lcp2"
export CTDB_LCP2="yes"
;;
*)
die "Unknown algorithm for testcase \"$_f\""
esac
printf "%-12s - %s\n" "$_f" "$1"
}
required_result ()
{
required_rc="${1:-0}"
required_output=$(cat)
}
simple_test ()
{
_states="$1"
_out=$($test_prog $_states 2>&1)
_rc=$?
if [ "$algorithm" = "lcp2" -a -n "$CTDB_TEST_LOGLEVEL" ] ; then
OUT_FILTER='s@^.*:@DATE TIME \[PID\]:@'
fi
if [ -n "$OUT_FILTER" ] ; then
_fout=$(echo "$_out" | sed -r "$OUT_FILTER")
else
_fout="$_out"
fi
if [ "$_fout" = "$required_output" -a $_rc = $required_rc ] ; then
echo "PASSED"
else
cat <<EOF
Algorithm: $algorithm
##################################################
Required output (Exit status: ${required_rc}):
##################################################
$required_output
##################################################
Actual output (Exit status: ${_rc}):
##################################################
$_out
EOF
return 1
fi
}
|