Commit 56a53af1 authored by unknown's avatar unknown
Browse files

mysql-test-run.sh:

  Added timing output for each test case.
  Added --embedded-server option.
mysqltest.c:
  Added 'start_timer', 'end_timer' commands
Makefile.am:
  Include mysys/my_getsystime.c to get time function in mysqltest
Many files:
  new file


client/Makefile.am:
  Include mysys/my_getsystime.c to get time function in mysqltest
client/mysqltest.c:
  Added 'start_timer', 'end_timer' commands
mysql-test/mysql-test-run.sh:
  Added timing output for each test case.
  Added --embedded-server option.
parent 29c44aa9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ mysqlcheck_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
mysqlshow_DEPENDENCIES=		$(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
mysqldump_DEPENDENCIES=		$(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
mysqlimport_DEPENDENCIES=	$(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
mysqltest_SOURCES=			mysqltest.c
mysqltest_SOURCES=		mysqltest.c ../mysys/my_getsystime.c
mysqltest_DEPENDENCIES=   	$(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
mysqlbinlog_SOURCES =   mysqlbinlog.cc ../mysys/mf_tempdir.c
mysqlbinlog_DEPENDENCIES=   	$(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
+87 −2
Original line number Diff line number Diff line
@@ -58,6 +58,13 @@
#include <stdarg.h>
#include <sys/stat.h>
#include <violite.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

#ifndef MAXPATHLEN
#define MAXPATHLEN 256
#endif

#define MAX_QUERY     131072
#define MAX_VAR_NAME	256
@@ -75,7 +82,7 @@
#ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546
#endif
#define MAX_SERVER_ARGS 20
#define MAX_SERVER_ARGS 64

/*
  Sometimes in a test the client starts before
@@ -132,6 +139,13 @@ static char *embedded_server_args[MAX_SERVER_ARGS];

static my_bool display_result_vertically= FALSE, display_metadata= FALSE;

/* See the timer_output() definition for details */
static char *timer_file = NULL;
static ulonglong timer_start;
static int got_end_timer= FALSE;
static void timer_output(void);
static ulonglong timer_now(void);

static const char *embedded_server_groups[] = {
  "server",
  "embedded",
@@ -230,6 +244,7 @@ Q_ENABLE_METADATA, Q_DISABLE_METADATA,
Q_EXEC, Q_DELIMITER,
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL,
Q_START_TIMER, Q_END_TIMER,

Q_UNKNOWN,			       /* Unknown command.   */
Q_COMMENT,			       /* Comments, ignored. */
@@ -308,6 +323,8 @@ const char *command_names[]=
  "horizontal_results",
  "query_vertical",
  "query_horizontal",
  "start_timer",
  "end_timer",
  0
};

@@ -1986,6 +2003,8 @@ static struct my_option my_long_options[] =
#include "sslopt-longopts.h"
  {"test-file", 'x', "Read test from/in this file (default stdin).",
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  {"timer-file", 'm', "File where the timing in micro seconds is stored.",
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  {"tmpdir", 't', "Temporary directory where sockets are put.",
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  {"user", 'u', "User for login.", (gptr*) &user, (gptr*) &user, 0, GET_STR,
@@ -2047,6 +2066,19 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
	die("Could not open %s: errno = %d", argument, errno);
      break;
    }
  case 'm':
    {
      static char buff[FN_REFLEN];
      if (!test_if_hard_path(argument))
      {
	strxmov(buff, opt_basedir, argument, NullS);
	argument= buff;
      }
      fn_format(buff, argument, "", "", 4);
      timer_file= buff;
      unlink(timer_file);	     /* Ignore error, may not exist */
      break;
    }
  case 'p':
    if (argument)
    {
@@ -2128,7 +2160,7 @@ char* safe_str_append(char* buf, const char* str, int size)
void str_to_file(const char* fname, char* str, int size)
{
  int fd;
  char buff[FN_REFLEN];
  char buff[MAXPATHLEN];
  if (!test_if_hard_path(fname))
  {
    strxmov(buff, opt_basedir, fname, NullS);
@@ -2599,6 +2631,9 @@ int main(int argc, char **argv)
  DBUG_ENTER("main");
  DBUG_PROCESS(argv[0]);

  /* Use all time until exit if no explicit 'start_timer' */
  timer_start= timer_now();

  save_file[0]=0;
  TMPDIR[0]=0;
  memset(cons, 0, sizeof(cons));
@@ -2813,6 +2848,15 @@ int main(int argc, char **argv)
      case Q_EXEC: 
	(void) do_exec(q);
	break;
      case Q_START_TIMER:
	/* Overwrite possible earlier start of timer */
	timer_start= timer_now();
	break;
      case Q_END_TIMER:
	/* End timer before ending mysqltest */
	timer_output();
	got_end_timer= TRUE;
	break;
      default: processed = 0; break;
      }
    }
@@ -2847,6 +2891,8 @@ int main(int argc, char **argv)
      printf("ok\n");
  }

  if (!got_end_timer)
    timer_output();				/* No end_timer cmd, end it */
  free_used_memory();
  exit(error ? 1 : 0);
  return error ? 1 : 0;				/* Keep compiler happy */
@@ -2900,6 +2946,45 @@ static int read_server_arguments(const char *name)
  return 0;
}

/****************************************************************************\
 *
 *  A primitive timer that give results in milliseconds if the
 *  --timer-file=<filename> is given. The timer result is written
 *  to that file when the result is available. To not confuse
 *  mysql-test-run with an old obsolete result, we remove the file
 *  before executing any commands. The time we measure is
 *
 *    - If no explicit 'start_timer' or 'end_timer' is given in the
 *      test case, the timer measure how long we execute in mysqltest.
 *
 *    - If only 'start_timer' is given we measure how long we execute
 *      from that point until we terminate mysqltest.
 *
 *    - If only 'end_timer' is given we measure how long we execute
 *      from that we enter mysqltest to the 'end_timer' is command is
 *      executed.
 *
 *    - If both 'start_timer' and 'end_timer' are given we measure
 *      the time between executing the two commands.
 *
\****************************************************************************/

static void timer_output(void)
{
  if (timer_file)
  {
    char buf[1024];
    ulonglong timer= timer_now() - timer_start;
    sprintf(buf,"%llu",timer);
    str_to_file(timer_file,buf,strlen(buf));
  }
}

static ulonglong timer_now(void)
{
  return my_getsystime() / 10000;
}

/****************************************************************************
* Handle replacement of strings
****************************************************************************/
+161 −65
Original line number Diff line number Diff line
@@ -232,9 +232,13 @@ DBUSER=""
START_WAIT_TIMEOUT=10
STOP_WAIT_TIMEOUT=10
MYSQL_TEST_SSL_OPTS=""
USE_EMBEDDED_SERVER=""
RESULT_EXT=""

while test $# -gt 0; do
  case "$1" in
    --embedded-server) USE_EMBEDDED_SERVER=1 ; USE_MANAGER=0 ; NO_SLAVE=1 ; \
      USE_RUNNING_SERVER="" RESULT_EXT=".es" ;;
    --user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;;
    --force)  FORCE=1 ;;
    --verbose-manager)  MANAGER_QUIET_OPT="" ;;
@@ -458,11 +462,19 @@ fi

if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi
E=`$EXPR $COLUMNS - 8`
DASH72=`$ECHO '------------------------------------------'|$CUT -c 1-$E`
DASH72=`$ECHO '-------------------------------------------------------'|$CUT -c 1-$E`

# on source dist, we pick up freshly build executables
# on binary, use what is installed
if [ x$SOURCE_DIST = x1 ] ; then
 if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
   if [ -f "$BASEDIR/libmysqld/examples/mysqltest" ] ; then
     MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest"
   else
     echo "Fatal error: Cannot find embedded server 'mysqltest'" 1>&2
     exit 1
   fi
 else
   MYSQLD="$VALGRIND $BASEDIR/sql/mysqld"
   if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then
     MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest"
@@ -471,6 +483,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
   else
     MYSQL_TEST="$BASEDIR/client/mysqltest"
   fi
 fi
 if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then
   MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump"
 else
@@ -565,7 +578,8 @@ export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR

MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
 --user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \
 --tmpdir=$MYSQL_TMP_DIR --port=$MASTER_MYPORT $MYSQL_TEST_SSL_OPTS"
 --tmpdir=$MYSQL_TMP_DIR --port=$MASTER_MYPORT --timer-file=$MY_LOG_DIR/timer \
 $MYSQL_TEST_SSL_OPTS"
MYSQL_TEST_BIN=$MYSQL_TEST
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
@@ -599,6 +613,13 @@ show_failed_diff ()
  result_file=r/$1.result
  eval_file=r/$1.eval

  # If we have an special externsion for result files we use it if we are recording
  # or a result file with that extension exists.
  if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ]
  then
    result_file="$result_file$RESULT_EXT"
  fi

  if [ -f $eval_file ]
  then
    result_file=$eval_file
@@ -880,6 +901,8 @@ EOF
 abort_if_failed "Could not execute manager command"
}

# The embedded server needs the cleanup so we do some of the start work
# but stop before actually running mysqld or anything.

start_master()
{
@@ -949,6 +972,18 @@ start_master()
  CUR_MYERR=$MASTER_MYERR
  CUR_MYSOCK=$MASTER_MYSOCK

  # For embedded server we collect the server flags and return
  if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
    # Add a -A to each argument to pass it to embedded server
    EMBEDDED_SERVER_OPTS=""
    for opt in $master_args
    do
      EMBEDDED_SERVER_OPTS="$EMBEDDED_SERVER_OPTS -A $opt"
    done
    EXTRA_MYSQL_TEST_OPT="$EMBEDDED_SERVER_OPTS"
    return
  fi

  if [ x$DO_DDD = x1 ]
  then
    $ECHO "set args $master_args" > $GDB_MASTER_INIT
@@ -1159,6 +1194,9 @@ stop_master ()
{
  if [ x$MASTER_RUNNING = x1 ]
  then
    # For embedded server we don't stop anyting but mark that
    # MASTER_RUNNING=0 to get cleanup when calling start_master().
    if [ x$USE_EMBEDDED_SERVER != x1 ] ; then
      pid=`$CAT $MASTER_MYPID`
      manager_term $pid master
      if [ $? != 0 ] && [ -f $MASTER_MYPID ]
@@ -1176,6 +1214,7 @@ stop_master ()
      else
	sleep $SLEEP_TIME_AFTER_RESTART
      fi
    fi
    MASTER_RUNNING=0
  fi
}
@@ -1217,9 +1256,13 @@ run_testcase ()
 master_init_script=$TESTDIR/$tname-master.sh
 slave_init_script=$TESTDIR/$tname-slave.sh
 slave_master_info_file=$TESTDIR/$tname.slave-mi
 result_file=$tname
 tsrcdir=$TESTDIR/$tname-src
 result_file="r/$tname.result"
 echo $tname > $CURRENT_TEST
 SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
 if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then
   result_file="$result_file$RESULT_EXT"
 fi
 if [ "$USE_MANAGER" = 1 ] ; then
   many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)`
 fi
@@ -1249,11 +1292,46 @@ run_testcase ()
   return
 fi

 # Stop all slave threads, so that we don't have useless reconnection attempts
 # and error messages in case the slave and master servers restart.
 if [ "x$USE_EMBEDDED_SERVER" != "x1" ] ; then
   # Stop all slave threads, so that we don't have useless reconnection
   #  attempts and error messages in case the slave and master servers restart.
   stop_slave_threads
   stop_slave_threads 1
   stop_slave_threads 2
 fi

 # FIXME temporary solution, we will get a new C version of this
 # script soon anyway so it is not worth it spending the time
 if [ "x$USE_EMBEDDED_SERVER" = "x1" -a -z "$DO_TEST" ] ; then
   for t in \

	"bdb-deadlock" \
	"connect" \
	"flush_block_commit" \
	"grant2" \
	"grant_cache" \
	"grant" \
	"init_connect" \
	"innodb-deadlock" \
	"innodb-lock" \
	"mix_innodb_myisam_binlog" \
	"mysqlbinlog2" \
	"mysqlbinlog" \
	"mysqldump" \
	"mysql_protocols" \
	"ps_1general" \
	"rename" \
	"show_check" \
        "system_mysql_db_fix" \
	"user_var" \
	"variables"
   do
     if [ "$tname" = "$t" ] ; then
       skip_test $tname
       return
     fi
   done
 fi

 if [ -z "$USE_RUNNING_SERVER" ] ;
 then
@@ -1269,6 +1347,10 @@ run_testcase ()
	 ;;
       --result-file=*)
         result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"`
         result_file="r/$result_file.result"
         if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then
	   result_file="$result_file$RESULT_EXT"
	 fi
	 # Note that this must be set to space, not "" for test-reset to work
	 EXTRA_MASTER_OPT=" "
         ;;
@@ -1278,7 +1360,11 @@ run_testcase ()
     start_master
     TZ=$MY_TZ; export TZ
   else
     if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || [ -f $master_init_script ]
     # If we had extra master opts to the previous run
     # or there is no master running (FIXME strange.....)
     # or there is a master init script
     if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || \
	[ -f $master_init_script ]
     then
       EXTRA_MASTER_OPT=""
       stop_master
@@ -1289,6 +1375,8 @@ run_testcase ()
     fi
   fi

   # We never start a slave if embedded server is used
   if [ "x$USE_EMBEDDED_SERVER" != "x1" ] ; then
     do_slave_restart=0
     if [ -f $slave_opt_file ] ;
     then
@@ -1325,11 +1413,12 @@ run_testcase ()
      start_slave 2
     fi
   fi
 fi
 cd $MYSQL_TEST_DIR

 if [ -f $tf ] ; then
    $RM -f r/$tname.*reject
    mysql_test_args="-R r/$result_file.result $EXTRA_MYSQL_TEST_OPT"
    mysql_test_args="-R $result_file $EXTRA_MYSQL_TEST_OPT"
    if [ -z "$DO_CLIENT_GDB" ] ; then
      `$MYSQL_TEST  $mysql_test_args < $tf 2> $TIMEFILE`;
    else
@@ -1349,7 +1438,12 @@ run_testcase ()
    if [ $res = 0 ]; then
      total_inc
      pass_inc
      $ECHO "$RES$RES_SPACE [ pass ]"
      TIMER=""
      if [ -f "$MY_LOG_DIR/timer" ]; then
	TIMER=`cat $MY_LOG_DIR/timer`
	TIMER=`$PRINTF "%13s" $TIMER`
      fi
      $ECHO "$RES$RES_SPACE [ pass ]   $TIMER"
    else
      # why the following ``if'' ? That is why res==1 is special ?
      if [ $res = 2 ]; then
@@ -1364,12 +1458,13 @@ run_testcase ()
	$ECHO "$RES$RES_SPACE [ fail ]"
        $ECHO
	error_is
	show_failed_diff $result_file
	show_failed_diff $tname
	$ECHO
	if [ x$FORCE != x1 ] ; then
	 $ECHO "Aborting: $tname failed. To continue, re-run with '--force'."
	 $ECHO
         if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
         if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
	    [ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
	 then
	   mysql_stop
	   stop_manager
@@ -1377,7 +1472,8 @@ run_testcase ()
	 exit 1
	fi

        if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
        if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
	   [ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
	then
	  mysql_restart
	fi
@@ -1511,7 +1607,7 @@ then
fi

$ECHO
$ECHO " TEST                           RESULT"
$ECHO "TEST                            RESULT        TIME (ms)"
$ECHO $DASH72

if [ -z "$1" ] ;
+483 −0

File added.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
reset master;
create database `drop-temp+table-test`;
use `drop-temp+table-test`;
create temporary table `table:name` (a int);
select get_lock("a",10);
get_lock("a",10)
1
select get_lock("a",10);
get_lock("a",10)
1
show binlog events;
drop database `drop-temp+table-test`;
Loading