# Please adjust MyDir to your environment
# I use a Linux SuSE 10.1 and MyDIR points into a filesystem of type tmpfs.
# The corresponding line in /etc/fstab is
# tmpfs /dev/shm tmpfs size=512m 0 0
My_Dir=/dev/shm
# Maximum number of attempts to find a problem
MAX_NUM=50

set -x 

# Check some prerequisites
ls -d $My_Dir
RC=$?
if [ $RC -eq 1 ]
then
   echo ----------------------------------
   echo ls -d $My_Dir failed
   echo abort
   echo ----------------------------------
   exit
fi
ls ./mysql-test-run.pl
RC=$?
if [ $RC -eq 1 ]
then
   echo ----------------------------------
   echo ls ./mysql-test-run.pl failed
   echo This test must be started from working directory mysql-test
   echo abort
   echo ----------------------------------
   exit
fi

# Loop endless until we get a crash
NUM=0
while [ 1 -eq 1 ]
do
   if [ $NUM -ge $MAX_NUM ]
   then
      echo ------------------------------------------------------
      echo $NUM attempts but no crash or unexpected result found.
      echo Maximum number of attempts is reached , abort
      echo -----------------------------------------------------
      exit
   fi

   NUM=`expr $NUM + 1`

   # testcase-timeout=2, because we want currently only hunt for
   # crashes
   ./mysql-test-run.pl --skip-ndb --vardir=$My_Dir/var \
                       --mysqld=--default-storage-engine=MyISAM \
                       --testcase-timeout=1 falcon_bug_138x
   # Check if we got a crash
   ls $My_Dir/var/master-data/core.*
   RC=$?
   if [ $RC -eq 0 ]
   then
      trace.sh
      exit
   fi
done
