diff options
Diffstat (limited to 'mysql-test/mysql-test-run')
-rwxr-xr-x | mysql-test/mysql-test-run | 262 |
1 files changed, 262 insertions, 0 deletions
diff --git a/mysql-test/mysql-test-run b/mysql-test/mysql-test-run new file mode 100755 index 00000000000..55ee153dd65 --- /dev/null +++ b/mysql-test/mysql-test-run @@ -0,0 +1,262 @@ +#! /bin/sh + +#++ +# Access Definitions +#-- +DB=test +USER=test +PASSWD= + +#++ +# Misc. Definitions +#-- +CWD=`pwd` +cd .. +BASEDIR=`pwd` +cd $CWD +MYBIN="$CWD/mybin" +TESTVER=3.23 +TESTDIR="$CWD/t/$TESTVER" +TOT_PASS=0 +TOT_FAIL=0 +TOT_TEST=0 +TIME_FORMAT='%U\t%S\t%E\t%P' +DASHBLANK="----\t----\t-------\t----" + +[ -z $COLUMNS ] && COLUMNS=80 +E=`expr $COLUMNS - 8` +C=0 + +while [ $C != $E ] +do + DASH72="${DASH72}-" + C=`expr $C + 1` +done + +#++ +# mysqld Environment Parameters +#-- +MYPORT=9306 +MYDDIR="$CWD/var/lib" +MYSOCK="$CWD/var/tmp/mysql.sock" +MYPID="$CWD/var/run/mysqld.pid" +MYLOG="$CWD/var/log/mysqld.log" +MYERR="$CWD/var/log/mysqld.err" + +#++ +# Program Definitions +#-- +TIME=/usr/bin/time +MYSQLD="$BASEDIR/sql/mysqld" +MYSQL_TEST="$BASEDIR/client/mysql-test" +MYSQLADMIN="$BASEDIR/client/mysqladmin" +MYSQL_TEST="$MYSQL_TEST --socket=$MYSOCK --database=$DB --user=$USER --password=$PASSWD --silent" +INSTALL_DB="$MYBIN/mysql-test_install_db" + + +#++ +# Terminal Modifications +#-- +MOVE_TO_COL="echo -en \\033[300C\\033[20D" +SETCOLOR_SUCCESS="echo -en \\033[1;32m" +SETCOLOR_FAILURE="echo -en \\033[1;31m" +SETCOLOR_WARNING="echo -en \\033[1;33m" +SETCOLOR_NORMAL="echo -en \\033[0;39m" + + + +#++ +# Function Definitions +#-- +echo_ok() { + $MOVE_TO_COL && $SETCOLOR_NORMAL + echo -n "[ " + $SETCOLOR_SUCCESS + echo -n "ok" + $SETCOLOR_NORMAL + echo " ]" + return 0 +} + +echo_notok() { + $MOVE_TO_COL && $SETCOLOR_NORMAL + echo -n "[ " + $SETCOLOR_FAILURE + echo -n "not ok" + $SETCOLOR_NORMAL + echo " ]" + return 0 +} + +echo_pass () { + $MOVE_TO_COL && $SETCOLOR_NORMAL + echo -n "[ " + $SETCOLOR_SUCCESS + echo -n "pass" + $SETCOLOR_NORMAL + echo " ]" + return 0 +} + +echo_fail () { + $MOVE_TO_COL && $SETCOLOR_NORMAL + echo -n "[ " + $SETCOLOR_FAILURE + echo -n "fail" + $SETCOLOR_NORMAL + echo " ]" + return 0 +} + +error () { + + $SETCOLOR_FAILURE + echo -n "Error: " && $SETCOLOR_NORMAL && echo $1 + $SETCOLOR_NORMAL + exit 1 +} + +pass_inc () { + TOT_PASS=`expr $TOT_PASS + 1` +} + +fail_inc () { + TOT_FAIL=`expr $TOT_FAIL + 1` +} + +total_inc () { + TOT_TEST=`expr $TOT_TEST + 1` +} + +report_stats () { + if [ $TOT_FAIL == 0 ]; then + echo "All tests successful." + else + echo -n "Failed ${TOT_FAIL}/${TOT_TEST} tests, " + + xten=`expr $TOT_PASS \* 10000` # + raw=`expr $xten / $TOT_TEST` # My God + raw=`printf %.4d $raw` # This is such a ... + whole=`printf %.2s $raw` # Narttu!! + xwhole=`expr $whole \* 100` # Hynda!!! + deci=`expr $raw - $xwhole` # + + echo "${whole}.${deci}% successful." + fi +} + +mysql_install_db () { + if [ `$INSTALL_DB` ]; then + error "Could not install tmp DBs" + fi + + return 0 +} + +mysql_start () { + + `$MYSQLD --no-defaults \ + --skip-networking \ + --basedir=$CWD \ + --datadir=$MYDDIR \ + --pid-file=$MYPID \ + --socket=$MYSOCK \ + --log=$MYLOG \ + --language=english >> $MYERR 2>&1 &` + + return 1 +} + +mysql_stop () { + + `$MYSQLADMIN --socket=$MYSOCK -u root shutdown` + + return 1 +} + +mysql_restart () { + + mysql_stop + res=$? + [ $res != 1 ] && echo_notok && error "Stopping mysqld" + + mysql_start + res=$? + [ $res != 1 ] && echo_notok && error "Starting mysqld" + + return 1 +} + +mysql_loadstd () { + + sleep 2 + return 1 +} + + +mysql_install_db + +$SETCOLOR_NORMAL && echo -n "Starting mysqld for Testing" +mysql_start +res=$? +res=1 +[ $res != 1 ] && echo_notok && error "Starting mysqld" +[ $res == 1 ] && echo_ok + +$SETCOLOR_NORMAL && echo -n "Loading Standard Test Database" +mysql_loadstd +res=$? +[ $res != 1 ] && echo_notok && error "Loading STD" +[ $res == 1 ] && echo_ok + +$SETCOLOR_NORMAL && echo -n "Starting Tests for MySQL $TESTVER Series" +$SETCOLOR_SUCCESS && echo_ok + +echo +echo -e " TEST\t\t\tUSER\tSYSTEM\tELAPSED\t%CPU\t RESULT" +echo $DASH72 + +for tf in $TESTDIR/* +do + mytime=`$TIME -f $TIME_FORMAT $MYSQL_TEST < $tf 2>&1` + res=$? + + tf=`basename $tf` + + [ $res == 1 ] && mytime=`echo -ne $mytime | cut -b 39-` && mytime=${mytime// /\\t} + $SETCOLOR_NORMAL && echo -ne "$tf\t\t$mytime" + [ $res == 1 ] && fail_inc && echo_fail + [ $res != 1 ] && pass_inc && echo_pass + + total_inc + + if [ $res != 0 ]; then + echo + $SETCOLOR_NORMAL && echo -ne "Restarting mysqld\t$DASHBLANK" + mysql_restart + $SETCOLOR_SUCCESS && echo_ok + $SETCOLOR_NORMAL && echo -ne "Resuming Tests\t\t$DASHBLANK" + $SETCOLOR_SUCCESS && echo_ok + echo + fi +done + +echo $DASH72 +echo +$SETCOLOR_NORMAL && echo -n "Ending Tests for MySQL $TESTVER Series" +$SETCOLOR_SUCCESS && echo_ok + +$SETCOLOR_NORMAL && echo -n "Shutdown mysqld" +mysql_stop +res=$? +res=1 +[ $res != 1 ] && echo_notok && error "Shutdown mysqld" +[ $res == 1 ] && echo_ok + +$SETCOLOR_NORMAL + +echo +report_stats +echo + +exit 0 |