timeout.sh 782 Bytes
Newer Older
Philip Carns's avatar
Philip Carns committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/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
Shane Snyder's avatar
Shane Snyder committed
22
    rm -rf $TMPOUT
Philip Carns's avatar
Philip Carns committed
23 24 25
    exit 1
fi

Shane Snyder's avatar
Shane Snyder committed
26
# check output; look for four "returned 2" to indicate HG_TIMEOUT in the four
Philip Carns's avatar
Philip Carns committed
27
# concurrent RPCs
Shane Snyder's avatar
Shane Snyder committed
28 29 30
LINECOUNT=$(grep "returned 2" $TMPOUT | wc -l) 
if [ $LINECOUNT -ne 4 ]; then
    rm -rf $TMPOUT
Philip Carns's avatar
Philip Carns committed
31 32 33 34 35 36 37 38 39 40
    exit 1
fi

#####################

# note that this test leaves the server running; it will be killed after the
# 8s timeout from test_start_servers

wait

Shane Snyder's avatar
Shane Snyder committed
41
rm -rf $TMPOUT
Philip Carns's avatar
Philip Carns committed
42
exit 0