mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
mysql-test-run.pl, mtr_cases.pl
- Back porting of some changes in later releases - Corrected valgrind support - Removed work around for TZ needed in VisualStudio 6 - Don't restart master to add special settings from "<testcase>-master.opt", if same settngs as running master, feature request in bug#12433 - With --reorder, keep tests with same *-master.opt content together, to save even more master restarts mysql-test/lib/mtr_misc.pl: Added functions to compare lists of options mysql-test/lib/mtr_cases.pl: Removed special code for Windows as in VC6 we unset TZ to avoid library bug mysql-test/mysql-test-run.pl: Handle pseudo option --timezone=<spec> that sets TZ
This commit is contained in:
@ -76,6 +76,7 @@ $Devel::Trace::TRACE= 0; # Don't trace boring init stuff
|
||||
#require 5.6.1;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
use File::Copy;
|
||||
use Cwd;
|
||||
use Getopt::Long;
|
||||
use Sys::Hostname;
|
||||
@ -152,6 +153,7 @@ our $path_language;
|
||||
our $path_timefile;
|
||||
our $path_manager_log; # Used by mysqldadmin
|
||||
our $path_slave_load_tmpdir; # What is this?!
|
||||
our $path_mysqltest_log;
|
||||
our $path_my_basedir;
|
||||
our $opt_vardir; # A path but set directly on cmd line
|
||||
our $opt_tmpdir; # A path but set directly on cmd line
|
||||
@ -239,7 +241,7 @@ our $opt_sleep_time_after_restart= 1;
|
||||
our $opt_sleep_time_for_delete= 10;
|
||||
our $opt_testcase_timeout;
|
||||
our $opt_suite_timeout;
|
||||
my $default_testcase_timeout= 10; # 10 min max
|
||||
my $default_testcase_timeout= 15; # 15 min max
|
||||
my $default_suite_timeout= 120; # 2 hours max
|
||||
|
||||
our $opt_socket;
|
||||
@ -258,6 +260,7 @@ 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_options;
|
||||
@ -476,8 +479,9 @@ sub command_line_setup () {
|
||||
#
|
||||
if ( $ENV{'MTR_BUILD_THREAD'} )
|
||||
{
|
||||
$opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 10 + 10000;
|
||||
$opt_slave_myport= $opt_master_myport + 2; # and 3 4
|
||||
# Up to two masters, up to three slaves
|
||||
$opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 10 + 10000; # and 1
|
||||
$opt_slave_myport= $opt_master_myport + 2; # and 3 4
|
||||
$opt_ndbcluster_port= $opt_master_myport + 5;
|
||||
}
|
||||
|
||||
@ -619,6 +623,7 @@ sub command_line_setup () {
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
$opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir;
|
||||
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any
|
||||
# FIXME maybe not needed?
|
||||
$path_manager_log= "$opt_vardir/log/manager.log"
|
||||
unless $path_manager_log;
|
||||
@ -735,6 +740,7 @@ sub command_line_setup () {
|
||||
# "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;
|
||||
|
||||
@ -844,6 +850,7 @@ sub command_line_setup () {
|
||||
}
|
||||
|
||||
$path_timefile= "$opt_vardir/log/mysqltest-time";
|
||||
$path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
|
||||
}
|
||||
|
||||
|
||||
@ -863,7 +870,8 @@ sub executable_setup () {
|
||||
"$glob_basedir/bin");
|
||||
$exe_mysqld= mtr_exe_exists ("$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");
|
||||
}
|
||||
@ -885,7 +893,19 @@ sub executable_setup () {
|
||||
}
|
||||
else
|
||||
{
|
||||
$exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
|
||||
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_mysql_client_test=
|
||||
mtr_exe_exists("$glob_basedir/tests/mysql_client_test",
|
||||
"/usr/bin/false");
|
||||
@ -995,6 +1015,7 @@ sub environment_setup () {
|
||||
$ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server;
|
||||
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
|
||||
$ENV{'MYSQL_TEST_WINDIR'}= $glob_mysql_test_dir;
|
||||
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
|
||||
$ENV{'MASTER_WINMYSOCK'}= $master->[0]->{'path_mysock'};
|
||||
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'};
|
||||
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'};
|
||||
@ -1006,6 +1027,8 @@ sub environment_setup () {
|
||||
# $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME
|
||||
$ENV{'MYSQL_TCP_PORT'}= 3306;
|
||||
|
||||
$ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port;
|
||||
|
||||
if ( $glob_cygwin_perl )
|
||||
{
|
||||
foreach my $key ('MYSQL_TEST_WINDIR','MASTER_MYSOCK')
|
||||
@ -1025,7 +1048,7 @@ sub environment_setup () {
|
||||
print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n";
|
||||
print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n";
|
||||
print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n";
|
||||
print "Using NDBCLUSTER_PORT = $opt_ndbcluster_port\n";
|
||||
print "Using NDBCLUSTER_PORT = $ENV{NDBCLUSTER_PORT}\n";
|
||||
}
|
||||
|
||||
|
||||
@ -1087,10 +1110,40 @@ sub kill_and_cleanup () {
|
||||
|
||||
mtr_report("Removing Stale Files");
|
||||
|
||||
rmtree("$opt_vardir/log");
|
||||
rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port");
|
||||
rmtree("$opt_vardir/run");
|
||||
rmtree("$opt_vardir/tmp");
|
||||
if ( $opt_vardir eq "$glob_mysql_test_dir/var" )
|
||||
{
|
||||
#
|
||||
# Running with "var" in mysql-test dir
|
||||
#
|
||||
if ( -l "$glob_mysql_test_dir/var" )
|
||||
{
|
||||
# Some users creates a soft link in mysql-test/var to another area
|
||||
# - allow it
|
||||
mtr_report("WARNING: Using the 'mysql-test/var' symlink");
|
||||
rmtree("$opt_vardir/log");
|
||||
rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port");
|
||||
rmtree("$opt_vardir/run");
|
||||
rmtree("$opt_vardir/tmp");
|
||||
}
|
||||
else
|
||||
{
|
||||
# Remove the entire "var" dir
|
||||
rmtree("$opt_vardir/");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#
|
||||
# Running with "var" in some other place
|
||||
#
|
||||
|
||||
# Remove the var/ dir in mysql-test dir if any
|
||||
# this could be an old symlink that shouldn't be there
|
||||
rmtree("$glob_mysql_test_dir/var");
|
||||
|
||||
# Remove the "var" dir
|
||||
rmtree("$opt_vardir/");
|
||||
}
|
||||
|
||||
mkpath("$opt_vardir/log");
|
||||
mkpath("$opt_vardir/run");
|
||||
@ -1114,14 +1167,22 @@ sub kill_and_cleanup () {
|
||||
mkpath("$data_dir/test");
|
||||
}
|
||||
|
||||
# To make some old test cases work, we create a soft
|
||||
# link from the old "var" location to the new one
|
||||
|
||||
if ( ! $glob_win32 and $opt_vardir ne "$glob_mysql_test_dir/var" )
|
||||
# Make a link std_data_ln in var/ that points to std_data
|
||||
if ( ! $glob_win32 )
|
||||
{
|
||||
# FIXME why bother with the above, why not always remove all of var?!
|
||||
rmtree("$glob_mysql_test_dir/var"); # Clean old var, FIXME or rename it?!
|
||||
symlink($opt_vardir, "$glob_mysql_test_dir/var");
|
||||
symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
|
||||
}
|
||||
else
|
||||
{
|
||||
# on windows, copy all files from std_data into var/std_data_ln
|
||||
mkpath("$opt_vardir/std_data_ln");
|
||||
opendir(DIR, "$glob_mysql_test_dir/std_data")
|
||||
or mtr_error("Can't find the std_data directory: $!");
|
||||
for my $elem ( readdir(DIR) ) {
|
||||
next if -d "$glob_mysql_test_dir/std_data/$elem";
|
||||
copy("$glob_mysql_test_dir/std_data/$elem", "$opt_vardir/std_data_ln/$elem");
|
||||
}
|
||||
closedir(DIR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1480,11 +1541,33 @@ sub run_testcase ($) {
|
||||
|
||||
if ( ! $glob_use_running_server and ! $glob_use_embedded_server )
|
||||
{
|
||||
if ( $tinfo->{'master_restart'} or
|
||||
$master->[0]->{'running_master_is_special'} )
|
||||
# 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 ( $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
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
@ -1553,6 +1636,7 @@ sub run_testcase ($) {
|
||||
}
|
||||
if ( $opt_with_ndbcluster and ! $master->[1]->{'pid'} )
|
||||
{
|
||||
# Test needs cluster, start an extra mysqld connected to cluster
|
||||
$master->[1]->{'pid'}=
|
||||
mysqld_start('master',1,$tinfo->{'master_opt'},[]);
|
||||
if ( ! $master->[1]->{'pid'} )
|
||||
@ -1564,7 +1648,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1797,7 +1882,7 @@ sub mysqld_arguments ($$$$$) {
|
||||
mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
|
||||
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
|
||||
|
||||
if ( defined $opt_valgrind )
|
||||
if ( defined $opt_valgrind_mysqld )
|
||||
{
|
||||
mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
|
||||
mtr_add_arg($args, "%s--skip-bdb", $prefix);
|
||||
@ -1864,6 +1949,10 @@ sub mysqld_arguments ($$$$$) {
|
||||
mtr_add_arg($args, "%s--skip-innodb", $prefix);
|
||||
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
|
||||
mtr_add_arg($args, "%s--skip-slave-start", $prefix);
|
||||
|
||||
# Directory where slaves find the dumps generated by "load data"
|
||||
# on the server. The path need to have constant length otherwise
|
||||
# test results will vary, thus a relative path is used.
|
||||
mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
|
||||
$path_slave_load_tmpdir);
|
||||
mtr_add_arg($args, "%s--socket=%s", $prefix,
|
||||
@ -2022,7 +2111,7 @@ sub mysqld_start ($$$$) {
|
||||
|
||||
mtr_init_args(\$args);
|
||||
|
||||
if ( defined $opt_valgrind )
|
||||
if ( defined $opt_valgrind_mysqld )
|
||||
{
|
||||
valgrind_arguments($args, \$exe);
|
||||
}
|
||||
|
Reference in New Issue
Block a user