#! /bin/sh

if [ $# -ne 5 ] 
then
  echo "usage: run_test.sh port threads loops checks outfile"
  exit -1
fi

PORT=$1
THREADS=$2
LOOPS=$3
CHECKS=$4
OUTFILE=$5

CLIENTS=$(($THREADS + 2))

echo ""                                                        >> $OUTFILE
echo "=======================================================" >> $OUTFILE
echo "port:" $PORT                                             >> $OUTFILE
echo "  threads:" $THREADS  " clients:" $CLIENTS               >> $OUTFILE
echo "  loops:" $LOOPS  " checks:" $CHECKS                     >> $OUTFILE
echo "-------------------------------------------------------" >> $OUTFILE

./server $PORT $THREADS $LOOPS $CHECKS >> $OUTFILE &

while [ $CLIENTS -ne 0 ]
do
  ./client localhost $PORT &
  CLIENTS=$(($CLIENTS - 1))
done

