List:Commits« Previous MessageNext Message »
From:Joerg Bruehe Date:April 4 2006 6:14pm
Subject:bk commit into 5.1 tree (joerg:1.2022)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of joerg. When joerg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2022 06/04/04 20:13:59 joerg@stripped +2 -0
  Merge mysql.com:/M51/mysql-5.1 into mysql.com:/M51/work-5.1

  mysql-test/mysql-test-run.sh
    1.311 06/04/04 20:13:56 joerg@stripped +0 -0
    Auto merged

  mysql-test/mysql-test-run.pl
    1.87 06/04/04 20:13:55 joerg@stripped +0 -0
    Auto merged

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	joerg
# Host:	trift2.
# Root:	/M51/work-5.1/RESYNC

--- 1.310/mysql-test/mysql-test-run.sh	2006-03-10 14:16:32 +01:00
+++ 1.311/mysql-test/mysql-test-run.sh	2006-04-04 20:13:56 +02:00
@@ -1088,7 +1088,7 @@
 
     found_error=0
     # Find errors
-    for i in "^Warning:" "^Error:" "^==.* at 0x" "InnoDB: Warning"
+    for i in "^Warning:" "^Error:" "^==.* at 0x" "InnoDB: Warning" "missing DBUG_RETURN"
     do
       if $GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings
       then

--- 1.86/mysql-test/mysql-test-run.pl	2006-03-10 14:16:32 +01:00
+++ 1.87/mysql-test/mysql-test-run.pl	2006-04-04 20:13:55 +02:00
@@ -134,6 +134,7 @@
 our $glob_win32_perl=             0; # ActiveState Win32 Perl
 our $glob_cygwin_perl=            0; # Cygwin Perl
 our $glob_cygwin_shell=           undef;
+our $glob_use_libtool=            1;
 our $glob_mysql_test_dir=         undef;
 our $glob_mysql_bench_dir=        undef;
 our $glob_hostname=               undef;
@@ -157,6 +158,7 @@
 our $path_client_bindir;
 our $path_language;
 our $path_timefile;
+our $path_snapshot;
 our $path_manager_log;           # Used by mysqldadmin
 our $path_slave_load_tmpdir;     # What is this?!
 our $path_mysqltest_log;
@@ -164,7 +166,6 @@
 our $opt_vardir;                 # A path but set directly on cmd line
 our $opt_vardir_trace;           # unix formatted opt_vardir for trace files
 our $opt_tmpdir;                 # A path but set directly on cmd line
-our $opt_restart_cleanup;        # Source a file with SQL drop statements
 
 our $opt_usage;
 our $opt_suite;
@@ -208,7 +209,6 @@
 our $opt_view_protocol;
 
 our $opt_current_test;
-our $opt_ddd;
 our $opt_debug;
 our $opt_do_test;
 our @opt_cases;                  # The test cases names in argv
@@ -222,9 +222,14 @@
 our $opt_gcov_err;
 our $opt_gcov_msg;
 
+our $glob_debugger= 0;
 our $opt_gdb;
 our $opt_client_gdb;
+our $opt_ddd;
+our $opt_client_ddd;
 our $opt_manual_gdb;
+our $opt_manual_ddd;
+our $opt_manual_debug;
 
 our $opt_gprof;
 our $opt_gprof_dir;
@@ -283,11 +288,12 @@
 our $opt_user;
 our $opt_user_test;
 
-our $opt_valgrind;
-our $opt_valgrind_mysqld;
-our $opt_valgrind_mysqltest;
-our $opt_valgrind_all;
+our $opt_valgrind= 0;
+our $opt_valgrind_mysqld= 0;
+our $opt_valgrind_mysqltest= 0;
+our $opt_valgrind_all= 0;
 our $opt_valgrind_options;
+our $opt_valgrind_path;
 
 our $opt_stress=               "";
 our $opt_stress_suite=     "main";
@@ -299,8 +305,6 @@
 our $opt_stress_init_file=     "";
 our $opt_stress_test_file=     "";
 
-our $opt_verbose;
-
 our $opt_wait_for_master;
 our $opt_wait_for_slave;
 our $opt_wait_timeout=  10;
@@ -319,11 +323,14 @@
 
 our $exe_ndb_mgm;
 our $path_ndb_tools_dir;
-our $path_ndb_backup_dir;
+our $path_ndb_data_dir;
+our $path_ndb_slave_data_dir;
 our $file_ndb_testrun_log;
 our $flag_ndb_status_ok= 1;
 our $flag_ndb_slave_status_ok= 1;
 
+our @data_dir_lst;
+
 ######################################################################
 #
 #  Function declarations
@@ -404,9 +411,10 @@
     {
       kill_and_cleanup();
       mysql_install_db();
-
-#    mysql_loadstd();  FIXME copying from "std_data" .frm and
-#                      .MGR but there are none?!
+      if ( $opt_force )
+      {
+	save_installed_db();
+      }
     }
   }
 
@@ -458,6 +466,12 @@
   $glob_cygwin_perl= ($^O eq "cygwin");
   $glob_win32=       ($glob_win32_perl or $glob_cygwin_perl);
 
+  # Use libtool on all platforms except windows
+  if ( $glob_win32 )
+  {
+    $glob_use_libtool= 0;
+  }
+
   # We require that we are in the "mysql-test" directory
   # to run mysql-test-run
 
@@ -480,9 +494,9 @@
   if ( $glob_cygwin_perl )
   {
     # Windows programs like 'mysqld' needs Windows paths
-    $glob_mysql_test_dir= `cygpath -m $glob_mysql_test_dir`;
+    $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
     my $shell= $ENV{'SHELL'} || "/bin/bash";
-    $glob_cygwin_shell=   `cygpath -w $shell`; # The Windows path c:\...
+    $glob_cygwin_shell=   `cygpath -w "$shell"`; # The Windows path c:\...
     chomp($glob_mysql_test_dir);
     chomp($glob_cygwin_shell);
   }
@@ -531,6 +545,10 @@
   # 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.
   #
+  # Also note the limiteation of ports we are allowed to hand out. This
+  # differs between operating systems and configuration, see
+  # http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
+  # But a fairly safe range seems to be 5001 - 32767
   if ( $ENV{'MTR_BUILD_THREAD'} )
   {
     # Up to two masters, up to three slaves
@@ -543,6 +561,13 @@
     $im_mysqld2_port=           $opt_master_myport + 9;
   }
 
+  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
+  {
+    mtr_error("MTR_BUILD_THREAD number results in a port",
+              "outside 5001 - 32767",
+              "($opt_master_myport - $opt_master_myport + 10)");
+  }
+
   # Read the command line
   # Note: Keep list, and the order, in sync with usage at end of this file
 
@@ -572,16 +597,18 @@
              'with-ndbcluster-only'     => \$opt_with_ndbcluster_only,
              'ndb-extra-test'           => \$opt_ndb_extra_test,
              'do-test=s'                => \$opt_do_test,
+             'start-from=s'             => \$opt_start_from,
              'suite=s'                  => \$opt_suite,
              'skip-rpl'                 => \$opt_skip_rpl,
              'skip-im'                  => \$opt_skip_im,
              'skip-test=s'              => \$opt_skip_test,
+             'big-test'                 => \$opt_big_test,
 
              # Specify ports
              'master_port=i'            => \$opt_master_myport,
              'slave_port=i'             => \$opt_slave_myport,
-             'ndbcluster_port=i'        => \$opt_ndbcluster_port,
-             'ndbcluster_port_slave=i'  => \$opt_ndbcluster_port_slave,
+             'ndbcluster-port=i'        => \$opt_ndbcluster_port,
+             'ndbcluster-port-slave=i'  => \$opt_ndbcluster_port_slave,
              'manager-port=i'           => \$opt_manager_port, # Currently not used
              'im-port=i'                => \$im_port, # Instance Manager port.
              'im-mysqld1-port=i'        => \$im_mysqld1_port, # Port of mysqld, controlled by IM
@@ -591,19 +618,21 @@
              'record'                   => \$opt_record,
              'check-testcases'          => \$opt_check_testcases,
 
-             # ???
+             # Extra options used when starting mysqld
              'mysqld=s'                 => \@opt_extra_mysqld_opt,
 
              # Run test on running server
              'extern'                   => \$opt_extern,
-             'ndbconnectstring=s'       => \$opt_ndbconnectstring,
-             'ndbconnectstring-slave=s' => \$opt_ndbconnectstring_slave,
+             'ndb-connectstring=s'       => \$opt_ndbconnectstring,
+             'ndb-connectstring-slave=s' => \$opt_ndbconnectstring_slave,
 
              # Debugging
              'gdb'                      => \$opt_gdb,
-             'manual-gdb'               => \$opt_manual_gdb,
              'client-gdb'               => \$opt_client_gdb,
+             'manual-gdb'               => \$opt_manual_gdb,
+             'manual-debug'             => \$opt_manual_debug,
              'ddd'                      => \$opt_ddd,
+             'client-ddd'               => \$opt_client_ddd,
              'strace-client'            => \$opt_strace_client,
              'master-binary=s'          => \$exe_master_mysqld,
              'slave-binary=s'           => \$exe_slave_mysqld,
@@ -611,10 +640,12 @@
              # Coverage, profiling etc
              'gcov'                     => \$opt_gcov,
              'gprof'                    => \$opt_gprof,
-             'valgrind:s'               => \$opt_valgrind,
-             'valgrind-mysqltest:s'     => \$opt_valgrind_mysqltest,
-             'valgrind-all:s'           => \$opt_valgrind_all,
+             'valgrind'                 => \$opt_valgrind,
+             'valgrind-mysqltest'       => \$opt_valgrind_mysqltest,
+             'valgrind-mysqld'          => \$opt_valgrind_mysqld,
+             'valgrind-all'             => \$opt_valgrind_all,
              'valgrind-options=s'       => \$opt_valgrind_options,
+             'valgrind-path=s'          => \$opt_valgrind_path,
 
              # Stress testing 
              'stress'                   => \$opt_stress,
@@ -627,8 +658,11 @@
              'stress-test-count=i'      => \$opt_stress_test_count,
              'stress-test-duration=i'   => \$opt_stress_test_duration,
 
+	     # Directories
+             'tmpdir=s'                 => \$opt_tmpdir,
+             'vardir=s'                 => \$opt_vardir,
+
              # Misc
-             'big-test'                 => \$opt_big_test,
              'comment=s'                => \$opt_comment,
              'debug'                    => \$opt_debug,
              'fast'                     => \$opt_fast,
@@ -637,20 +671,15 @@
              'netware'                  => \$opt_netware,
              'old-master'               => \$opt_old_master,
              'reorder'                  => \$opt_reorder,
-             'restart-cleanup'          => \$opt_restart_cleanup,
              'script-debug'             => \$opt_script_debug,
              'sleep=i'                  => \$opt_sleep,
              'socket=s'                 => \$opt_socket,
              'start-dirty'              => \$opt_start_dirty,
              'start-and-exit'           => \$opt_start_and_exit,
-             'start-from=s'             => \$opt_start_from,
              'timer'                    => \$opt_timer,
-             'tmpdir=s'                 => \$opt_tmpdir,
              'unified-diff|udiff'       => \$opt_udiff,
              'user-test=s'              => \$opt_user_test,
              'user=s'                   => \$opt_user,
-             'vardir=s'                 => \$opt_vardir,
-             'verbose'                  => \$opt_verbose,
              'wait-timeout=i'           => \$opt_wait_timeout,
              'testcase-timeout=i'       => \$opt_testcase_timeout,
              'suite-timeout=i'          => \$opt_suite_timeout,
@@ -781,48 +810,34 @@
     mtr_error("Coverage test needs the source - please use source dist");
   }
 
-  if ( $opt_gdb )
-  {
+  # Check debug related options
+  if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
+       $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug)
+  {
+    # Indicate that we are using debugger 
+    $glob_debugger= 1;
+    # Increase timeouts
     $opt_wait_timeout=  300;
     if ( $opt_extern )
     {
-      mtr_error("Can't use --extern with --gdb");
+      mtr_error("Can't use --extern when using debugger");
     }
   }
 
-  if ( $opt_manual_gdb )
+  # Turn on valgrinding of all executables if "valgrind" or "valgrind-all"
+  if ( $opt_valgrind or $opt_valgrind_all )
   {
-    $opt_gdb=  1;
-    if ( $opt_extern )
-    {
-      mtr_error("Can't use --extern with --manual-gdb");
-    }
+    mtr_report("Turning on valgrind for all executables");
+    $opt_valgrind= 1;
+    $opt_valgrind_mysqld= 1;
+    $opt_valgrind_mysqltest= 1;
   }
-
-  if ( $opt_ddd )
+  elsif ( $opt_valgrind_mysqld or $opt_valgrind_mysqltest )
   {
-    if ( $opt_extern )
-    {
-      mtr_error("Can't use --extern with --ddd");
-    }
-  }
-
-  # The ":s" in the argument spec, means we have three different cases
-  #
-  #   undefined    option not set
-  #   ""           option set with no argument
-  #   "somestring" option is name/path of valgrind executable
-
-  # Take executable path from any of them, if any
-  $opt_valgrind_mysqld= $opt_valgrind;
-  $opt_valgrind= $opt_valgrind_mysqltest if $opt_valgrind_mysqltest;
-  $opt_valgrind= $opt_valgrind_all       if $opt_valgrind_all;
-
-  # If valgrind flag not defined, define if other valgrind flags are
-  unless ( defined $opt_valgrind )
-  {
-    $opt_valgrind= ""
-      if defined $opt_valgrind_mysqltest or defined $opt_valgrind_all;
+    # If test's are run for a specific executable, turn on
+    # verbose and show-reachable
+    $opt_valgrind= 1;
+    $opt_valgrind_all= 1;
   }
 
   if ( ! $opt_testcase_timeout )
@@ -837,12 +852,11 @@
     $opt_suite_timeout*= 4 if defined $opt_valgrind;
   }
 
-  if ( defined $opt_valgrind )
+  # Increase times to wait for executables to start if using valgrind
+  if ( $opt_valgrind )
   {
     $opt_sleep_time_after_restart= 10;
     $opt_sleep_time_for_delete= 60;
-    # >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr
-    #  valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && VALGRIND="$VALGRIND --tool=memcheck"
   }
 
   if ( ! $opt_user )
@@ -969,6 +983,22 @@
 
   $path_timefile=  "$opt_vardir/log/mysqltest-time";
   $path_mysqltest_log=  "$opt_vardir/log/mysqltest.log";
+
+  $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
+
+  # Make a list of all data_dirs
+  @data_dir_lst = (
+    $master->[0]->{'path_myddir'},
+    $master->[1]->{'path_myddir'},
+    $slave->[0]->{'path_myddir'},
+    $slave->[1]->{'path_myddir'},
+    $slave->[2]->{'path_myddir'});
+
+  foreach my $instance (@{$instance_manager->{'instances'}})
+  {
+    push(@data_dir_lst, $instance->{'path_datadir'});
+  }
+
 }
 
 
@@ -1030,21 +1060,11 @@
     }
     else
     {
-      if ( $opt_valgrind_mysqltest )
-      {
-        # client/mysqltest might be a libtool .sh script, so look for real exe
-        # to avoid valgrinding bash ;)
-        $exe_mysqltest=
-  	  mtr_exe_exists("$path_client_bindir/.libs/lt-mysqltest",
-		         "$path_client_bindir/.libs/mysqltest",
-		         "$path_client_bindir/mysqltest");
-      }
-      else
-      {
-        $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
-      }
+      $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
       $exe_mysql_client_test=
         mtr_exe_exists("$glob_basedir/tests/mysql_client_test",
+                       "$glob_basedir/tests/release/mysql_client_test",
+                       "$glob_basedir/tests/debug/mysql_client_test",
                        "$path_client_bindir/mysql_client_test",
 		       "/usr/bin/false");
     }
@@ -1056,7 +1076,8 @@
     $exe_mysqladmin=     mtr_exe_exists("$path_client_bindir/mysqladmin");
     $exe_mysql=          mtr_exe_exists("$path_client_bindir/mysql");
     $exe_mysql_fix_system_tables=
-      mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables");
+      mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
+                        "/usr/bin/false");
     $path_ndb_tools_dir= mtr_path_exists("$glob_basedir/storage/ndb/tools");
     $exe_ndb_mgm=        "$glob_basedir/storage/ndb/src/mgmclient/ndb_mgm";
   }
@@ -1072,7 +1093,8 @@
     $exe_mysql=          mtr_exe_exists("$path_client_bindir/mysql");
     $exe_mysql_fix_system_tables=
       mtr_script_exists("$path_client_bindir/mysql_fix_privilege_tables",
-			"$glob_basedir/scripts/mysql_fix_privilege_tables");
+			"$glob_basedir/scripts/mysql_fix_privilege_tables",
+                        "/usr/bin/false");
     $exe_my_print_defaults=
       mtr_exe_exists("$path_client_bindir/my_print_defaults");
 
@@ -1108,6 +1130,8 @@
       $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
       $exe_mysql_client_test=
         mtr_exe_exists("$path_client_bindir/mysql_client_test",
+                       "$glob_basedir/tests/release/mysql_client_test",
+                       "$glob_basedir/tests/debug/mysql_client_test",
 		       "/usr/bin/false"); # FIXME temporary
     }
 
@@ -1118,8 +1142,8 @@
   $exe_master_mysqld= $exe_master_mysqld || $exe_mysqld;
   $exe_slave_mysqld=  $exe_slave_mysqld  || $exe_mysqld;
 
-  $path_ndb_backup_dir=
-    "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
+  $path_ndb_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
+  $path_ndb_slave_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
   $file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
 }
 
@@ -1150,6 +1174,14 @@
   }
 
   # --------------------------------------------------------------------------
+  # Add the path where mysqld will find udf_example.so
+  # --------------------------------------------------------------------------
+  $ENV{'LD_LIBRARY_PATH'}=
+    "$glob_basedir/sql/.libs" .
+      ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : "");
+
+
+  # --------------------------------------------------------------------------
   # Also command lines in .opt files may contain env vars
   # --------------------------------------------------------------------------
 
@@ -1302,21 +1334,7 @@
   mkpath("$opt_vardir/tmp");
   mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
 
-  # FIXME do we really need to create these all, or are they
-  # created for us when tables are created?
-
-  my @data_dir_lst = (
-    $master->[0]->{'path_myddir'},
-    $master->[1]->{'path_myddir'},
-    $slave->[0]->{'path_myddir'},
-    $slave->[1]->{'path_myddir'},
-    $slave->[2]->{'path_myddir'});
-
-  foreach my $instance (@{$instance_manager->{'instances'}})
-  {
-    push(@data_dir_lst, $instance->{'path_datadir'});
-  }
-
+  # Remove old and create new data dirs
   foreach my $data_dir (@data_dir_lst)
   {
     rmtree("$data_dir");
@@ -1726,8 +1744,9 @@
 
   mtr_print_line();
 
-  if ( ! $opt_gdb and ! $glob_use_running_server and
-       ! $opt_ddd and ! $glob_use_embedded_server )
+  if ( ! $glob_debugger and
+       ! $glob_use_running_server and
+       ! $glob_use_embedded_server )
   {
     stop_masters_slaves();
   }
@@ -2022,13 +2041,37 @@
 
   if ( ! $glob_use_running_server and ! $glob_use_embedded_server )
   {
-    if ( $tinfo->{'master_restart'} or
-         $master->[0]->{'running_master_is_special'} or
-	 # Stop if cluster is started but test cases does not need cluster
-	 ( $opt_with_ndbcluster && $tinfo->{'ndb_test'} != $using_ndbcluster_master ) )
+    # We try to find out if we are to restart the server
+    my $do_restart= 0;          # Assumes we don't have to
+
+    if ( $tinfo->{'master_sh'} )
+    {
+      $do_restart= 1;           # Always restart if script to run
+    }
+    elsif ( $opt_with_ndbcluster and $tinfo->{'ndb_test'} != $using_ndbcluster_master )
+    {
+      $do_restart= 1;           # Restart without cluster
+    }
+    elsif ( $master->[0]->{'running_master_is_special'} and
+            $master->[0]->{'running_master_is_special'}->{'timezone'} eq
+            $tinfo->{'timezone'} and
+            mtr_same_opts($master->[0]->{'running_master_is_special'}->{'master_opt'},
+                          $tinfo->{'master_opt'}) )
+    {
+      # If running master was started with special settings, but
+      # the current test requuires the same ones, we *don't* restart.
+      $do_restart= 0;
+    }
+    elsif ( $tinfo->{'master_restart'} or
+            $master->[0]->{'running_master_is_special'} )
+    {
+      $do_restart= 1;
+    }
+
+    if ( $do_restart )
     {
       stop_masters();
-      $master->[0]->{'running_master_is_special'}= 0; # Forget why we stopped
+      delete $master->[0]->{'running_master_is_special'}; # Forget history
     }
 
     # ----------------------------------------------------------------------
@@ -2120,7 +2163,8 @@
 
       if ( $tinfo->{'master_restart'} )
       {
-        $master->[0]->{'running_master_is_special'}= 1;
+        # Save this test case information, so next can examine it
+        $master->[0]->{'running_master_is_special'}= $tinfo;
       }
     }
     elsif ( ! $opt_skip_im and $tinfo->{'component_id'} eq 'im' )
@@ -2232,10 +2276,9 @@
       report_failure_and_restart($tinfo);
     }
     # Save info from this testcase run to mysqltest.log
+    my $testcase_log= mtr_fromfile($path_timefile) if -f $path_timefile;
     mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n");
-    my $testcase_log= mtr_fromfile($path_timefile);
-    mtr_tofile($path_mysqltest_log,
-	       $testcase_log);
+    mtr_tofile($path_mysqltest_log, $testcase_log);
   }
 
   # ----------------------------------------------------------------------
@@ -2249,6 +2292,102 @@
   }
 }
 
+sub copy_dir($$) {
+  my $from_dir= shift;
+  my $to_dir= shift;
+
+  mkpath("$to_dir");
+  opendir(DIR, "$from_dir")
+    or mtr_error("Can't find $from_dir$!");
+  for(readdir(DIR)) {
+    next if "$_" eq "." or "$_" eq "..";
+    if ( -d "$from_dir/$_" )
+    {
+      copy_dir("$from_dir/$_", "$to_dir/$_");
+      next;
+    }
+    copy("$from_dir/$_", "$to_dir/$_");
+  }
+  closedir(DIR);
+
+}
+
+#
+# Save a snapshot of the installed test db(s)
+# I.e take a snapshot of the var/ dir
+#
+sub save_installed_db () {
+
+  mtr_report("Saving snapshot of installed databases");
+  rmtree($path_snapshot);
+
+  foreach my $data_dir (@data_dir_lst)
+  {
+    my $name= basename($data_dir);
+    copy_dir("$data_dir", "$path_snapshot/$name");
+  }
+}
+
+
+#
+# Save any interesting files in the data_dir
+# before the data dir is removed.
+#
+sub save_files_before_restore($$) {
+  my $test_name= shift;
+  my $data_dir= shift;
+  my $save_name= "$opt_vardir/log/$test_name";
+
+  # Look for core files
+  foreach my $core_file ( glob("$data_dir/core*") )
+  {
+    my $core_name= basename($core_file);
+    mtr_report("Saving $core_name");
+    mkdir($save_name) if ! -d $save_name;
+    rename("$core_file", "$save_name/$core_name");
+  }
+}
+
+#
+# Restore snapshot of the installed test db(s)
+# if the snapshot exists
+#
+sub restore_installed_db ($) {
+  my $test_name= shift;
+
+  if ( -d $path_snapshot)
+  {
+    kill_running_server ();
+
+    mtr_report("Restoring snapshot of databases");
+
+    foreach my $data_dir (@data_dir_lst)
+    {
+      my $name= basename($data_dir);
+      save_files_before_restore($test_name, $data_dir);
+      rmtree("$data_dir");
+      copy_dir("$path_snapshot/$name", "$data_dir");
+    }
+    if ($opt_with_ndbcluster)
+    {
+      # Remove the ndb_*_fs dirs, forcing a clean start of ndb
+      rmtree("$path_ndb_data_dir/ndb_1_fs");
+      rmtree("$path_ndb_data_dir/ndb_2_fs");
+
+      if ( $opt_with_ndbcluster_slave )
+      {
+	# Remove also the ndb_*_fs dirs for slave cluster
+	rmtree("$path_ndb_slave_data_dir/ndb_1_fs");
+      }
+    }
+  }
+  else
+  {
+    # No snapshot existed, just stop all processes
+    stop_masters_slaves();
+  }
+}
+
 
 sub report_failure_and_restart ($) {
   my $tinfo= shift;
@@ -2256,27 +2395,25 @@
   mtr_report_test_failed($tinfo);
   mtr_show_failed_diff($tinfo->{'name'});
   print "\n";
-  if ( ! $opt_force )
+  if ( $opt_force )
   {
-    my $test_mode= join(" ", @::glob_test_mode) || "default";
-    print "Aborting: $tinfo->{'name'} failed in $test_mode mode. ";
-    print "To continue, re-run with '--force'.\n";
-    if ( ! $opt_gdb and ! $glob_use_running_server and
-         ! $opt_ddd and ! $glob_use_embedded_server )
-    {
-      stop_masters_slaves();
-    }
-    mtr_exit(1);
+    # Restore the snapshot of the installed test db
+    restore_installed_db($tinfo->{'name'});
+    print "Resuming Tests\n\n";
+    return;
   }
 
-  # FIXME always terminate on failure?!
-  if ( ! $opt_gdb and ! $glob_use_running_server and
-       ! $opt_ddd and ! $glob_use_embedded_server )
+  my $test_mode= join(" ", @::glob_test_mode) || "default";
+  print "Aborting: $tinfo->{'name'} failed in $test_mode mode. ";
+  print "To continue, re-run with '--force'.\n";
+  if ( ! $glob_debugger and
+       ! $glob_use_running_server and
+       ! $glob_use_embedded_server )
   {
     stop_masters_slaves();
   }
-  $glob_mysqld_restart= 1;
-  print "Resuming Tests\n\n";
+  mtr_exit(1);
+
 }
 
 
@@ -2399,7 +2536,7 @@
   mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
   mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
 
-  if ( defined $opt_valgrind_mysqld )
+  if ( $opt_valgrind_mysqld )
   {
     mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
     mtr_add_arg($args, "%s--skip-bdb", $prefix);
@@ -2551,7 +2688,8 @@
     mtr_add_arg($args, "%s--log-warnings", $prefix);
   }
 
-  if ( $opt_gdb or $opt_client_gdb or $opt_manual_gdb or $opt_ddd)
+  # Indicate to "mysqld" it will be debugged in debugger
+  if ( $glob_debugger )
   {
     mtr_add_arg($args, "%s--gdb", $prefix);
   }
@@ -2627,7 +2765,7 @@
 
   my $args;                             # Arg vector
   my $exe;
-  my $pid;
+  my $pid= -1;
 
   if ( $type eq 'master' )
   {
@@ -2644,7 +2782,7 @@
 
   mtr_init_args(\$args);
 
-  if ( defined $opt_valgrind_mysqld )
+  if ( $opt_valgrind_mysqld )
   {
     valgrind_arguments($args, \$exe);
   }
@@ -2652,29 +2790,53 @@
   mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info,
 		   $using_ndbcluster);
 
+  if ( $opt_gdb || $opt_manual_gdb)
+  {
+    gdb_arguments(\$args, \$exe, "$type"."_$idx");
+  }
+  elsif ( $opt_ddd || $opt_manual_ddd )
+  {
+    ddd_arguments(\$args, \$exe, "$type"."_$idx");
+  }
+  elsif ( $opt_manual_debug )
+  {
+     print "\nStart $type in your debugger\n" .
+           "dir: $glob_mysql_test_dir\n" .
+           "exe: $exe\n" .
+	   "args:  " . join(" ", @$args)  . "\n\n" .
+	   "Waiting ....\n";
+
+     # Indicate the exe should not be started
+    $exe= undef;
+  }
+
   if ( $type eq 'master' )
   {
-    if ( $pid= mtr_spawn($exe, $args, "",
-                         $master->[$idx]->{'path_myerr'},
-                         $master->[$idx]->{'path_myerr'},
-                         "",
-                         { append_log_file => 1 }) )
+    if ( ! defined $exe or
+	 $pid= mtr_spawn($exe, $args, "",
+			 $master->[$idx]->{'path_myerr'},
+			 $master->[$idx]->{'path_myerr'},
+			 "",
+			 { append_log_file => 1 }) )
     {
       return sleep_until_file_created($master->[$idx]->{'path_mypid'},
-                                      $master->[$idx]->{'start_timeout'}, $pid);
+                                      $master->[$idx]->{'start_timeout'},
+				      $pid);
     }
   }
 
   if ( $type eq 'slave' )
   {
-    if ( $pid= mtr_spawn($exe, $args, "",
+    if ( ! defined $exe or
+	 $pid= mtr_spawn($exe, $args, "",
                          $slave->[$idx]->{'path_myerr'},
                          $slave->[$idx]->{'path_myerr'},
                          "",
                          { append_log_file => 1 }) )
     {
       return sleep_until_file_created($slave->[$idx]->{'path_mypid'},
-                                      $master->[$idx]->{'start_timeout'}, $pid);
+                                      $master->[$idx]->{'start_timeout'},
+				      $pid);
     }
   }
 
@@ -3012,7 +3174,8 @@
   $ENV{'NDB_SLAVE_STATUS_OK'}=      $flag_ndb_slave_status_ok;
   $ENV{'NDB_EXTRA_TEST'}=           $opt_ndb_extra_test;
   $ENV{'NDB_MGM'}=                  $exe_ndb_mgm;
-  $ENV{'NDB_BACKUP_DIR'}=           $path_ndb_backup_dir;
+  $ENV{'NDB_BACKUP_DIR'}=           $path_ndb_data_dir;
+  $ENV{'NDB_DATA_DIR'}=             $path_ndb_data_dir;
   $ENV{'NDB_TOOLS_DIR'}=            $path_ndb_tools_dir;
   $ENV{'NDB_TOOLS_OUTPUT'}=         $file_ndb_testrun_log;
   $ENV{'NDB_CONNECTSTRING'}=        $opt_ndbconnectstring;
@@ -3022,7 +3185,7 @@
 
   mtr_init_args(\$args);
 
-  if ( defined $opt_valgrind_mysqltest )
+  if ( $opt_valgrind_mysqltest )
   {
     valgrind_arguments($args, \$exe);
   }
@@ -3097,12 +3260,6 @@
     mtr_add_arg($args, "--sleep=%d", $opt_sleep);
   }
 
-  if ( $opt_restart_cleanup and $glob_mysqld_restart )
-  {
-    mtr_add_arg($args, "--include=%s", "include/drop-on-restart.inc");
-    $glob_mysqld_restart= 0;
-  }
-
   if ( $opt_debug )
   {
     mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir_trace);
@@ -3148,7 +3305,10 @@
   # Add arguments that should not go into the MYSQL_TEST env var
   # ----------------------------------------------------------------------
 
-  mtr_add_arg($args, "-R");
+  mtr_add_arg($args, "--test-file");
+  mtr_add_arg($args, $tinfo->{'path'});
+
+  mtr_add_arg($args, "--result-file");
   mtr_add_arg($args, $tinfo->{'result_file'});
 
   if ( $opt_record )
@@ -3156,21 +3316,169 @@
     mtr_add_arg($args, "--record");
   }
 
+  if ( $opt_client_gdb )
+  {
+    gdb_arguments(\$args, \$exe, "client");
+  }
+  elsif ( $opt_client_ddd )
+  {
+    ddd_arguments(\$args, \$exe, "client");
+  }
+
+  if ($glob_use_libtool and $opt_valgrind)
+  {
+    # Add "libtool --mode-execute" before the test to execute
+    # if running in valgrind(to avoid valgrinding bash)
+    unshift(@$args, "--mode=execute", $exe);
+    $exe= "libtool";
+  }
+
   if ( $opt_check_testcases )
   {
     run_check_testcase("before");
   }
 
-  my $res = mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,"");
+  my $res = mtr_run_test($exe,$args,"","",$path_timefile,"");
 
   if ( $opt_check_testcases )
   {
     run_check_testcase("after");
   }
+
   return $res;
+
+}
+
+
+#
+# Modify the exe and args so that program is run in gdb in xterm
+#
+sub gdb_arguments {
+  my $args= shift;
+  my $exe=  shift;
+  my $type= shift;
+
+  # Write $args to gdb init file
+  my $str= join(" ", @$$args);
+  my $gdb_init_file= "$opt_tmpdir/gdbinit.$type";
+
+  # Remove the old gdbinit file
+  unlink($gdb_init_file);
+
+  if ( $type eq "client" )
+  {
+    # write init file for client
+    mtr_tofile($gdb_init_file,
+	       "set args $str\n" .
+	       "break main\n");
+  }
+  else
+  {
+    # write init file for mysqld
+    mtr_tofile($gdb_init_file,
+	       "set args $str\n" .
+	       "break mysql_parse\n" .
+	       "commands 1\n" .
+	       "disable 1\n" .
+	       "end\n" .
+	       "run");
+  }
+
+  if ( $opt_manual_gdb )
+  {
+     print "\nTo start gdb for $type, type in another window:\n";
+     print "cd $glob_mysql_test_dir;\n";
+     print "gdb -x $gdb_init_file $$exe\n";
+
+     # Indicate the exe should not be started
+     $$exe= undef;
+     return;
+  }
+
+  $$args= [];
+  mtr_add_arg($$args, "-title");
+  mtr_add_arg($$args, "$type");
+  mtr_add_arg($$args, "-e");
+
+  if ( $glob_use_libtool )
+  {
+    mtr_add_arg($$args, "libtool");
+    mtr_add_arg($$args, "--mode=execute");
+  }
+
+  mtr_add_arg($$args, "gdb");
+  mtr_add_arg($$args, "-x");
+  mtr_add_arg($$args, "$gdb_init_file");
+  mtr_add_arg($$args, "$$exe");
+
+  $$exe= "xterm";
 }
 
+#
+# Modify the exe and args so that program is run in ddd
+#
+sub ddd_arguments {
+  my $args= shift;
+  my $exe=  shift;
+  my $type= shift;
+
+  # Write $args to ddd init file
+  my $str= join(" ", @$$args);
+  my $gdb_init_file= "$opt_tmpdir/gdbinit.$type";
 
+  # Remove the old gdbinit file
+  unlink($gdb_init_file);
+
+  if ( $type eq "client" )
+  {
+    # write init file for client
+    mtr_tofile($gdb_init_file,
+	       "set args $str\n" .
+	       "break main\n");
+  }
+  else
+  {
+    # write init file for mysqld
+    mtr_tofile($gdb_init_file,
+	       "file $$exe\n" .
+	       "set args $str\n" .
+	       "break mysql_parse\n" .
+	       "commands 1\n" .
+	       "disable 1\n" .
+	       "end\n" .
+	       "run");
+  }
+
+  if ( $opt_manual_ddd )
+  {
+     print "\nTo start ddd for $type, type in another window:\n";
+     print "cd $glob_mysql_test_dir;\n";
+     print "ddd -x $gdb_init_file $$exe\n";
+
+     # Indicate the exe should not be started
+     $$exe= undef;
+     return;
+  }
+
+  my $save_exe= $$exe;
+  $$args= [];
+  if ( $glob_use_libtool )
+  {
+    $$exe= "libtool";
+    mtr_add_arg($$args, "--mode=execute");
+    mtr_add_arg($$args, "ddd");
+  }
+  else
+  {
+    $$exe= "ddd";
+  }
+  mtr_add_arg($$args, "--command=$gdb_init_file");
+  mtr_add_arg($$args, "$save_exe");
+}
+
+#
+# Modify the exe and args so that program is run in valgrind
+#
 sub valgrind_arguments {
   my $args= shift;
   my $exe=  shift;
@@ -3182,7 +3490,7 @@
   mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
     if -f "$glob_mysql_test_dir/valgrind.supp";
 
-  if ( defined $opt_valgrind_all )
+  if ( $opt_valgrind_all )
   {
     mtr_add_arg($args, "-v");
     mtr_add_arg($args, "--show-reachable=yes");
@@ -3190,14 +3498,13 @@
 
   if ( $opt_valgrind_options )
   {
-    # FIXME split earlier and put into @glob_valgrind_*
     mtr_add_arg($args, split(' ', $opt_valgrind_options));
   }
 
 
   mtr_add_arg($args, $$exe);
 
-  $$exe= $opt_valgrind || "valgrind";
+  $$exe= $opt_valgrind_path || "valgrind";
 }
 
 
@@ -3228,6 +3535,13 @@
   bench                 Run the benchmark suite FIXME
   small-bench           FIXME
 
+Options to control directories to use
+  vardir=DIR            The directory where files generated from the test run
+                        is stored(default: ./var). Specifying a ramdisk or tmpfs
+                        will speed up tests.
+  tmpdir=DIR            The directory where temporary files are stored
+                        (default: ./var/tmp).
+
 Options to control what test suites or cases to run
 
   force                 Continue to run the suite after failure
@@ -3241,12 +3555,15 @@
   skip-rpl              Skip the replication test cases.
   skip-im               Don't start IM, and skip the IM test cases
   skip-test=PREFIX      Skip test cases which name are prefixed with PREFIX
+  big-test              Pass "--big-test" to mysqltest which will set the environment
+                        variable BIG_TEST, which can be checked from test cases.
 
 Options that specify ports
 
   master_port=PORT      Specify the port number used by the first master
   slave_port=PORT       Specify the port number used by the first slave
-  ndbcluster_port=PORT  Specify the port number used by cluster
+  ndbcluster-port=PORT  Specify the port number used by cluster
+  ndbcluster-port-slave=PORT  Specify the port number used by slave cluster
 
 Options for test case authoring
 
@@ -3265,10 +3582,12 @@
 
 Options for debugging the product
 
-  gdb                   FIXME
-  manual-gdb            FIXME
-  client-gdb            FIXME
-  ddd                   FIXME
+  gdb                   Start the mysqld(s) in gdb
+  manual-gdb            Let user manually start mysqld in gdb, before running test(s)
+  manual-debug          Let user manually start mysqld in debugger, before running test(s)
+  client-gdb            Start mysqltest client in gdb
+  ddd                   Start mysqld in ddd
+  client-ddd            Start mysqltest client in ddd
   strace-client         FIXME
   master-binary=PATH    Specify the master "mysqld" to use
   slave-binary=PATH     Specify the slave "mysqld" to use
@@ -3277,16 +3596,17 @@
 
   gcov                  FIXME
   gprof                 FIXME
-  valgrind[=EXE]        Run the "mysqld" server using valgrind, optionally
-                        specifying the executable path/name
-  valgrind-mysqltest[=EXE] In addition, run the "mysqltest" executable with valgrind
-  valgrind-all[=EXE]    Adds verbose flag, and --show-reachable to valgrind
+  valgrind              Run the "mysqltest" and "mysqld" executables using valgrind
+  valgrind-all          Same as "valgrind" but will also add "verbose" and "--show-reachable"
+                        flags to valgrind
+  valgrind-mysqltest    Run the "mysqltest" executable with valgrind
+  valgrind-mysqld       Run the "mysqld" executable with valgrind
   valgrind-options=ARGS Extra options to give valgrind
+  valgrind-path=[EXE]   Path to the valgrind executable
 
 Misc options
 
   comment=STR           Write STR to the output
-  verbose               Verbose output from this script
   script-debug          Debug this script itself
   timer                 Show test case execution time
   start-and-exit        Only initiate and start the "mysqld" servers, use the startup
@@ -3297,16 +3617,14 @@
   help                  Get this help text
   unified-diff | udiff  When presenting differences, use unified diff
 
-  testcase-timeout=MINUTES Max test case run time (default 5)
-  suite-timeout=MINUTES    Max test suite run time (default 120)
+  testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
+  suite-timeout=MINUTES    Max test suite run time (default $default_suite_timeout)
 
 Deprecated options
   with-openssl          Deprecated option for ssl
 
 
 Options not yet described, or that I want to look into more
-
-  big-test              
   debug                 
   local                 
   local-master          
@@ -3314,7 +3632,6 @@
   old-master            
   sleep=SECONDS         
   socket=PATH           
-  tmpdir=DIR            
   user-test=s           
   wait-timeout=SECONDS  
   warnings              
Thread
bk commit into 5.1 tree (joerg:1.2022)Joerg Bruehe4 Apr