📄 mysql-test-run-shell
字号:
#!/bin/sh# mysql-test-run - originally written by Matt Wagner <matt@mysql.com># modified by Sasha Pachev <sasha@mysql.com># Slightly updated by Monty# Cleaned up again by Matt# Fixed by Sergei# List of failed cases (--force) backported from 4.1 by Joerg# :-)#++# Access Definitions#--DB=testDBPASSWD=""VERBOSE=""USE_MANAGER=0MY_TZ=GMT-3TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to workLOCAL_SOCKET=/opt/lampp/var/mysql/mysql.sockMYSQL_TCP_PORT=3306umask 022# For query_cache testcase `uname` in SCO_SV | UnixWare | OpenUNIX ) # do nothing (Causes strange behavior) ;; QNX) # do nothing (avoid error message) ;; * ) ulimit -n 1024 ;;esac#++# Program Definitions#--LC_COLLATE=Cexport LC_COLLATEPATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$PATHMASTER_40_ARGS="--rpl-recovery-rank=1 --init-rpl-role=master"# Standard functionswhich (){ IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' for file do for dir in $PATH do if test -f $dir/$file then echo "$dir/$file" continue 2 fi done echo "Fatal error: Cannot find program $file in $PATH" 1>&2 exit 1 done IFS="$save_ifs" exit 0}sleep_until_file_deleted (){ pid=$1; file=$2 loop=$SLEEP_TIME_FOR_DELETE while (test $loop -gt 0) do if [ ! -r $file ] then if test $pid != "0" then wait_for_pid $pid fi return fi sleep 1 loop=`expr $loop - 1` done}sleep_until_file_created (){ file=$1 loop=$2 org_time=$2 while (test $loop -gt 0) do if [ -r $file ] then return 0 fi sleep 1 loop=`expr $loop - 1` done echo "ERROR: $file was not created in $org_time seconds; Aborting" exit 1;}# For the futurewait_for_pid(){ pid=$1 #$WAIT_PID pid $SLEEP_TIME_FOR_DELETE}# Check that valgrind is installedfind_valgrind(){ FIND_VALGRIND=`which valgrind` # this will print an error if not found # Give good warning to the user and stop if [ -z "$FIND_VALGRIND" ] ; then $ECHO "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://valgrind.kde.org ." exit 1 fi # >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && FIND_VALGRIND="$FIND_VALGRIND --tool=memcheck" FIND_VALGRIND="$FIND_VALGRIND --alignment=8 --leak-check=yes --num-callers=16 --suppressions=$MYSQL_TEST_DIR/valgrind.supp"}# No paths below as we can't be sure where the program is!SED=sedBASENAME=`which basename`if test $? != 0; then exit 1; fiDIFF=`which diff | $SED q`if test $? != 0; then exit 1; fiCAT=catCUT=cutHEAD=headTAIL=tailECHO=echo # use internal echo if possibleEXPR=expr # use internal if possibleFIND=findGREP=grepif test $? != 0; then exit 1; fiPRINTF=printfRM=rmif test $? != 0; then exit 1; fiTR=trXARGS=`which xargs`if test $? != 0; then exit 1; fiSORT=sort# Are we using a source or a binary distribution?testdir=/opt/lampp/mysql-testif [ -d bin/mysqld ] && [ -d mysql-test ] ; then cd mysql-testelse if [ -d $testdir/mysql-test ] ; then cd $testdir fifiif [ ! -f ./mysql-test-run ] ; then $ECHO "Can't find the location for the mysql-test-run script" $ECHO "Go to to the mysql-test directory and execute the script as follows:" $ECHO "./mysql-test-run." exit 1fi#++# Misc. Definitions#--# BASEDIR is always above mysql-test directory ...MYSQL_TEST_DIR=`pwd`cd ..if [ -d ./sql ] ; then SOURCE_DIST=1else BINARY_DIST=1 # ... one level for tar.gz, two levels for a RPM installation if [ ! -f ./bin/mysql_upgrade ] ; then # Has to be RPM installation cd .. fifiBASEDIR=`pwd`cd $MYSQL_TEST_DIRMYSQL_TEST_WINDIR=$MYSQL_TEST_DIRMYSQLTEST_VARDIR=$MYSQL_TEST_DIR/varexport MYSQL_TEST_DIR MYSQL_TEST_WINDIR MYSQLTEST_VARDIRSTD_DATA=$MYSQL_TEST_DIR/std_datahostname=`hostname` # Installed in the mysql privilege tableMANAGER_QUIET_OPT="-q"TESTDIR="$MYSQL_TEST_DIR/t"TESTSUFFIX=testTOT_SKIP=0TOT_PASS=0TOT_FAIL=0TOT_TEST=0GOT_WARNINGS=0USERT=0SYST=0REALT=0FAST_START=""MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmpexport MYSQL_TMP_DIR# Use a relative path for where the slave will find the dumps# generated by "LOAD DATA" on the master. The path is relative# since it must have fixed length to test logging# i.e otherwise the output from "SHOW MASTER STATUS" will vary# with the strlen() of MYSQL_TEST_DIRSLAVE_LOAD_TMPDIR=../tmpRES_SPACE=" "MYSQLD_SRC_DIRS="strings mysys include extra regex myisam \ myisammrg heap sql"MY_LOG_DIR="$MYSQL_TEST_DIR/var/log" ## Set LD_LIBRARY_PATH if we are using shared libraries#LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$LD_LIBRARY_PATH"DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$DYLD_LIBRARY_PATH"export LD_LIBRARY_PATH DYLD_LIBRARY_PATH## Allow anyone in the group to see the generated database files#UMASK=0660UMASK_DIR=0770export UMASK UMASK_DIRMASTER_RUNNING=0MASTER1_RUNNING=0MASTER_MYPORT=9306SLAVE_RUNNING=0SLAVE_MYPORT=9308 # leave room for 2 masters for cluster testsMYSQL_MANAGER_PORT=9305 # needs to be out of the way of slavesNDBCLUSTER_PORT=9350MYSQL_MANAGER_PW_FILE=$MYSQL_TEST_DIR/var/tmp/manager.pwdMYSQL_MANAGER_LOG=$MYSQL_TEST_DIR/var/log/manager.logMYSQL_MANAGER_USER=root## To make it easier for different devs to work on the same host,# an environment variable can be used to control all ports. A small# number is to be used, 0 - 16 or similar.## Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x# versions of this script, else a 4.0 test run might conflict with a# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means# all port numbers might not be used in this version of the script.#if [ -n "$MTR_BUILD_THREAD" ] ; then MASTER_MYPORT=`expr $MTR_BUILD_THREAD '*' 10 + 10000` MYSQL_MANAGER_PORT=`expr $MASTER_MYPORT + 2` SLAVE_MYPORT=`expr $MASTER_MYPORT + 3` NDBCLUSTER_PORT=`expr $MASTER_MYPORT + 6` echo "Using MTR_BUILD_THREAD = $MTR_BUILD_THREAD" echo "Using MASTER_MYPORT = $MASTER_MYPORT" echo "Using MYSQL_MANAGER_PORT = $MYSQL_MANAGER_PORT" echo "Using SLAVE_MYPORT = $SLAVE_MYPORT" echo "Using NDBCLUSTER_PORT = $NDBCLUSTER_PORT"fiNO_SLAVE=0USER_TEST=FAILED_CASES=EXTRA_MASTER_OPT=""EXTRA_MYSQL_TEST_OPT=""EXTRA_MYSQLCHECK_OPT=""EXTRA_MYSQLDUMP_OPT=""EXTRA_MYSQLSHOW_OPT=""EXTRA_MYSQLBINLOG_OPT=""USE_RUNNING_SERVER=0USE_NDBCLUSTER=""USE_NDBCLUSTER_ONLY=0USE_RUNNING_NDBCLUSTER=""USE_PURIFY=""PURIFY_LOGS=""DO_GCOV=""DO_GDB=""MANUAL_GDB=""DO_DDD=""DO_CLIENT_GDB=""SLEEP_TIME_AFTER_RESTART=1SLEEP_TIME_FOR_DELETE=10SLEEP_TIME_FOR_FIRST_MASTER=400 # Enough time to create innodb tablesSLEEP_TIME_FOR_SECOND_MASTER=400SLEEP_TIME_FOR_FIRST_SLAVE=400SLEEP_TIME_FOR_SECOND_SLAVE=300CHARACTER_SET=latin1DBUSER=""START_WAIT_TIMEOUT=10STOP_WAIT_TIMEOUT=10MYSQL_TEST_SSL_OPTS=""USE_TIMER=""USE_EMBEDDED_SERVER=""TEST_MODE=""NDB_MGM_EXTRA_OPTS=NDB_MGMD_EXTRA_OPTS=NDBD_EXTRA_OPTS=DO_STRESS=""STRESS_SUITE="main"STRESS_MODE="random"STRESS_THREADS=5STRESS_TEST_COUNT=""STRESS_LOOP_COUNT=""STRESS_TEST_DURATION=""STRESS_INIT_FILE=""STRESS_TEST_FILE=""STRESS_TEST=""$ECHO "Logging: $0 $*" # To ensure we see all arguments in the output, for the test analysis toolwhile test $# -gt 0; do case "$1" in --embedded-server) USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 USE_RUNNING_SERVER=0 USE_NDBCLUSTER="" TEST_MODE="$TEST_MODE embedded" ;; --purify) USE_PURIFY=1 USE_MANAGER=0 USE_RUNNING_SERVER=0 TEST_MODE="$TEST_MODE purify" ;; --user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;; --force) FORCE=1 ;; --timer) USE_TIMER=1 ;; --verbose-manager) MANAGER_QUIET_OPT="" ;; --old-master) MASTER_40_ARGS="";; --master-binary=*) MASTER_MYSQLD=`$ECHO "$1" | $SED -e "s;--master-binary=;;"` ;; --slave-binary=*) SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;; --local) USE_RUNNING_SERVER=0 ;; --extern) USE_RUNNING_SERVER=1 ;; --with-ndbcluster) USE_NDBCLUSTER="--ndbcluster" ;; --with-ndbcluster-only) USE_NDBCLUSTER="--ndbcluster" USE_NDBCLUSTER_SLAVE="--ndbcluster" USE_NDBCLUSTER_ONLY=1 ;; --ndb-connectstring=*) USE_NDBCLUSTER="--ndbcluster" ; USE_RUNNING_NDBCLUSTER=`$ECHO "$1" | $SED -e "s;--ndb-connectstring=;;"` ;; --ndb_mgm-extra-opts=*) NDB_MGM_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndb_mgm-extra-opts=;;"` ;; --ndb_mgmd-extra-opts=*) NDB_MGMD_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndb_mgmd-extra-opts=;;"` ;; --ndbd-extra-opts=*) NDBD_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndbd-extra-opts=;;"` ;; --tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;; --local-master) MASTER_MYPORT=3306; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --host=127.0.0.1 \ --port=$MYSQL_MYPORT" LOCAL_MASTER=1 ;; --master_port=*) MASTER_MYPORT=`$ECHO "$1" | $SED -e "s;--master_port=;;"` ;; --slave_port=*) SLAVE_MYPORT=`$ECHO "$1" | $SED -e "s;--slave_port=;;"` ;; --manager-port=*) MYSQL_MANAGER_PORT=`$ECHO "$1" | $SED -e "s;--manager_port=;;"` ;; --ndbcluster_port=*) NDBCLUSTER_PORT=`$ECHO "$1" | $SED -e "s;--ndbcluster_port=;;"` ;; --with-openssl) EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \ --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem \ --ssl-cert=$MYSQL_TEST_DIR/std_data/server-cert.pem \ --ssl-key=$MYSQL_TEST_DIR/std_data/server-key.pem" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT \ --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem \ --ssl-cert=$MYSQL_TEST_DIR/std_data/server-cert.pem \ --ssl-key=$MYSQL_TEST_DIR/std_data/server-key.pem" MYSQL_TEST_SSL_OPTS="--ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem \ --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem \ --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem" ;; --no-manager | --skip-manager) USE_MANAGER=0 ;; --manager) USE_MANAGER=1 USE_RUNNING_SERVER=0 ;; --start-and-exit) START_AND_EXIT=1 ;; --socket=*) LOCAL_SOCKET=`$ECHO "$1" | $SED -e "s;--socket=;;"` ;; --skip-rpl) NO_SLAVE=1 ;; --skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;; --do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;; --start-from=* ) START_FROM=`$ECHO "$1" | $SED -e "s;--start-from=;;"` ;; --warnings | --log-warnings) EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --log-warnings" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --log-warnings" ;; --wait-timeout=*) START_WAIT_TIMEOUT=`$ECHO "$1" | $SED -e "s;--wait-timeout=;;"` STOP_WAIT_TIMEOUT=$START_WAIT_TIMEOUT;; --record) RECORD=1; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;; --small-bench) DO_SMALL_BENCH=1 DO_BENCH=1 NO_SLAVE=1 ;; --bench) DO_BENCH=1 NO_SLAVE=1 ;; --stress) DO_STRESS=1 NO_SLAVE=1 SKIP_SLAVE=1 ;; --stress-suite=*) STRESS_SUITE=`$ECHO "$1" | $SED -e "s;--stress-suite=;;"` ;; --stress-threads=*) STRESS_THREADS=`$ECHO "$1" | $SED -e "s;--stress-threads=;;"` ;; --stress-test-file=*) STRESS_TEST_FILE=`$ECHO "$1" | $SED -e "s;--stress-test-file=;;"` ;; --stress-init-file=*) STRESS_INIT_FILE=`$ECHO "$1" | $SED -e "s;--stress-init-file=;;"` ;; --stress-mode=*) STRESS_MODE=`$ECHO "$1" | $SED -e "s;--stress-mode=;;"` ;; --stress-loop-count=*) STRESS_LOOP_COUNT=`$ECHO "$1" | $SED -e "s;--stress-loop-count=;;"` ;; --stress-test-count=*) STRESS_TEST_COUNT=`$ECHO "$1" | $SED -e "s;--stress-test-count=;;"` ;; --stress-test-duration=*) STRESS_TEST_DURATION=`$ECHO "$1" | $SED -e "s;--stress-test-duration=;;"`
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -