test-util.sh 997 Bytes
Newer Older
1 2 3 4
#
# General test script utilities
#

5 6 7 8
if [ -z "$TIMEOUT" ] ; then
    echo expected TIMEOUT variable defined to its respective command
    exit 1
fi
9 10 11 12 13

function run_to ()
{
    maxtime=${1}s
    shift
14
    $TIMEOUT --signal=9 $maxtime "$@"
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
}

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
30
        $TIMEOUT --signal=9 ${maxtime} examples/server tcp://$i single &
31 32 33 34 35 36 37 38 39 40 41 42 43 44
        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"
}