2004-12-30 16:34:01 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# -*- cperl -*-
|
|
|
|
|
|
|
|
#
|
2006-10-05 22:05:42 +02:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# mysql-test-run.pl
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# Tool used for executing a suite of .test files
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
2006-10-05 22:05:42 +02:00
|
|
|
# See the "MySQL Test framework manual" for more information
|
|
|
|
# http://dev.mysql.com/doc/mysqltest/en/index.html
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
2006-10-05 22:05:42 +02:00
|
|
|
# Please keep the test framework tools identical in all versions!
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
2006-10-05 22:05:42 +02:00
|
|
|
##############################################################################
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
# Check that mysql-test-run.pl is started from mysql-test/
|
|
|
|
unless ( -f "mysql-test-run.pl" )
|
|
|
|
{
|
|
|
|
print "**** ERROR **** ",
|
|
|
|
"You must start mysql-test-run from the mysql-test/ directory\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
# Check that lib exist
|
|
|
|
unless ( -d "lib/" )
|
|
|
|
{
|
|
|
|
print "**** ERROR **** ",
|
|
|
|
"Could not find the lib/ directory \n";
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-11-23 15:02:50 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Include settings that control how the script behaves
|
|
|
|
require "lib/mtr_settings.pl";
|
|
|
|
}
|
2007-11-23 15:02:50 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
use lib "lib";
|
2004-12-30 16:34:01 +01:00
|
|
|
use Cwd;
|
|
|
|
use Getopt::Long;
|
2007-12-12 18:19:24 +01:00
|
|
|
use My::File::Path; # Patched version of File::Path
|
|
|
|
use File::Basename;
|
|
|
|
use File::Copy;
|
|
|
|
use File::Temp qw / tempdir /;
|
|
|
|
use My::SafeProcess;
|
|
|
|
use My::ConfigFactory;
|
2008-01-07 19:44:48 +01:00
|
|
|
use My::Options;
|
2007-12-12 18:19:24 +01:00
|
|
|
use mtr_cases;
|
2006-11-02 21:05:20 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
our $is_win32_perl= ($^O eq "MSWin32"); # ActiveState Win32 Perl
|
|
|
|
our $is_cygwin= ($^O eq "cygwin"); # Cygwin Perl
|
|
|
|
our $is_win32= ($is_win32_perl or $is_cygwin);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
require "lib/mtr_process.pl";
|
|
|
|
require "lib/mtr_io.pl";
|
|
|
|
require "lib/mtr_gcov.pl";
|
|
|
|
require "lib/mtr_report.pl";
|
|
|
|
require "lib/mtr_match.pl";
|
|
|
|
require "lib/mtr_misc.pl";
|
2006-11-17 16:52:21 +01:00
|
|
|
require "lib/mtr_unique.pl";
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
$SIG{INT}= sub { mtr_error("Got ^C signal"); };
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
our $mysql_version_id;
|
2007-12-12 18:19:24 +01:00
|
|
|
our $glob_mysql_test_dir;
|
|
|
|
our $basedir;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
our $path_charsetsdir;
|
|
|
|
our $path_client_bindir;
|
|
|
|
our $path_language;
|
|
|
|
our $path_timefile;
|
2006-04-24 11:26:41 +02:00
|
|
|
our $path_current_test_log;
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
our $default_vardir;
|
|
|
|
our $opt_vardir; # Path to use for var/ dir
|
|
|
|
my $path_vardir_trace; # unix formatted opt_vardir for trace files
|
|
|
|
my $opt_tmpdir; # Path to use for tmp/ dir
|
|
|
|
my $path_config_file; # The generated config file, var/my.cnf
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-11-02 21:05:20 +01:00
|
|
|
# Visual Studio produces executables in different sub-directories based on the
|
|
|
|
# configuration used to build them. To make life easier, an environment
|
|
|
|
# variable or command-line option may be specified to control which set of
|
|
|
|
# executables will be used by the test suite.
|
|
|
|
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
our $opt_suites= DEFAULT_SUITES;
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2006-07-07 16:47:51 +02:00
|
|
|
our $opt_verbose= 0; # Verbose output, enable with --verbose
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $exe_mysqld;
|
2004-12-30 16:34:01 +01:00
|
|
|
our $exe_mysql;
|
|
|
|
our $exe_mysqladmin;
|
|
|
|
our $exe_mysqltest;
|
2006-05-18 23:35:17 +02:00
|
|
|
our $exe_ndbd;
|
2007-12-12 18:19:24 +01:00
|
|
|
our $exe_ndb_mgmd= "";
|
2006-05-02 14:46:18 +02:00
|
|
|
our $exe_libtool;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-11-17 11:01:09 +01:00
|
|
|
our $opt_big_test= 0;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-11-23 13:29:31 +01:00
|
|
|
our @opt_combinations;
|
2007-11-02 22:32:17 +01:00
|
|
|
|
2005-06-10 21:29:37 +02:00
|
|
|
our @opt_extra_mysqld_opt;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
our $opt_compress;
|
2005-10-04 15:43:55 +02:00
|
|
|
our $opt_ssl;
|
|
|
|
our $opt_skip_ssl;
|
|
|
|
our $opt_ssl_supported;
|
|
|
|
our $opt_ps_protocol;
|
2005-11-03 19:00:37 +01:00
|
|
|
our $opt_sp_protocol;
|
|
|
|
our $opt_cursor_protocol;
|
|
|
|
our $opt_view_protocol;
|
2005-10-04 15:43:55 +02:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
our $opt_debug;
|
2005-02-03 21:13:27 +01:00
|
|
|
our @opt_cases; # The test cases names in argv
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_embedded_server;
|
2006-11-17 13:30:42 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Options used when connecting to an already running server
|
|
|
|
my %opts_extern;
|
|
|
|
sub using_extern { return (keys %opts_extern > 0);};
|
2006-11-17 13:30:42 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
our $opt_fast= 0;
|
2004-12-30 16:34:01 +01:00
|
|
|
our $opt_force;
|
2006-11-07 11:07:27 +01:00
|
|
|
our $opt_mem= $ENV{'MTR_MEM'};
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
our $opt_gcov;
|
|
|
|
our $opt_gcov_err;
|
|
|
|
our $opt_gcov_msg;
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
our $glob_debugger= 0;
|
2004-12-30 16:34:01 +01:00
|
|
|
our $opt_gdb;
|
|
|
|
our $opt_client_gdb;
|
2006-03-23 15:07:39 +01:00
|
|
|
our $opt_ddd;
|
|
|
|
our $opt_client_ddd;
|
2004-12-30 16:34:01 +01:00
|
|
|
our $opt_manual_gdb;
|
2006-03-23 15:07:39 +01:00
|
|
|
our $opt_manual_ddd;
|
|
|
|
our $opt_manual_debug;
|
2006-04-04 09:49:32 +02:00
|
|
|
our $opt_debugger;
|
|
|
|
our $opt_client_debugger;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $config; # The currently running config
|
|
|
|
my $current_config_name; # The currently running config file template
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_baseport;
|
|
|
|
my $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
|
2005-08-29 20:28:42 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_record;
|
2006-11-23 17:26:06 +01:00
|
|
|
my $opt_report_features;
|
2007-12-19 10:25:21 +01:00
|
|
|
our $opt_check_testcases;
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_mark_progress;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_sleep;
|
2005-01-01 19:27:41 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_testcase_timeout= 15; # 15 minutes
|
|
|
|
my $opt_suite_timeout = 180; # 3 hours
|
|
|
|
my $opt_shutdown_timeout= 10; # 10 seconds
|
|
|
|
my $opt_start_timeout = 30; # 30 seconds
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_start;
|
|
|
|
my $opt_start_dirty;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_strace_client;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-04-19 23:09:49 +02:00
|
|
|
our $opt_timer= 1;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2005-01-11 01:35:08 +01:00
|
|
|
our $opt_user;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_valgrind= 0;
|
|
|
|
my $opt_valgrind_mysqld= 0;
|
|
|
|
my $opt_valgrind_mysqltest= 0;
|
|
|
|
my @default_valgrind_args= ("--show-reachable=yes");
|
|
|
|
my @valgrind_args;
|
|
|
|
my $opt_valgrind_path;
|
|
|
|
my $opt_callgrind;
|
|
|
|
|
|
|
|
our $opt_warnings= 1;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-02-06 15:42:26 +01:00
|
|
|
our $opt_skip_ndbcluster= 0;
|
|
|
|
our $opt_skip_ndbcluster_slave= 0;
|
2006-06-14 21:45:15 +02:00
|
|
|
our $opt_with_ndbcluster= 0;
|
2006-10-18 13:24:06 +02:00
|
|
|
our $glob_ndbcluster_supported= 0;
|
2006-02-06 15:42:26 +01:00
|
|
|
our $opt_ndb_extra_test= 0;
|
2006-04-20 14:43:06 +02:00
|
|
|
our $opt_skip_master_binlog= 0;
|
|
|
|
our $opt_skip_slave_binlog= 0;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
our $exe_ndb_mgm="";
|
2006-05-18 23:35:17 +02:00
|
|
|
our $exe_ndb_waiter;
|
2007-12-12 18:19:24 +01:00
|
|
|
our $path_ndb_tools_dir= "";
|
|
|
|
our $path_ndb_examples_dir= "";
|
|
|
|
our $exe_ndb_example= "";
|
2006-10-04 12:47:32 +02:00
|
|
|
our $path_ndb_testrun_log;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
our $path_sql_dir;
|
|
|
|
|
2006-06-11 23:13:32 +02:00
|
|
|
our $debug_compiled_binaries;
|
2006-06-11 15:49:34 +02:00
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
our %mysqld_variables;
|
|
|
|
|
2006-11-23 17:30:32 +01:00
|
|
|
my $source_dist= 0;
|
|
|
|
|
2007-01-19 09:41:08 +01:00
|
|
|
our $opt_max_save_core= 5;
|
|
|
|
my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far.
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
select(STDOUT);
|
|
|
|
$| = 1; # Automatically flush STDOUT
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
main();
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub main {
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
command_line_setup();
|
2005-10-04 15:43:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Checking supported features...");
|
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
check_ndbcluster_support(\%mysqld_variables);
|
|
|
|
check_ssl_support(\%mysqld_variables);
|
|
|
|
check_debug_support(\%mysqld_variables);
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
executable_setup();
|
2005-07-13 13:07:09 +02:00
|
|
|
|
2005-01-11 01:35:08 +01:00
|
|
|
environment_setup();
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
if ( $opt_gcov )
|
|
|
|
{
|
|
|
|
gcov_prepare();
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Figure out which tests we are going to run
|
|
|
|
mtr_report("Collecting tests...");
|
2008-01-07 19:44:48 +01:00
|
|
|
my $tests= collect_test_cases($opt_suites, \@opt_cases);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
initialize_servers();
|
2006-11-10 13:12:08 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_report_features ) {
|
|
|
|
# Put "report features" as the first test to run
|
|
|
|
my $tinfo = {};
|
|
|
|
$tinfo->{'name'} = 'report_features';
|
|
|
|
$tinfo->{'result_file'} = undef; # Prints result
|
|
|
|
$tinfo->{'path'} = 'include/report-features.test';
|
|
|
|
$tinfo->{'master_opt'} = [];
|
|
|
|
$tinfo->{'slave_opt'} = [];
|
|
|
|
unshift(@$tests, $tinfo);
|
2005-01-03 16:54:08 +01:00
|
|
|
}
|
2005-08-18 00:16:44 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( using_extern() ) {
|
|
|
|
create_config_file_for_extern(%opts_extern);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
run_tests($tests);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
exit(0);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
|
2007-12-21 13:06:56 +01:00
|
|
|
sub ignore_option {
|
|
|
|
my ($opt, $value)= @_;
|
|
|
|
print "Ignoring option '$opt'\n";
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub command_line_setup {
|
2006-02-17 16:20:53 +01:00
|
|
|
my $opt_comment;
|
2007-12-12 18:19:24 +01:00
|
|
|
my $opt_usage;
|
2006-03-30 00:48:46 +02:00
|
|
|
|
2006-07-05 20:17:04 +02:00
|
|
|
# This is needed for test log evaluation in "gen-build-status-page"
|
|
|
|
# in all cases where the calling tool does not log the commands
|
|
|
|
# directly before it executes them, like "make test-force-pl" in RPM builds.
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Logging: $0 ", join(" ", @ARGV));
|
2006-07-05 20:17:04 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Read the command line options
|
2005-01-02 16:57:21 +01:00
|
|
|
# Note: Keep list, and the order, in sync with usage at end of this file
|
2005-09-28 23:24:44 +02:00
|
|
|
Getopt::Long::Configure("pass_through");
|
2004-12-30 16:34:01 +01:00
|
|
|
GetOptions(
|
2005-01-02 16:57:21 +01:00
|
|
|
# Control what engine/variation to run
|
2004-12-30 16:34:01 +01:00
|
|
|
'embedded-server' => \$opt_embedded_server,
|
2005-01-01 19:27:41 +01:00
|
|
|
'ps-protocol' => \$opt_ps_protocol,
|
2005-11-03 19:00:37 +01:00
|
|
|
'sp-protocol' => \$opt_sp_protocol,
|
|
|
|
'view-protocol' => \$opt_view_protocol,
|
|
|
|
'cursor-protocol' => \$opt_cursor_protocol,
|
2005-10-12 13:56:07 +02:00
|
|
|
'ssl|with-openssl' => \$opt_ssl,
|
2005-10-04 15:43:55 +02:00
|
|
|
'skip-ssl' => \$opt_skip_ssl,
|
|
|
|
'compress' => \$opt_compress,
|
2007-03-29 11:31:50 +02:00
|
|
|
'with-ndbcluster|ndb' => \$opt_with_ndbcluster,
|
2007-12-12 18:19:24 +01:00
|
|
|
'vs-config' => \$opt_vs_config,
|
|
|
|
|
|
|
|
# Config file to use as template for all tests
|
|
|
|
'defaults-file=s' => \&collect_option,
|
|
|
|
# Extra config file to append to all generated configs
|
|
|
|
'defaults-extra-file=s' => \&collect_option,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
# Control what test suites or cases to run
|
2004-12-30 16:34:01 +01:00
|
|
|
'force' => \$opt_force,
|
2007-12-12 18:19:24 +01:00
|
|
|
'with-ndbcluster-only' => \&collect_option,
|
2005-06-20 21:37:39 +02:00
|
|
|
'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
|
2006-01-12 19:51:02 +01:00
|
|
|
'skip-ndbcluster-slave|skip-ndb-slave'
|
|
|
|
=> \$opt_skip_ndbcluster_slave,
|
|
|
|
'ndb-extra-test' => \$opt_ndb_extra_test,
|
2006-04-20 14:43:06 +02:00
|
|
|
'skip-master-binlog' => \$opt_skip_master_binlog,
|
|
|
|
'skip-slave-binlog' => \$opt_skip_slave_binlog,
|
2007-06-27 14:28:02 +02:00
|
|
|
'suite|suites=s' => \$opt_suites,
|
2007-12-12 18:19:24 +01:00
|
|
|
'skip-rpl' => \&collect_option,
|
|
|
|
'skip-test=s' => \&collect_option,
|
|
|
|
'do-test=s' => \&collect_option,
|
|
|
|
'start-from=s' => \&collect_option,
|
2006-03-29 08:55:29 +02:00
|
|
|
'big-test' => \$opt_big_test,
|
2007-12-12 18:19:24 +01:00
|
|
|
'combination=s' => \@opt_combinations,
|
|
|
|
'skip-combination' => \&collect_option,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2007-12-21 13:06:56 +01:00
|
|
|
'skip-im' => \&ignore_option,
|
|
|
|
|
2005-01-02 16:57:21 +01:00
|
|
|
# Specify ports
|
2007-12-19 12:58:06 +01:00
|
|
|
'build-thread|mtr-build-thread=i' => \$opt_mtr_build_thread,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
# Test case authoring
|
|
|
|
'record' => \$opt_record,
|
2006-01-26 17:54:34 +01:00
|
|
|
'check-testcases' => \$opt_check_testcases,
|
2006-12-20 16:53:06 +01:00
|
|
|
'mark-progress' => \$opt_mark_progress,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2006-03-29 08:55:29 +02:00
|
|
|
# Extra options used when starting mysqld
|
2005-06-10 21:29:37 +02:00
|
|
|
'mysqld=s' => \@opt_extra_mysqld_opt,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
# Run test on running server
|
2007-12-12 18:19:24 +01:00
|
|
|
'extern=s' => \%opts_extern, # Append to hash
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
# Debugging
|
2007-12-12 18:19:24 +01:00
|
|
|
'debug' => \$opt_debug,
|
2004-12-30 16:34:01 +01:00
|
|
|
'gdb' => \$opt_gdb,
|
2005-01-02 16:57:21 +01:00
|
|
|
'client-gdb' => \$opt_client_gdb,
|
2006-03-23 15:07:39 +01:00
|
|
|
'manual-gdb' => \$opt_manual_gdb,
|
|
|
|
'manual-debug' => \$opt_manual_debug,
|
2005-01-02 16:57:21 +01:00
|
|
|
'ddd' => \$opt_ddd,
|
2006-03-23 15:07:39 +01:00
|
|
|
'client-ddd' => \$opt_client_ddd,
|
2007-04-13 15:06:05 +02:00
|
|
|
'manual-ddd' => \$opt_manual_ddd,
|
2006-04-04 09:49:32 +02:00
|
|
|
'debugger=s' => \$opt_debugger,
|
|
|
|
'client-debugger=s' => \$opt_client_debugger,
|
2007-12-12 18:19:24 +01:00
|
|
|
'strace-client:s' => \$opt_strace_client,
|
2007-01-19 09:41:08 +01:00
|
|
|
'max-save-core=i' => \$opt_max_save_core,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
# Coverage, profiling etc
|
|
|
|
'gcov' => \$opt_gcov,
|
2006-06-16 15:56:08 +02:00
|
|
|
'valgrind|valgrind-all' => \$opt_valgrind,
|
2006-03-23 15:07:39 +01:00
|
|
|
'valgrind-mysqltest' => \$opt_valgrind_mysqltest,
|
|
|
|
'valgrind-mysqld' => \$opt_valgrind_mysqld,
|
2007-12-12 18:19:24 +01:00
|
|
|
'valgrind-options=s' => sub {
|
|
|
|
my ($opt, $value)= @_;
|
|
|
|
# Deprecated option unless it's what we know pushbuild uses
|
|
|
|
if ($value eq "--gen-suppressions=all --show-reachable=yes") {
|
|
|
|
push(@valgrind_args, $_) for (split(' ', $value));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
die("--valgrind-options=s is deprecated. Use ",
|
|
|
|
"--valgrind-option=s, to be specified several",
|
|
|
|
" times if necessary");
|
|
|
|
},
|
|
|
|
'valgrind-option=s' => \@valgrind_args,
|
2006-03-23 15:07:39 +01:00
|
|
|
'valgrind-path=s' => \$opt_valgrind_path,
|
2006-07-26 14:44:59 +02:00
|
|
|
'callgrind' => \$opt_callgrind,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2006-03-23 16:39:51 +01:00
|
|
|
# Directories
|
|
|
|
'tmpdir=s' => \$opt_tmpdir,
|
|
|
|
'vardir=s' => \$opt_vardir,
|
2006-11-13 12:44:12 +01:00
|
|
|
'mem' => \$opt_mem,
|
2006-03-23 16:39:51 +01:00
|
|
|
|
2005-01-02 16:57:21 +01:00
|
|
|
# Misc
|
2006-11-10 13:12:08 +01:00
|
|
|
'report-features' => \$opt_report_features,
|
2006-02-20 00:32:07 +01:00
|
|
|
'comment=s' => \$opt_comment,
|
2005-01-02 16:57:21 +01:00
|
|
|
'fast' => \$opt_fast,
|
2008-01-09 11:15:59 +01:00
|
|
|
'reorder' => \&collect_option,
|
2007-12-12 18:19:24 +01:00
|
|
|
'enable-disabled' => \&collect_option,
|
|
|
|
'verbose+' => \$opt_verbose,
|
2004-12-30 16:34:01 +01:00
|
|
|
'sleep=i' => \$opt_sleep,
|
2005-04-13 11:47:28 +02:00
|
|
|
'start-dirty' => \$opt_start_dirty,
|
2007-12-12 18:19:24 +01:00
|
|
|
'start' => \$opt_start,
|
|
|
|
'print-testcases' => \&collect_option,
|
|
|
|
# TODO 'repeat'
|
|
|
|
# TODO 'retry'
|
2006-04-19 23:09:49 +02:00
|
|
|
'timer!' => \$opt_timer,
|
2004-12-30 16:34:01 +01:00
|
|
|
'user=s' => \$opt_user,
|
2005-08-18 00:16:44 +02:00
|
|
|
'testcase-timeout=i' => \$opt_testcase_timeout,
|
|
|
|
'suite-timeout=i' => \$opt_suite_timeout,
|
2007-12-12 18:19:24 +01:00
|
|
|
'shutdown-timeout=i' => \$opt_shutdown_timeout,
|
|
|
|
'warnings!' => \$opt_warnings,
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
'help|h' => \$opt_usage,
|
2004-12-30 16:34:01 +01:00
|
|
|
) or usage("Can't read options");
|
|
|
|
|
2006-02-17 16:20:53 +01:00
|
|
|
usage("") if $opt_usage;
|
|
|
|
|
2006-11-02 21:05:20 +01:00
|
|
|
if ( -d "../sql" )
|
|
|
|
{
|
2006-11-23 17:30:32 +01:00
|
|
|
$source_dist= 1;
|
2006-11-02 21:05:20 +01:00
|
|
|
}
|
|
|
|
|
2006-11-11 14:32:10 +01:00
|
|
|
# Find the absolute path to the test directory
|
2006-11-02 21:05:20 +01:00
|
|
|
$glob_mysql_test_dir= cwd();
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $is_cygwin )
|
2005-01-02 16:57:21 +01:00
|
|
|
{
|
2006-11-02 21:05:20 +01:00
|
|
|
# Windows programs like 'mysqld' needs Windows paths
|
|
|
|
$glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
|
|
|
|
chomp($glob_mysql_test_dir);
|
2005-01-02 16:57:21 +01:00
|
|
|
}
|
2006-11-11 14:32:10 +01:00
|
|
|
|
|
|
|
# In most cases, the base directory we find everything relative to,
|
|
|
|
# is the parent directory of the "mysql-test" directory. For source
|
|
|
|
# distributions, TAR binary distributions and some other packages.
|
2007-12-12 18:19:24 +01:00
|
|
|
$basedir= dirname($glob_mysql_test_dir);
|
2006-11-11 14:32:10 +01:00
|
|
|
|
|
|
|
# In the RPM case, binaries and libraries are installed in the
|
|
|
|
# default system locations, instead of having our own private base
|
|
|
|
# directory. And we install "/usr/share/mysql-test". Moving up one
|
|
|
|
# more directory relative to "mysql-test" gives us a usable base
|
|
|
|
# directory for RPM installs.
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( ! $source_dist and ! -d "$basedir/bin" )
|
2007-08-03 20:43:12 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$basedir= dirname($basedir);
|
2007-08-03 20:43:12 +02:00
|
|
|
}
|
|
|
|
|
2007-12-19 12:58:06 +01:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Check mtr_build_thread and calculate baseport
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
set_mtr_build_thread_ports($opt_mtr_build_thread);
|
|
|
|
|
2006-11-02 21:05:20 +01:00
|
|
|
#
|
|
|
|
# Find the mysqld executable to be able to find the mysqld version
|
|
|
|
# number as early as possible
|
|
|
|
#
|
|
|
|
|
2006-11-28 20:00:27 +01:00
|
|
|
# Look for the client binaries directory
|
2007-12-12 18:19:24 +01:00
|
|
|
$path_client_bindir= mtr_path_exists("$basedir/client_release",
|
|
|
|
"$basedir/client_debug",
|
2006-11-16 15:23:13 +01:00
|
|
|
vs_config_dirs('client', ''),
|
2007-12-12 18:19:24 +01:00
|
|
|
"$basedir/client",
|
|
|
|
"$basedir/bin");
|
2006-11-02 21:05:20 +01:00
|
|
|
|
2007-04-18 14:24:09 +02:00
|
|
|
# Look for language files and charsetsdir, use same share
|
2007-12-12 18:19:24 +01:00
|
|
|
my $path_share= mtr_path_exists("$basedir/share/mysql",
|
|
|
|
"$basedir/sql/share",
|
|
|
|
"$basedir/share");
|
2007-04-18 14:24:09 +02:00
|
|
|
|
|
|
|
$path_language= mtr_path_exists("$path_share/english");
|
|
|
|
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Look for SQL scripts directory
|
|
|
|
if ( mtr_file_exists("$path_share/mysql_system_tables.sql") ne "")
|
2007-02-23 12:13:55 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# The SQL scripts are in path_share
|
|
|
|
$path_sql_dir= $path_share;
|
2007-02-23 12:13:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$path_sql_dir= mtr_path_exists("$basedir/share",
|
|
|
|
"$basedir/scripts");
|
2007-02-23 12:13:55 +01:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
$exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
|
|
|
|
vs_config_dirs('sql', 'mysqld-debug'),
|
|
|
|
"$basedir/sql/mysqld",
|
|
|
|
"$path_client_bindir/mysqld-max-nt",
|
|
|
|
"$path_client_bindir/mysqld-max",
|
|
|
|
"$path_client_bindir/mysqld-nt",
|
|
|
|
"$path_client_bindir/mysqld",
|
|
|
|
"$path_client_bindir/mysqld-debug",
|
|
|
|
"$path_client_bindir/mysqld-max",
|
|
|
|
"$basedir/libexec/mysqld",
|
|
|
|
"$basedir/bin/mysqld",
|
|
|
|
"$basedir/sbin/mysqld");
|
|
|
|
|
|
|
|
# Use the mysqld found above to find out what features are available
|
|
|
|
collect_mysqld_features();
|
|
|
|
|
2006-02-17 16:20:53 +01:00
|
|
|
if ( $opt_comment )
|
2005-01-02 16:57:21 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report();
|
|
|
|
mtr_print_thick_line('#');
|
|
|
|
mtr_report("# $opt_comment");
|
|
|
|
mtr_print_thick_line('#');
|
2005-01-02 16:57:21 +01:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2005-09-28 23:24:44 +02:00
|
|
|
foreach my $arg ( @ARGV )
|
|
|
|
{
|
|
|
|
if ( $arg =~ /^--skip-/ )
|
|
|
|
{
|
|
|
|
push(@opt_extra_mysqld_opt, $arg);
|
|
|
|
}
|
2006-06-08 14:52:33 +02:00
|
|
|
elsif ( $arg =~ /^--$/ )
|
|
|
|
{
|
|
|
|
# It is an effect of setting 'pass_through' in option processing
|
|
|
|
# that the lone '--' separating options from arguments survives,
|
|
|
|
# simply ignore it.
|
|
|
|
}
|
2005-09-28 23:24:44 +02:00
|
|
|
elsif ( $arg =~ /^-/ )
|
|
|
|
{
|
|
|
|
usage("Invalid option \"$arg\"");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push(@opt_cases, $arg);
|
|
|
|
}
|
|
|
|
}
|
2005-02-03 21:13:27 +01:00
|
|
|
|
2006-06-11 15:49:34 +02:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Find out type of logging that are being used
|
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $arg ( @opt_extra_mysqld_opt )
|
2006-06-11 15:49:34 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $arg =~ /binlog[-_]format=(\S+)/ )
|
2007-11-20 17:55:51 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Save this for collect phase
|
|
|
|
collect_option('binlog-format', $1);
|
|
|
|
mtr_report("Using binlog format '$1'");
|
2007-11-20 17:55:51 +01:00
|
|
|
}
|
2006-06-11 15:49:34 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 11:31:50 +02:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Find out default storage engine being used(if any)
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
foreach my $arg ( @opt_extra_mysqld_opt )
|
|
|
|
{
|
|
|
|
if ( $arg =~ /default-storage-engine=(\S+)/ )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Save this for collect phase
|
|
|
|
collect_option('default-storage-engine', $1);
|
|
|
|
mtr_report("Using default engine '$1'")
|
2007-03-29 11:31:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-15 17:22:54 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-10-05 14:37:46 +02:00
|
|
|
# Check if we should speed up tests by trying to run on tmpfs
|
2005-05-15 17:22:54 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-11-08 23:16:44 +01:00
|
|
|
if ( defined $opt_mem )
|
2006-10-05 14:37:46 +02:00
|
|
|
{
|
|
|
|
mtr_error("Can't use --mem and --vardir at the same time ")
|
|
|
|
if $opt_vardir;
|
|
|
|
mtr_error("Can't use --mem and --tmpdir at the same time ")
|
|
|
|
if $opt_tmpdir;
|
|
|
|
|
2006-11-08 23:16:44 +01:00
|
|
|
# Search through list of locations that are known
|
2008-01-08 10:50:07 +01:00
|
|
|
# to be "fast disks" to find a suitable location
|
2006-11-08 23:16:44 +01:00
|
|
|
# Use --mem=<dir> as first location to look.
|
|
|
|
my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp");
|
|
|
|
|
2006-10-05 14:37:46 +02:00
|
|
|
foreach my $fs (@tmpfs_locations)
|
|
|
|
{
|
|
|
|
if ( -d $fs )
|
|
|
|
{
|
2008-01-08 10:50:07 +01:00
|
|
|
my $template= "var_${opt_mtr_build_thread}_XXXX";
|
|
|
|
$opt_mem= tempdir( $template, DIR => $fs, CLEANUP => 0);
|
2006-10-05 14:37:46 +02:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-08 06:11:05 +01:00
|
|
|
|
2005-05-15 17:22:54 +02:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Set the "var/" directory, as it is the base for everything else
|
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
$default_vardir= "$glob_mysql_test_dir/var";
|
2005-05-15 17:22:54 +02:00
|
|
|
if ( ! $opt_vardir )
|
|
|
|
{
|
2006-10-06 16:26:17 +02:00
|
|
|
$opt_vardir= $default_vardir;
|
2005-05-15 17:22:54 +02:00
|
|
|
}
|
2006-10-06 16:26:17 +02:00
|
|
|
elsif ( $mysql_version_id < 50000 and
|
2006-10-23 13:32:20 +02:00
|
|
|
$opt_vardir ne $default_vardir)
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2006-10-06 16:26:17 +02:00
|
|
|
# Version 4.1 and --vardir was specified
|
|
|
|
# Only supported as a symlink from var/
|
|
|
|
# by setting up $opt_mem that symlink will be created
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( ! $is_win32 )
|
2006-10-23 16:51:48 +02:00
|
|
|
{
|
|
|
|
# Only platforms that have native symlinks can use the vardir trick
|
|
|
|
$opt_mem= $opt_vardir;
|
|
|
|
mtr_report("Using 4.1 vardir trick");
|
|
|
|
}
|
|
|
|
|
2006-10-06 16:26:17 +02:00
|
|
|
$opt_vardir= $default_vardir;
|
2005-05-15 17:22:54 +02:00
|
|
|
}
|
2006-10-04 12:47:32 +02:00
|
|
|
|
|
|
|
$path_vardir_trace= $opt_vardir;
|
2006-03-03 14:55:05 +01:00
|
|
|
# Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
|
2006-10-04 12:47:32 +02:00
|
|
|
$path_vardir_trace=~ s/^\w://;
|
2006-03-03 14:55:05 +01:00
|
|
|
|
2005-06-05 20:10:47 +02:00
|
|
|
# We make the path absolute, as the server will do a chdir() before usage
|
|
|
|
unless ( $opt_vardir =~ m,^/, or
|
2007-12-12 18:19:24 +01:00
|
|
|
($is_win32 and $opt_vardir =~ m,^[a-z]:/,i) )
|
2005-05-15 17:22:54 +02:00
|
|
|
{
|
|
|
|
# Make absolute path, relative test dir
|
|
|
|
$opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Location of my.cnf that all clients use
|
|
|
|
$path_config_file= "$opt_vardir/my.cnf";
|
|
|
|
|
2005-05-15 17:22:54 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-10-08 15:50:16 +02:00
|
|
|
# Set tmpdir
|
2005-05-15 17:22:54 +02:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
$opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir;
|
2006-02-12 04:13:24 +01:00
|
|
|
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# fast option
|
2004-12-30 16:34:01 +01:00
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
if ($opt_fast){
|
|
|
|
$opt_shutdown_timeout= 0; # Kill processes instead of nice shutdown
|
2007-03-28 11:16:50 +02:00
|
|
|
}
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
# --------------------------------------------------------------------------
|
2006-10-08 15:50:16 +02:00
|
|
|
# Record flag
|
2004-12-30 16:34:01 +01:00
|
|
|
# --------------------------------------------------------------------------
|
2005-02-03 21:13:27 +01:00
|
|
|
if ( $opt_record and ! @opt_cases )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
|
|
|
mtr_error("Will not run in record mode without a specific test case");
|
|
|
|
}
|
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# Embedded server flag
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_embedded_server )
|
2005-08-25 16:25:54 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$opt_embedded_server= 1;
|
|
|
|
if ( $is_win32 )
|
|
|
|
{
|
|
|
|
# Add the location for libmysqld.dll to the path.
|
|
|
|
my $separator= ";";
|
|
|
|
my $lib_mysqld=
|
|
|
|
mtr_path_exists(vs_config_dirs('libmysqld',''));
|
|
|
|
if ( $is_cygwin )
|
|
|
|
{
|
|
|
|
$lib_mysqld= `cygpath "$lib_mysqld"`;
|
|
|
|
chomp($lib_mysqld);
|
|
|
|
$separator= ":";
|
|
|
|
}
|
|
|
|
$ENV{'PATH'}= "$ENV{'PATH'}".$separator.$lib_mysqld;
|
|
|
|
}
|
|
|
|
$opt_skip_ndbcluster= 1; # Turn off use of NDB cluster
|
|
|
|
$opt_skip_ssl= 1; # Turn off use of SSL
|
2005-08-25 16:25:54 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Turn off use of bin log
|
|
|
|
push(@opt_extra_mysqld_opt, "--skip-log-bin");
|
|
|
|
|
|
|
|
if ( using_extern() )
|
|
|
|
{
|
|
|
|
mtr_error("Can't use --extern with --embedded-server");
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-11-17 11:01:09 +01:00
|
|
|
# Big test flags
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-11-17 13:14:07 +01:00
|
|
|
if ( $opt_big_test )
|
|
|
|
{
|
|
|
|
$ENV{'BIG_TEST'}= 1;
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Gcov flag
|
|
|
|
# --------------------------------------------------------------------------
|
2006-11-23 17:30:32 +01:00
|
|
|
if ( $opt_gcov and ! $source_dist )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2005-01-01 19:27:41 +01:00
|
|
|
mtr_error("Coverage test needs the source - please use source dist");
|
|
|
|
}
|
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-03-23 15:07:39 +01:00
|
|
|
# Check debug related options
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-03-23 16:22:56 +01:00
|
|
|
if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
|
2006-04-04 09:49:32 +02:00
|
|
|
$opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
|
|
|
|
$opt_debugger || $opt_client_debugger )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-04-04 09:49:32 +02:00
|
|
|
# Indicate that we are using debugger
|
2006-03-23 15:07:39 +01:00
|
|
|
$glob_debugger= 1;
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( using_extern() )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-03-23 15:07:39 +01:00
|
|
|
mtr_error("Can't use --extern when using debugger");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-06-16 15:56:08 +02:00
|
|
|
# Check valgrind arguments
|
2006-10-08 15:50:16 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-03-23 15:07:39 +01:00
|
|
|
mtr_report("Turning on valgrind for all executables");
|
|
|
|
$opt_valgrind= 1;
|
|
|
|
$opt_valgrind_mysqld= 1;
|
|
|
|
$opt_valgrind_mysqltest= 1;
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# Increase the timeouts when running with valgrind
|
|
|
|
$opt_testcase_timeout*= 10;
|
|
|
|
$opt_suite_timeout*= 6;
|
|
|
|
$opt_start_timeout*= 10;
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2006-06-16 15:56:08 +02:00
|
|
|
elsif ( $opt_valgrind_mysqld )
|
2005-09-17 01:09:32 +02:00
|
|
|
{
|
2006-06-16 15:56:08 +02:00
|
|
|
mtr_report("Turning on valgrind for mysqld(s) only");
|
2006-03-23 15:07:39 +01:00
|
|
|
$opt_valgrind= 1;
|
2006-06-16 15:56:08 +02:00
|
|
|
}
|
|
|
|
elsif ( $opt_valgrind_mysqltest )
|
|
|
|
{
|
2006-10-25 14:34:18 +02:00
|
|
|
mtr_report("Turning on valgrind for mysqltest and mysql_client_test only");
|
2006-03-23 15:07:39 +01:00
|
|
|
$opt_valgrind= 1;
|
2006-06-16 15:56:08 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 14:44:59 +02:00
|
|
|
if ( $opt_callgrind )
|
|
|
|
{
|
|
|
|
mtr_report("Turning on valgrind with callgrind for mysqld(s)");
|
|
|
|
$opt_valgrind= 1;
|
|
|
|
$opt_valgrind_mysqld= 1;
|
|
|
|
|
|
|
|
# Set special valgrind options unless options passed on command line
|
2007-12-12 18:19:24 +01:00
|
|
|
push(@valgrind_args, "--trace-children=yes")
|
|
|
|
unless @valgrind_args;
|
2006-07-26 14:44:59 +02:00
|
|
|
}
|
|
|
|
|
2006-06-16 15:56:08 +02:00
|
|
|
if ( $opt_valgrind )
|
|
|
|
{
|
|
|
|
# Set valgrind_options to default unless already defined
|
2007-12-12 18:19:24 +01:00
|
|
|
push(@valgrind_args, @default_valgrind_args)
|
|
|
|
unless @valgrind_args;
|
2005-09-17 01:09:32 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Running valgrind with options \"",
|
|
|
|
join(" ", @valgrind_args), "\"");
|
2005-09-17 01:09:32 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2005-02-07 20:32:56 +01:00
|
|
|
if ( ! $opt_user )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$opt_user= "root"; # We want to do FLUSH xxx commands
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-01-04 10:32:52 +01:00
|
|
|
# On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
|
|
|
|
# considered different, so avoid the extra slash (/) in the socket
|
|
|
|
# paths.
|
|
|
|
my $sockdir = $opt_tmpdir;
|
|
|
|
$sockdir =~ s|/+$||;
|
|
|
|
|
2006-12-18 13:44:21 +01:00
|
|
|
# On some operating systems, there is a limit to the length of a
|
|
|
|
# UNIX domain socket's path far below PATH_MAX, so try to avoid long
|
|
|
|
# socket path names.
|
2007-05-10 13:28:24 +02:00
|
|
|
$sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 );
|
2006-12-18 13:44:21 +01:00
|
|
|
|
2005-05-15 17:22:54 +02:00
|
|
|
$path_timefile= "$opt_vardir/log/mysqltest-time";
|
2006-04-24 11:26:41 +02:00
|
|
|
$path_current_test_log= "$opt_vardir/log/current_test";
|
2006-10-04 12:47:32 +02:00
|
|
|
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
|
2006-03-13 10:30:36 +01:00
|
|
|
|
2006-04-21 18:48:49 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2006-11-23 17:39:10 +01:00
|
|
|
#
|
|
|
|
# To make it easier for different devs to work on the same host,
|
|
|
|
# an environment variable can be used to control all ports. A small
|
|
|
|
# number is to be used, 0 - 16 or similar.
|
|
|
|
#
|
|
|
|
# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
|
|
|
|
# versions of this script, else a 4.0 test run might conflict with a
|
|
|
|
# 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 limitation 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
|
|
|
|
#
|
2006-11-27 22:19:53 +01:00
|
|
|
sub set_mtr_build_thread_ports($) {
|
2007-12-12 18:19:24 +01:00
|
|
|
my $mtr_build_thread= shift || 0;
|
2006-11-23 17:39:10 +01:00
|
|
|
|
2006-11-30 22:45:55 +01:00
|
|
|
if ( lc($mtr_build_thread) eq 'auto' ) {
|
|
|
|
print "Requesting build thread... ";
|
2007-12-12 18:19:24 +01:00
|
|
|
$mtr_build_thread=
|
|
|
|
mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
|
2006-11-30 22:45:55 +01:00
|
|
|
print "got ".$mtr_build_thread."\n";
|
|
|
|
}
|
2007-12-19 12:58:06 +01:00
|
|
|
$ENV{MTR_BUILD_THREAD}= $mtr_build_thread;
|
2006-11-30 22:45:55 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Calculate baseport
|
|
|
|
$opt_baseport= $mtr_build_thread * 10 + 10000;
|
|
|
|
if ( $opt_baseport < 5001 or $opt_baseport + 9 >= 32767 )
|
2006-11-23 17:39:10 +01:00
|
|
|
{
|
|
|
|
mtr_error("MTR_BUILD_THREAD number results in a port",
|
|
|
|
"outside 5001 - 32767",
|
2007-12-12 18:19:24 +01:00
|
|
|
"($opt_baseport - $opt_baseport + 9)");
|
2006-12-20 23:44:53 +01:00
|
|
|
}
|
2006-03-13 10:30:36 +01:00
|
|
|
|
2008-01-08 15:48:55 +01:00
|
|
|
mtr_report("Using MR_BUILD_THREAD $mtr_build_thread,",
|
2007-12-12 18:19:24 +01:00
|
|
|
"with reserved ports $opt_baseport..".($opt_baseport+9));
|
2006-03-13 10:30:36 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub collect_mysqld_features {
|
2006-10-04 12:47:32 +02:00
|
|
|
my $found_variable_list_start= 0;
|
2007-10-05 17:54:19 +02:00
|
|
|
my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function
|
2006-05-03 20:04:57 +02:00
|
|
|
|
2006-11-28 22:16:31 +01:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# Execute "mysqld --no-defaults --help --verbose" to get a
|
2007-03-28 11:16:50 +02:00
|
|
|
# list of all features and settings
|
2006-11-28 22:16:31 +01:00
|
|
|
#
|
2007-04-15 15:47:27 +02:00
|
|
|
# --no-defaults and --skip-grant-tables are to avoid loading
|
|
|
|
# system-wide configs and plugins
|
|
|
|
#
|
2007-04-30 16:45:56 +02:00
|
|
|
# --datadir must exist, mysqld will chdir into it
|
2007-04-30 02:46:18 +02:00
|
|
|
#
|
2007-10-05 17:55:30 +02:00
|
|
|
my $list= `$exe_mysqld --no-defaults --datadir=$tmpdir --language=$path_language --skip-grant-tables --verbose --help`;
|
2005-06-21 02:21:52 +02:00
|
|
|
|
2006-11-28 22:16:31 +01:00
|
|
|
foreach my $line (split('\n', $list))
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
# First look for version
|
|
|
|
if ( !$mysql_version_id )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
# Look for version
|
2006-10-06 13:33:12 +02:00
|
|
|
my $exe_name= basename($exe_mysqld);
|
|
|
|
mtr_verbose("exe_name: $exe_name");
|
|
|
|
if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2006-10-05 22:29:16 +02:00
|
|
|
#print "Major: $1 Minor: $2 Build: $3\n";
|
2006-10-04 12:47:32 +02:00
|
|
|
$mysql_version_id= $1*10000 + $2*100 + $3;
|
2006-10-05 22:29:16 +02:00
|
|
|
#print "mysql_version_id: $mysql_version_id\n";
|
|
|
|
mtr_report("MySQL Version $1.$2.$3");
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
2005-06-19 20:06:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
if (!$found_variable_list_start)
|
2006-03-08 19:15:56 +01:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
# Look for start of variables list
|
2006-10-04 16:28:23 +02:00
|
|
|
if ( $line =~ /[\-]+\s[\-]+/ )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
|
|
|
$found_variable_list_start= 1;
|
|
|
|
}
|
2006-10-04 16:28:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
# Put variables into hash
|
2006-10-23 20:36:44 +02:00
|
|
|
if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2006-10-23 20:36:44 +02:00
|
|
|
# print "$1=\"$2\"\n";
|
2006-10-04 12:47:32 +02:00
|
|
|
$mysqld_variables{$1}= $2;
|
|
|
|
}
|
2006-10-04 16:28:23 +02:00
|
|
|
else
|
|
|
|
{
|
2006-10-05 13:38:08 +02:00
|
|
|
# The variable list is ended with a blank line
|
|
|
|
if ( $line =~ /^[\s]*$/ )
|
|
|
|
{
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Send out a warning, we should fix the variables that has no
|
|
|
|
# space between variable name and it's value
|
|
|
|
# or should it be fixed width column parsing? It does not
|
|
|
|
# look like that in function my_print_variables in my_getopt.c
|
|
|
|
mtr_warning("Could not parse variable list line : $line");
|
|
|
|
}
|
2006-10-04 16:28:23 +02:00
|
|
|
}
|
2006-03-08 19:15:56 +01:00
|
|
|
}
|
2005-06-19 20:06:27 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2007-10-05 17:54:19 +02:00
|
|
|
rmtree($tmpdir);
|
2006-10-04 12:47:32 +02:00
|
|
|
mtr_error("Could not find version of MySQL") unless $mysql_version_id;
|
2006-10-04 16:28:23 +02:00
|
|
|
mtr_error("Could not find variabes list") unless $found_variable_list_start;
|
2006-10-04 12:47:32 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub executable_setup_ndb () {
|
2007-03-28 11:16:50 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Look for ndb tols and binaries
|
|
|
|
my $ndb_path= mtr_file_exists("$basedir/ndb",
|
|
|
|
"$basedir/storage/ndb",
|
|
|
|
"$basedir/bin");
|
2006-10-23 12:02:56 +02:00
|
|
|
|
|
|
|
$exe_ndbd=
|
|
|
|
mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
|
|
|
|
"$ndb_path/ndbd");
|
|
|
|
$exe_ndb_mgm=
|
|
|
|
mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
|
|
|
|
"$ndb_path/ndb_mgm");
|
|
|
|
$exe_ndb_mgmd=
|
|
|
|
mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
|
|
|
|
"$ndb_path/ndb_mgmd");
|
|
|
|
$exe_ndb_waiter=
|
|
|
|
mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
|
|
|
|
"$ndb_path/ndb_waiter");
|
|
|
|
|
|
|
|
# May not exist
|
|
|
|
$path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools",
|
|
|
|
"$ndb_path");
|
|
|
|
# May not exist
|
|
|
|
$path_ndb_examples_dir=
|
|
|
|
mtr_file_exists("$ndb_path/ndbapi-examples",
|
|
|
|
"$ndb_path/examples");
|
|
|
|
# May not exist
|
|
|
|
$exe_ndb_example=
|
|
|
|
mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple");
|
|
|
|
|
|
|
|
return ( $exe_ndbd eq "" or
|
|
|
|
$exe_ndb_mgm eq "" or
|
|
|
|
$exe_ndb_mgmd eq "" or
|
|
|
|
$exe_ndb_waiter eq "");
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
sub executable_setup () {
|
|
|
|
|
2006-05-03 20:04:57 +02:00
|
|
|
#
|
|
|
|
# Check if libtool is available in this distribution/clone
|
|
|
|
# we need it when valgrinding or debugging non installed binary
|
|
|
|
# Otherwise valgrind will valgrind the libtool wrapper or bash
|
|
|
|
# and gdb will not find the real executable to debug
|
|
|
|
#
|
|
|
|
if ( -x "../libtool")
|
|
|
|
{
|
|
|
|
$exe_libtool= "../libtool";
|
|
|
|
if ($opt_valgrind or $glob_debugger)
|
|
|
|
{
|
|
|
|
mtr_report("Using \"$exe_libtool\" when running valgrind or debugger");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-11 01:35:08 +01:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# Look for the client binaries
|
|
|
|
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
|
|
|
|
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
|
2005-06-21 02:21:52 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) {
|
|
|
|
mtr_warning("Could not find all required ndb binaries, " .
|
|
|
|
"all ndb tests will fail, use --skip-ndbcluster to " .
|
|
|
|
"skip testing it.");
|
2005-02-08 06:11:05 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $cluster ( clusters()) {
|
|
|
|
$cluster->{"executable_setup_failed"}= 1;
|
2007-02-23 12:13:55 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-15 00:09:56 +01:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# Look for mysqltest executable
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_embedded_server )
|
2005-06-10 21:29:37 +02:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
$exe_mysqltest=
|
2006-11-13 13:39:49 +01:00
|
|
|
mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'),
|
2007-12-12 18:19:24 +01:00
|
|
|
"$basedir/libmysqld/examples/mysqltest_embedded",
|
2006-11-02 21:05:20 +01:00
|
|
|
"$path_client_bindir/mysqltest_embedded");
|
2005-06-10 21:29:37 +02:00
|
|
|
}
|
2006-10-04 12:47:32 +02:00
|
|
|
else
|
|
|
|
{
|
2006-11-13 13:39:49 +01:00
|
|
|
$exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
2005-02-08 06:11:05 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
sub client_debug_arg($$) {
|
|
|
|
my ($args, $client_name)= @_;
|
|
|
|
|
|
|
|
if ( $opt_debug ) {
|
|
|
|
mtr_add_arg($args,
|
|
|
|
"--debug=d:t:A,%s/log/%s.trace",
|
|
|
|
$path_vardir_trace, $client_name)
|
|
|
|
}
|
2006-08-16 10:30:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mysql_fix_arguments () {
|
2005-01-11 01:35:08 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return "" if ( $is_win32 );
|
2006-10-25 14:34:18 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $exe=
|
|
|
|
mtr_script_exists("$basedir/scripts/mysql_fix_privilege_tables",
|
|
|
|
"$path_client_bindir/mysql_fix_privilege_tables");
|
2006-10-25 14:34:18 +02:00
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
2006-10-25 14:34:18 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--basedir=", $basedir);
|
|
|
|
mtr_add_arg($args, "--bindir=", $path_client_bindir);
|
|
|
|
mtr_add_arg($args, "--verbose");
|
|
|
|
return mtr_args2str($exe, @$args);
|
|
|
|
}
|
2006-10-25 14:34:18 +02:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub client_arguments ($) {
|
|
|
|
my $client_name= shift;
|
|
|
|
my $client_exe= mtr_exe_exists("$path_client_bindir/$client_name");
|
2006-10-25 14:34:18 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
client_debug_arg($args, $client_name);
|
|
|
|
return mtr_args2str($client_exe, @$args);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub mysqlslap_arguments () {
|
|
|
|
my $exe= mtr_exe_maybe_exists("$path_client_bindir/mysqlslap");
|
|
|
|
if ( $exe eq "" ) {
|
|
|
|
# mysqlap was not found
|
|
|
|
|
|
|
|
if (defined $mysql_version_id and $mysql_version_id >= 50100 ) {
|
|
|
|
mtr_error("Could not find the mysqlslap binary");
|
|
|
|
}
|
|
|
|
return ""; # Don't care about mysqlslap
|
2006-10-25 14:34:18 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
client_debug_arg($args, "mysqlslap");
|
|
|
|
return mtr_args2str($exe, @$args);
|
2006-10-25 14:34:18 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
sub mysqldump_arguments ($) {
|
|
|
|
my($group_suffix) = @_;
|
|
|
|
my $exe= mtr_exe_exists("$path_client_bindir/mysqldump");
|
2006-11-13 13:39:49 +01:00
|
|
|
|
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
mtr_add_arg($args, "--defaults-group-suffix=_%s", $group_suffix);
|
|
|
|
client_debug_arg($args, "mysqldump-$group_suffix");
|
|
|
|
return mtr_args2str($exe, @$args);
|
|
|
|
}
|
2006-11-13 13:39:49 +01:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mysql_client_test_arguments(){
|
|
|
|
my $exe;
|
|
|
|
# mysql_client_test executable may _not_ exist
|
|
|
|
if ( $opt_embedded_server ) {
|
|
|
|
$exe= mtr_exe_maybe_exists(
|
|
|
|
vs_config_dirs('libmysqld/examples','mysql_client_test_embedded'),
|
|
|
|
"$basedir/libmysqld/examples/mysql_client_test_embedded");
|
|
|
|
} else {
|
|
|
|
$exe= mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'),
|
|
|
|
"$basedir/tests/mysql_client_test",
|
|
|
|
"$basedir/bin/mysql_client_test");
|
|
|
|
}
|
|
|
|
|
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
if ( $opt_valgrind_mysqltest ) {
|
|
|
|
valgrind_arguments($args, \$exe);
|
2006-11-13 13:39:49 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
mtr_add_arg($args, "--testcase");
|
|
|
|
mtr_add_arg($args, "--vardir=$opt_vardir");
|
|
|
|
client_debug_arg($args,"mysql_client_test");
|
2006-11-13 13:39:49 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return mtr_args2str($exe, @$args);
|
2006-11-13 13:39:49 +01:00
|
|
|
}
|
|
|
|
|
2005-01-11 01:35:08 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Set environment to be used by childs of this process for
|
|
|
|
# things that are constant during the whole lifetime of mysql-test-run
|
|
|
|
#
|
|
|
|
sub environment_setup {
|
2005-01-11 01:35:08 +01:00
|
|
|
|
2006-05-28 14:51:01 +02:00
|
|
|
umask(022);
|
|
|
|
|
2006-09-27 13:42:16 +02:00
|
|
|
my @ld_library_paths;
|
2006-08-16 15:25:30 +02:00
|
|
|
|
2005-01-11 01:35:08 +01:00
|
|
|
# --------------------------------------------------------------------------
|
2006-08-16 15:25:30 +02:00
|
|
|
# Setup LD_LIBRARY_PATH so the libraries from this distro/clone
|
|
|
|
# are used in favor of the system installed ones
|
2005-01-11 01:35:08 +01:00
|
|
|
# --------------------------------------------------------------------------
|
2006-11-23 17:30:32 +01:00
|
|
|
if ( $source_dist )
|
2005-06-21 02:21:52 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
push(@ld_library_paths, "$basedir/libmysql/.libs/",
|
|
|
|
"$basedir/libmysql_r/.libs/",
|
|
|
|
"$basedir/zlib.libs/");
|
2006-08-16 15:25:30 +02:00
|
|
|
}
|
|
|
|
else
|
2005-06-21 02:21:52 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
push(@ld_library_paths, "$basedir/lib");
|
2006-09-27 13:56:32 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# --------------------------------------------------------------------------
|
2006-09-27 13:56:32 +02:00
|
|
|
# Add the path where libndbclient can be found
|
|
|
|
# --------------------------------------------------------------------------
|
2006-10-18 13:24:06 +02:00
|
|
|
if ( $glob_ndbcluster_supported )
|
2006-09-27 13:56:32 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
push(@ld_library_paths, "$basedir/storage/ndb/src/.libs");
|
|
|
|
}
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Add the path where mysqld will find udf_example.so
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
my $lib_udf_example=
|
|
|
|
mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
|
|
|
|
"$basedir/sql/.libs/udf_example.so",);
|
|
|
|
|
|
|
|
if ( $lib_udf_example )
|
|
|
|
{
|
|
|
|
push(@ld_library_paths, dirname($lib_udf_example));
|
|
|
|
}
|
|
|
|
|
|
|
|
$ENV{'UDF_EXAMPLE_LIB'}=
|
|
|
|
($lib_udf_example ? basename($lib_udf_example) : "");
|
|
|
|
$ENV{'UDF_EXAMPLE_LIB_OPT'}=
|
|
|
|
($lib_udf_example ? "--plugin_dir=" . dirname($lib_udf_example) : "");
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
# Add the path where mysqld will find ha_example.so
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
if ($mysql_version_id >= 50100) {
|
|
|
|
my $lib_example_plugin=
|
|
|
|
mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
|
|
|
|
"$basedir/storage/example/.libs/ha_example.so",);
|
|
|
|
$ENV{'EXAMPLE_PLUGIN'}=
|
|
|
|
($lib_example_plugin ? basename($lib_example_plugin) : "");
|
|
|
|
$ENV{'EXAMPLE_PLUGIN_OPT'}=
|
|
|
|
($lib_example_plugin ?
|
|
|
|
"--plugin_dir=" . dirname($lib_example_plugin) : "");
|
2005-06-21 02:21:52 +02:00
|
|
|
}
|
2005-01-11 01:35:08 +01:00
|
|
|
|
2006-09-01 15:14:50 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-09-27 13:56:32 +02:00
|
|
|
# Valgrind need to be run with debug libraries otherwise it's almost
|
2006-09-27 13:42:16 +02:00
|
|
|
# impossible to add correct supressions, that means if "/usr/lib/debug"
|
|
|
|
# is available, it should be added to
|
|
|
|
# LD_LIBRARY_PATH
|
2006-11-24 12:38:39 +01:00
|
|
|
#
|
|
|
|
# But pthread is broken in libc6-dbg on Debian <= 3.1 (see Debian
|
|
|
|
# bug 399035, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=399035),
|
|
|
|
# so don't change LD_LIBRARY_PATH on that platform.
|
2006-09-01 15:14:50 +02:00
|
|
|
# --------------------------------------------------------------------------
|
2006-09-27 13:42:16 +02:00
|
|
|
my $debug_libraries_path= "/usr/lib/debug";
|
2006-11-24 12:38:39 +01:00
|
|
|
my $deb_version;
|
|
|
|
if ( $opt_valgrind and -d $debug_libraries_path and
|
|
|
|
(! -e '/etc/debian_version' or
|
2007-12-12 18:19:24 +01:00
|
|
|
($deb_version=
|
|
|
|
mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
|
2006-11-24 12:38:39 +01:00
|
|
|
$deb_version > 3.1 ) )
|
2006-09-08 15:55:11 +02:00
|
|
|
{
|
2006-09-27 13:42:16 +02:00
|
|
|
push(@ld_library_paths, $debug_libraries_path);
|
2006-09-08 15:55:11 +02:00
|
|
|
}
|
2006-09-01 15:14:50 +02:00
|
|
|
|
2006-09-27 13:42:16 +02:00
|
|
|
$ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
|
2007-02-23 12:13:55 +01:00
|
|
|
$ENV{'LD_LIBRARY_PATH'} ?
|
2006-10-11 14:50:19 +02:00
|
|
|
split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
|
2006-09-27 13:42:16 +02:00
|
|
|
mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
|
|
|
|
|
|
|
|
$ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
|
2006-10-11 14:50:19 +02:00
|
|
|
$ENV{'DYLD_LIBRARY_PATH'} ?
|
|
|
|
split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
|
2006-09-27 13:42:16 +02:00
|
|
|
mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
|
2006-03-10 10:41:04 +01:00
|
|
|
|
2007-05-31 14:22:21 +02:00
|
|
|
# The environment variable used for shared libs on AIX
|
|
|
|
$ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
|
|
|
|
$ENV{'SHLIB_PATH'} ?
|
|
|
|
split(':', $ENV{'SHLIB_PATH'}) : ());
|
|
|
|
mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
|
|
|
|
|
|
|
|
# The environment variable used for shared libs on hp-ux
|
|
|
|
$ENV{'LIBPATH'}= join(":", @ld_library_paths,
|
|
|
|
$ENV{'LIBPATH'} ?
|
|
|
|
split(':', $ENV{'LIBPATH'}) : ());
|
|
|
|
mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
|
2006-03-10 10:41:04 +01:00
|
|
|
|
2006-08-16 10:30:22 +02:00
|
|
|
$ENV{'CHARSETSDIR'}= $path_charsetsdir;
|
2005-02-03 21:13:27 +01:00
|
|
|
$ENV{'UMASK'}= "0660"; # The octal *string*
|
|
|
|
$ENV{'UMASK_DIR'}= "0770"; # The octal *string*
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2007-05-23 14:32:40 +02:00
|
|
|
#
|
|
|
|
# MySQL tests can produce output in various character sets
|
|
|
|
# (especially, ctype_xxx.test). To avoid confusing Perl
|
|
|
|
# with output which is incompatible with the current locale
|
|
|
|
# settings, we reset the current values of LC_ALL and LC_CTYPE to "C".
|
|
|
|
# For details, please see
|
|
|
|
# Bug#27636 tests fails if LC_* variables set to *_*.UTF-8
|
|
|
|
#
|
|
|
|
$ENV{'LC_ALL'}= "C";
|
|
|
|
$ENV{'LC_CTYPE'}= "C";
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2005-02-03 21:13:27 +01:00
|
|
|
$ENV{'LC_COLLATE'}= "C";
|
2007-12-12 18:19:24 +01:00
|
|
|
$ENV{'USE_RUNNING_SERVER'}= using_extern();
|
2005-02-03 21:13:27 +01:00
|
|
|
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
|
2006-01-24 08:30:54 +01:00
|
|
|
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
|
2007-12-12 18:19:24 +01:00
|
|
|
$ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'} || 3306;
|
2006-10-03 16:42:59 +02:00
|
|
|
|
2006-08-16 10:30:22 +02:00
|
|
|
# ----------------------------------------------------
|
|
|
|
# Setup env for NDB
|
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
|
|
|
|
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test;
|
|
|
|
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir;
|
|
|
|
$ENV{'NDB_TOOLS_OUTPUT'}= $path_ndb_testrun_log;
|
|
|
|
$ENV{'NDB_EXAMPLES_DIR'}= $path_ndb_examples_dir;
|
|
|
|
$ENV{'NDB_EXAMPLES_BINARY'}= $exe_ndb_example;
|
|
|
|
$ENV{'NDB_EXAMPLES_OUTPUT'}= $path_ndb_testrun_log;
|
2006-01-17 10:48:47 +01:00
|
|
|
|
2006-08-16 10:30:22 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# mysql clients
|
2006-08-16 10:30:22 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
$ENV{'MYSQL_CHECK'}= client_arguments("mysqlcheck");
|
|
|
|
$ENV{'MYSQL_DUMP'}= mysqldump_arguments(".1");
|
|
|
|
$ENV{'MYSQL_DUMP_SLAVE'}= mysqldump_arguments(".2");
|
|
|
|
$ENV{'MYSQL_SLAP'}= mysqlslap_arguments();
|
|
|
|
$ENV{'MYSQL_IMPORT'}= client_arguments("mysqlimport");
|
|
|
|
$ENV{'MYSQL_SHOW'}= client_arguments("mysqlshow");
|
|
|
|
$ENV{'MYSQL_BINLOG'}= client_arguments("mysqlbinlog");
|
|
|
|
$ENV{'MYSQL'}= client_arguments("mysql");
|
|
|
|
$ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade");
|
|
|
|
$ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin);
|
|
|
|
$ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments();
|
|
|
|
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= mysql_fix_arguments();
|
|
|
|
$ENV{'EXE_MYSQL'}= $exe_mysql;
|
2005-08-29 20:28:42 +02:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# bug25714 executable may _not_ exist in
|
|
|
|
# some versions, test using it should be skipped
|
2006-11-13 13:39:49 +01:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
my $exe_bug25714=
|
|
|
|
mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
|
|
|
|
"$basedir/tests/bug25714");
|
|
|
|
$ENV{'MYSQL_BUG25714'}= mtr_native_path($exe_bug25714);
|
2006-11-13 13:39:49 +01:00
|
|
|
|
2006-08-16 10:30:22 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# mysql_fix_privilege_tables.sql
|
2006-08-16 10:30:22 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
my $file_mysql_fix_privilege_tables=
|
|
|
|
mtr_file_exists("$basedir/scripts/mysql_fix_privilege_tables.sql",
|
|
|
|
"$basedir/share/mysql_fix_privilege_tables.sql");
|
2007-04-04 15:40:40 +02:00
|
|
|
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
|
2006-08-16 10:30:22 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# my_print_defaults
|
2006-08-16 10:30:22 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
my $exe_my_print_defaults=
|
|
|
|
mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'),
|
|
|
|
"$path_client_bindir/my_print_defaults",
|
|
|
|
"$basedir/extra/my_print_defaults");
|
2007-02-16 15:19:38 +01:00
|
|
|
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
|
2006-08-16 10:30:22 +02:00
|
|
|
|
2006-11-10 13:25:10 +01:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
# perror
|
2006-08-16 10:43:08 +02:00
|
|
|
# ----------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
my $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'),
|
|
|
|
"$basedir/extra/perror",
|
|
|
|
"$path_client_bindir/perror");
|
2007-02-16 15:19:38 +01:00
|
|
|
$ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
|
2006-08-16 10:43:08 +02:00
|
|
|
|
2006-10-05 20:45:16 +02:00
|
|
|
# Create an environment variable to make it possible
|
|
|
|
# to detect that valgrind is being used from test cases
|
|
|
|
$ENV{'VALGRIND_TEST'}= $opt_valgrind;
|
|
|
|
|
2005-01-11 01:35:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-13 11:47:28 +02:00
|
|
|
|
2006-11-28 13:57:07 +01:00
|
|
|
#
|
|
|
|
# Remove var and any directories in var/ created by previous
|
|
|
|
# tests
|
|
|
|
#
|
|
|
|
sub remove_stale_vardir () {
|
2006-10-05 14:37:46 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Removing old var directory...");
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-11-28 13:57:07 +01:00
|
|
|
# Safety!
|
|
|
|
mtr_error("No, don't remove the vardir when running with --extern")
|
2007-12-12 18:19:24 +01:00
|
|
|
if using_extern();
|
2006-11-28 13:57:07 +01:00
|
|
|
|
|
|
|
mtr_verbose("opt_vardir: $opt_vardir");
|
2006-10-06 16:26:17 +02:00
|
|
|
if ( $opt_vardir eq $default_vardir )
|
2006-01-24 08:30:54 +01:00
|
|
|
{
|
|
|
|
#
|
|
|
|
# Running with "var" in mysql-test dir
|
|
|
|
#
|
2006-10-05 14:37:46 +02:00
|
|
|
if ( -l $opt_vardir)
|
2006-01-24 08:30:54 +01:00
|
|
|
{
|
2006-10-05 14:37:46 +02:00
|
|
|
# var is a symlink
|
2006-11-28 16:22:59 +01:00
|
|
|
|
2008-01-08 10:50:07 +01:00
|
|
|
if ( $opt_mem )
|
2006-10-05 14:37:46 +02:00
|
|
|
{
|
|
|
|
# Remove the directory which the link points at
|
2006-11-28 13:57:07 +01:00
|
|
|
mtr_verbose("Removing " . readlink($opt_vardir));
|
2007-12-12 18:19:24 +01:00
|
|
|
rmtree(readlink($opt_vardir));
|
2006-11-28 15:39:23 +01:00
|
|
|
|
2006-10-18 13:24:06 +02:00
|
|
|
# Remove the "var" symlink
|
2006-11-28 13:57:07 +01:00
|
|
|
mtr_verbose("unlink($opt_vardir)");
|
2006-10-18 13:24:06 +02:00
|
|
|
unlink($opt_vardir);
|
2006-10-05 14:37:46 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Some users creates a soft link in mysql-test/var to another area
|
2006-11-28 13:57:07 +01:00
|
|
|
# - allow it, but remove all files in it
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - WARNING: Using the 'mysql-test/var' symlink");
|
2006-11-28 13:57:07 +01:00
|
|
|
|
2006-11-28 16:22:59 +01:00
|
|
|
# Make sure the directory where it points exist
|
|
|
|
mtr_error("The destination for symlink $opt_vardir does not exist")
|
|
|
|
if ! -d readlink($opt_vardir);
|
|
|
|
|
2006-11-28 13:57:07 +01:00
|
|
|
foreach my $bin ( glob("$opt_vardir/*") )
|
|
|
|
{
|
|
|
|
mtr_verbose("Removing bin $bin");
|
2007-12-12 18:19:24 +01:00
|
|
|
rmtree($bin);
|
2006-11-28 13:57:07 +01:00
|
|
|
}
|
2006-10-05 14:37:46 +02:00
|
|
|
}
|
2006-01-24 08:30:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Remove the entire "var" dir
|
2006-11-28 13:57:07 +01:00
|
|
|
mtr_verbose("Removing $opt_vardir/");
|
2007-12-12 18:19:24 +01:00
|
|
|
rmtree("$opt_vardir/");
|
2006-01-24 08:30:54 +01:00
|
|
|
}
|
2007-02-28 13:47:41 +01:00
|
|
|
|
|
|
|
if ( $opt_mem )
|
|
|
|
{
|
|
|
|
# A symlink from var/ to $opt_mem will be set up
|
|
|
|
# remove the $opt_mem dir to assure the symlink
|
|
|
|
# won't point at an old directory
|
|
|
|
mtr_verbose("Removing $opt_mem");
|
2007-12-12 18:19:24 +01:00
|
|
|
rmtree($opt_mem);
|
2007-02-28 13:47:41 +01:00
|
|
|
}
|
|
|
|
|
2006-01-24 08:30:54 +01:00
|
|
|
}
|
|
|
|
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
|
2006-11-28 13:57:07 +01:00
|
|
|
mtr_verbose("Removing $default_vardir");
|
2007-12-12 18:19:24 +01:00
|
|
|
rmtree($default_vardir);
|
2006-01-24 08:30:54 +01:00
|
|
|
|
|
|
|
# Remove the "var" dir
|
2006-11-28 13:57:07 +01:00
|
|
|
mtr_verbose("Removing $opt_vardir/");
|
2007-12-12 18:19:24 +01:00
|
|
|
rmtree("$opt_vardir/");
|
2006-01-24 08:30:54 +01:00
|
|
|
}
|
2006-11-28 13:57:07 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
|
2006-11-28 13:57:07 +01:00
|
|
|
#
|
|
|
|
# Create var and the directories needed in var
|
|
|
|
#
|
|
|
|
sub setup_vardir() {
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Creating var directory...");
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-11-28 15:51:52 +01:00
|
|
|
if ( $opt_vardir eq $default_vardir )
|
2006-10-05 14:37:46 +02:00
|
|
|
{
|
2006-11-28 15:51:52 +01:00
|
|
|
#
|
|
|
|
# Running with "var" in mysql-test dir
|
|
|
|
#
|
|
|
|
if ( -l $opt_vardir )
|
|
|
|
{
|
|
|
|
# it's a symlink
|
2006-11-28 13:57:07 +01:00
|
|
|
|
2006-11-28 15:51:52 +01:00
|
|
|
# Make sure the directory where it points exist
|
|
|
|
mtr_error("The destination for symlink $opt_vardir does not exist")
|
|
|
|
if ! -d readlink($opt_vardir);
|
|
|
|
}
|
|
|
|
elsif ( $opt_mem )
|
|
|
|
{
|
|
|
|
# Runinng with "var" as a link to some "memory" location, normally tmpfs
|
|
|
|
mtr_verbose("Creating $opt_mem");
|
|
|
|
mkpath($opt_mem);
|
2006-11-28 13:57:07 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - symlinking 'var' to '$opt_mem'");
|
2006-11-28 15:51:52 +01:00
|
|
|
symlink($opt_mem, $opt_vardir);
|
|
|
|
}
|
2006-10-05 14:37:46 +02:00
|
|
|
}
|
|
|
|
|
2006-11-28 23:06:06 +01:00
|
|
|
if ( ! -d $opt_vardir )
|
|
|
|
{
|
|
|
|
mtr_verbose("Creating $opt_vardir");
|
|
|
|
mkpath($opt_vardir);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-11-28 23:06:06 +01:00
|
|
|
# Ensure a proper error message if vardir couldn't be created
|
|
|
|
unless ( -d $opt_vardir and -w $opt_vardir )
|
2006-10-05 14:37:46 +02:00
|
|
|
{
|
2006-11-28 23:06:06 +01:00
|
|
|
mtr_error("Writable 'var' directory is needed, use the " .
|
|
|
|
"'--vardir=<path>' option");
|
2006-10-05 14:37:46 +02:00
|
|
|
}
|
|
|
|
|
2005-05-15 17:22:54 +02:00
|
|
|
mkpath("$opt_vardir/log");
|
|
|
|
mkpath("$opt_vardir/run");
|
|
|
|
mkpath("$opt_vardir/tmp");
|
2005-05-15 20:38:54 +02:00
|
|
|
mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# copy all files from std_data into var/std_data
|
|
|
|
# and make them writable
|
|
|
|
copytree("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data");
|
2006-11-20 21:42:06 +01:00
|
|
|
|
|
|
|
# Remove old log files
|
2006-11-23 15:41:21 +01:00
|
|
|
foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
|
2006-11-20 21:42:06 +01:00
|
|
|
{
|
|
|
|
unlink($name);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Check if running as root
|
|
|
|
# i.e a file can be read regardless what mode we set it to
|
|
|
|
#
|
2006-04-24 10:21:09 +02:00
|
|
|
sub check_running_as_root () {
|
2006-05-04 10:28:49 +02:00
|
|
|
my $test_file= "$opt_vardir/test_running_as_root.txt";
|
2006-04-24 10:21:09 +02:00
|
|
|
mtr_tofile($test_file, "MySQL");
|
|
|
|
chmod(oct("0000"), $test_file);
|
|
|
|
|
|
|
|
my $result="";
|
|
|
|
if (open(FILE,"<",$test_file))
|
|
|
|
{
|
|
|
|
$result= join('', <FILE>);
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
2007-05-23 12:13:49 +02:00
|
|
|
# Some filesystems( for example CIFS) allows reading a file
|
|
|
|
# although mode was set to 0000, but in that case a stat on
|
|
|
|
# the file will not return 0000
|
|
|
|
my $file_mode= (stat($test_file))[2] & 07777;
|
2006-04-24 10:21:09 +02:00
|
|
|
|
|
|
|
$ENV{'MYSQL_TEST_ROOT'}= "NO";
|
2007-05-23 12:13:49 +02:00
|
|
|
mtr_verbose("result: $result, file_mode: $file_mode");
|
|
|
|
if ($result eq "MySQL" && $file_mode == 0)
|
2006-04-24 10:21:09 +02:00
|
|
|
{
|
|
|
|
mtr_warning("running this script as _root_ will cause some " .
|
|
|
|
"tests to be skipped");
|
|
|
|
$ENV{'MYSQL_TEST_ROOT'}= "YES";
|
|
|
|
}
|
2007-05-23 12:13:49 +02:00
|
|
|
|
|
|
|
chmod(oct("0755"), $test_file);
|
|
|
|
unlink($test_file);
|
2006-04-24 10:21:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
sub check_ssl_support ($) {
|
|
|
|
my $mysqld_variables= shift;
|
2005-10-04 15:43:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ($opt_skip_ssl)
|
2005-10-04 15:43:55 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - skipping SSL");
|
2005-10-04 15:43:55 +02:00
|
|
|
$opt_ssl_supported= 0;
|
|
|
|
$opt_ssl= 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-04 16:28:23 +02:00
|
|
|
if ( ! $mysqld_variables->{'ssl'} )
|
2005-10-04 15:43:55 +02:00
|
|
|
{
|
|
|
|
if ( $opt_ssl)
|
|
|
|
{
|
|
|
|
mtr_error("Couldn't find support for SSL");
|
|
|
|
return;
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - skipping SSL, mysqld not compiled with SSL");
|
2005-10-04 15:43:55 +02:00
|
|
|
$opt_ssl_supported= 0;
|
|
|
|
$opt_ssl= 0;
|
|
|
|
return;
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - SSL connections supported");
|
2005-10-04 15:43:55 +02:00
|
|
|
$opt_ssl_supported= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
sub check_debug_support ($) {
|
|
|
|
my $mysqld_variables= shift;
|
2006-06-11 23:13:32 +02:00
|
|
|
|
2006-10-05 00:19:24 +02:00
|
|
|
if ( ! $mysqld_variables->{'debug'} )
|
2006-06-11 23:13:32 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
#mtr_report(" - binaries are not debug compiled");
|
2006-06-11 23:13:32 +02:00
|
|
|
$debug_compiled_binaries= 0;
|
2006-06-14 11:59:04 +02:00
|
|
|
|
|
|
|
if ( $opt_debug )
|
|
|
|
{
|
|
|
|
mtr_error("Can't use --debug, binaries does not support it");
|
|
|
|
}
|
2006-06-11 23:13:32 +02:00
|
|
|
return;
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - binaries are debug compiled");
|
2006-06-11 23:13:32 +02:00
|
|
|
$debug_compiled_binaries= 1;
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2006-11-02 21:05:20 +01:00
|
|
|
#
|
|
|
|
# Helper function to handle configuration-based subdirectories which Visual
|
|
|
|
# Studio uses for storing binaries. If opt_vs_config is set, this returns
|
|
|
|
# a path based on that setting; if not, it returns paths for the default
|
|
|
|
# /release/ and /debug/ subdirectories.
|
|
|
|
#
|
|
|
|
# $exe can be undefined, if the directory itself will be used
|
|
|
|
#
|
|
|
|
sub vs_config_dirs ($$) {
|
|
|
|
my ($path_part, $exe) = @_;
|
|
|
|
|
|
|
|
$exe = "" if not defined $exe;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Don't look in these dirs when not on windows
|
|
|
|
return () unless $is_win32;
|
|
|
|
|
2006-11-02 21:05:20 +01:00
|
|
|
if ($opt_vs_config)
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
return ("$basedir/$path_part/$opt_vs_config/$exe");
|
2006-11-02 21:05:20 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return ("$basedir/$path_part/release/$exe",
|
|
|
|
"$basedir/$path_part/relwithdebinfo/$exe",
|
|
|
|
"$basedir/$path_part/debug/$exe");
|
2006-11-02 21:05:20 +01:00
|
|
|
}
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
sub check_ndbcluster_support ($) {
|
|
|
|
my $mysqld_variables= shift;
|
2005-10-04 15:43:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ($opt_skip_ndbcluster)
|
2005-10-04 15:43:55 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - skipping ndbcluster");
|
2006-01-13 03:13:58 +01:00
|
|
|
$opt_skip_ndbcluster_slave= 1;
|
2005-10-04 15:43:55 +02:00
|
|
|
return;
|
|
|
|
}
|
2005-07-13 13:07:09 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( ! $mysqld_variables{'ndb-connectstring'} )
|
2005-07-13 13:07:09 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - skipping ndbcluster, mysqld not compiled with ndbcluster");
|
2006-01-13 03:13:58 +01:00
|
|
|
$opt_skip_ndbcluster= 1;
|
|
|
|
$opt_skip_ndbcluster_slave= 1;
|
2005-10-04 15:43:55 +02:00
|
|
|
return;
|
2005-07-13 13:07:09 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2006-10-18 13:24:06 +02:00
|
|
|
$glob_ndbcluster_supported= 1;
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - using ndbcluster when necessary, mysqld supports it");
|
2006-10-08 15:50:16 +02:00
|
|
|
|
|
|
|
if ( $mysql_version_id < 50100 )
|
|
|
|
{
|
|
|
|
# Slave cluster is not supported until 5.1
|
2007-12-12 18:19:24 +01:00
|
|
|
$opt_skip_ndbcluster_slave= 1;
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2005-02-08 06:11:05 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2006-06-15 22:12:05 +02:00
|
|
|
sub ndbcluster_wait_started($$){
|
2006-05-18 23:35:17 +02:00
|
|
|
my $cluster= shift;
|
2006-06-15 22:12:05 +02:00
|
|
|
my $ndb_waiter_extra_opt= shift;
|
2007-12-12 18:19:24 +01:00
|
|
|
my $path_waitlog= join('/', $opt_vardir, $cluster->name(), "ndb_waiter.log");
|
2006-06-15 22:12:05 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $args;
|
2006-06-15 22:12:05 +02:00
|
|
|
mtr_init_args(\$args);
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
|
2006-06-15 22:12:05 +02:00
|
|
|
mtr_add_arg($args, "--timeout=60");
|
|
|
|
|
|
|
|
if ($ndb_waiter_extra_opt)
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "$ndb_waiter_extra_opt");
|
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
|
|
|
|
# Start the ndb_waiter which will connect to the ndb_mgmd
|
|
|
|
# and poll it for state of the ndbd's, will return when
|
|
|
|
# all nodes in the cluster is started
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $res= My::SafeProcess->run
|
|
|
|
(
|
|
|
|
name => "ndb_waiter ".$cluster->name(),
|
|
|
|
path => $exe_ndb_waiter,
|
|
|
|
args => \$args,
|
|
|
|
output => $path_waitlog,
|
|
|
|
error => $path_waitlog,
|
|
|
|
append => 1,
|
|
|
|
);
|
2005-02-08 06:11:05 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Check that ndb_mgmd(s) are still alive
|
|
|
|
foreach my $ndb_mgmd ( in_cluster($cluster, ndb_mgmds()) )
|
|
|
|
{
|
|
|
|
my $proc= $ndb_mgmd->{proc};
|
|
|
|
if ( ! $proc->wait_one(0) )
|
|
|
|
{
|
|
|
|
mtr_warning("$proc died");
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
2006-06-15 18:40:18 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Check that all started ndbd(s) are still alive
|
|
|
|
foreach my $ndbd ( in_cluster($cluster, ndbds()) )
|
|
|
|
{
|
|
|
|
my $proc= $ndbd->{proc};
|
|
|
|
next unless defined $proc;
|
|
|
|
if ( ! $proc->wait_one(0) )
|
|
|
|
{
|
|
|
|
mtr_warning("$proc died");
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|
2006-05-23 15:27:56 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ($res)
|
2007-06-26 12:26:21 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("ndbcluster_wait_started failed");
|
2007-06-26 12:26:21 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2006-01-12 19:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-31 10:28:48 +02:00
|
|
|
sub ndb_mgmd_wait_started($) {
|
|
|
|
my ($cluster)= @_;
|
|
|
|
|
|
|
|
my $retries= 100;
|
2007-12-12 18:19:24 +01:00
|
|
|
while ($retries)
|
2006-08-31 10:28:48 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my $result= ndbcluster_wait_started($cluster, "--no-contact");
|
|
|
|
if ($result == 0)
|
|
|
|
{
|
|
|
|
# ndb_mgmd is started
|
|
|
|
mtr_verbose("ndb_mgmd is started");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
elsif ($result > 1)
|
|
|
|
{
|
|
|
|
mtr_warning("Cluster process failed while waiting for start");
|
|
|
|
return $result;
|
|
|
|
}
|
2006-08-31 10:28:48 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_milli_sleep(100);
|
2006-08-31 10:28:48 +02:00
|
|
|
$retries--;
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return 1;
|
2006-08-31 10:28:48 +02:00
|
|
|
}
|
|
|
|
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub ndb_mgmd_start ($$) {
|
|
|
|
my ($cluster, $ndb_mgmd)= @_;
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("ndb_mgmd_start");
|
|
|
|
|
|
|
|
my $dir= $ndb_mgmd->value("DataDir");
|
|
|
|
mkpath($dir) unless -d $dir;
|
|
|
|
|
|
|
|
my $args;
|
2006-05-18 23:35:17 +02:00
|
|
|
mtr_init_args(\$args);
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
|
|
|
|
mtr_add_arg($args, "--mycnf");
|
2006-06-15 18:40:18 +02:00
|
|
|
mtr_add_arg($args, "--nodaemon");
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $path_ndb_mgmd_log= "$dir/ndb_mgmd.log";
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
$ndb_mgmd->{'proc'}= My::SafeProcess->new
|
|
|
|
(
|
|
|
|
name => $ndb_mgmd->after('cluster_config.'),
|
|
|
|
path => $exe_ndb_mgmd,
|
|
|
|
args => \$args,
|
|
|
|
output => $path_ndb_mgmd_log,
|
|
|
|
error => $path_ndb_mgmd_log,
|
|
|
|
append => 1,
|
|
|
|
verbose => $opt_verbose,
|
|
|
|
);
|
|
|
|
mtr_verbose("Started $ndb_mgmd->{proc}");
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2006-06-15 18:40:18 +02:00
|
|
|
# FIXME Should not be needed
|
|
|
|
# Unfortunately the cluster nodes will fail to start
|
|
|
|
# if ndb_mgmd has not started properly
|
2006-08-31 10:28:48 +02:00
|
|
|
if (ndb_mgmd_wait_started($cluster))
|
2006-06-15 22:12:05 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_warning("Failed to wait for start of ndb_mgmd");
|
|
|
|
return 1;
|
2006-06-15 22:12:05 +02:00
|
|
|
}
|
2006-06-15 18:40:18 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return 0;
|
2006-01-12 19:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub ndbd_start {
|
|
|
|
my ($cluster, $ndbd)= @_;
|
|
|
|
|
|
|
|
mtr_verbose("ndbd_start");
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $dir= $ndbd->value("DataDir");
|
|
|
|
mkpath($dir) unless -d $dir;
|
2006-01-12 19:51:02 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $args;
|
2006-05-18 23:35:17 +02:00
|
|
|
mtr_init_args(\$args);
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
|
2006-05-18 23:35:17 +02:00
|
|
|
mtr_add_arg($args, "--nodaemon");
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# > 5.0 { 'character-sets-dir' => \&fix_charset_dir },
|
2006-05-18 23:35:17 +02:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $path_ndbd_log= "$dir/ndbd.log";
|
|
|
|
my $proc= My::SafeProcess->new
|
|
|
|
(
|
|
|
|
name => $ndbd->after('cluster_config.'),
|
|
|
|
path => $exe_ndbd,
|
|
|
|
args => \$args,
|
|
|
|
output => $path_ndbd_log,
|
|
|
|
error => $path_ndbd_log,
|
|
|
|
append => 1,
|
|
|
|
verbose => $opt_verbose,
|
|
|
|
);
|
|
|
|
mtr_verbose("Started $proc");
|
2006-07-20 13:23:45 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
$ndbd->{proc}= $proc;
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return;
|
2006-01-12 19:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub ndbcluster_start ($) {
|
2006-05-18 23:35:17 +02:00
|
|
|
my $cluster= shift;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("ndbcluster_start '".$cluster->name()."'");
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $ndb_mgmd ( in_cluster($cluster, ndb_mgmds()) )
|
2006-01-13 03:13:58 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
next if started($ndb_mgmd);
|
|
|
|
ndb_mgmd_start($cluster, $ndb_mgmd);
|
2006-01-13 03:13:58 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $ndbd ( in_cluster($cluster, ndbds()) )
|
2006-05-18 23:35:17 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
next if started($ndbd);
|
|
|
|
ndbd_start($cluster, $ndbd);
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
|
|
|
|
2006-01-12 19:51:02 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# Run the collected tests
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
my $suite_timeout_proc;
|
|
|
|
sub run_tests {
|
|
|
|
my ($tests)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report();
|
|
|
|
mtr_print_thick_line();
|
|
|
|
mtr_print_header();
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
$suite_timeout_proc= My::SafeProcess->timer($opt_suite_timeout* 60);
|
|
|
|
foreach my $tinfo ( @$tests )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
if (run_testcase_check_skip_test($tinfo))
|
2005-02-03 21:13:27 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
next;
|
2005-02-03 21:13:27 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
run_testcase($tinfo);
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
# Kill the test suite timer
|
|
|
|
$suite_timeout_proc->kill();
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_print_line();
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
stop_all_servers();
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_gcov )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
gcov_collect(); # collect coverage information
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report_stats($tests);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub create_config_file_for_extern {
|
|
|
|
my %opts=
|
|
|
|
(
|
|
|
|
socket => '/tmp/mysqld.sock',
|
|
|
|
port => 3306,
|
|
|
|
user => 'test',
|
|
|
|
password => '',
|
|
|
|
@_
|
|
|
|
);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Creating my.cnf file for extern server...");
|
|
|
|
my $F= IO::File->new($path_config_file, "w")
|
|
|
|
or mtr_error("Can't write to $path_config_file: $!");
|
|
|
|
|
|
|
|
print $F "[client]\n";
|
|
|
|
while (my ($option, $value)= each( %opts )) {
|
|
|
|
print $F "$option= $value\n";
|
|
|
|
mtr_report(" $option= $value");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
print $F <<EOF
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# binlog reads from [client] and [mysqlbinlog]
|
|
|
|
[mysqlbinlog]
|
|
|
|
character-sets-dir= $path_charsetsdir
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# mysql_fix_privilege_tables.sh don't read from [client]
|
|
|
|
[mysql_fix_privilege_tables]
|
|
|
|
socket = $opts{'socket'}
|
|
|
|
port = $opts{'port'}
|
|
|
|
user = $opts{'user'}
|
|
|
|
password = $opts{'password'}
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
EOF
|
|
|
|
;
|
2005-08-18 00:16:44 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
$F= undef; # Close file
|
|
|
|
}
|
2006-07-06 17:40:36 +02:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Kill processes left from previous runs, normally
|
|
|
|
# there should be none so make sure to warn
|
|
|
|
# if there is one
|
|
|
|
#
|
|
|
|
sub kill_leftovers ($) {
|
|
|
|
my $rundir= shift;
|
|
|
|
return unless ( -d $rundir );
|
|
|
|
|
|
|
|
mtr_report("Checking leftover processes...");
|
|
|
|
|
|
|
|
# Scan the "run" directory for process id's to kill
|
|
|
|
opendir(RUNDIR, $rundir)
|
|
|
|
or mtr_error("kill_leftovers, can't open dir \"$rundir\": $!");
|
|
|
|
while ( my $elem= readdir(RUNDIR) )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Only read pid from files that end with .pid
|
|
|
|
if ( $elem =~ /.*[.]pid$/ )
|
2006-08-23 15:35:24 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my $pidfile= "$rundir/$elem";
|
|
|
|
next unless -f $pidfile;
|
|
|
|
my $pid= mtr_fromfile($pidfile);
|
|
|
|
unlink($pidfile);
|
|
|
|
unless ($pid=~ /^(\d+)/){
|
|
|
|
# The pid was not a valid number
|
|
|
|
mtr_warning("Got invalid pid '$pid' from '$elem'");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
mtr_report(" - found old pid $pid in '$elem', killing it...");
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $ret= kill(9, $pid);
|
|
|
|
if ($ret == 0) {
|
|
|
|
mtr_report(" process did not exist!");
|
|
|
|
next;
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $check_counter= 100;
|
|
|
|
while ($ret > 0 and $check_counter--) {
|
|
|
|
mtr_milli_sleep(100);
|
|
|
|
$ret= kill(0, $pid);
|
|
|
|
}
|
|
|
|
mtr_report($check_counter ? " ok!" : " failed!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mtr_warning("Found non pid file '$elem' in '$rundir'")
|
|
|
|
if -f "$rundir/$elem";
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
closedir(RUNDIR);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Check that all the ports that are going to
|
|
|
|
# be used are free
|
|
|
|
#
|
|
|
|
sub check_ports_free
|
|
|
|
{
|
|
|
|
my @ports_to_check;
|
|
|
|
for ($opt_baseport..$opt_baseport+9){
|
|
|
|
push(@ports_to_check, $_);
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Checking ports...");
|
|
|
|
# print "@ports_to_check\n";
|
|
|
|
foreach my $port (@ports_to_check){
|
|
|
|
if (mtr_ping_port($port)){
|
|
|
|
mtr_report(" - 'localhost:$port' was not free");
|
|
|
|
return 1; # One port was not free
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return 0; # All ports free
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub initialize_servers {
|
2006-10-06 01:22:33 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( using_extern() )
|
2006-11-28 13:57:07 +01:00
|
|
|
{
|
|
|
|
# Running against an already started server, if the specified
|
|
|
|
# vardir does not already exist it should be created
|
|
|
|
if ( ! -d $opt_vardir )
|
|
|
|
{
|
|
|
|
setup_vardir();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-28 10:08:26 +02:00
|
|
|
mtr_verbose("No need to create '$opt_vardir' it already exists");
|
2006-11-28 13:57:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-04-21 18:48:49 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Kill leftovers from previous run
|
|
|
|
# using any pidfiles found in var/run
|
|
|
|
kill_leftovers("$opt_vardir/run");
|
|
|
|
|
|
|
|
if (check_ports_free()){
|
|
|
|
# Some port was not free(which one has already been printed)
|
|
|
|
mtr_error("Some port(s) was not free")
|
|
|
|
}
|
2006-08-30 21:09:47 +02:00
|
|
|
|
2006-10-12 11:29:13 +02:00
|
|
|
if ( ! $opt_start_dirty )
|
2006-04-21 18:48:49 +02:00
|
|
|
{
|
2006-11-28 13:57:07 +01:00
|
|
|
remove_stale_vardir();
|
|
|
|
setup_vardir();
|
|
|
|
|
2006-04-21 18:48:49 +02:00
|
|
|
mysql_install_db();
|
|
|
|
}
|
2006-11-01 18:41:09 +01:00
|
|
|
}
|
2006-11-28 13:57:07 +01:00
|
|
|
check_running_as_root();
|
2007-08-03 12:36:32 +02:00
|
|
|
|
|
|
|
mtr_log_init("$opt_vardir/log/mysql-test-run.log");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Copy the reference database into selected datadir
|
|
|
|
#
|
|
|
|
sub copy_install_db ($) {
|
|
|
|
my $path_data_dir= shift;
|
2006-08-31 20:58:00 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Don't install over another db
|
|
|
|
mtr_error("There is already an installed db in '$path_data_dir'")
|
|
|
|
if -d $path_data_dir;
|
2006-08-31 20:58:00 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# copy the installed db into place
|
|
|
|
copytree("$opt_vardir/install.db", $path_data_dir);
|
2006-08-31 20:58:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mysql_install_db {
|
|
|
|
my $data_dir= "$opt_vardir/install.db";
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Installing system database...");
|
2005-02-07 20:32:56 +01:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
my $args;
|
2004-12-30 16:34:01 +01:00
|
|
|
mtr_init_args(\$args);
|
|
|
|
mtr_add_arg($args, "--no-defaults");
|
|
|
|
mtr_add_arg($args, "--bootstrap");
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--basedir=%s", $basedir);
|
2004-12-30 16:34:01 +01:00
|
|
|
mtr_add_arg($args, "--datadir=%s", $data_dir);
|
2007-04-13 19:23:02 +02:00
|
|
|
mtr_add_arg($args, "--loose-skip-innodb");
|
|
|
|
mtr_add_arg($args, "--loose-skip-ndbcluster");
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
2006-06-04 17:52:22 +02:00
|
|
|
mtr_add_arg($args, "--tmpdir=.");
|
2006-10-24 21:02:04 +02:00
|
|
|
mtr_add_arg($args, "--core-file");
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-09-19 18:39:04 +02:00
|
|
|
if ( $opt_debug )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap.trace",
|
|
|
|
$path_vardir_trace);
|
2006-09-19 18:39:04 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--language=%s", $path_language);
|
|
|
|
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-01-10 03:22:01 +01:00
|
|
|
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
|
|
|
|
# configure --disable-grant-options), mysqld will not recognize the
|
|
|
|
# --bootstrap or --skip-grant-tables options. The user can set
|
|
|
|
# MYSQLD_BOOTSTRAP to the full path to a mysqld which does accept
|
|
|
|
# --bootstrap, to accommodate this.
|
|
|
|
my $exe_mysqld_bootstrap = $ENV{'MYSQLD_BOOTSTRAP'} || $exe_mysqld;
|
|
|
|
|
2007-02-20 12:48:15 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Create the bootstrap.sql file
|
|
|
|
# ----------------------------------------------------------------------
|
2007-02-28 14:26:58 +01:00
|
|
|
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
|
2007-02-26 11:49:24 +01:00
|
|
|
|
|
|
|
# Use the mysql database for system tables
|
|
|
|
mtr_tofile($bootstrap_sql_file, "use mysql");
|
|
|
|
|
2007-02-28 14:26:58 +01:00
|
|
|
# Add the offical mysql system tables
|
|
|
|
# for a production system
|
2007-02-26 11:49:24 +01:00
|
|
|
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
|
|
|
|
$bootstrap_sql_file);
|
|
|
|
|
2007-02-28 14:26:58 +01:00
|
|
|
# Add the mysql system tables initial data
|
|
|
|
# for a production system
|
|
|
|
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables_data.sql",
|
|
|
|
$bootstrap_sql_file);
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# Add test data for timezone - this is just a subset, on a real
|
|
|
|
# system these tables will be populated either by mysql_tzinfo_to_sql
|
|
|
|
# or by downloading the timezone table package from our website
|
|
|
|
mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql",
|
|
|
|
$bootstrap_sql_file);
|
|
|
|
|
|
|
|
# Fill help tables, just an empty file when running from bk repo
|
|
|
|
# but will be replaced by a real fill_help_tables.sql when
|
|
|
|
# building the source dist
|
|
|
|
mtr_appendfile_to_file("$path_sql_dir/fill_help_tables.sql",
|
|
|
|
$bootstrap_sql_file);
|
|
|
|
|
2007-10-04 11:30:30 +02:00
|
|
|
# Remove anonymous users
|
2007-08-24 15:43:45 +02:00
|
|
|
mtr_tofile($bootstrap_sql_file,
|
|
|
|
"DELETE FROM mysql.user where user= '';");
|
|
|
|
|
2006-04-24 11:26:41 +02:00
|
|
|
# Log bootstrap command
|
|
|
|
my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log";
|
|
|
|
mtr_tofile($path_bootstrap_log,
|
2007-01-10 03:22:01 +01:00
|
|
|
"$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
|
2006-04-24 11:26:41 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Create directories mysql and test
|
|
|
|
mkpath("$data_dir/mysql");
|
|
|
|
mkpath("$data_dir/test");
|
|
|
|
|
|
|
|
if ( My::SafeProcess->run
|
|
|
|
(
|
|
|
|
name => "bootstrap",
|
|
|
|
path => $exe_mysqld_bootstrap,
|
|
|
|
args => \$args,
|
|
|
|
input => $bootstrap_sql_file,
|
|
|
|
output => $path_bootstrap_log,
|
|
|
|
error => $path_bootstrap_log,
|
|
|
|
append => 1,
|
|
|
|
) != 0)
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2005-01-01 19:27:41 +01:00
|
|
|
mtr_error("Error executing mysqld --bootstrap\n" .
|
2007-02-28 14:26:58 +01:00
|
|
|
"Could not install system database from $bootstrap_sql_file\n" .
|
|
|
|
"see $path_bootstrap_log for errors");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-21 09:53:04 +02:00
|
|
|
sub run_testcase_check_skip_test($)
|
|
|
|
{
|
|
|
|
my ($tinfo)= @_;
|
2005-02-08 06:11:05 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# If marked to skip, just print out and return.
|
|
|
|
# Note that a test case not marked as 'skip' can still be
|
|
|
|
# skipped later, because of the test case itself in cooperation
|
|
|
|
# with the mysqltest program tells us so.
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
if ( $tinfo->{'skip'} )
|
|
|
|
{
|
|
|
|
mtr_report_test_skipped($tinfo);
|
2006-08-21 09:53:04 +02:00
|
|
|
return 1;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-10-05 13:09:06 +02:00
|
|
|
if ($tinfo->{'ndb_test'})
|
2006-03-07 19:44:58 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $cluster ( clusters() )
|
2006-10-05 13:09:06 +02:00
|
|
|
{
|
2006-10-23 12:02:56 +02:00
|
|
|
# If test needs this cluster, check binaries was found ok
|
|
|
|
if ( $cluster->{'executable_setup_failed'} )
|
|
|
|
{
|
|
|
|
$tinfo->{comment}=
|
|
|
|
"Failed to find cluster binaries";
|
|
|
|
mtr_report_test_failed($tinfo);
|
|
|
|
return 1;
|
|
|
|
}
|
2006-03-08 19:15:56 +01:00
|
|
|
}
|
2006-03-07 19:44:58 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-19 11:08:41 +01:00
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
sub run_query {
|
|
|
|
my ($tinfo, $mysqld, $query)= @_;
|
2007-12-19 11:08:41 +01:00
|
|
|
|
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
|
|
|
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
|
2008-01-07 19:44:48 +01:00
|
|
|
|
|
|
|
mtr_add_arg($args, "-e %s", $query);
|
|
|
|
|
2007-12-19 11:08:41 +01:00
|
|
|
my $res= My::SafeProcess->run
|
|
|
|
(
|
2008-01-07 19:44:48 +01:00
|
|
|
name => "run_query -> ".$mysqld->name(),
|
2007-12-19 11:08:41 +01:00
|
|
|
path => $exe_mysql,
|
|
|
|
args => \$args,
|
2008-01-07 19:44:48 +01:00
|
|
|
output => '/dev/null',
|
|
|
|
error => '/dev/null'
|
2007-12-12 18:19:24 +01:00
|
|
|
);
|
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
return $res
|
2006-08-21 09:53:04 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
|
2006-08-23 15:35:24 +02:00
|
|
|
sub do_before_run_mysqltest($)
|
|
|
|
{
|
|
|
|
my $tinfo= shift;
|
|
|
|
|
2006-10-06 00:57:10 +02:00
|
|
|
# Remove old files produced by mysqltest
|
2007-06-27 14:28:02 +02:00
|
|
|
my $base_file= mtr_match_extension($tinfo->{'result_file'},
|
|
|
|
"result"); # Trim extension
|
|
|
|
unlink("$base_file.reject");
|
|
|
|
unlink("$base_file.progress");
|
|
|
|
unlink("$base_file.log");
|
|
|
|
unlink("$base_file.warnings");
|
2006-08-23 15:35:24 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $mysql_version_id < 50000 ) {
|
|
|
|
# Set environment variable NDB_STATUS_OK to 1
|
|
|
|
# if script decided to run mysqltest cluster _is_ installed ok
|
|
|
|
$ENV{'NDB_STATUS_OK'} = "1";
|
|
|
|
} elsif ( $mysql_version_id < 50100 ) {
|
|
|
|
# Set environment variable NDB_STATUS_OK to YES
|
|
|
|
# if script decided to run mysqltest cluster _is_ installed ok
|
|
|
|
$ENV{'NDB_STATUS_OK'} = "YES";
|
2006-10-05 12:28:23 +02:00
|
|
|
}
|
2006-08-23 15:35:24 +02:00
|
|
|
}
|
2005-03-21 16:01:39 +01:00
|
|
|
|
2006-08-25 15:17:03 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub run_check_testcase_all($$)
|
2006-11-28 19:54:16 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my ($tinfo, $mode)= @_;
|
2007-12-19 10:25:21 +01:00
|
|
|
my $result;
|
2006-11-28 19:54:16 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $mysqld ( mysqlds() )
|
2007-04-16 16:08:29 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( defined $mysqld->{'proc'} )
|
|
|
|
{
|
|
|
|
if (run_check_testcase($tinfo, $mode, $mysqld))
|
|
|
|
{
|
|
|
|
# Check failed, mark the test case with that info
|
|
|
|
$tinfo->{'check_testcase_failed'}= 1;
|
2007-12-19 10:25:21 +01:00
|
|
|
$result= 1;
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
}
|
2007-04-16 16:08:29 +02:00
|
|
|
}
|
2007-12-19 10:25:21 +01:00
|
|
|
return $result;
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
2007-04-16 16:08:29 +02:00
|
|
|
|
2006-11-28 19:54:16 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mark_log {
|
|
|
|
my ($log, $tinfo)= @_;
|
|
|
|
my $log_msg= "CURRENT_TEST: $tinfo->{name}\n";
|
|
|
|
mtr_tofile($log, $log_msg);
|
2006-11-28 19:54:16 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2006-10-13 10:41:40 +02:00
|
|
|
sub find_testcase_skipped_reason($)
|
|
|
|
{
|
|
|
|
my ($tinfo)= @_;
|
|
|
|
|
2007-06-13 10:35:20 +02:00
|
|
|
# Set default message
|
|
|
|
$tinfo->{'comment'}= "Detected by testcase(no log file)";
|
|
|
|
|
2007-06-13 10:36:47 +02:00
|
|
|
# Open mysqltest-time(the mysqltest log file)
|
2007-06-13 10:35:20 +02:00
|
|
|
my $F= IO::File->new($path_timefile)
|
|
|
|
or return;
|
2006-10-13 10:41:40 +02:00
|
|
|
my $reason;
|
|
|
|
|
|
|
|
while ( my $line= <$F> )
|
|
|
|
{
|
2006-11-23 15:41:21 +01:00
|
|
|
# Look for "reason: <reason for skipping test>"
|
2006-10-13 10:41:40 +02:00
|
|
|
if ( $line =~ /reason: (.*)/ )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-10-13 10:41:40 +02:00
|
|
|
$reason= $1;
|
|
|
|
}
|
|
|
|
}
|
2006-02-09 09:40:48 +01:00
|
|
|
|
2006-10-13 10:41:40 +02:00
|
|
|
if ( ! $reason )
|
|
|
|
{
|
|
|
|
mtr_warning("Could not find reason for skipping test in $path_timefile");
|
|
|
|
$reason= "Detected by testcase(reason unknown) ";
|
2006-08-23 15:35:24 +02:00
|
|
|
}
|
2006-10-13 10:41:40 +02:00
|
|
|
$tinfo->{'comment'}= $reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Return timezone value of tinfo or default value
|
|
|
|
sub timezone {
|
|
|
|
my ($tinfo)= @_;
|
|
|
|
return $tinfo->{timezone} || "GMT-3";
|
|
|
|
}
|
2006-08-21 09:53:04 +02:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Storage for changed environment variables
|
|
|
|
my %old_env;
|
2006-08-21 09:53:04 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Run a single test case
|
|
|
|
#
|
2006-08-21 09:53:04 +02:00
|
|
|
sub run_testcase ($) {
|
|
|
|
my $tinfo= shift;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Running test:", $tinfo->{name});
|
|
|
|
|
2006-10-20 17:09:07 +02:00
|
|
|
# -------------------------------------------------------
|
|
|
|
# Init variables that can change between each test case
|
|
|
|
# -------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
my $timezone= timezone($tinfo);
|
|
|
|
$ENV{'TZ'}= $timezone;
|
|
|
|
mtr_verbose("Setting timezone: $timezone");
|
2006-10-20 17:09:07 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( ! using_extern() )
|
2006-08-16 10:30:22 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my @restart= servers_need_restart($tinfo);
|
|
|
|
if ( @restart != 0) {
|
|
|
|
stop_servers($tinfo, @restart );
|
2005-08-29 20:28:42 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( started(all_servers()) == 0 )
|
|
|
|
{
|
|
|
|
# Restore old ENV
|
|
|
|
while (my ($option, $value)= each( %old_env )) {
|
|
|
|
if (defined $value){
|
|
|
|
mtr_verbose("Restoring $option to $value");
|
|
|
|
$ENV{$option}= $value;
|
|
|
|
} else {
|
|
|
|
mtr_verbose("Removing $option");
|
|
|
|
delete($ENV{$option});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%old_env= ();
|
|
|
|
|
|
|
|
mtr_verbose("Generating my.cnf from '$tinfo->{template_path}'");
|
|
|
|
|
|
|
|
# Generate new config file from template
|
|
|
|
$config= My::ConfigFactory->new_config
|
|
|
|
( {
|
|
|
|
basedir => $basedir,
|
|
|
|
template_path => $tinfo->{template_path},
|
|
|
|
extra_template_path => $tinfo->{extra_template_path},
|
|
|
|
vardir => $opt_vardir,
|
|
|
|
tmpdir => $opt_tmpdir,
|
|
|
|
baseport => $opt_baseport,
|
|
|
|
#hosts => [ 'host1', 'host2' ],
|
|
|
|
user => $opt_user,
|
|
|
|
password => '',
|
2007-12-13 15:02:50 +01:00
|
|
|
ssl => $opt_ssl_supported,
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
);
|
2006-11-28 19:54:16 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Write the new my.cnf
|
|
|
|
$config->save($path_config_file);
|
2006-11-28 19:54:16 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Remember current config so a restart can occur when a test need
|
|
|
|
# to use a different one
|
|
|
|
$current_config_name= $tinfo->{template_path};
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set variables in the ENV section
|
|
|
|
#
|
|
|
|
foreach my $option ($config->options_in_group("ENV"))
|
|
|
|
{
|
|
|
|
# Save old value to restore it before next time
|
|
|
|
$old_env{$option->name()}= $ENV{$option->name()};
|
|
|
|
|
|
|
|
mtr_verbose($option->name(), "=",$option->value());
|
|
|
|
$ENV{$option->name()}= $option->value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Write start of testcase to log
|
|
|
|
mark_log($path_current_test_log, $tinfo);
|
|
|
|
|
|
|
|
if (start_servers($tinfo))
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2006-10-06 17:15:26 +02:00
|
|
|
report_failure_and_restart($tinfo);
|
|
|
|
return 1;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2006-08-16 10:30:22 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# If --start or --start-dirty given, stop here to let user manually
|
2006-04-21 04:17:14 +02:00
|
|
|
# run tests
|
2005-08-17 03:35:50 +02:00
|
|
|
# ----------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_start or $opt_start_dirty )
|
2005-08-17 03:35:50 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("\nServers started, sleeping");
|
|
|
|
sleep(1) while (1);
|
2005-08-17 03:35:50 +02:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $test_timeout_proc= My::SafeProcess->timer($opt_testcase_timeout * 60);
|
|
|
|
|
|
|
|
do_before_run_mysqltest($tinfo);
|
|
|
|
|
|
|
|
if ( $opt_check_testcases )
|
|
|
|
{
|
|
|
|
run_check_testcase_all($tinfo, "before")
|
|
|
|
}
|
2006-11-21 22:12:45 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $test= start_mysqltest($tinfo);
|
2006-11-21 21:32:58 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
my $proc= My::SafeProcess->wait_any();
|
|
|
|
unless ( defined $proc )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_error("wait_any failed");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Got $proc");
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# Stop the test case timer
|
|
|
|
# ----------------------------------------------------
|
|
|
|
$test_timeout_proc->kill();
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# Was it the test program that exited
|
|
|
|
# ----------------------------------------------------
|
|
|
|
if ($proc eq $test)
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my $res= $test->exit_status();
|
|
|
|
|
|
|
|
if ( $res == 0 )
|
|
|
|
{
|
|
|
|
mtr_report_test_passed($tinfo, $opt_timer);
|
|
|
|
|
|
|
|
if ( $opt_check_testcases )
|
|
|
|
{
|
2007-12-19 10:25:21 +01:00
|
|
|
if (run_check_testcase_all($tinfo, "after"))
|
|
|
|
{
|
|
|
|
# Stop all servers that are known to be running
|
|
|
|
stop_all_servers();
|
|
|
|
mtr_report("Resuming tests...\n");
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ( $res == 62 )
|
|
|
|
{
|
|
|
|
# Testcase itself tell us to skip this one
|
|
|
|
$tinfo->{skip_detected_by_test}= 1;
|
|
|
|
# Try to get reason from mysqltest.log
|
|
|
|
find_testcase_skipped_reason($tinfo);
|
|
|
|
mtr_report_test_skipped($tinfo);
|
|
|
|
}
|
|
|
|
elsif ( $res == 65 )
|
|
|
|
{
|
|
|
|
# Testprogram killed by signal
|
|
|
|
$tinfo->{comment}=
|
|
|
|
"testprogram crashed(returned code $res)";
|
|
|
|
report_failure_and_restart($tinfo);
|
|
|
|
}
|
|
|
|
elsif ( $res == 1 )
|
|
|
|
{
|
|
|
|
# Test case failure reported by mysqltest
|
|
|
|
report_failure_and_restart($tinfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# mysqltest failed, probably crashed
|
|
|
|
$tinfo->{comment}=
|
|
|
|
"mysqltest failed with unexpected return code $res";
|
|
|
|
report_failure_and_restart($tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Save info from this testcase run to mysqltest.log
|
|
|
|
my $path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
|
|
|
|
mtr_appendfile_to_file($path_current_test_log, $path_mysqltest_log)
|
|
|
|
if -f $path_current_test_log;
|
|
|
|
mtr_appendfile_to_file($path_timefile, $path_mysqltest_log)
|
|
|
|
if -f $path_timefile;
|
|
|
|
|
|
|
|
# Remove the file that mysqltest writes info to
|
|
|
|
unlink($path_timefile);
|
|
|
|
# Remove the file that mysql-test-run writes info to
|
|
|
|
unlink($path_current_test_log);
|
|
|
|
|
|
|
|
return;
|
2006-07-19 14:25:52 +02:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# Check if it was an expected crash
|
|
|
|
# ----------------------------------------------------
|
|
|
|
if ( check_expected_crash_and_restart($proc) )
|
2005-08-18 00:16:44 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
next;
|
2005-08-18 00:16:44 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# It's not mysqltest that has exited, kill it
|
|
|
|
# ----------------------------------------------------
|
|
|
|
$test->kill();
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# Check if it was a server that died
|
|
|
|
# ----------------------------------------------------
|
|
|
|
if ( grep($proc eq $_, started(all_servers())) )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Server failed, probably crashed
|
|
|
|
$tinfo->{comment}=
|
|
|
|
"Server failed during test run";
|
|
|
|
|
2006-10-17 10:31:06 +02:00
|
|
|
report_failure_and_restart($tinfo);
|
2007-12-12 18:19:24 +01:00
|
|
|
return;
|
2006-10-17 10:31:06 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# Check if testcase timer expired
|
|
|
|
# ----------------------------------------------------
|
|
|
|
if ( $proc eq $test_timeout_proc )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Test case timeout!");
|
|
|
|
$tinfo->{'timeout'}= 1; # Mark as timeout
|
2005-02-03 21:13:27 +01:00
|
|
|
report_failure_and_restart($tinfo);
|
2007-12-12 18:19:24 +01:00
|
|
|
return;
|
2005-02-03 21:13:27 +01:00
|
|
|
}
|
2005-08-29 20:28:42 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# ----------------------------------------------------
|
|
|
|
# Check if test suite timer expired
|
|
|
|
# ----------------------------------------------------
|
|
|
|
if ( $proc eq $suite_timeout_proc )
|
|
|
|
{
|
|
|
|
mtr_report("Test suite timeout! Terminating...");
|
|
|
|
exit(1);
|
|
|
|
}
|
2006-11-27 00:47:38 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_error("Unhandled process $proc exited");
|
2005-08-29 20:28:42 +02:00
|
|
|
}
|
2005-02-03 21:13:27 +01:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2006-03-13 10:30:36 +01:00
|
|
|
|
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# Loop through our list of processes and look for and entry
|
|
|
|
# with the provided pid, if found check for the file indicating
|
|
|
|
# expected crash and restart it.
|
2006-03-13 10:30:36 +01:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
sub check_expected_crash_and_restart {
|
|
|
|
my ($proc)= @_;
|
2006-03-13 10:30:36 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $mysqld ( mysqlds() )
|
2006-03-13 10:30:36 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
next unless ( $mysqld->{proc} eq $proc );
|
|
|
|
|
|
|
|
# Check if crash expected by looking at the .expect file
|
|
|
|
# in var/tmp
|
|
|
|
my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
|
|
|
|
if ( -f $expect_file )
|
|
|
|
{
|
|
|
|
mtr_verbose("Crash was expected, file $expect_file exists");
|
|
|
|
# Start server with same settings as last time
|
|
|
|
mysqld_start($mysqld, $mysqld->{'started_opts'});
|
|
|
|
unlink($expect_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2006-03-13 10:30:36 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# Not an expected crash
|
|
|
|
return 0;
|
2006-03-13 10:30:36 +01:00
|
|
|
}
|
|
|
|
|
2006-03-22 22:34:48 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Save any interesting files in the data_dir
|
|
|
|
# before the data dir is removed.
|
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
sub save_files_after_test_failure($$) {
|
2006-03-22 22:34:48 +01:00
|
|
|
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*") )
|
|
|
|
{
|
2007-01-19 09:41:08 +01:00
|
|
|
last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core;
|
2006-03-22 22:34:48 +01:00
|
|
|
my $core_name= basename($core_file);
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report(" - saving '$core_name'");
|
|
|
|
mkpath($save_name) if ! -d $save_name;
|
2006-03-22 22:34:48 +01:00
|
|
|
rename("$core_file", "$save_name/$core_name");
|
2007-01-19 09:41:08 +01:00
|
|
|
++$num_saved_cores;
|
2006-03-22 22:34:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub after_test_failure ($) {
|
2006-03-22 22:34:48 +01:00
|
|
|
my $test_name= shift;
|
2006-03-13 10:30:36 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Cleaning datadirs...");
|
2006-03-13 10:30:36 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $mysqld ( mysqlds() )
|
|
|
|
{
|
|
|
|
my $data_dir= $mysqld->value('datadir');
|
|
|
|
my $name= basename($data_dir);
|
|
|
|
save_files_after_test_failure($test_name, $data_dir);
|
|
|
|
mtr_debug("Removing '$data_dir'");
|
|
|
|
rmtree($data_dir);
|
|
|
|
}
|
2006-03-13 11:30:16 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Remove the ndb_*_fs dirs for all ndbd nodes
|
|
|
|
# forcing a clean start of ndb next time
|
|
|
|
foreach my $cluster ( clusters() )
|
|
|
|
{
|
|
|
|
foreach my $ndbd ( ndbds($cluster) )
|
2006-06-10 21:20:14 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my $datadir= $ndbd->value('DataDir');
|
|
|
|
foreach my $fs_dir ( glob("$datadir/ndb_*_fs") ) {
|
|
|
|
if (-d $fs_dir) {
|
|
|
|
rmtree($fs_dir);
|
|
|
|
mtr_debug("Removing '$fs_dir'");
|
|
|
|
}
|
2006-03-13 11:30:16 +01:00
|
|
|
}
|
2006-03-13 10:30:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2005-02-03 21:13:27 +01:00
|
|
|
sub report_failure_and_restart ($) {
|
|
|
|
my $tinfo= shift;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report_test_failed($tinfo, $path_timefile);
|
2005-02-03 21:13:27 +01:00
|
|
|
print "\n";
|
2006-03-13 10:30:36 +01:00
|
|
|
if ( $opt_force )
|
2005-02-03 21:13:27 +01:00
|
|
|
{
|
2006-06-10 20:59:14 +02:00
|
|
|
# Stop all servers that are known to be running
|
|
|
|
stop_all_servers();
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
after_test_failure($tinfo->{'name'});
|
|
|
|
mtr_report("Resuming tests...\n");
|
2006-03-13 10:30:36 +01:00
|
|
|
return;
|
2005-02-03 21:13:27 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_error("Test '$tinfo->{'name'}' failed.",
|
|
|
|
"To continue, re-run with '--force'");
|
2007-05-01 20:05:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub run_sh_script {
|
|
|
|
my ($script)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return 0 unless defined $script;
|
2007-05-28 18:03:24 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Running '$script'");
|
|
|
|
my $ret= system("/bin/sh $script") >> 8;
|
|
|
|
return $ret;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mysqld_stop {
|
|
|
|
my $mysqld= shift or die "usage: mysqld_stop(<mysqld>)";
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
2007-05-28 18:03:24 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--no-defaults");
|
|
|
|
mtr_add_arg($args, "--user=%s", $opt_user);
|
|
|
|
mtr_add_arg($args, "--password=");
|
|
|
|
mtr_add_arg($args, "--port=%d", $mysqld->value('port'));
|
|
|
|
mtr_add_arg($args, "--host=%s", $mysqld->value('#host'));
|
|
|
|
mtr_add_arg($args, "--connect_timeout=20");
|
|
|
|
mtr_add_arg($args, "--protocol=tcp");
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "shutdown");
|
2006-10-04 23:05:12 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
My::SafeProcess->run
|
|
|
|
(
|
|
|
|
name => "mysqladmin shutdown ".$mysqld->name(),
|
|
|
|
path => $exe_mysqladmin,
|
|
|
|
args => \$args,
|
|
|
|
error => "/dev/null",
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
);
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mysqld_arguments ($$$) {
|
2005-02-03 21:13:27 +01:00
|
|
|
my $args= shift;
|
2007-03-15 09:58:39 +01:00
|
|
|
my $mysqld= shift;
|
2008-01-07 19:44:48 +01:00
|
|
|
my $extra_opts= shift;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
my $prefix= ""; # If mysqltest server arg
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_embedded_server )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
|
|
|
$prefix= "--server-arg=";
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "%s--defaults-file=%s", $prefix, $path_config_file);
|
|
|
|
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
|
2007-09-21 17:52:02 +02:00
|
|
|
|
2007-10-30 15:22:52 +01:00
|
|
|
# When mysqld is run by a root user(euid is 0), it will fail
|
2007-11-23 15:54:11 +01:00
|
|
|
# to start unless we specify what user to run as, see BUG#30630
|
|
|
|
my $euid= $>;
|
2007-12-12 18:19:24 +01:00
|
|
|
if (!$is_win32 and $euid == 0 and
|
2008-01-07 19:44:48 +01:00
|
|
|
(grep(/^--user/, @$extra_opts)) == 0) {
|
2007-11-23 15:54:11 +01:00
|
|
|
mtr_add_arg($args, "%s--user=root", $prefix);
|
2007-10-30 15:22:52 +01:00
|
|
|
}
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
if ( $opt_valgrind_mysqld )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
|
|
|
mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
|
2006-11-07 16:09:32 +01:00
|
|
|
|
|
|
|
if ( $mysql_version_id < 50100 )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "%s--skip-bdb", $prefix);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-03-15 09:58:39 +01:00
|
|
|
if ( $mysql_version_id >= 50106 )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Turn on logging to both tables and file
|
2007-03-15 09:58:39 +01:00
|
|
|
mtr_add_arg($args, "%s--log-output=table,file", $prefix);
|
|
|
|
}
|
|
|
|
|
2007-12-13 11:28:34 +01:00
|
|
|
# Check if "extra_opt" contains skip-log-bin
|
2008-01-07 19:44:48 +01:00
|
|
|
my $skip_binlog= grep(/^(--|--loose-)skip-log-bin/, @$extra_opts);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
if ( $opt_debug )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s.trace",
|
|
|
|
$prefix, $path_vardir_trace, $mysqld->name());
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Indicate to mysqld it will be debugged in debugger
|
2006-03-23 15:07:39 +01:00
|
|
|
if ( $glob_debugger )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
|
|
|
mtr_add_arg($args, "%s--gdb", $prefix);
|
|
|
|
}
|
|
|
|
|
2006-09-17 20:54:06 +02:00
|
|
|
my $found_skip_core= 0;
|
2008-01-07 19:44:48 +01:00
|
|
|
foreach my $arg ( @$extra_opts )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-03-15 09:58:39 +01:00
|
|
|
# Allow --skip-core-file to be set in <testname>-[master|slave].opt file
|
2006-09-17 20:54:06 +02:00
|
|
|
if ($arg eq "--skip-core-file")
|
|
|
|
{
|
|
|
|
$found_skip_core= 1;
|
|
|
|
}
|
2007-02-06 14:19:07 +01:00
|
|
|
elsif ($skip_binlog and mtr_match_prefix($arg, "--binlog-format"))
|
|
|
|
{
|
|
|
|
; # Dont add --binlog-format when running without binlog
|
|
|
|
}
|
2006-09-17 20:54:06 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "%s%s", $prefix, $arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !$found_skip_core )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "%s%s", $prefix, "--core-file");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $is_win32 ){
|
|
|
|
mtr_add_arg($args, "%s--log-error=%s", $prefix, $mysqld->{"path_myerr"});
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub mysqld_start ($$) {
|
2006-05-18 23:35:17 +02:00
|
|
|
my $mysqld= shift;
|
2008-01-07 19:44:48 +01:00
|
|
|
my $extra_opts= shift;
|
|
|
|
|
|
|
|
mtr_verbose(My::Options::toStr("mysqld_start", @$extra_opts));
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $exe= $exe_mysqld;
|
2006-05-18 23:35:17 +02:00
|
|
|
my $wait_for_pid_file= 1;
|
|
|
|
|
2006-10-20 17:09:07 +02:00
|
|
|
mtr_error("Internal error: mysqld should never be started for embedded")
|
2007-12-12 18:19:24 +01:00
|
|
|
if $opt_embedded_server;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $args;
|
2004-12-30 16:34:01 +01:00
|
|
|
mtr_init_args(\$args);
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
if ( $opt_valgrind_mysqld )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2005-09-17 01:09:32 +02:00
|
|
|
valgrind_arguments($args, \$exe);
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
mysqld_arguments($args,$mysqld,$extra_opts);
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $opt_gdb || $opt_manual_gdb )
|
2006-03-23 15:07:39 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
gdb_arguments(\$args, \$exe, $mysqld->name());
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
|
|
|
elsif ( $opt_ddd || $opt_manual_ddd )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
ddd_arguments(\$args, \$exe, $mysqld->name());
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
2006-04-04 09:49:32 +02:00
|
|
|
elsif ( $opt_debugger )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
debugger_arguments(\$args, \$exe, $mysqld->name());
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
2006-03-23 16:22:56 +01:00
|
|
|
elsif ( $opt_manual_debug )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
print "\nStart $mysqld->name() in your debugger\n" .
|
2006-03-23 16:22:56 +01:00
|
|
|
"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;
|
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
# Default to not wait until pid file has been created
|
|
|
|
$wait_for_pid_file= 0;
|
|
|
|
}
|
2006-03-23 15:07:39 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Remove the old pidfile if any
|
|
|
|
unlink($mysqld->value('pid-file'));
|
2007-08-29 17:54:02 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $output= $mysqld->value('log-error');
|
|
|
|
if ( $opt_valgrind and $opt_debug )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# When both --valgrind and --debug is selected, send
|
|
|
|
# all output to the trace file, making it possible to
|
|
|
|
# see the exact location where valgrind complains
|
|
|
|
$output= "$opt_vardir/log/".$mysqld->name().".trace";
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( defined $exe )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$mysqld->{'proc'}= My::SafeProcess->new
|
|
|
|
(
|
|
|
|
name => $mysqld->name(),
|
|
|
|
path => $exe,
|
|
|
|
args => \$args,
|
|
|
|
output => $output,
|
|
|
|
error => $output,
|
|
|
|
append => 1,
|
|
|
|
verbose => $opt_verbose,
|
|
|
|
host => undef,
|
|
|
|
shutdown => sub { mysqld_stop($mysqld) },
|
|
|
|
);
|
|
|
|
mtr_verbose("Started $mysqld->{proc}");
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $wait_for_pid_file &&
|
|
|
|
!sleep_until_file_created($mysqld->value('pid-file'),
|
|
|
|
$opt_start_timeout,
|
|
|
|
$mysqld->{'proc'}))
|
|
|
|
{
|
|
|
|
mtr_error("Failed to start mysqld $mysqld->name()");
|
|
|
|
}
|
2006-06-11 10:10:55 +02:00
|
|
|
|
|
|
|
# Remember options used when starting
|
2008-01-07 19:44:48 +01:00
|
|
|
$mysqld->{'started_opts'}= $extra_opts;
|
2006-06-11 10:10:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2006-05-18 23:35:17 +02:00
|
|
|
sub stop_all_servers () {
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("Stopping all servers...");
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Kill all started servers
|
|
|
|
My::SafeProcess::shutdown(0, # shutdown timeout 0 => kill
|
|
|
|
started(all_servers()));
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2008-01-08 11:11:06 +01:00
|
|
|
# Remove pidfiles
|
|
|
|
foreach my $server ( all_servers() )
|
|
|
|
{
|
|
|
|
my $pid_file= $server->if_exist('pid-file');
|
|
|
|
unlink($pid_file) if defined $pid_file;
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Mark servers as stopped
|
|
|
|
map($_->{proc}= undef, all_servers());
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Find out if server should be restarted for this test
|
|
|
|
sub server_need_restart {
|
|
|
|
my ($tinfo, $server)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( using_extern() )
|
2006-05-18 23:35:17 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("No restart: using extern");
|
|
|
|
return 0;
|
2006-10-11 14:50:19 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
if ( $opt_embedded_server )
|
2006-10-11 14:50:19 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("No start or restart for embedded server");
|
|
|
|
return 0;
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
if ( $tinfo->{'force_restart'} ) {
|
|
|
|
mtr_verbose("Restart: forced in .opt file");
|
|
|
|
return 1;
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
if ( $tinfo->{template_path} ne $current_config_name)
|
2006-06-11 10:10:55 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Restart: using different config file");
|
|
|
|
return 1;
|
2006-06-11 10:10:55 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
if ( $tinfo->{'master_sh'} || $tinfo->{'slave_sh'} )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Restart: script to run");
|
|
|
|
return 1;
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
if ( ! started($server) )
|
2006-05-19 17:19:57 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Restart: not started");
|
|
|
|
return 1;
|
2006-05-19 17:19:57 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
my $started_tinfo= $server->{'started_tinfo'};
|
|
|
|
if ( defined $started_tinfo )
|
2006-10-06 11:23:19 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# Check if timezone of test that server was started
|
|
|
|
# with differs from timezone of next test
|
|
|
|
if ( timezone($started_tinfo) ne timezone($tinfo) )
|
2006-11-17 10:46:21 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_verbose("Restart: Different timezone");
|
|
|
|
return 1;
|
2006-11-17 10:46:21 +01:00
|
|
|
}
|
2006-10-06 11:23:19 +02:00
|
|
|
}
|
2006-08-16 10:30:22 +02:00
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
my $is_mysqld= grep ($server eq $_, mysqlds());
|
2007-12-19 11:08:41 +01:00
|
|
|
if ($is_mysqld)
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2007-12-19 11:08:41 +01:00
|
|
|
# Check that running process was started with same options
|
|
|
|
# as the current test requires
|
2008-01-07 19:44:48 +01:00
|
|
|
my $extra_opts= get_extra_opts($server, $tinfo);
|
2007-12-19 11:08:41 +01:00
|
|
|
my $started_opts= $server->{'started_opts'};
|
2008-01-07 19:44:48 +01:00
|
|
|
|
|
|
|
if (!My::Options::same($started_opts, $extra_opts) )
|
2007-12-19 11:08:41 +01:00
|
|
|
{
|
2008-01-09 13:47:09 +01:00
|
|
|
my $use_dynamic_option_switch= 0;
|
|
|
|
return 1 if (!$use_dynamic_option_switch);
|
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
mtr_verbose(My::Options::toStr("started_opts", @$started_opts));
|
|
|
|
mtr_verbose(My::Options::toStr("extra_opts", @$extra_opts));
|
|
|
|
|
|
|
|
# Get diff and check if dynamic switch is possible
|
|
|
|
my @diff_opts= My::Options::diff($started_opts, $extra_opts);
|
|
|
|
mtr_verbose(My::Options::toStr("diff_opts", @diff_opts));
|
|
|
|
|
|
|
|
my $query= My::Options::toSQL(@diff_opts);
|
|
|
|
mtr_verbose("Attempting dynamic switch '$query'");
|
|
|
|
if (run_query($tinfo, $server, $query)){
|
2007-12-19 11:08:41 +01:00
|
|
|
mtr_verbose("Restart: running with different options '" .
|
2008-01-07 19:44:48 +01:00
|
|
|
join(" ", @{$extra_opts}) . "' != '" .
|
2007-12-19 11:08:41 +01:00
|
|
|
join(" ", @{$server->{'started_opts'}}) . "'" );
|
|
|
|
return 1;
|
|
|
|
}
|
2008-01-08 15:47:04 +01:00
|
|
|
|
|
|
|
# Remember the dynamically set options
|
|
|
|
$server->{'started_opts'}= $extra_opts;
|
2006-10-06 11:23:19 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2006-08-16 10:30:22 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Default, no restart
|
|
|
|
return 0;
|
2006-08-16 10:30:22 +02:00
|
|
|
}
|
|
|
|
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub servers_need_restart($) {
|
|
|
|
my ($tinfo)= @_;
|
|
|
|
return grep { server_need_restart($tinfo, $_); } all_servers();
|
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Return list of specific servers
|
|
|
|
# - there is no servers in an empty config
|
|
|
|
#
|
|
|
|
sub _like { return $config ? $config->like($_[0]) : (); }
|
|
|
|
sub mysqlds { return _like('mysqld.'); }
|
|
|
|
sub ndbds { return _like('cluster_config.ndbd.');}
|
|
|
|
sub ndb_mgmds { return _like('cluster_config.ndb_mgmd.'); }
|
|
|
|
sub clusters { return _like('mysql_cluster.'); }
|
|
|
|
sub all_servers { return ( mysqlds(), ndb_mgmds(), ndbds() ); }
|
2006-05-18 23:35:17 +02:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Filter a list of servers and return only those that are part
|
|
|
|
# of the specified cluster
|
|
|
|
#
|
|
|
|
sub in_cluster {
|
|
|
|
my ($cluster)= shift;
|
|
|
|
# Return only processes for a specific cluster
|
|
|
|
return grep { $_->suffix() eq $cluster->suffix() } @_;
|
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
|
|
|
# Filter a list of servers and return the SafeProcess
|
|
|
|
# for only those that are started or stopped
|
|
|
|
#
|
|
|
|
sub started { return grep(defined $_, map($_->{proc}, @_)); }
|
|
|
|
sub stopped { return grep(!defined $_, map($_->{proc}, @_)); }
|
2006-06-11 10:10:55 +02:00
|
|
|
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
sub get_extra_opts {
|
2007-12-12 18:19:24 +01:00
|
|
|
my ($mysqld, $tinfo)= @_;
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
return
|
|
|
|
$mysqld->option("#!use-slave-opt") ?
|
|
|
|
$tinfo->{slave_opt} : $tinfo->{master_opt};
|
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub stop_servers($$) {
|
|
|
|
my ($tinfo, @servers)= @_;
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Remember if we restarted for this test case (count restarts)
|
|
|
|
$tinfo->{'restarted'}= 1;
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( join('|', @servers) eq join('|', all_servers()) )
|
|
|
|
{
|
|
|
|
# All servers are going down, use some kind of order to
|
|
|
|
# avoid too many warnings in the log files
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2008-01-09 13:47:09 +01:00
|
|
|
mtr_report("Restarting all servers");
|
2006-06-11 10:10:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# mysqld processes
|
|
|
|
My::SafeProcess::shutdown( $opt_shutdown_timeout, started(mysqlds()) );
|
2006-06-11 10:10:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# cluster processes
|
|
|
|
My::SafeProcess::shutdown( $opt_shutdown_timeout,
|
|
|
|
started(ndbds(), ndb_mgmds()) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-01-09 13:47:09 +01:00
|
|
|
mtr_report("Restarting ", started(@servers));
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Stop only some servers
|
|
|
|
My::SafeProcess::shutdown( $opt_shutdown_timeout,
|
|
|
|
started(@servers) );
|
2005-02-08 06:11:05 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $server (@servers)
|
2006-05-18 23:35:17 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Remove datadir
|
|
|
|
if ( $server->option('#!remove-datadir') )
|
2006-05-18 23:35:17 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my $datadir= $server->value('datadir');
|
|
|
|
mtr_debug("Removing '$datadir'");
|
|
|
|
rmtree($datadir);
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# Mark server as stopped
|
|
|
|
$server->{proc}= undef;
|
|
|
|
|
|
|
|
# Forget history
|
|
|
|
delete $server->{'started_tinfo'};
|
|
|
|
delete $server->{'started_opts'};
|
|
|
|
delete $server->{'started_cnf'};
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-05-02 14:46:18 +02:00
|
|
|
|
2006-10-06 17:15:26 +02:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# start_servers
|
2006-10-06 17:15:26 +02:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# Start servers not already started
|
2006-10-06 17:15:26 +02:00
|
|
|
#
|
|
|
|
# RETURN
|
|
|
|
# 0 OK
|
|
|
|
# 1 Start failed
|
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
sub start_servers($) {
|
|
|
|
my ($tinfo)= @_;
|
2006-10-06 17:15:26 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Start clusters
|
|
|
|
foreach my $cluster ( clusters() )
|
|
|
|
{
|
|
|
|
ndbcluster_start($cluster);
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Start mysqlds
|
|
|
|
foreach my $mysqld ( mysqlds() )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $mysqld->{proc} )
|
2006-05-18 23:35:17 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
# Already started
|
|
|
|
|
|
|
|
# Write start of testcase to log file
|
|
|
|
mark_log($mysqld->value('log-error'), $tinfo);
|
|
|
|
|
|
|
|
next;
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $datadir= $mysqld->value('datadir');
|
|
|
|
|
|
|
|
# Don't delete anything if starting dirty
|
|
|
|
if (!$opt_start_dirty)
|
2006-05-18 23:35:17 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
my @options= ('log-bin', 'relay-log');
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $option_name ( @options ) {
|
|
|
|
next unless $mysqld->option($option_name);
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $value= $mysqld->value($option_name);
|
2006-06-11 10:10:55 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $file ( glob("$datadir/$value*") )
|
2006-10-04 16:28:23 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
#print "removing: $file\n";
|
|
|
|
mtr_debug("Removing '$file'");
|
|
|
|
unlink($file);
|
2006-10-04 16:28:23 +02:00
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# Remove old master.info and relay-log.info files
|
|
|
|
# from the servers datadir
|
|
|
|
unlink("$datadir/master.info");
|
|
|
|
unlink("$datadir/relay-log.info");
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Copy datadir from installed system db
|
|
|
|
copy_install_db($datadir) unless -d $datadir;
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Write start of testcase to log file
|
|
|
|
mark_log($mysqld->value('log-error'), $tinfo);
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Run <tname>-master.sh
|
|
|
|
if ($mysqld->option('#!run-master-sh') and
|
|
|
|
run_sh_script($tinfo->{master_sh}) )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$tinfo->{'comment'}= "Failed to execute '$tinfo->{master_sh}'";
|
2006-10-06 17:15:26 +02:00
|
|
|
return 1;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Run <tname>-slave.sh
|
|
|
|
if ($mysqld->option('#!run-slave-sh') and
|
|
|
|
run_sh_script($tinfo->{slave_sh}))
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$tinfo->{'comment'}= "Failed to execute '$tinfo->{slave_sh}'";
|
|
|
|
return 1;
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
|
|
|
|
2008-01-07 19:44:48 +01:00
|
|
|
my $extra_opts= get_extra_opts($mysqld, $tinfo);
|
|
|
|
mysqld_start($mysqld,$extra_opts);
|
2006-06-11 10:10:55 +02:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
# Save this test case information, so next can examine it
|
2007-12-12 18:19:24 +01:00
|
|
|
$mysqld->{'started_tinfo'}= $tinfo;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2006-05-23 15:27:56 +02:00
|
|
|
# Wait for clusters to start
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $cluster ( clusters() )
|
2006-01-12 19:51:02 +01:00
|
|
|
{
|
2006-06-15 22:12:05 +02:00
|
|
|
if (ndbcluster_wait_started($cluster, ""))
|
2006-05-23 15:27:56 +02:00
|
|
|
{
|
|
|
|
# failed to start
|
2007-12-12 18:19:24 +01:00
|
|
|
$tinfo->{'comment'}= "Start of '".$cluster->name()."' cluster failed";
|
2006-10-06 17:15:26 +02:00
|
|
|
return 1;
|
2006-05-23 15:27:56 +02:00
|
|
|
}
|
2006-01-12 19:51:02 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Wait for mysqlds to start
|
|
|
|
foreach my $mysqld ( mysqlds() )
|
2006-05-19 16:28:08 +02:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
if (sleep_until_file_created($mysqld->value('pid-file'),
|
|
|
|
$opt_start_timeout,
|
|
|
|
$mysqld->{'proc'}) == 0) {
|
|
|
|
$tinfo->{comment}=
|
|
|
|
"Failed to start ".$mysqld->name();
|
2006-10-06 17:15:26 +02:00
|
|
|
return 1;
|
2006-05-23 15:27:56 +02:00
|
|
|
}
|
2006-05-18 23:35:17 +02:00
|
|
|
}
|
2006-10-06 17:15:26 +02:00
|
|
|
return 0;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2006-01-26 17:54:34 +01:00
|
|
|
#
|
|
|
|
# Run include/check-testcase.test
|
2007-12-12 18:19:24 +01:00
|
|
|
# Before a testcase, run in record mode and save result file to var/tmp
|
2006-01-26 17:54:34 +01:00
|
|
|
# After testcase, run and compare with the recorded file, they should be equal!
|
|
|
|
#
|
2006-10-08 17:48:01 +02:00
|
|
|
# RETURN VALUE
|
|
|
|
# 0 OK
|
|
|
|
# 1 Check failed
|
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
sub run_check_testcase ($$$) {
|
|
|
|
my $tinfo= shift;
|
2006-01-26 17:54:34 +01:00
|
|
|
my $mode= shift;
|
2006-06-10 19:33:37 +02:00
|
|
|
my $mysqld= shift;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $name= "check-".$mysqld->name();
|
|
|
|
my $tname= $tinfo->{name};
|
2006-01-26 17:54:34 +01:00
|
|
|
|
|
|
|
my $args;
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
|
|
|
|
mtr_add_arg($args, "--no-defaults");
|
|
|
|
mtr_add_arg($args, "--silent");
|
|
|
|
mtr_add_arg($args, "--skip-safemalloc");
|
|
|
|
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
|
2006-11-08 22:53:40 +01:00
|
|
|
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
|
2006-01-26 17:54:34 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--socket=%s", $mysqld->value('socket'));
|
|
|
|
mtr_add_arg($args, "--port=%d", $mysqld->value('port'));
|
2006-01-26 17:54:34 +01:00
|
|
|
mtr_add_arg($args, "--database=test");
|
|
|
|
mtr_add_arg($args, "--user=%s", $opt_user);
|
|
|
|
mtr_add_arg($args, "--password=");
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--result-file=%s", "$opt_vardir/tmp/$name.result");
|
|
|
|
mtr_add_arg($args, "--test-file=%s", "include/check-testcase.test");
|
2006-01-26 17:54:34 +01:00
|
|
|
|
|
|
|
if ( $mode eq "before" )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--record");
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
my $errfile= "$opt_vardir/tmp/$name.err";
|
|
|
|
my $res= My::SafeProcess->run
|
|
|
|
(
|
|
|
|
name => $name,
|
|
|
|
path => $exe_mysqltest,
|
|
|
|
error => $errfile,
|
|
|
|
args => \$args,
|
|
|
|
);
|
2006-01-26 17:54:34 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
if ( $mode eq "after" and $res == 1 )
|
2006-01-26 17:54:34 +01:00
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("\nThe check of testcase '$tname' failed, this is the\n",
|
|
|
|
"diff between before and after:\n");
|
|
|
|
# Test failed, display the report mysqltest has created
|
|
|
|
mtr_printfile("$opt_vardir/tmp/$name.err");
|
2006-01-26 17:54:34 +01:00
|
|
|
}
|
|
|
|
elsif ( $res )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_report("\nCould not execute 'check-testcase' $mode testcase '$tname':");
|
|
|
|
mtr_printfile("$opt_vardir/tmp/$name.err");
|
|
|
|
mtr_report();
|
2006-01-26 17:54:34 +01:00
|
|
|
}
|
2006-10-08 17:48:01 +02:00
|
|
|
return $res;
|
2006-01-26 17:54:34 +01:00
|
|
|
}
|
|
|
|
|
2006-11-10 13:12:08 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub run_mysqltest ($) {
|
|
|
|
my $proc= start_mysqltest(@_);
|
|
|
|
$proc->wait();
|
2006-11-10 13:12:08 +01:00
|
|
|
}
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2006-07-10 12:06:30 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub start_mysqltest ($) {
|
2006-08-16 10:30:22 +02:00
|
|
|
my ($tinfo)= @_;
|
2005-01-01 19:27:41 +01:00
|
|
|
my $exe= $exe_mysqltest;
|
|
|
|
my $args;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
|
2004-12-30 16:34:01 +01:00
|
|
|
mtr_add_arg($args, "--silent");
|
|
|
|
mtr_add_arg($args, "--skip-safemalloc");
|
|
|
|
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
|
2006-11-08 22:53:40 +01:00
|
|
|
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
|
2006-11-21 21:32:58 +01:00
|
|
|
mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
|
2005-08-29 20:28:42 +02:00
|
|
|
|
2006-12-20 16:53:06 +01:00
|
|
|
# Log line number and time for each line in .test file
|
|
|
|
mtr_add_arg($args, "--mark-progress")
|
|
|
|
if $opt_mark_progress;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, "--database=test");
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2005-01-01 19:27:41 +01:00
|
|
|
if ( $opt_ps_protocol )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--ps-protocol");
|
|
|
|
}
|
|
|
|
|
2005-11-03 19:00:37 +01:00
|
|
|
if ( $opt_sp_protocol )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--sp-protocol");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opt_view_protocol )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--view-protocol");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opt_cursor_protocol )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--cursor-protocol");
|
|
|
|
}
|
|
|
|
|
2005-01-01 19:27:41 +01:00
|
|
|
if ( $opt_strace_client )
|
|
|
|
{
|
2007-12-12 18:19:24 +01:00
|
|
|
$exe= $opt_strace_client || "strace";
|
2005-01-01 19:27:41 +01:00
|
|
|
mtr_add_arg($args, "-o");
|
2005-05-15 17:22:54 +02:00
|
|
|
mtr_add_arg($args, "%s/log/mysqltest.strace", $opt_vardir);
|
2005-01-01 19:27:41 +01:00
|
|
|
mtr_add_arg($args, "$exe_mysqltest");
|
|
|
|
}
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
if ( $opt_timer )
|
|
|
|
{
|
2005-05-15 17:22:54 +02:00
|
|
|
mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opt_compress )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--compress");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opt_sleep )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--sleep=%d", $opt_sleep);
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
client_debug_arg($args, "mysqltest");
|
2005-10-04 15:43:55 +02:00
|
|
|
|
|
|
|
if ( $opt_ssl )
|
|
|
|
{
|
2006-08-16 10:30:22 +02:00
|
|
|
# Turn on SSL for _all_ test cases if option --ssl was used
|
2006-11-08 22:56:06 +01:00
|
|
|
mtr_add_arg($args, "--ssl");
|
2005-10-04 15:43:55 +02:00
|
|
|
}
|
2007-12-20 18:42:23 +01:00
|
|
|
elsif ( $opt_ssl_supported )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--skip-ssl");
|
|
|
|
}
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# export MYSQL_TEST variable containing <path>/mysqltest <args>
|
|
|
|
# ----------------------------------------------------------------------
|
2007-02-16 15:19:38 +01:00
|
|
|
$ENV{'MYSQL_TEST'}=
|
|
|
|
mtr_native_path($exe_mysqltest) . " " . join(" ", @$args);
|
2005-07-15 17:51:43 +02:00
|
|
|
|
2005-09-21 10:24:46 +02:00
|
|
|
# ----------------------------------------------------------------------
|
2005-09-20 14:11:58 +02:00
|
|
|
# Add arguments that should not go into the MYSQL_TEST env var
|
2005-09-21 10:24:46 +02:00
|
|
|
# ----------------------------------------------------------------------
|
2006-04-10 17:58:21 +02:00
|
|
|
if ( $opt_valgrind_mysqltest )
|
2006-04-08 22:27:43 +02:00
|
|
|
{
|
|
|
|
# Prefix the Valgrind options to the argument list.
|
|
|
|
# We do this here, since we do not want to Valgrind the nested invocations
|
|
|
|
# of mysqltest; that would mess up the stderr output causing test failure.
|
|
|
|
my @args_saved = @$args;
|
|
|
|
mtr_init_args(\$args);
|
|
|
|
valgrind_arguments($args, \$exe);
|
|
|
|
mtr_add_arg($args, "%s", $_) for @args_saved;
|
|
|
|
}
|
|
|
|
|
2007-06-26 12:26:21 +02:00
|
|
|
mtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
|
2006-03-23 15:07:39 +01:00
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
# Number of lines of resut to include in failure report
|
|
|
|
mtr_add_arg($args, "--tail-lines=20");
|
|
|
|
|
2006-11-10 13:12:08 +01:00
|
|
|
if ( defined $tinfo->{'result_file'} ) {
|
2007-06-26 12:26:21 +02:00
|
|
|
mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
|
2006-11-10 13:12:08 +01:00
|
|
|
}
|
2005-09-21 10:24:46 +02:00
|
|
|
|
|
|
|
if ( $opt_record )
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--record");
|
|
|
|
}
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
if ( $opt_client_gdb )
|
|
|
|
{
|
|
|
|
gdb_arguments(\$args, \$exe, "client");
|
|
|
|
}
|
|
|
|
elsif ( $opt_client_ddd )
|
|
|
|
{
|
|
|
|
ddd_arguments(\$args, \$exe, "client");
|
|
|
|
}
|
2006-04-04 09:49:32 +02:00
|
|
|
elsif ( $opt_client_debugger )
|
|
|
|
{
|
|
|
|
debugger_arguments(\$args, \$exe, "client");
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
2006-03-23 15:30:21 +01:00
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $proc= My::SafeProcess->new
|
|
|
|
(
|
|
|
|
name => "mysqltest",
|
|
|
|
path => $exe,
|
|
|
|
args => \$args,
|
|
|
|
error => $path_timefile,
|
|
|
|
verbose => $opt_verbose,
|
|
|
|
);
|
|
|
|
mtr_verbose("Started $proc");
|
|
|
|
return $proc;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2005-09-17 01:09:32 +02:00
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
#
|
|
|
|
# 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";
|
|
|
|
|
2006-03-23 20:05:09 +01:00
|
|
|
# Remove the old gdbinit file
|
|
|
|
unlink($gdb_init_file);
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
if ( $type eq "client" )
|
|
|
|
{
|
|
|
|
# write init file for client
|
|
|
|
mtr_tofile($gdb_init_file,
|
2006-03-23 16:22:56 +01:00
|
|
|
"set args $str\n" .
|
|
|
|
"break main\n");
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
|
|
|
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" .
|
2006-03-23 16:22:56 +01:00
|
|
|
"run");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opt_manual_gdb )
|
|
|
|
{
|
2006-03-23 20:05:09 +01:00
|
|
|
print "\nTo start gdb for $type, type in another window:\n";
|
2007-04-13 15:06:05 +02:00
|
|
|
print "gdb -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
|
2006-03-23 16:22:56 +01:00
|
|
|
|
|
|
|
# Indicate the exe should not be started
|
|
|
|
$$exe= undef;
|
|
|
|
return;
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$$args= [];
|
|
|
|
mtr_add_arg($$args, "-title");
|
|
|
|
mtr_add_arg($$args, "$type");
|
|
|
|
mtr_add_arg($$args, "-e");
|
2006-03-23 16:22:56 +01:00
|
|
|
|
2006-05-03 20:04:57 +02:00
|
|
|
if ( $exe_libtool )
|
2006-03-23 15:07:39 +01:00
|
|
|
{
|
2006-05-02 14:46:18 +02:00
|
|
|
mtr_add_arg($$args, $exe_libtool);
|
2006-03-23 15:07:39 +01:00
|
|
|
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";
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2006-04-24 10:39:56 +02:00
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
#
|
|
|
|
# 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";
|
2005-09-17 01:09:32 +02:00
|
|
|
|
2006-03-23 20:05:09 +01:00
|
|
|
# Remove the old gdbinit file
|
|
|
|
unlink($gdb_init_file);
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
if ( $type eq "client" )
|
|
|
|
{
|
|
|
|
# write init file for client
|
|
|
|
mtr_tofile($gdb_init_file,
|
|
|
|
"set args $str\n" .
|
2006-03-23 16:22:56 +01:00
|
|
|
"break main\n");
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
|
|
|
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" .
|
2006-04-21 12:30:33 +02:00
|
|
|
"end");
|
2006-03-23 16:22:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opt_manual_ddd )
|
|
|
|
{
|
2006-03-23 20:05:09 +01:00
|
|
|
print "\nTo start ddd for $type, type in another window:\n";
|
2007-04-13 15:06:05 +02:00
|
|
|
print "ddd -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
|
2006-03-23 16:22:56 +01:00
|
|
|
|
|
|
|
# Indicate the exe should not be started
|
|
|
|
$$exe= undef;
|
|
|
|
return;
|
2006-03-23 15:07:39 +01:00
|
|
|
}
|
2005-09-17 01:09:32 +02:00
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
my $save_exe= $$exe;
|
|
|
|
$$args= [];
|
2006-05-03 20:04:57 +02:00
|
|
|
if ( $exe_libtool )
|
2006-03-23 15:07:39 +01:00
|
|
|
{
|
2006-05-02 14:46:18 +02:00
|
|
|
$$exe= $exe_libtool;
|
2006-03-23 15:07:39 +01:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2006-04-04 09:49:32 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Modify the exe and args so that program is run in the selected debugger
|
|
|
|
#
|
|
|
|
sub debugger_arguments {
|
|
|
|
my $args= shift;
|
|
|
|
my $exe= shift;
|
|
|
|
my $debugger= $opt_debugger || $opt_client_debugger;
|
|
|
|
|
2007-03-05 09:52:40 +01:00
|
|
|
if ( $debugger =~ /vcexpress|vc|devenv/ )
|
2006-04-04 09:49:32 +02:00
|
|
|
{
|
|
|
|
# vc[express] /debugexe exe arg1 .. argn
|
|
|
|
|
|
|
|
# Add /debugexe and name of the exe before args
|
|
|
|
unshift(@$$args, "/debugexe");
|
|
|
|
unshift(@$$args, "$$exe");
|
|
|
|
|
2007-03-05 09:52:40 +01:00
|
|
|
# Set exe to debuggername
|
|
|
|
$$exe= $debugger;
|
|
|
|
|
2006-04-04 09:49:32 +02:00
|
|
|
}
|
2007-03-05 09:52:40 +01:00
|
|
|
elsif ( $debugger =~ /windbg/ )
|
2006-04-04 09:49:32 +02:00
|
|
|
{
|
|
|
|
# windbg exe arg1 .. argn
|
|
|
|
|
|
|
|
# Add name of the exe before args
|
|
|
|
unshift(@$$args, "$$exe");
|
|
|
|
|
2007-03-05 09:52:40 +01:00
|
|
|
# Set exe to debuggername
|
|
|
|
$$exe= $debugger;
|
|
|
|
|
|
|
|
}
|
|
|
|
elsif ( $debugger eq "dbx" )
|
|
|
|
{
|
|
|
|
# xterm -e dbx -r exe arg1 .. argn
|
|
|
|
|
|
|
|
unshift(@$$args, $$exe);
|
|
|
|
unshift(@$$args, "-r");
|
|
|
|
unshift(@$$args, $debugger);
|
|
|
|
unshift(@$$args, "-e");
|
|
|
|
|
|
|
|
$$exe= "xterm";
|
|
|
|
|
2006-04-04 09:49:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mtr_error("Unknown argument \"$debugger\" passed to --debugger");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
#
|
|
|
|
# Modify the exe and args so that program is run in valgrind
|
|
|
|
#
|
2005-09-17 01:09:32 +02:00
|
|
|
sub valgrind_arguments {
|
|
|
|
my $args= shift;
|
|
|
|
my $exe= shift;
|
|
|
|
|
2006-07-26 14:44:59 +02:00
|
|
|
if ( $opt_callgrind)
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--tool=callgrind");
|
|
|
|
mtr_add_arg($args, "--base=$opt_vardir/log");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
|
|
|
|
mtr_add_arg($args, "--alignment=8");
|
|
|
|
mtr_add_arg($args, "--leak-check=yes");
|
|
|
|
mtr_add_arg($args, "--num-callers=16");
|
|
|
|
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
|
|
|
|
if -f "$glob_mysql_test_dir/valgrind.supp";
|
|
|
|
}
|
2005-09-17 01:09:32 +02:00
|
|
|
|
2006-06-16 15:56:08 +02:00
|
|
|
# Add valgrind options, can be overriden by user
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr_add_arg($args, '%s', $_) for (@valgrind_args);
|
2005-12-09 17:52:29 +01:00
|
|
|
|
2005-09-17 01:09:32 +02:00
|
|
|
mtr_add_arg($args, $$exe);
|
|
|
|
|
2006-03-23 15:07:39 +01:00
|
|
|
$$exe= $opt_valgrind_path || "valgrind";
|
2006-10-25 14:34:18 +02:00
|
|
|
|
|
|
|
if ($exe_libtool)
|
|
|
|
{
|
|
|
|
# Add "libtool --mode-execute" before the test to execute
|
|
|
|
# if running in valgrind(to avoid valgrinding bash)
|
|
|
|
unshift(@$args, "--mode=execute", $$exe);
|
|
|
|
$$exe= $exe_libtool;
|
|
|
|
}
|
2005-09-17 01:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-02 16:57:21 +01:00
|
|
|
#
|
2007-12-12 18:19:24 +01:00
|
|
|
# Usage
|
2005-01-02 16:57:21 +01:00
|
|
|
#
|
2005-06-21 20:25:50 +02:00
|
|
|
sub usage ($) {
|
2006-06-08 19:55:22 +02:00
|
|
|
my $message= shift;
|
|
|
|
|
|
|
|
if ( $message )
|
|
|
|
{
|
2007-02-23 12:13:55 +01:00
|
|
|
print STDERR "$message\n";
|
2006-06-08 19:55:22 +02:00
|
|
|
}
|
|
|
|
|
2007-02-23 12:13:55 +01:00
|
|
|
print <<HERE;
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
$0 [ OPTIONS ] [ TESTCASE ]
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
Options to control what engine/variation to run
|
|
|
|
|
|
|
|
embedded-server Use the embedded server, i.e. no mysqld daemons
|
|
|
|
ps-protocol Use the binary protocol between client and server
|
2005-11-03 19:00:37 +01:00
|
|
|
cursor-protocol Use the cursor protocol between client and server
|
|
|
|
(implies --ps-protocol)
|
|
|
|
view-protocol Create a view to execute all non updating queries
|
|
|
|
sp-protocol Create a stored procedure to execute all queries
|
2005-10-04 15:43:55 +02:00
|
|
|
compress Use the compressed protocol between client and server
|
|
|
|
ssl Use ssl protocol between client and server
|
2006-01-24 08:30:54 +01:00
|
|
|
skip-ssl Dont start server with support for ssl connections
|
2007-03-29 11:31:50 +02:00
|
|
|
ndb|with-ndbcluster Use cluster as default table type
|
2006-11-02 21:05:20 +01:00
|
|
|
vs-config Visual Studio configuration used to create executables
|
|
|
|
(default: MTR_VS_CONFIG environment variable)
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
config|defaults-file=<config template> Use fixed config template for all
|
|
|
|
tests
|
|
|
|
extra_defaults_file=<config template> Extra config template to add to
|
|
|
|
all generated configs
|
|
|
|
|
2006-03-23 16:39:51 +01:00
|
|
|
Options to control directories to use
|
2006-04-19 23:09:49 +02:00
|
|
|
benchdir=DIR The directory where the benchmark suite is stored
|
|
|
|
(default: ../../mysql-bench)
|
2006-03-23 16:39:51 +01:00
|
|
|
tmpdir=DIR The directory where temporary files are stored
|
|
|
|
(default: ./var/tmp).
|
2006-04-19 23:09:49 +02:00
|
|
|
vardir=DIR The directory where files generated from the test run
|
|
|
|
is stored (default: ./var). Specifying a ramdisk or
|
|
|
|
tmpfs will speed up tests.
|
2006-11-13 12:44:12 +01:00
|
|
|
mem Run testsuite in "memory" using tmpfs or ramdisk
|
|
|
|
Attempts to find a suitable location
|
|
|
|
using a builtin list of standard locations
|
2006-11-08 23:16:44 +01:00
|
|
|
for tmpfs (/dev/shm)
|
|
|
|
The option can also be set using environment
|
|
|
|
variable MTR_MEM=[DIR]
|
2006-03-23 16:39:51 +01:00
|
|
|
|
2005-01-02 16:57:21 +01:00
|
|
|
Options to control what test suites or cases to run
|
|
|
|
|
|
|
|
force Continue to run the suite after failure
|
2006-02-06 15:42:26 +01:00
|
|
|
with-ndbcluster-only Run only tests that include "ndb" in the filename
|
2006-06-14 21:45:15 +02:00
|
|
|
skip-ndb[cluster] Skip all tests that need cluster
|
|
|
|
skip-ndb[cluster]-slave Skip all tests that need a slave cluster
|
|
|
|
ndb-extra Run extra tests from ndb directory
|
2007-10-05 19:23:44 +02:00
|
|
|
do-test=PREFIX or REGEX
|
|
|
|
Run test cases which name are prefixed with PREFIX
|
|
|
|
or fulfills REGEX
|
|
|
|
skip-test=PREFIX or REGEX
|
|
|
|
Skip test cases which name are prefixed with PREFIX
|
|
|
|
or fulfills REGEX
|
2005-01-02 16:57:21 +01:00
|
|
|
start-from=PREFIX Run test cases starting from test prefixed with PREFIX
|
2007-06-27 14:28:02 +02:00
|
|
|
suite[s]=NAME1,..,NAMEN Collect tests in suites from the comma separated
|
|
|
|
list of suite names.
|
|
|
|
The default is: "$opt_suites"
|
2005-01-02 16:57:21 +01:00
|
|
|
skip-rpl Skip the replication test cases.
|
2006-11-17 11:01:09 +01:00
|
|
|
big-test Set the environment variable BIG_TEST, which can be
|
|
|
|
checked from test cases.
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
Options that specify ports
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
mtr-build-thread=# Specify unique number to calculate port number(s) from.
|
2007-12-19 12:58:06 +01:00
|
|
|
build-thread=# Can be set in environment variable MTR_BUILD_THREAD.
|
2007-12-12 18:19:24 +01:00
|
|
|
Set MTR_BUILD_THREAD="auto" to automatically aquire
|
|
|
|
a build thread id that is unique to current host
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
Options for test case authoring
|
|
|
|
|
|
|
|
record TESTNAME (Re)genereate the result file for TESTNAME
|
2006-01-26 17:54:34 +01:00
|
|
|
check-testcases Check testcases for sideeffects
|
2006-12-20 16:53:06 +01:00
|
|
|
mark-progress Log line number and elapsed time to <testname>.progress
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
Options that pass on options
|
|
|
|
|
|
|
|
mysqld=ARGS Specify additional arguments to "mysqld"
|
|
|
|
|
|
|
|
Options to run test on running server
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
extern option=value Run only the tests against an already started server
|
|
|
|
the options to use for connection to the extern server
|
|
|
|
must be specified using name-value pair notation
|
|
|
|
For example:
|
|
|
|
./$0 --extern socket=/tmp/mysqld.sock
|
|
|
|
|
2006-11-17 13:30:42 +01:00
|
|
|
user=USER User for connection to extern server
|
|
|
|
socket=PATH Socket for connection to extern server
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
Options for debugging the product
|
|
|
|
|
2006-04-19 23:09:49 +02:00
|
|
|
client-ddd Start mysqltest client in ddd
|
|
|
|
client-debugger=NAME Start mysqltest in the selected debugger
|
2006-03-23 15:07:39 +01:00
|
|
|
client-gdb Start mysqltest client in gdb
|
|
|
|
ddd Start mysqld in ddd
|
2006-04-19 23:09:49 +02:00
|
|
|
debug Dump trace output for all servers and client programs
|
2006-04-04 09:49:32 +02:00
|
|
|
debugger=NAME Start mysqld in the selected debugger
|
2006-04-19 23:09:49 +02:00
|
|
|
gdb Start the mysqld(s) in gdb
|
|
|
|
manual-debug Let user manually start mysqld in debugger, before
|
|
|
|
running test(s)
|
|
|
|
manual-gdb Let user manually start mysqld in gdb, before running
|
|
|
|
test(s)
|
2007-04-13 15:06:05 +02:00
|
|
|
manual-ddd Let user manually start mysqld in ddd, before running
|
|
|
|
test(s)
|
2007-12-12 18:19:24 +01:00
|
|
|
strace-client=[path] Create strace output for mysqltest client, optionally
|
|
|
|
specifying name and path to the trace program to use.
|
|
|
|
Example: $0 --strace-client=ktrace
|
2007-01-19 09:41:08 +01:00
|
|
|
max-save-core Limit the number of core files saved (to avoid filling
|
|
|
|
up disks for heavily crashing server). Defaults to
|
|
|
|
$opt_max_save_core, set to 0 for no limit.
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
Options for valgrind
|
2005-01-02 16:57:21 +01:00
|
|
|
|
2006-04-19 23:09:49 +02:00
|
|
|
valgrind Run the "mysqltest" and "mysqld" executables using
|
2007-12-12 18:19:24 +01:00
|
|
|
valgrind with default options
|
2006-06-16 15:56:08 +02:00
|
|
|
valgrind-all Synonym for --valgrind
|
2006-10-25 14:34:18 +02:00
|
|
|
valgrind-mysqltest Run the "mysqltest" and "mysql_client_test" executable
|
|
|
|
with valgrind
|
2006-03-23 15:07:39 +01:00
|
|
|
valgrind-mysqld Run the "mysqld" executable with valgrind
|
2007-12-12 18:19:24 +01:00
|
|
|
valgrind-options=ARGS Deprecated, use --valgrind-option
|
|
|
|
valgrind-option=ARGS Option to give valgrind, replaces default option(s),
|
|
|
|
can be specified more then once
|
2006-03-23 15:07:39 +01:00
|
|
|
valgrind-path=[EXE] Path to the valgrind executable
|
2006-07-26 14:44:59 +02:00
|
|
|
callgrind Instruct valgrind to use callgrind
|
2005-01-02 16:57:21 +01:00
|
|
|
|
|
|
|
Misc options
|
|
|
|
|
2006-03-01 13:29:37 +01:00
|
|
|
comment=STR Write STR to the output
|
2006-04-19 23:09:49 +02:00
|
|
|
notimer Don't show test case execution time
|
2007-12-12 18:19:24 +01:00
|
|
|
verbose More verbose output(use multiple times for even more)
|
|
|
|
start Only initialize and start the servers, using the
|
|
|
|
startup settings for the first specified test case
|
|
|
|
Example:
|
|
|
|
$0 --start alias &
|
2006-04-21 04:17:14 +02:00
|
|
|
start-dirty Only start the servers (without initialization) for
|
2007-12-12 18:19:24 +01:00
|
|
|
the first specified test case
|
|
|
|
fast Run as fast as possible, dont't wait for servers
|
|
|
|
to shutdown etc.
|
2006-04-21 04:17:14 +02:00
|
|
|
reorder Reorder tests to get fewer server restarts
|
2005-01-02 16:57:21 +01:00
|
|
|
help Get this help text
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
testcase-timeout=MINUTES Max test case run time (default $opt_testcase_timeout)
|
|
|
|
suite-timeout=MINUTES Max test suite run time (default $opt_suite_timeout)
|
|
|
|
shutdown-timeout=SECONDS Max number of seconds to wait for server shutdown
|
|
|
|
before killing servers (default $opt_shutdown_timeout)
|
|
|
|
warnings Scan the log files for warnings. Use --nowarnings
|
|
|
|
to turn off.
|
2005-08-18 00:16:44 +02:00
|
|
|
|
2006-11-17 13:36:10 +01:00
|
|
|
sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time
|
2006-06-14 21:45:15 +02:00
|
|
|
|
2005-01-02 16:57:21 +01:00
|
|
|
HERE
|
2007-12-12 18:19:24 +01:00
|
|
|
exit(1);
|
2005-08-18 00:16:44 +02:00
|
|
|
|
2005-01-02 16:57:21 +01:00
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|