1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Fixes to get mysql-test-run more portable

This commit is contained in:
monty@donna.mysql.com
2001-01-04 02:56:38 +02:00
parent ff0e2e2d7a
commit 7541a877bc
16 changed files with 199 additions and 130 deletions

View File

@@ -18,6 +18,10 @@ You can create your own test cases. To create a test case:
We would appreciate if the test tables were called t1, t2, t3 ... (to not
conflict too much with existing tables).
Your test should begin by dropping the tables you are going to create and
end by dropping them again. This will ensure that one can run the test
over and over again.
If you are using mysqltest commands (like result file names) in your
test case you should do create the result file as follows:

View File

@@ -0,0 +1,3 @@
-- require r/have_default_master.require
connection master;
show variables like "port";

View File

@@ -1,7 +1,7 @@
connect (master,localhost,root,,test,0,var/tmp/mysql.sock);
connect (master1,localhost,root,,test,0,var/tmp/mysql.sock);
connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock);
connect (slave1,localhost,root,,test,0,var/tmp/mysql-slave.sock);
connect (master,localhost,root,,test,0,mysql-master.sock);
connect (master1,localhost,root,,test,0,mysql-master.sock);
connect (slave,localhost,root,,test,0,mysql-slave.sock);
connect (slave1,localhost,root,,test,0,mysql-slave.sock);
connection slave;
!slave stop;
@r/slave-stopped.result show status like 'Slave_running';

View File

@@ -41,6 +41,7 @@ fi
# On IRIX hostname is in /usr/bsd so add this to the path
PATH=$PATH:/usr/bsd
hostname=`hostname` # Install this too in the user table
hostname="$hostname%" # Fix if not fully qualified hostname
resolved=127.0.0.1

View File

@@ -19,7 +19,7 @@ TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
# Program Definitions
#--
PATH=/bin:/usr/bin:/usr/local/bin
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd
# No paths below as we can't be sure where the program is!
@@ -65,6 +65,7 @@ if [ -d ../sql ] ; then
else
BINARY_DIST=1
fi
#BASEDIR is always one above mysql-test directory
CWD=`pwd`
cd ..
@@ -83,28 +84,77 @@ USERT=0
SYST=0
REALT=0
MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
TIMEFILE="$MYSQL_TMP_DIR/mysqltest-time"
RES_SPACE=" "
MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
myisammrg heap sql"
GCOV_MSG=$MYSQL_TMP_DIR/mysqld-gcov.out
GCOV_ERR=$MYSQL_TMP_DIR/mysqld-gcov.err
MASTER_RUNNING=0
MASTER_MYPORT=9306
SLAVE_RUNNING=0
SLAVE_MYPORT=9307
EXTRA_MYSQL_TEST_OPT=""
USE_RUNNING_SERVER=1
DO_GCOV=""
DO_GDB=""
DO_DDD=""
SLEEP_TIME=2
while test $# -gt 0; do
case "$1" in
--force ) FORCE=1 ;;
--local) USE_RUNNING_SERVER="" ;;
--tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;;
--master_port=*) MASTER_MYPORT=`$ECHO "$1" | $SED -e "s;--master_port=;;"` ;;
--slave_port=*) SLAVE_MYPORT=`$ECHO "$1" | $SED -e "s;--slave_port=;;"` ;;
--record)
RECORD=1;
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
--sleep=*)
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1"
SLEEP_TIME=`$ECHO "$1" | $SED -e "s;--sleep=;;"`
;;
--gcov )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Cannot do coverage test without the source - please use source dist"
exit 1
fi
DO_GCOV=1
;;
--gdb )
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
DO_GDB=1
;;
--ddd )
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
DO_DDD=1
;;
--debug)
EXTRA_MASTER_MYSQLD_OPT=--debug=d:t:O,$MYSQL_TMP_DIR/master.trace
EXTRA_SLAVE_MYSQLD_OPT=--debug=d:t:O,$MYSQL_TMP_DIR/slave.trace
;;
-- ) shift; break ;;
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
* ) break ;;
esac
shift
done
#++
# mysqld Environment Parameters
#--
MYRUN_DIR=$MYSQL_TEST_DIR/var/run
MASTER_MYPORT=9306
MASTER_MYDDIR="$MYSQL_TEST_DIR/var/lib"
MASTER_MYSOCK="$MYSQL_TMP_DIR/mysql.sock"
MASTER_MYSOCK="$MYSQL_TMP_DIR/mysql-master.sock"
MASTER_MYPID="$MYRUN_DIR/mysqld.pid"
MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
MASTER_MYERR="$MYSQL_TEST_DIR/var/log/mysqld.err"
SLAVE_MYPORT=9307
SLAVE_MYDDIR="$MYSQL_TEST_DIR/var/slave-data"
SLAVE_MYSOCK="$MYSQL_TMP_DIR/mysql-slave.sock"
SLAVE_MYPID="$MYRUN_DIR/mysqld-slave.pid"
@@ -145,59 +195,16 @@ else
INSTALL_DB="./install_test_db -bin"
fi
SLAVE_MYSQLD=$MYSQLD #this will be changed later if we are doing gcov
MYSQL_TEST="$MYSQL_TEST --no-defaults --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent -v"
GDB_MASTER_INIT=$MYSQL_TMP_DIR/gdbinit.master
GDB_SLAVE_INIT=$MYSQL_TMP_DIR/gdbinit.slave
USE_RUNNING_SERVER=1
DO_GCOV=""
DO_GDB=""
DO_DDD=""
while test $# -gt 0; do
case "$1" in
--force ) FORCE=1 ;;
--record ) RECORD=1 ;;
--local) USE_RUNNING_SERVER="" ;;
--gcov )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Cannot do coverage test without the source - please use source dist"
exit 1
fi
DO_GCOV=1
;;
--gdb )
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
DO_GDB=1
;;
--ddd )
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
DO_DDD=1
;;
--debug)
EXTRA_MASTER_MYSQLD_OPT=--debug=d:t:O,$MYSQL_TMP_DIR/master.trace
EXTRA_SLAVE_MYSQLD_OPT=--debug=d:t:O,$MYSQL_TMP_DIR/slave.trace
;;
-- ) shift; break ;;
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
* ) break ;;
esac
shift
done
# If we should run all tests cases, we will use a local server for that
if [ -z "$1" ]
then
USE_RUNNING_SERVER=""
fi
if [ -n "$USE_RUNNING_SERVER" ]
then
MASTER_MYSOCK="/tmp/mysql.sock"
fi
if [ -w / ]
then
@@ -206,6 +213,15 @@ then
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root"
fi
MYSQL_TEST="$MYSQL_TEST --no-defaults --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent -v --tmpdir=$MYSQL_TMP_DIR"
GDB_MASTER_INIT=$MYSQL_TMP_DIR/gdbinit.master
GDB_SLAVE_INIT=$MYSQL_TMP_DIR/gdbinit.slave
GCOV_MSG=$MYSQL_TMP_DIR/mysqld-gcov.out
GCOV_ERR=$MYSQL_TMP_DIR/mysqld-gcov.err
TIMEFILE="$MYSQL_TMP_DIR/mysqltest-time"
SLAVE_MYSQLD=$MYSQLD #this can be changed later if we are doing gcov
#++
# Function Definitions
#--
@@ -223,7 +239,7 @@ error () {
}
error_is () {
$ECHO `$CAT $TIMEFILE` | $SED -e 's/.* At line \(.*\)\: \(.*\)Command .*$/ \>\> Error at line \1: \2<\</'
$TR "\n" " " < $TIMEFILE | $SED -e 's/.* At line \(.*\)\: \(.*\)Command .*$/ \>\> Error at line \1: \2<\</'
}
prefix_to_8() {
@@ -316,6 +332,7 @@ start_master()
--socket=$MASTER_MYSOCK \
--log=$MASTER_MYLOG --default-character-set=latin1 \
--core \
--tmpdir=$MYSQL_TMP_DIR \
--language=english $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
if [ x$DO_DDD = x1 ]
then
@@ -358,11 +375,12 @@ start_slave()
--socket=$SLAVE_MYSOCK \
--log=$SLAVE_MYLOG --default-character-set=latin1 \
--core \
--tmpdir=$MYSQL_TMP_DIR \
--language=english $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT"
if [ x$DO_DDD = x1 ]
then
$ECHO "set args $master_args" > $GDB_SLAVE_INIT
ddd --debugger "gdb -x $GDB_SLAVE_INIT" $MYSQLD &
ddd --debugger "gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD &
prompt_user "Hit enter to continue after you've started the master"
elif [ x$DO_GDB = x1 ]
then
@@ -380,6 +398,7 @@ mysql_start () {
start_master
start_slave
cd $MYSQL_TEST_DIR
sleep $SLEEP_TIME # Give mysqld time to start properly
return 1
}
@@ -392,7 +411,7 @@ stop_slave ()
then # try harder!
$ECHO "slave not cooperating with mysqladmin, will try manual kill"
kill `$CAT $SLAVE_MYPID`
sleep 2
sleep $SLEEP_TIME
if [ -f $SLAVE_MYPID ] ; then
$ECHO "slave refused to die, resorting to SIGKILL murder"
kill -9 `$CAT $SLAVE_MYPID`
@@ -402,7 +421,7 @@ stop_slave ()
fi
fi
SLAVE_RUNNING=0
sleep 2 # Give mysqld time to go down properly
sleep $SLEEP_TIME # Give mysqld time to go down properly
fi
}
@@ -415,7 +434,7 @@ stop_master ()
then # try harder!
$ECHO "master not cooperating with mysqladmin, will try manual kill"
kill `$CAT $MASTER_MYPID`
sleep 2
sleep $SLEEP_TIME
if [ -f $MASTER_MYPID ] ; then
$ECHO "master refused to die, resorting to SIGKILL murder"
kill -9 `$CAT $MASTER_MYPID`
@@ -425,7 +444,7 @@ stop_master ()
fi
fi
MASTER_RUNNING=0
sleep 2 # Give mysqld time to go down properly
sleep $SLEEP_TIME # Give mysqld time to go down properly
fi
}
@@ -461,11 +480,6 @@ run_testcase ()
slave_opt_file=$TESTDIR/$tname-slave.opt
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ x$RECORD = x1 ]; then
extra_flags="-r"
else
extra_flags=""
fi
if [ -f $master_opt_file ] ;
then
@@ -514,18 +528,18 @@ run_testcase ()
if [ -f $tf ] ; then
$RM -f r/$tname.*reject
mytime=`$TIME -p $MYSQL_TEST -R r/$tname.result $extra_flags \
mytime=`$TIME -p $MYSQL_TEST -R r/$tname.result $EXTRA_MYSQL_TEST_OPT \
< $tf 2> $TIMEFILE`
res=$?
if [ $res = 0 ]; then
mytime=`$CAT $TIMEFILE | $TAIL -3 | $TR '\n' '-'`
mytime=`$CAT $TIMEFILE | $TAIL -3 | $TR '\n' ':'`
USERT=`$ECHO $mytime | $CUT -d - -f 2 | $CUT -d ' ' -f 2`
USERT=`$ECHO $mytime | $CUT -d : -f 2 | $CUT -d ' ' -f 2`
USERT=`prefix_to_8 $USERT`
SYST=`$ECHO $mytime | $CUT -d - -f 3 | $CUT -d ' ' -f 2`
SYST=`$ECHO $mytime | $CUT -d : -f 3 | $CUT -d ' ' -f 2`
SYST=`prefix_to_8 $SYST`
REALT=`$ECHO $mytime | $CUT -d - -f 1 | $CUT -d ' ' -f 2`
REALT=`$ECHO $mytime | $CUT -d : -f 1 | $CUT -d ' ' -f 2`
REALT=`prefix_to_8 $REALT`
else
USERT=" ...."
@@ -533,21 +547,19 @@ run_testcase ()
REALT=" ...."
fi
timestr="$USERT $SYST $REALT"
pname=`$ECHO "$tname "|$CUT -c 1-16`
$ECHO -n "$pname $timestr"
timestr="$USERT $SYST $REALT"
pname=`$ECHO "$tname "|$CUT -c 1-16`
RES="$pname $timestr"
if [ $res = 0 ]; then
total_inc
pass_inc
$ECHO "$RES_SPACE [ pass ]"
$ECHO "$RES$RES_SPACE [ pass ]"
else
if [ $res = 1 ]; then
total_inc
fail_inc
$ECHO "$RES_SPACE [ fail ]"
$ECHO "$RES$RES_SPACE [ fail ]"
$ECHO
error_is
$ECHO
@@ -563,7 +575,7 @@ run_testcase ()
$ECHO ""
else
pass_inc
$ECHO "$RES_SPACE [ skipped ]"
$ECHO "$RES$RES_SPACE [ skipped ]"
fi
fi
fi

View File

@@ -1,9 +1,5 @@
0 256 00000000000000065536 2147483647 -2147483648 2147483648 +4294967296
0 256 65536 2147483647 -2147483648 2147483648 4294967296
922337203685477580 92233720368547758000
922337203685477580 92233720368547758080
-922337203685477580 -92233720368547758000
-922337203685477580 -92233720368547758080
9223372036854775807 -009223372036854775808
9223372036854775807 -9223372036854775808
+9999999999999999999 -9999999999999999999

View File

@@ -0,0 +1,2 @@
Variable_name Value
port 9306

View File

@@ -2,8 +2,6 @@
# Test of reading of bigint values
#
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
select 922337203685477580,92233720368547758000;
select -922337203685477580,-92233720368547758000;
select 9223372036854775807,-009223372036854775808;
select +9999999999999999999,-9999999999999999999;

View File

@@ -18,7 +18,7 @@ drop table if exists choo;
create table choo (k int);
insert into choo values(55);
connection slave;
sleep 2;
sleep 3;
@r/rpl000008.result select foo.n,bar.m,choo.k from foo,bar,choo;
connection master;
drop table if exists foo,bar,choo;

View File

@@ -21,6 +21,6 @@ sleep 1;
#
# Clean up
#
connect (master2,localhost,root,,test,0,var/tmp/mysql.sock);
connect (master2,localhost,root,,test,0,mysql-master.sock);
connection master2;
drop table if exists t1,t2;

View File

@@ -27,6 +27,6 @@ while ($1)
#
# Clean up
#
connect (master2,localhost,root,,test,0,var/tmp/mysql.sock);
connect (master2,localhost,root,,test,0,mysql-master.sock);
connection master2;
drop table if exists t1,t2;

View File

@@ -1,4 +1,5 @@
source include/master-slave.inc;
source include/have_default_master.inc;
connection master;
show master status;
connection slave;

View File

@@ -1,5 +1,6 @@
connect (master,localhost,root,,test,0,var/tmp/mysql.sock);
connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock);
connect (master,localhost,root,,test,0,mysql-master.sock);
connect (slave,localhost,root,,test,0, mysql-slave.sock);
source include/have_default_master.inc;
connection master;
reset master;
show master status;

View File

@@ -1,5 +1,6 @@
connect (master,localhost,root,,test,0,var/tmp/mysql.sock);
connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock);
connect (master,localhost,root,,test,0,mysql-master.sock);
connect (slave,localhost,root,,test,0,mysql-slave.sock);
source include/have_default_master.inc;
system cat /dev/null > var/slave-data/master.info;
system chmod 000 var/slave-data/master.info;
connection slave;