# 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

./mysql-test-run.pl --skip-ndb --vardir=$My_Dir/var \
                    --mysqld=--default-storage-engine=MyISAM \
                    --gdb --start-and-exit

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 --vardir=$My_Dir/var \
                       --mysqld=--default-storage-engine=MyISAM \
                       --extern --socket=$My_Dir/var/tmp/master.sock \
                       --testcase-timeout=1 falcon_bug_138x
done
