diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 51eed62c1ff..d8f3e61bd11 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -155,11 +155,24 @@ sub collect_test_cases ($) { if ( $::opt_reorder ) { @$cases = sort { - if ( $a->{'master_restart'} and $b->{'master_restart'} or - ! $a->{'master_restart'} and ! $b->{'master_restart'} ) + if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} ) { return $a->{'name'} cmp $b->{'name'}; } + + if ( $a->{'master_restart'} and $b->{'master_restart'} ) + { + my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'}); + if ( $cmp == 0 ) + { + return $a->{'name'} cmp $b->{'name'}; + } + else + { + return $cmp; + } + } + if ( $a->{'master_restart'} ) { return 1; # Is greater diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index a76f1b2d7b1..5b2fd5c6df6 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -13,6 +13,9 @@ sub mtr_add_arg ($$@); sub mtr_path_exists(@); sub mtr_script_exists(@); sub mtr_exe_exists(@); +sub mtr_copy_dir($$); +sub mtr_same_opts($$); +sub mtr_cmp_opts($$); ############################################################################## # @@ -108,5 +111,44 @@ sub mtr_exe_exists (@) { } } +sub mtr_copy_dir($$) { + my $srcdir= shift; + my $dstdir= shift; + + # Create destination directory + mkpath($dstdir); + find(\&mtr_copy_one_file, $dstdir); +} + +sub mtr_copy_one_file { + print $File::Find::name, "\n"; +} + +sub mtr_same_opts ($$) { + my $l1= shift; + my $l2= shift; + return mtr_cmp_opts($l1,$l2) == 0; +} + +sub mtr_cmp_opts ($$) { + my $l1= shift; + my $l2= shift; + + my @l1= @$l1; + my @l2= @$l2; + + return -1 if @l1 < @l2; + return 1 if @l1 > @l2; + + while ( @l1 ) # Same length + { + my $e1= shift @l1; + my $e2= shift @l2; + my $cmp= ($e1 cmp $e2); + return $cmp if $cmp != 0; + } + + return 0; # They are the same +} 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 75491795a60..1e369fade2e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -464,9 +464,9 @@ sub initial_setup () { 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); } @@ -973,7 +973,8 @@ sub executable_setup () { $exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-max", "$path_client_bindir/mysqld-nt", "$path_client_bindir/mysqld", - "$path_client_bindir/mysqld-debug",); + "$path_client_bindir/mysqld-debug", + "$path_client_bindir/mysqld-max"); $path_language= mtr_path_exists("$glob_basedir/share/english/"); $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets"); $exe_my_print_defaults= @@ -1837,13 +1838,37 @@ sub run_testcase ($) { 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 } # ---------------------------------------------------------------------- @@ -1930,7 +1955,8 @@ sub run_testcase ($) { 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' )