#!/bin/sh
# Test multiple perl connections.

test_file="/tmp/test"

echo "Starting 5 mysql_test tests"

mysql_test > ${test_file}-1.log 2>&1 &
mysql_test > ${test_file}-2.log 2>&1 &
mysql_test > ${test_file}-3.log 2>&1 &
mysql_test > ${test_file}-4.log 2>&1 &
mysql_test > ${test_file}-5.log 2>&1 &

echo "Waiting 30 sec for test to finnish"
sleep 30

echo "Checking results"

grep "end of test" ${test_file}-1.log > /dev/null
if test $? -ne 0
then
  echo "Can\`t find \"end of test\" in $test_file-1.log"
  exit 1
fi

prev=1
for i in 2 3 4 5
do
  cmp -s ${test_file}-$prev.log ${test_file}-$i.log
  if test $? -ne 0
  then
    echo "Warning: ${test_file}-$prev.log and ${test_file}-$i.log differ";
    exit 1
  fi
  rm ${test_file}-$prev.log
  prev=$i;
done

rm ${test_file}-$prev.log
echo "Test ok";
