2000-07-31 21:29:14 +02:00
|
|
|
|
#! /bin/sh
|
2000-12-07 15:54:59 +01:00
|
|
|
|
# mysql-test-run - originally written by Matt Wagner <matt@mysql.com>
|
|
|
|
|
# modified by Sasha Pachev <sasha@mysql.com>
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
|
|
#++
|
|
|
|
|
# Access Definitions
|
|
|
|
|
#--
|
|
|
|
|
DB=test
|
2000-10-11 15:50:13 +02:00
|
|
|
|
DBUSER=test
|
|
|
|
|
DBPASSWD=
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-12-07 15:54:59 +01:00
|
|
|
|
# Are we on source or binary distribution?
|
|
|
|
|
|
|
|
|
|
if [ $0 = scripts/mysql-test-run ] ;
|
|
|
|
|
then
|
|
|
|
|
BINARY_DIST=1
|
|
|
|
|
cd mysql-test
|
|
|
|
|
else
|
|
|
|
|
if [ -d mysql-test ] ; then
|
|
|
|
|
cd mysql-test
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f ./mysql-test-run ] && [ -d ../sql ] ; then
|
|
|
|
|
SOURCE_DIST=1
|
|
|
|
|
else
|
2000-12-12 03:34:56 +01:00
|
|
|
|
echo "If you are using binary distribution, run me from install root as \
|
2000-12-07 15:54:59 +01:00
|
|
|
|
scripts/mysql-test-run. On source distribution run me from source root as \
|
|
|
|
|
mysql-test/mysql-test-run or from mysql-test as ./mysql-test-run"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2000-10-12 01:38:30 +02:00
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
|
#++
|
|
|
|
|
# Misc. Definitions
|
|
|
|
|
#--
|
2000-12-07 15:54:59 +01:00
|
|
|
|
|
|
|
|
|
#BASEDIR is always one above mysql-test directory
|
2000-07-31 21:29:14 +02:00
|
|
|
|
CWD=`pwd`
|
|
|
|
|
cd ..
|
|
|
|
|
BASEDIR=`pwd`
|
|
|
|
|
cd $CWD
|
2000-12-07 15:54:59 +01:00
|
|
|
|
MYSQL_TEST_DIR=$BASEDIR/mysql-test
|
2000-12-12 16:24:50 +01:00
|
|
|
|
STD_DATA=$MYSQL_TEST_DIR/std_data
|
2000-12-07 15:54:59 +01:00
|
|
|
|
|
|
|
|
|
TESTDIR="$MYSQL_TEST_DIR/t/"
|
2000-10-10 10:42:07 +02:00
|
|
|
|
TESTSUFFIX=test
|
2000-07-31 21:29:14 +02:00
|
|
|
|
TOT_PASS=0
|
|
|
|
|
TOT_FAIL=0
|
|
|
|
|
TOT_TEST=0
|
2000-10-11 15:50:13 +02:00
|
|
|
|
USERT=0
|
|
|
|
|
SYST=0
|
|
|
|
|
REALT=0
|
2000-12-07 15:54:59 +01:00
|
|
|
|
MY_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
|
|
|
|
|
TIMEFILE="$MYSQL_TEST_DIR/var/tmp/mysqltest-time"
|
2000-10-11 15:50:13 +02:00
|
|
|
|
DASHBLANK="---- ---- -------"
|
2000-10-12 01:01:58 +02:00
|
|
|
|
MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
|
|
|
|
|
myisammrg heap sql"
|
2000-12-09 01:32:30 +01:00
|
|
|
|
GCOV_MSG=/tmp/mysqld-gcov.out #gcov output
|
|
|
|
|
GCOV_ERR=/tmp/mysqld-gcov.err
|
2000-11-18 07:35:40 +01:00
|
|
|
|
|
|
|
|
|
[ -d $MY_TMP_DIR ] || mkdir -p $MY_TMP_DIR
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
|
|
[ -z $COLUMNS ] && COLUMNS=80
|
|
|
|
|
E=`expr $COLUMNS - 8`
|
|
|
|
|
C=0
|
|
|
|
|
|
|
|
|
|
while [ $C != $E ]
|
|
|
|
|
do
|
|
|
|
|
DASH72="${DASH72}-"
|
|
|
|
|
C=`expr $C + 1`
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
#++
|
|
|
|
|
# mysqld Environment Parameters
|
|
|
|
|
#--
|
2000-11-18 07:35:40 +01:00
|
|
|
|
MYRUN_DIR=var/run
|
|
|
|
|
MASTER_MYPORT=9306
|
2000-12-07 15:54:59 +01:00
|
|
|
|
MASTER_MYDDIR="$MYSQL_TEST_DIR/var/lib"
|
|
|
|
|
MASTER_MYSOCK="$MYSQL_TEST_DIR/var/tmp/mysql.sock"
|
|
|
|
|
MASTER_MYPID="$MYSQL_TEST_DIR/var/run/mysqld.pid"
|
|
|
|
|
MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
|
|
|
|
|
MASTER_MYERR="$MYSQL_TEST_DIR/var/log/mysqld.err"
|
|
|
|
|
|
2000-11-18 07:35:40 +01:00
|
|
|
|
|
|
|
|
|
SLAVE_MYPORT=9307
|
2000-12-07 15:54:59 +01:00
|
|
|
|
SLAVE_MYDDIR="$MYSQL_TEST_DIR/var/slave-data"
|
|
|
|
|
SLAVE_MYSOCK="$MYSQL_TEST_DIR/var/tmp/mysql-slave.sock"
|
|
|
|
|
SLAVE_MYPID="$MYSQL_TEST_DIR/var/run/mysqld-slave.pid"
|
|
|
|
|
SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld-slave.log"
|
|
|
|
|
SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
|
|
|
|
|
|
|
|
|
|
if [ x$SOURCE_DIST = x1 ] ; then
|
|
|
|
|
MY_BASEDIR=$MYSQL_TEST_DIR
|
|
|
|
|
else
|
|
|
|
|
MY_BASEDIR=$BASEDIR
|
|
|
|
|
fi
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
|
|
#++
|
|
|
|
|
# Program Definitions
|
|
|
|
|
#--
|
2000-12-12 03:34:56 +01:00
|
|
|
|
BASENAME=`which basename | head -1`
|
2000-10-11 15:50:13 +02:00
|
|
|
|
CAT=/bin/cat
|
|
|
|
|
CUT=/usr/bin/cut
|
2000-10-10 10:42:07 +02:00
|
|
|
|
ECHO=/bin/echo
|
2000-12-12 03:34:56 +01:00
|
|
|
|
EXPR=`which expr | head -1`
|
2000-10-13 14:14:39 +02:00
|
|
|
|
FIND=/usr/bin/find
|
2000-12-12 03:34:56 +01:00
|
|
|
|
GCOV=`which gcov | head -1`
|
2000-10-10 10:42:07 +02:00
|
|
|
|
PRINTF=/usr/bin/printf
|
2000-10-11 15:50:13 +02:00
|
|
|
|
RM=/bin/rm
|
2000-07-31 21:29:14 +02:00
|
|
|
|
TIME=/usr/bin/time
|
2000-10-11 15:50:13 +02:00
|
|
|
|
TR=/usr/bin/tr
|
2000-12-12 03:34:56 +01:00
|
|
|
|
XARGS=`which xargs | head -1`
|
2000-12-07 15:54:59 +01:00
|
|
|
|
|
|
|
|
|
# on source dist, we pick up freshly build executables
|
|
|
|
|
# on binary, use what is installed
|
|
|
|
|
if [ x$SOURCE_DIST = x1 ] ; then
|
|
|
|
|
MYSQLD="$BASEDIR/sql/mysqld"
|
|
|
|
|
MYSQL_TEST="$BASEDIR/client/mysqltest"
|
|
|
|
|
MYSQLADMIN="$BASEDIR/client/mysqladmin"
|
|
|
|
|
INSTALL_DB="./install_test_db"
|
|
|
|
|
else
|
|
|
|
|
MYSQLD="$BASEDIR/bin/mysqld"
|
|
|
|
|
MYSQL_TEST="$BASEDIR/bin/mysqltest"
|
|
|
|
|
MYSQLADMIN="$BASEDIR/bin/mysqladmin"
|
|
|
|
|
INSTALL_DB="../scripts/install_test_db -bin"
|
|
|
|
|
fi
|
|
|
|
|
|
2000-12-12 16:24:50 +01:00
|
|
|
|
|
2000-12-09 01:32:30 +01:00
|
|
|
|
SLAVE_MYSQLD=$MYSQLD #this will be changed later if we are doing gcov
|
2000-12-07 15:54:59 +01:00
|
|
|
|
|
|
|
|
|
|
2000-12-12 03:34:56 +01:00
|
|
|
|
MYSQL_TEST="$MYSQL_TEST --no-defaults --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent"
|
2000-11-21 07:38:08 +01:00
|
|
|
|
GDB_MASTER_INIT=/tmp/gdbinit.master
|
|
|
|
|
GDB_SLAVE_INIT=/tmp/gdbinit.slave
|
|
|
|
|
|
2000-12-07 15:54:59 +01:00
|
|
|
|
if [ "$1" = "-force" ] ; then
|
|
|
|
|
FORCE=1
|
|
|
|
|
shift 1
|
|
|
|
|
fi
|
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
if [ "$1" = "-gcov" ];
|
|
|
|
|
then
|
2000-12-07 15:54:59 +01:00
|
|
|
|
if [ x$BINARY_DIST = x1 ] ; then
|
|
|
|
|
echo "Cannot do coverage test without the source - please us source dist"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2000-11-21 07:38:08 +01:00
|
|
|
|
DO_GCOV=1
|
|
|
|
|
shift 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "-gdb" ];
|
|
|
|
|
then
|
2000-12-07 15:54:59 +01:00
|
|
|
|
# if the user really wanted to run binary dist in a debugger, he can
|
|
|
|
|
# but we should warn him
|
|
|
|
|
if [ x$BINARY_DIST = x1 ] ; then
|
|
|
|
|
echo "Note: you will get more meaningful output on a source distribution \
|
|
|
|
|
compiled with debugging option when running tests with -gdb option"
|
|
|
|
|
fi
|
2000-11-21 07:38:08 +01:00
|
|
|
|
DO_GDB=1
|
|
|
|
|
shift 1
|
|
|
|
|
fi
|
2000-10-13 14:14:39 +02:00
|
|
|
|
|
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
|
#++
|
|
|
|
|
# Terminal Modifications
|
|
|
|
|
#--
|
2000-10-11 15:50:13 +02:00
|
|
|
|
MOVE_TO_COL="$ECHO -n [300C[20D"
|
|
|
|
|
SETCOLOR_SUCCESS="$ECHO -n [1;32m"
|
|
|
|
|
SETCOLOR_FAILURE="$ECHO -n [1;31m"
|
|
|
|
|
SETCOLOR_WARNING="$ECHO -n [1;33m"
|
|
|
|
|
SETCOLOR_NORMAL="$ECHO -n [0;39m"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
|
|
#++
|
|
|
|
|
# Function Definitions
|
|
|
|
|
#--
|
|
|
|
|
echo_ok() {
|
|
|
|
|
$MOVE_TO_COL && $SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "[ "
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_SUCCESS
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "ok"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO " ]"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo_notok() {
|
|
|
|
|
$MOVE_TO_COL && $SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "[ "
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_FAILURE
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "not ok"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO " ]"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo_pass () {
|
|
|
|
|
$MOVE_TO_COL && $SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "[ "
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_SUCCESS
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "pass"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO " ]"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
prompt_user ()
|
|
|
|
|
{
|
|
|
|
|
echo $1
|
2000-12-07 15:54:59 +01:00
|
|
|
|
read unused
|
2000-11-21 07:38:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
|
echo_fail () {
|
|
|
|
|
$MOVE_TO_COL && $SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "[ "
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_FAILURE
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "fail"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_NORMAL
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO " ]"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error () {
|
|
|
|
|
|
|
|
|
|
$SETCOLOR_FAILURE
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "Error: " && $SETCOLOR_NORMAL && $ECHO $1
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_NORMAL
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pass_inc () {
|
2000-10-10 10:42:07 +02:00
|
|
|
|
TOT_PASS=`$EXPR $TOT_PASS + 1`
|
2000-07-31 21:29:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fail_inc () {
|
2000-10-10 10:42:07 +02:00
|
|
|
|
TOT_FAIL=`$EXPR $TOT_FAIL + 1`
|
2000-07-31 21:29:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
total_inc () {
|
2000-10-10 10:42:07 +02:00
|
|
|
|
TOT_TEST=`$EXPR $TOT_TEST + 1`
|
2000-07-31 21:29:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report_stats () {
|
2000-10-10 00:41:21 +02:00
|
|
|
|
if [ $TOT_FAIL = 0 ]; then
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO "All tests successful."
|
2000-07-31 21:29:14 +02:00
|
|
|
|
else
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO -n "Failed ${TOT_FAIL}/${TOT_TEST} tests, "
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
xten=`$EXPR $TOT_PASS \* 10000`
|
|
|
|
|
raw=`$EXPR $xten / $TOT_TEST`
|
|
|
|
|
raw=`$PRINTF %.4d $raw`
|
|
|
|
|
whole=`$PRINTF %.2s $raw`
|
|
|
|
|
xwhole=`$EXPR $whole \* 100`
|
|
|
|
|
deci=`$EXPR $raw - $xwhole`
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO "${whole}.${deci}% successful."
|
2000-07-31 21:29:14 +02:00
|
|
|
|
fi
|
|
|
|
|
}
|
2000-10-11 15:50:13 +02:00
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
|
mysql_install_db () {
|
2000-11-18 07:35:40 +01:00
|
|
|
|
$RM -rf $MASTER_MYDDIR $SLAVE_MYDDIR $SLAVE_MYLOG $MASTER_MYLOG \
|
|
|
|
|
$SLAVE_MYERR $MASTER_MYERR
|
|
|
|
|
[ -d $MYRUN_DIR ] || mkdir -p $MYRUN_DIR
|
|
|
|
|
$INSTALL_DB
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
error "Could not install master test DBs"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
$INSTALL_DB -slave
|
2000-10-10 00:41:21 +02:00
|
|
|
|
if [ $? != 0 ]; then
|
2000-11-18 07:35:40 +01:00
|
|
|
|
error "Could not install slave test DBs"
|
2000-10-10 00:41:21 +02:00
|
|
|
|
exit 1
|
2000-07-31 21:29:14 +02:00
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-18 07:35:40 +01:00
|
|
|
|
gcov_prepare () {
|
2000-10-13 14:14:39 +02:00
|
|
|
|
$FIND $BASEDIR -name \*.gcov \
|
|
|
|
|
-or -name \*.da | $XARGS $RM
|
2000-10-12 01:01:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gcov_collect () {
|
2000-10-13 14:14:39 +02:00
|
|
|
|
$ECHO "Collecting source coverage info..."
|
2000-12-09 01:32:30 +01:00
|
|
|
|
[ -f $GCOV_MSG ] && $RM $GCOV_MSG
|
|
|
|
|
[ -f $GCOV_ERR ] && $RM $GCOV_ERR
|
2000-10-13 14:14:39 +02:00
|
|
|
|
for d in $MYSQLD_SRC_DIRS; do
|
|
|
|
|
cd $BASEDIR/$d
|
|
|
|
|
for f in *.h *.cc *.c; do
|
2000-12-09 01:32:30 +01:00
|
|
|
|
$GCOV $f 2>>$GCOV_ERR >>$GCOV_MSG
|
2000-10-13 14:14:39 +02:00
|
|
|
|
done
|
2000-12-07 15:54:59 +01:00
|
|
|
|
cd $MYSQL_TEST_DIR
|
2000-10-12 01:01:58 +02:00
|
|
|
|
done
|
|
|
|
|
|
2000-12-09 01:32:30 +01:00
|
|
|
|
$ECHO "gcov info in $GCOV_MSG, errors in $GCOV_ERR"
|
2000-10-12 01:01:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
start_master()
|
|
|
|
|
{
|
2000-10-13 14:14:39 +02:00
|
|
|
|
cd $BASEDIR # for gcov
|
2000-11-18 07:35:40 +01:00
|
|
|
|
#start master
|
2000-11-21 07:38:08 +01:00
|
|
|
|
master_args="--no-defaults --log-bin \
|
2000-11-18 07:35:40 +01:00
|
|
|
|
--server-id=1 \
|
2000-12-07 15:54:59 +01:00
|
|
|
|
--basedir=$MY_BASEDIR \
|
2000-11-18 07:35:40 +01:00
|
|
|
|
--port=$MASTER_MYPORT \
|
2000-12-08 23:14:37 +01:00
|
|
|
|
--exit-info=256 \
|
2000-11-18 07:35:40 +01:00
|
|
|
|
--datadir=$MASTER_MYDDIR \
|
|
|
|
|
--pid-file=$MASTER_MYPID \
|
|
|
|
|
--socket=$MASTER_MYSOCK \
|
|
|
|
|
--log=$MASTER_MYLOG \
|
2000-11-21 07:38:08 +01:00
|
|
|
|
--language=english $EXTRA_MASTER_OPT"
|
|
|
|
|
if [ x$DO_GDB = x1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "set args $master_args" > $GDB_MASTER_INIT
|
|
|
|
|
xterm -title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD &
|
|
|
|
|
prompt_user "Hit enter to continue after you've started the master"
|
|
|
|
|
else
|
|
|
|
|
$MYSQLD $master_args >> $MASTER_MYERR 2>&1 &
|
|
|
|
|
fi
|
|
|
|
|
MASTER_RUNNING=1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start_slave()
|
|
|
|
|
{
|
2000-11-22 08:23:31 +01:00
|
|
|
|
[ x$SKIP_SLAVE = x1 ] && return
|
2000-11-21 07:38:08 +01:00
|
|
|
|
slave_args="--no-defaults --server-id=2 \
|
2000-11-18 07:35:40 +01:00
|
|
|
|
--master-user=root \
|
2000-11-21 07:38:08 +01:00
|
|
|
|
--master-connect-retry=1 \
|
2000-11-18 07:35:40 +01:00
|
|
|
|
--master-host=127.0.0.1 \
|
|
|
|
|
--master-port=$MASTER_MYPORT \
|
2000-12-08 23:14:37 +01:00
|
|
|
|
--exit-info=256 \
|
|
|
|
|
--log-bin --log-slave-updates \
|
2000-12-07 15:54:59 +01:00
|
|
|
|
--basedir=$MY_BASEDIR \
|
2000-11-18 07:35:40 +01:00
|
|
|
|
--datadir=$SLAVE_MYDDIR \
|
|
|
|
|
--pid-file=$SLAVE_MYPID \
|
|
|
|
|
--port=$SLAVE_MYPORT \
|
|
|
|
|
--socket=$SLAVE_MYSOCK \
|
|
|
|
|
--log=$SLAVE_MYLOG \
|
2000-11-21 07:38:08 +01:00
|
|
|
|
--language=english $EXTRA_SLAVE_OPT"
|
|
|
|
|
if [ x$DO_GDB = x1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "set args $slave_args" > $GDB_SLAVE_INIT
|
2000-12-09 01:32:30 +01:00
|
|
|
|
xterm -title "Slave" -e gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD &
|
2000-11-21 07:38:08 +01:00
|
|
|
|
prompt_user "Hit enter to continue after you've started the slave"
|
2000-12-09 01:32:30 +01:00
|
|
|
|
else
|
|
|
|
|
$SLAVE_MYSQLD $slave_args >> $SLAVE_MYERR 2>&1 &
|
2000-11-21 07:38:08 +01:00
|
|
|
|
fi
|
|
|
|
|
SLAVE_RUNNING=1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mysql_start () {
|
|
|
|
|
start_master
|
|
|
|
|
start_slave
|
2000-12-07 15:54:59 +01:00
|
|
|
|
cd $MYSQL_TEST_DIR
|
2000-07-31 21:29:14 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
stop_slave ()
|
|
|
|
|
{
|
|
|
|
|
if [ x$SLAVE_RUNNING = x1 ]
|
|
|
|
|
then
|
2000-12-12 03:34:56 +01:00
|
|
|
|
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root shutdown
|
2000-12-12 20:12:41 +01:00
|
|
|
|
if [ $? != 0 ] ; then # try harder!
|
|
|
|
|
echo "slave not cooperating with mysqladmin, will try manual kill"
|
|
|
|
|
kill `cat $SLAVE_MYPID`
|
|
|
|
|
sleep 2
|
|
|
|
|
if [ -f $SLAVE_MYPID ] ; then
|
|
|
|
|
echo "slave refused to die, resorting to SIGKILL murder"
|
|
|
|
|
kill -9 `cat $SLAVE_MYPID`
|
|
|
|
|
rm -f $SLAVE_MYPID
|
|
|
|
|
else
|
|
|
|
|
echo "slave responded to SIGTERM "
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2000-11-21 07:38:08 +01:00
|
|
|
|
SLAVE_RUNNING=0
|
|
|
|
|
fi
|
|
|
|
|
}
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
stop_master ()
|
|
|
|
|
{
|
|
|
|
|
if [ x$MASTER_RUNNING = x1 ]
|
|
|
|
|
then
|
2000-12-12 03:34:56 +01:00
|
|
|
|
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root shutdown
|
2000-12-12 20:12:41 +01:00
|
|
|
|
if [ $? != 0 ] ; then # try harder!
|
|
|
|
|
echo "master not cooperating with mysqladmin, will try manual kill"
|
|
|
|
|
kill `cat $MASTER_MYPID`
|
|
|
|
|
sleep 2
|
|
|
|
|
if [ -f $MASTER_MYPID ] ; then
|
|
|
|
|
echo "master refused to die, resorting to SIGKILL murder"
|
|
|
|
|
kill -9 `cat $MASTER_MYPID`
|
|
|
|
|
rm -f $MASTER_MYPID
|
|
|
|
|
else
|
|
|
|
|
echo "master responded to SIGTERM "
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2000-11-21 07:38:08 +01:00
|
|
|
|
MASTER_RUNNING=0
|
|
|
|
|
fi
|
|
|
|
|
}
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
mysql_stop ()
|
|
|
|
|
{
|
|
|
|
|
stop_master
|
|
|
|
|
stop_slave
|
|
|
|
|
return 1
|
2000-07-31 21:29:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mysql_restart () {
|
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
return 1
|
2000-07-31 21:29:14 +02:00
|
|
|
|
mysql_stop
|
|
|
|
|
res=$?
|
|
|
|
|
[ $res != 1 ] && echo_notok && error "Stopping mysqld"
|
|
|
|
|
|
|
|
|
|
mysql_start
|
|
|
|
|
res=$?
|
|
|
|
|
[ $res != 1 ] && echo_notok && error "Starting mysqld"
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mysql_loadstd () {
|
2000-12-12 16:24:50 +01:00
|
|
|
|
|
|
|
|
|
cp $STD_DATA/*.frm $STD_DATA/*.MRG $MASTER_MYDDIR/test
|
2000-07-31 21:29:14 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
run_testcase ()
|
|
|
|
|
{
|
|
|
|
|
tf=$1
|
|
|
|
|
tname=`$BASENAME $tf`
|
|
|
|
|
tname=`$ECHO $tname | $CUT -d . -f 1`
|
|
|
|
|
master_opt_file=$TESTDIR/$tname-master.opt
|
|
|
|
|
slave_opt_file=$TESTDIR/$tname-slave.opt
|
2000-12-07 00:18:46 +01:00
|
|
|
|
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
|
2000-11-21 07:38:08 +01:00
|
|
|
|
|
|
|
|
|
if [ -f $master_opt_file ] ;
|
|
|
|
|
then
|
|
|
|
|
EXTRA_MASTER_OPT=`cat $master_opt_file`
|
|
|
|
|
stop_master
|
|
|
|
|
start_master
|
|
|
|
|
else
|
|
|
|
|
if [ ! -z EXTRA_MASTER_OPT ] || [ x$MASTER_RUNNING != x1 ] ;
|
|
|
|
|
then
|
|
|
|
|
EXTRA_MASTER_OPT=""
|
|
|
|
|
stop_master
|
|
|
|
|
start_master
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f $slave_opt_file ] ;
|
|
|
|
|
then
|
|
|
|
|
EXTRA_SLAVE_OPT=`cat $slave_opt_file`
|
|
|
|
|
stop_slave
|
|
|
|
|
start_slave
|
|
|
|
|
else
|
|
|
|
|
if [ ! -z EXTRA_SLAVE_OPT ] || [ x$SLAVE_RUNNING != x1 ] ;
|
|
|
|
|
then
|
|
|
|
|
EXTRA_SLAVE_OPT=""
|
|
|
|
|
stop_slave
|
|
|
|
|
start_slave
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-12-07 15:54:59 +01:00
|
|
|
|
cd $MYSQL_TEST_DIR
|
2000-11-21 07:38:08 +01:00
|
|
|
|
|
2000-10-10 01:53:10 +02:00
|
|
|
|
if [ -f $tf ] ; then
|
2000-10-11 15:50:13 +02:00
|
|
|
|
mytime=`$TIME -p $MYSQL_TEST < $tf 2> $TIMEFILE`
|
2000-07-31 21:29:14 +02:00
|
|
|
|
res=$?
|
|
|
|
|
|
2000-10-11 15:50:13 +02:00
|
|
|
|
if [ $res != 1 ]; then
|
|
|
|
|
mytime=`$CAT $TIMEFILE | $TR '\n' '-'`
|
|
|
|
|
|
|
|
|
|
USERT=`$ECHO $mytime | $CUT -d - -f 2 | $CUT -d ' ' -f 2`
|
|
|
|
|
SYST=`$ECHO $mytime | $CUT -d - -f 3 | $CUT -d ' ' -f 2`
|
|
|
|
|
REALT=`$ECHO $mytime | $CUT -d - -f 1 | $CUT -d ' ' -f 2`
|
|
|
|
|
else
|
|
|
|
|
USERT="...."
|
|
|
|
|
SYST="...."
|
|
|
|
|
REALT="...."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
timestr="$USERT $SYST $REALT"
|
2000-11-21 07:38:08 +01:00
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "$tname $timestr"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-10-11 15:50:13 +02:00
|
|
|
|
[ $res != 1 ] && pass_inc && echo_pass
|
|
|
|
|
[ $res = 1 ] && fail_inc && echo_fail
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-10-11 15:50:13 +02:00
|
|
|
|
total_inc
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
|
|
if [ $res != 0 ]; then
|
2000-11-18 07:35:40 +01:00
|
|
|
|
$ECHO "failed output"
|
|
|
|
|
$CAT $TIMEFILE
|
|
|
|
|
$ECHO
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO
|
2000-12-07 15:54:59 +01:00
|
|
|
|
if [ x$FORCE != x1 ] ; then
|
|
|
|
|
$SETCOLOR_NORMAL
|
|
|
|
|
echo "Aborting, if you want to continue, re-run with -force"
|
|
|
|
|
mysql_stop
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2000-10-11 15:50:13 +02:00
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Restarting mysqld $DASHBLANK"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
mysql_restart
|
|
|
|
|
$SETCOLOR_SUCCESS && echo_ok
|
2000-10-11 15:50:13 +02:00
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Resuming Tests $DASHBLANK"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_SUCCESS && echo_ok
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO
|
2000-07-31 21:29:14 +02:00
|
|
|
|
fi
|
2000-10-10 01:53:10 +02:00
|
|
|
|
fi
|
2000-11-21 07:38:08 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ "$DO_GCOV" -a ! -x "$GCOV" ] && error "No gcov found"
|
|
|
|
|
|
|
|
|
|
[ "$DO_GCOV" ] && gcov_prepare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mysql_install_db
|
|
|
|
|
|
2000-11-22 08:23:31 +01:00
|
|
|
|
#do not automagically start deamons if we are in gdb or running only one test
|
|
|
|
|
#case
|
|
|
|
|
if [ -z $DO_GDB ] && [ -z $1 ]
|
2000-11-21 07:38:08 +01:00
|
|
|
|
then
|
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Starting mysqld for Testing"
|
|
|
|
|
mysql_start
|
|
|
|
|
res=$?
|
|
|
|
|
res=1
|
|
|
|
|
[ $res != 1 ] && echo_notok && error "Starting mysqld"
|
|
|
|
|
[ $res = 1 ] && echo_ok
|
|
|
|
|
fi
|
|
|
|
|
|
2000-12-12 16:24:50 +01:00
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Loading Standard Test Database"
|
|
|
|
|
mysql_loadstd
|
|
|
|
|
res=$?
|
|
|
|
|
[ x$res != x1 ] && echo_notok && error "Loading STD"
|
|
|
|
|
[ x$res = x1 ] && echo_ok
|
2000-11-21 07:38:08 +01:00
|
|
|
|
|
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Starting Tests for MySQL $TESTVER Series"
|
|
|
|
|
$SETCOLOR_SUCCESS && echo_ok
|
|
|
|
|
|
|
|
|
|
$ECHO
|
|
|
|
|
$ECHO " TEST USER SYSTEM ELAPSED RESULT"
|
|
|
|
|
$ECHO $DASH72
|
|
|
|
|
|
|
|
|
|
if [ -z $1 ] ;
|
|
|
|
|
then
|
|
|
|
|
for tf in $TESTDIR/*.$TESTSUFFIX
|
|
|
|
|
do
|
|
|
|
|
run_testcase $tf
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
tf=$TESTDIR/$1.$TESTSUFFIX
|
|
|
|
|
run_testcase $tf
|
|
|
|
|
fi
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO $DASH72
|
|
|
|
|
$ECHO
|
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Ending Tests for MySQL $TESTVER Series"
|
2000-07-31 21:29:14 +02:00
|
|
|
|
$SETCOLOR_SUCCESS && echo_ok
|
2000-10-11 15:50:13 +02:00
|
|
|
|
$RM $TIMEFILE
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-11-21 07:38:08 +01:00
|
|
|
|
if [ -z $DO_GDB ] ;
|
|
|
|
|
then
|
|
|
|
|
$SETCOLOR_NORMAL && $ECHO -n "Shutdown mysqld"
|
|
|
|
|
mysql_stop
|
|
|
|
|
res=$?
|
|
|
|
|
res=1
|
|
|
|
|
[ $res != 1 ] && echo_notok && error "Shutdown mysqld"
|
|
|
|
|
[ $res = 1 ] && echo_ok
|
|
|
|
|
fi
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
|
|
$SETCOLOR_NORMAL
|
|
|
|
|
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO
|
2000-07-31 21:29:14 +02:00
|
|
|
|
report_stats
|
2000-10-10 10:42:07 +02:00
|
|
|
|
$ECHO
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
2000-10-12 15:51:19 +02:00
|
|
|
|
[ "$DO_GCOV" ] && gcov_collect # collect coverage information
|
2000-10-12 01:01:58 +02:00
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
|
exit 0
|