Commit 8f775834 authored by Philip Carns's avatar Philip Carns

make check test for timeout

parent ce603b6b
check_PROGRAMS += \
examples/sleep \
examples/server \
examples/client
examples/client \
examples/server-hang \
examples/client-timeout
TESTS += \
tests/sleep.sh \
tests/basic.sh
tests/basic.sh \
tests/timeout.sh
EXTRA_DIST += \
tests/sleep.sh \
tests/basic.sh
tests/basic.sh \
tests/timeout.sh \
tests/test-util.sh \
tests/test-util-hang.sh
#
# General test script utilities
#
function run_to ()
{
maxtime=${1}s
shift
timeout --signal=9 $maxtime "$@"
}
function test_start_servers ()
{
nservers=${1:-4}
startwait=${2:-15}
maxtime=${3:-120}s
repfactor=${4:-0}
pid=$$
startport=3344
endport=`expr 3344 + $nservers - 1`
# start daemons
for i in `seq $startport $endport`
do
timeout --signal=9 ${maxtime} examples/server-hang tcp://localhost:$i &
if [ $? -ne 0 ]; then
# TODO: this doesn't actually work; can't check return code of
# something executing in background. We have to rely on the
# return codes of the actual client side tests to tell if
# everything started properly
exit 1
fi
done
# wait for servers to start
sleep ${startwait}
svr1="tcp://localhost:$startport"
}
#!/bin/bash -x
if [ -z $srcdir ]; then
echo srcdir variable not set.
exit 1
fi
source $srcdir/tests/test-util-hang.sh
TMPOUT=$(mktemp --tmpdir test-XXXXXX)
# start 1 server with 2 second wait, 8s timeout
test_start_servers 1 2 8
sleep 1
#####################
# run client test
run_to 10 examples/client-timeout $svr1 &> $TMPOUT
if [ $? -ne 0 ]; then
wait
exit 1
fi
# check output; look for four "returned 9" to indicate HG_CANCELED in the four
# concurrent RPCs
LINECOUNT=$(grep "returned 9" $TMPOUT | wc -l)
if [$LINECOUNT -ne 4]; then
exit 1
fi
#####################
# note that this test leaves the server running; it will be killed after the
# 8s timeout from test_start_servers
wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment