|
|
@ -68,8 +68,8 @@ use My::File::Path; # Patched version of File::Path |
|
|
|
use File::Basename; |
|
|
|
use File::Copy; |
|
|
|
use File::Find; |
|
|
|
use File::Temp qw / tempdir /; |
|
|
|
use File::Spec::Functions qw / splitdir /; |
|
|
|
use File::Temp qw/tempdir/; |
|
|
|
use File::Spec::Functions qw/splitdir/; |
|
|
|
use My::Platform; |
|
|
|
use My::SafeProcess; |
|
|
|
use My::ConfigFactory; |
|
|
@ -87,6 +87,7 @@ use IO::Select; |
|
|
|
require "lib/mtr_process.pl"; |
|
|
|
require "lib/mtr_io.pl"; |
|
|
|
require "lib/mtr_gcov.pl"; |
|
|
|
require "lib/mtr_gprof.pl"; |
|
|
|
require "lib/mtr_misc.pl"; |
|
|
|
|
|
|
|
$SIG{INT}= sub { mtr_error("Got ^C signal"); }; |
|
|
@ -118,6 +119,8 @@ END { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sub env_or_val($$) { defined $ENV{$_[0]} ? $ENV{$_[0]} : $_[1] } |
|
|
|
|
|
|
|
my $path_config_file; # The generated config file, var/my.cnf |
|
|
|
|
|
|
|
# Visual Studio produces executables in different sub-directories based on the |
|
|
@ -167,6 +170,9 @@ our $opt_gcov_exe= "gcov"; |
|
|
|
our $opt_gcov_err= "mysql-test-gcov.msg"; |
|
|
|
our $opt_gcov_msg= "mysql-test-gcov.err"; |
|
|
|
|
|
|
|
our $opt_gprof; |
|
|
|
our %gprof_dirs; |
|
|
|
|
|
|
|
our $glob_debugger= 0; |
|
|
|
our $opt_gdb; |
|
|
|
our $opt_client_gdb; |
|
|
@ -185,7 +191,9 @@ our $opt_experimental; |
|
|
|
our $experimental_test_cases; |
|
|
|
|
|
|
|
my $baseport; |
|
|
|
# $opt_build_thread may later be set from $opt_port_base |
|
|
|
my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto"; |
|
|
|
my $opt_port_base= $ENV{'MTR_PORT_BASE'} || "auto"; |
|
|
|
my $build_thread= 0; |
|
|
|
|
|
|
|
my $opt_record; |
|
|
@ -195,6 +203,7 @@ my $opt_skip_core; |
|
|
|
|
|
|
|
our $opt_check_testcases= 1; |
|
|
|
my $opt_mark_progress; |
|
|
|
my $opt_max_connections; |
|
|
|
|
|
|
|
my $opt_sleep; |
|
|
|
|
|
|
@ -213,7 +222,8 @@ my $start_only; |
|
|
|
my $opt_wait_all; |
|
|
|
my $opt_repeat= 1; |
|
|
|
my $opt_retry= 3; |
|
|
|
my $opt_retry_failure= 2; |
|
|
|
my $opt_retry_failure= env_or_val(MTR_RETRY_FAILURE => 2); |
|
|
|
my $opt_reorder= 1; |
|
|
|
|
|
|
|
my $opt_strace_client; |
|
|
|
|
|
|
@ -226,6 +236,7 @@ my @default_valgrind_args= ("--show-reachable=yes"); |
|
|
|
my @valgrind_args; |
|
|
|
my $opt_valgrind_path; |
|
|
|
my $opt_callgrind; |
|
|
|
my %mysqld_logs; |
|
|
|
my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions. |
|
|
|
|
|
|
|
our $opt_warnings= 1; |
|
|
@ -242,9 +253,9 @@ our %mysqld_variables; |
|
|
|
|
|
|
|
my $source_dist= 0; |
|
|
|
|
|
|
|
my $opt_max_save_core= $ENV{MTR_MAX_SAVE_CORE} || 5; |
|
|
|
my $opt_max_save_datadir= $ENV{MTR_MAX_SAVE_DATADIR} || 20; |
|
|
|
my $opt_max_test_fail= $ENV{MTR_MAX_TEST_FAIL} || 10; |
|
|
|
my $opt_max_save_core= env_or_val(MTR_MAX_SAVE_CORE => 5); |
|
|
|
my $opt_max_save_datadir= env_or_val(MTR_MAX_SAVE_DATADIR => 20); |
|
|
|
my $opt_max_test_fail= env_or_val(MTR_MAX_TEST_FAIL => 10); |
|
|
|
|
|
|
|
my $opt_parallel= $ENV{MTR_PARALLEL} || 1; |
|
|
|
|
|
|
@ -265,6 +276,9 @@ sub main { |
|
|
|
|
|
|
|
command_line_setup(); |
|
|
|
|
|
|
|
# --help will not reach here, so now it's safe to assume we have binaries |
|
|
|
My::SafeProcess::find_bin(); |
|
|
|
|
|
|
|
if ( $opt_gcov ) { |
|
|
|
gcov_prepare($basedir); |
|
|
|
} |
|
|
@ -294,7 +308,7 @@ sub main { |
|
|
|
} |
|
|
|
|
|
|
|
mtr_report("Collecting tests..."); |
|
|
|
my $tests= collect_test_cases($opt_suites, \@opt_cases); |
|
|
|
my $tests= collect_test_cases($opt_reorder, $opt_suites, \@opt_cases); |
|
|
|
|
|
|
|
if ( $opt_report_features ) { |
|
|
|
# Put "report features" as the first test to run |
|
|
@ -411,7 +425,7 @@ sub main { |
|
|
|
$opt_gcov_msg, $opt_gcov_err); |
|
|
|
} |
|
|
|
|
|
|
|
mtr_report_stats($completed); |
|
|
|
mtr_report_stats("Completed", $completed); |
|
|
|
|
|
|
|
exit(0); |
|
|
|
} |
|
|
@ -435,7 +449,7 @@ sub run_test_server ($$$) { |
|
|
|
my $result; |
|
|
|
my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump |
|
|
|
|
|
|
|
my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout()); |
|
|
|
my $suite_timeout= start_timer(suite_timeout()); |
|
|
|
|
|
|
|
my $s= IO::Select->new(); |
|
|
|
$s->add($server); |
|
|
@ -456,7 +470,6 @@ sub run_test_server ($$$) { |
|
|
|
mtr_verbose("Child closed socket"); |
|
|
|
$s->remove($sock); |
|
|
|
if (--$childs == 0){ |
|
|
|
$suite_timeout_proc->kill(); |
|
|
|
return $completed; |
|
|
|
} |
|
|
|
next; |
|
|
@ -525,15 +538,13 @@ sub run_test_server ($$$) { |
|
|
|
|
|
|
|
if ( !$opt_force ) { |
|
|
|
# Test has failed, force is off |
|
|
|
$suite_timeout_proc->kill(); |
|
|
|
push(@$completed, $result); |
|
|
|
return $completed; |
|
|
|
} |
|
|
|
elsif ($opt_max_test_fail > 0 and |
|
|
|
$num_failed_test >= $opt_max_test_fail) { |
|
|
|
$suite_timeout_proc->kill(); |
|
|
|
push(@$completed, $result); |
|
|
|
mtr_report_stats($completed, 1); |
|
|
|
mtr_report_stats("Too many failed", $completed, 1); |
|
|
|
mtr_report("Too many tests($num_failed_test) failed!", |
|
|
|
"Terminating..."); |
|
|
|
return undef; |
|
|
@ -620,9 +631,9 @@ sub run_test_server ($$$) { |
|
|
|
next; |
|
|
|
} |
|
|
|
|
|
|
|
# Prefer same configuration |
|
|
|
if (defined $result and |
|
|
|
$result->{template_path} eq $t->{template_path}) |
|
|
|
# Prefer same configuration, or just use next if --noreorder |
|
|
|
if (!$opt_reorder or (defined $result and |
|
|
|
$result->{template_path} eq $t->{template_path})) |
|
|
|
{ |
|
|
|
#mtr_report("Test uses same config => good match"); |
|
|
|
# Test uses same config => good match |
|
|
@ -663,9 +674,9 @@ sub run_test_server ($$$) { |
|
|
|
# ---------------------------------------------------- |
|
|
|
# Check if test suite timer expired |
|
|
|
# ---------------------------------------------------- |
|
|
|
if ( ! $suite_timeout_proc->wait_one(0) ) |
|
|
|
if ( has_expired($suite_timeout) ) |
|
|
|
{ |
|
|
|
mtr_report_stats($completed, 1); |
|
|
|
mtr_report_stats("Timeout", $completed, 1); |
|
|
|
mtr_report("Test suite timeout! Terminating..."); |
|
|
|
return undef; |
|
|
|
} |
|
|
@ -741,6 +752,12 @@ sub run_worker ($) { |
|
|
|
elsif ($line eq 'BYE'){ |
|
|
|
mtr_report("Server said BYE"); |
|
|
|
stop_all_servers($opt_shutdown_timeout); |
|
|
|
if ($opt_valgrind_mysqld) { |
|
|
|
valgrind_exit_reports(); |
|
|
|
} |
|
|
|
if ( $opt_gprof ) { |
|
|
|
gprof_collect (find_mysqld($basedir), keys %gprof_dirs); |
|
|
|
} |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
else { |
|
|
@ -783,11 +800,12 @@ sub set_vardir { |
|
|
|
sub command_line_setup { |
|
|
|
my $opt_comment; |
|
|
|
my $opt_usage; |
|
|
|
my $opt_list_options; |
|
|
|
|
|
|
|
# Read the command line options |
|
|
|
# Note: Keep list, and the order, in sync with usage at end of this file |
|
|
|
Getopt::Long::Configure("pass_through"); |
|
|
|
GetOptions( |
|
|
|
my %options=( |
|
|
|
# Control what engine/variation to run |
|
|
|
'embedded-server' => \$opt_embedded_server, |
|
|
|
'ps-protocol' => \$opt_ps_protocol, |
|
|
@ -823,6 +841,7 @@ sub command_line_setup { |
|
|
|
|
|
|
|
# Specify ports |
|
|
|
'build-thread|mtr-build-thread=i' => \$opt_build_thread, |
|
|
|
'port-base|mtr-port-base=i' => \$opt_port_base, |
|
|
|
|
|
|
|
# Test case authoring |
|
|
|
'record' => \$opt_record, |
|
|
@ -853,6 +872,7 @@ sub command_line_setup { |
|
|
|
|
|
|
|
# Coverage, profiling etc |
|
|
|
'gcov' => \$opt_gcov, |
|
|
|
'gprof' => \$opt_gprof, |
|
|
|
'valgrind|valgrind-all' => \$opt_valgrind, |
|
|
|
'valgrind-mysqltest' => \$opt_valgrind_mysqltest, |
|
|
|
'valgrind-mysqld' => \$opt_valgrind_mysqld, |
|
|
@ -883,7 +903,7 @@ sub command_line_setup { |
|
|
|
'report-features' => \$opt_report_features, |
|
|
|
'comment=s' => \$opt_comment, |
|
|
|
'fast' => \$opt_fast, |
|
|
|
'reorder!' => \&collect_option, |
|
|
|
'reorder!' => \$opt_reorder, |
|
|
|
'enable-disabled' => \&collect_option, |
|
|
|
'verbose+' => \$opt_verbose, |
|
|
|
'verbose-restart' => \&report_option, |
|
|
@ -903,11 +923,16 @@ sub command_line_setup { |
|
|
|
'warnings!' => \$opt_warnings, |
|
|
|
'timestamp' => \&report_option, |
|
|
|
'timediff' => \&report_option, |
|
|
|
'max-connections=i' => \$opt_max_connections, |
|
|
|
|
|
|
|
'help|h' => \$opt_usage, |
|
|
|
) or usage("Can't read options"); |
|
|
|
'list-options' => \$opt_list_options, |
|
|
|
); |
|
|
|
|
|
|
|
GetOptions(%options) or usage("Can't read options"); |
|
|
|
|
|
|
|
usage("") if $opt_usage; |
|
|
|
list_options(\%options) if $opt_list_options; |
|
|
|
|
|
|
|
# -------------------------------------------------------------------------- |
|
|
|
# Setup verbosity |
|
|
@ -923,6 +948,11 @@ sub command_line_setup { |
|
|
|
|
|
|
|
# Find the absolute path to the test directory |
|
|
|
$glob_mysql_test_dir= cwd(); |
|
|
|
if ($glob_mysql_test_dir =~ / /) |
|
|
|
{ |
|
|
|
die("Working directory \"$glob_mysql_test_dir\" contains space\n". |
|
|
|
"Bailing out, cannot function properly with space in path"); |
|
|
|
} |
|
|
|
if (IS_CYGWIN) |
|
|
|
{ |
|
|
|
# Use mixed path format i.e c:/path/to/ |
|
|
@ -1075,6 +1105,21 @@ sub command_line_setup { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (IS_WINDOWS and defined $opt_mem) { |
|
|
|
mtr_report("--mem not supported on Windows, ignored"); |
|
|
|
$opt_mem= undef; |
|
|
|
} |
|
|
|
|
|
|
|
if ($opt_port_base ne "auto") |
|
|
|
{ |
|
|
|
if (my $rem= $opt_port_base % 10) |
|
|
|
{ |
|
|
|
mtr_warning ("Port base $opt_port_base rounded down to multiple of 10"); |
|
|
|
$opt_port_base-= $rem; |
|
|
|
} |
|
|
|
$opt_build_thread= $opt_port_base / 10 - 1000; |
|
|
|
} |
|
|
|
|
|
|
|
# -------------------------------------------------------------------------- |
|
|
|
# Check if we should speed up tests by trying to run on tmpfs |
|
|
|
# -------------------------------------------------------------------------- |
|
|
@ -1240,7 +1285,7 @@ sub command_line_setup { |
|
|
|
# -------------------------------------------------------------------------- |
|
|
|
# Gcov flag |
|
|
|
# -------------------------------------------------------------------------- |
|
|
|
if ( $opt_gcov and ! $source_dist ) |
|
|
|
if ( ($opt_gcov or $opt_gprof) and ! $source_dist ) |
|
|
|
{ |
|
|
|
mtr_error("Coverage test needs the source - please use source dist"); |
|
|
|
} |
|
|
@ -1339,8 +1384,7 @@ sub command_line_setup { |
|
|
|
push(@valgrind_args, @default_valgrind_args) |
|
|
|
unless @valgrind_args; |
|
|
|
|
|
|
|
# Make valgrind run in quiet mode so it only print errors |
|
|
|
push(@valgrind_args, "--quiet" ); |
|
|
|
# Don't add --quiet; you will loose the summary reports. |
|
|
|
|
|
|
|
mtr_report("Running valgrind with options \"", |
|
|
|
join(" ", @valgrind_args), "\""); |
|
|
@ -1445,6 +1489,12 @@ sub collect_mysqld_features { |
|
|
|
mtr_add_arg($args, "--verbose"); |
|
|
|
mtr_add_arg($args, "--help"); |
|
|
|
|
|
|
|
# Need --user=root if running as *nix root user |
|
|
|
if (!IS_WINDOWS and $> == 0) |
|
|
|
{ |
|
|
|
mtr_add_arg($args, "--user=root"); |
|
|
|
} |
|
|
|
|
|
|
|
my $exe_mysqld= find_mysqld($basedir); |
|
|
|
my $cmd= join(" ", $exe_mysqld, @$args); |
|
|
|
my $list= `$cmd`; |
|
|
@ -1763,11 +1813,11 @@ sub environment_setup { |
|
|
|
{ |
|
|
|
push(@ld_library_paths, "$basedir/libmysql/.libs/", |
|
|
|
"$basedir/libmysql_r/.libs/", |
|
|
|
"$basedir/zlib.libs/"); |
|
|
|
"$basedir/zlib/.libs/"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
push(@ld_library_paths, "$basedir/lib"); |
|
|
|
push(@ld_library_paths, "$basedir/lib", "$basedir/lib/mysql"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -2555,6 +2605,7 @@ sub create_config_file_for_extern { |
|
|
|
# binlog reads from [client] and [mysqlbinlog] |
|
|
|
[mysqlbinlog] |
|
|
|
character-sets-dir= $path_charsetsdir |
|
|
|
local-load= $opt_tmpdir |
|
|
|
|
|
|
|
# mysql_fix_privilege_tables.sh don't read from [client] |
|
|
|
[mysql_fix_privilege_tables] |
|
|
@ -2984,11 +3035,11 @@ sub check_testcase($$) |
|
|
|
# Return immediately if no check proceess was started |
|
|
|
return 0 unless ( keys %started ); |
|
|
|
|
|
|
|
my $timeout_proc= My::SafeProcess->timer(check_timeout()); |
|
|
|
my $timeout= start_timer(check_timeout()); |
|
|
|
|
|
|
|
while (1){ |
|
|
|
my $result; |
|
|
|
my $proc= My::SafeProcess->wait_any(); |
|
|
|
my $proc= My::SafeProcess->wait_any_timeout($timeout); |
|
|
|
mtr_report("Got $proc"); |
|
|
|
|
|
|
|
if ( delete $started{$proc->pid()} ) { |
|
|
@ -3012,9 +3063,6 @@ sub check_testcase($$) |
|
|
|
|
|
|
|
if ( keys(%started) == 0){ |
|
|
|
# All checks completed |
|
|
|
|
|
|
|
$timeout_proc->kill(); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
# Wait for next process to exit |
|
|
@ -3055,10 +3103,9 @@ test case was executed:\n"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
elsif ( $proc eq $timeout_proc ) { |
|
|
|
$tinfo->{comment}.= "Timeout $timeout_proc for ". |
|
|
|
"'check-testcase' expired after ".check_timeout(). |
|
|
|
" seconds"; |
|
|
|
elsif ( $proc->{timeout} ) { |
|
|
|
$tinfo->{comment}.= "Timeout for 'check-testcase' expired after " |
|
|
|
.check_timeout()." seconds"; |
|
|
|
$result= 4; |
|
|
|
} |
|
|
|
else { |
|
|
@ -3073,8 +3120,6 @@ test case was executed:\n"; |
|
|
|
# Kill any check processes still running |
|
|
|
map($_->kill(), values(%started)); |
|
|
|
|
|
|
|
$timeout_proc->kill(); |
|
|
|
|
|
|
|
return $result; |
|
|
|
} |
|
|
|
|
|
|
@ -3146,11 +3191,11 @@ sub run_on_all($$) |
|
|
|
# Return immediately if no check proceess was started |
|
|
|
return 0 unless ( keys %started ); |
|
|
|
|
|
|
|
my $timeout_proc= My::SafeProcess->timer(check_timeout()); |
|
|
|
my $timeout= start_timer(check_timeout()); |
|
|
|
|
|
|
|
while (1){ |
|
|
|
my $result; |
|
|
|
my $proc= My::SafeProcess->wait_any(); |
|
|
|
my $proc= My::SafeProcess->wait_any_timeout($timeout); |
|
|
|
mtr_report("Got $proc"); |
|
|
|
|
|
|
|
if ( delete $started{$proc->pid()} ) { |
|
|
@ -3169,17 +3214,15 @@ sub run_on_all($$) |
|
|
|
|
|
|
|
if ( keys(%started) == 0){ |
|
|
|
# All completed |
|
|
|
$timeout_proc->kill(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
# Wait for next process to exit |
|
|
|
next; |
|
|
|
} |
|
|
|
elsif ( $proc eq $timeout_proc ) { |
|
|
|
$tinfo->{comment}.= "Timeout $timeout_proc for '$run' ". |
|
|
|
"expired after ". check_timeout(). |
|
|
|
" seconds"; |
|
|
|
elsif ($proc->{timeout}) { |
|
|
|
$tinfo->{comment}.= "Timeout for '$run' expired after " |
|
|
|
.check_timeout()." seconds"; |
|
|
|
} |
|
|
|
else { |
|
|
|
# Unknown process returned, most likley a crash, abort everything |
|
|
@ -3191,8 +3234,6 @@ sub run_on_all($$) |
|
|
|
# Kill any check processes still running |
|
|
|
map($_->kill(), values(%started)); |
|
|
|
|
|
|
|
$timeout_proc->kill(); |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
mtr_error("INTERNAL_ERROR: run_on_all"); |
|
|
@ -3299,9 +3340,11 @@ sub run_testcase ($) { |
|
|
|
|
|
|
|
mtr_verbose("Running test:", $tinfo->{name}); |
|
|
|
|
|
|
|
# Allow only alpanumerics pluss _ - + . in combination names |
|
|
|
# Allow only alpanumerics pluss _ - + . in combination names, |
|
|
|
# or anything beginning with -- (the latter comes from --combination) |
|
|
|
my $combination= $tinfo->{combination}; |
|
|
|
if ($combination && $combination !~ /^\w[-\w\.\+]+$/) |
|
|
|
if ($combination && $combination !~ /^\w[-\w\.\+]+$/ |
|
|
|
&& $combination !~ /^--/) |
|
|
|
{ |
|
|
|
mtr_error("Combination '$combination' contains illegal characters"); |
|
|
|
} |
|
|
@ -3422,7 +3465,7 @@ sub run_testcase ($) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout()); |
|
|
|
my $test_timeout= start_timer(testcase_timeout()); |
|
|
|
|
|
|
|
do_before_run_mysqltest($tinfo); |
|
|
|
|
|
|
@ -3430,9 +3473,6 @@ sub run_testcase ($) { |
|
|
|
# Failed to record state of server or server crashed |
|
|
|
report_failure_and_restart($tinfo); |
|
|
|
|
|
|
|
# Stop the test case timer |
|
|
|
$test_timeout_proc->kill(); |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
@ -3450,20 +3490,20 @@ sub run_testcase ($) { |
|
|
|
if ($proc) |
|
|
|
{ |
|
|
|
mtr_verbose ("Found exited process $proc"); |
|
|
|
# If that was the timeout, cancel waiting |
|
|
|
if ( $proc eq $test_timeout_proc ) |
|
|
|
{ |
|
|
|
$keep_waiting_proc = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
$proc = $keep_waiting_proc; |
|
|
|
# Also check if timer has expired, if so cancel waiting |
|
|
|
if ( has_expired($test_timeout) ) |
|
|
|
{ |
|
|
|
$keep_waiting_proc = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
if (! $keep_waiting_proc) |
|
|
|
{ |
|
|
|
$proc= My::SafeProcess->wait_any(); |
|
|
|
$proc= My::SafeProcess->wait_any_timeout($test_timeout); |
|
|
|
} |
|
|
|
|
|
|
|
# Will be restored if we need to keep waiting |
|
|
@ -3480,9 +3520,6 @@ sub run_testcase ($) { |
|
|
|
# ---------------------------------------------------- |
|
|
|
if ($proc eq $test) |
|
|
|
{ |
|
|
|
# Stop the test case timer |
|
|
|
$test_timeout_proc->kill(); |
|
|
|
|
|
|
|
my $res= $test->exit_status(); |
|
|
|
|
|
|
|
if ($res == 0 and $opt_warnings and check_warnings($tinfo) ) |
|
|
@ -3539,6 +3576,14 @@ sub run_testcase ($) { |
|
|
|
run_on_all($tinfo, "analyze-$analyze"); |
|
|
|
} |
|
|
|
|
|
|
|
# Wait a bit and see if a server died, if so report that instead |
|
|
|
mtr_milli_sleep(100); |
|
|
|
my $srvproc= My::SafeProcess::check_any(); |
|
|
|
if ($srvproc && grep($srvproc eq $_, started(all_servers()))) { |
|
|
|
$proc= $srvproc; |
|
|
|
goto SRVDIED; |
|
|
|
} |
|
|
|
|
|
|
|
# Test case failure reported by mysqltest |
|
|
|
report_failure_and_restart($tinfo); |
|
|
|
} |
|
|
@ -3546,7 +3591,7 @@ sub run_testcase ($) { |
|
|
|
{ |
|
|
|
# mysqltest failed, probably crashed |
|
|
|
$tinfo->{comment}= |
|
|
|
"mysqltest failed with unexpected return code $res"; |
|
|
|
"mysqltest failed with unexpected return code $res\n"; |
|
|
|
report_failure_and_restart($tinfo); |
|
|
|
} |
|
|
|
|
|
|
@ -3564,6 +3609,7 @@ sub run_testcase ($) { |
|
|
|
# ---------------------------------------------------- |
|
|
|
# Check if it was an expected crash |
|
|
|
# ---------------------------------------------------- |
|
|
|
SRVDIED: |
|
|
|
my $check_crash = check_expected_crash_and_restart($proc); |
|
|
|
if ($check_crash) |
|
|
|
{ |
|
|
@ -3576,7 +3622,7 @@ sub run_testcase ($) { |
|
|
|
# ---------------------------------------------------- |
|
|
|
# Stop the test case timer |
|
|
|
# ---------------------------------------------------- |
|
|
|
$test_timeout_proc->kill(); |
|
|
|
$test_timeout= 0; |
|
|
|
|
|
|
|
# ---------------------------------------------------- |
|
|
|
# Check if it was a server that died |
|
|
@ -3615,7 +3661,7 @@ sub run_testcase ($) { |
|
|
|
# ---------------------------------------------------- |
|
|
|
# Check if testcase timer expired |
|
|
|
# ---------------------------------------------------- |
|
|
|
if ( $proc eq $test_timeout_proc ) |
|
|
|
if ( $proc->{timeout} ) |
|
|
|
{ |
|
|
|
my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log"; |
|
|
|
$tinfo->{comment}= |
|
|
@ -3737,16 +3783,24 @@ sub extract_warning_lines ($$) { |
|
|
|
( |
|
|
|
qr/^Warning:|mysqld: Warning|\[Warning\]/, |
|
|
|
qr/^Error:|\[ERROR\]/, |
|
|
|
qr/^==\d*==/, # valgrind errors |
|
|
|
qr/^==\d+==\s+\S/, # valgrind errors |
|
|
|
qr/InnoDB: Warning|InnoDB: Error/, |
|
|
|
qr/^safe_mutex:|allocated at line/, |
|
|
|
qr/missing DBUG_RETURN/, |
|
|
|
qr/Attempting backtrace/, |
|
|
|
qr/Assertion .* failed/, |
|
|
|
); |
|
|
|
my $skip_valgrind= 0; |
|
|
|
|
|
|
|
foreach my $line ( @lines ) |
|
|
|
{ |
|
|
|
if ($opt_valgrind_mysqld) { |
|
|
|
# Skip valgrind summary from tests where server has been restarted |
|
|
|
# Should this contain memory leaks, the final report will find it |
|
|
|
$skip_valgrind= 1 if $line =~ /^==\d+== ERROR SUMMARY:/; |
|
|
|
$skip_valgrind= 0 unless $line =~ /^==\d+==/; |
|
|
|
next if $skip_valgrind; |
|
|
|
} |
|
|
|
foreach my $pat ( @patterns ) |
|
|
|
{ |
|
|
|
if ( $line =~ /$pat/ ) |
|
|
@ -3786,7 +3840,6 @@ sub start_check_warnings ($$) { |
|
|
|
|
|
|
|
mtr_add_arg($args, "--skip-safemalloc"); |
|
|
|
mtr_add_arg($args, "--test-file=%s", "include/check-warnings.test"); |
|
|
|
mtr_add_arg($args, "--verbose"); |
|
|
|
|
|
|
|
if ( $opt_embedded_server ) |
|
|
|
{ |
|
|
@ -3849,11 +3902,11 @@ sub check_warnings ($) { |
|
|
|
# Return immediately if no check proceess was started |
|
|
|
return 0 unless ( keys %started ); |
|
|
|
|
|
|
|
my $timeout_proc= My::SafeProcess->timer(check_timeout()); |
|
|
|
my $timeout= start_timer(check_timeout()); |
|
|
|
|
|
|
|
while (1){ |
|
|
|
my $result= 0; |
|
|
|
my $proc= My::SafeProcess->wait_any(); |
|
|
|
my $proc= My::SafeProcess->wait_any_timeout($timeout); |
|
|
|
mtr_report("Got $proc"); |
|
|
|
|
|
|
|
if ( delete $started{$proc->pid()} ) { |
|
|
@ -3882,9 +3935,6 @@ sub check_warnings ($) { |
|
|
|
|
|
|
|
if ( keys(%started) == 0){ |
|
|
|
# All checks completed |
|
|
|
|
|
|
|
$timeout_proc->kill(); |
|
|
|
|
|
|
|
return $result; |
|
|
|
} |
|
|
|
# Wait for next process to exit |
|
|
@ -3901,10 +3951,9 @@ sub check_warnings ($) { |
|
|
|
$result= 2; |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ( $proc eq $timeout_proc ) { |
|
|
|
$tinfo->{comment}.= "Timeout $timeout_proc for ". |
|
|
|
"'check warnings' expired after ".check_timeout(). |
|
|
|
" seconds"; |
|
|
|
elsif ( $proc->{timeout} ) { |
|
|
|
$tinfo->{comment}.= "Timeout for 'check warnings' expired after " |
|
|
|
.check_timeout()." seconds"; |
|
|
|
$result= 4; |
|
|
|
} |
|
|
|
else { |
|
|
@ -3918,8 +3967,6 @@ sub check_warnings ($) { |
|
|
|
# Kill any check processes still running |
|
|
|
map($_->kill(), values(%started)); |
|
|
|
|
|
|
|
$timeout_proc->kill(); |
|
|
|
|
|
|
|
return $result; |
|
|
|
} |
|
|
|
|
|
|
@ -3937,7 +3984,7 @@ sub check_expected_crash_and_restart { |
|
|
|
|
|
|
|
foreach my $mysqld ( mysqlds() ) |
|
|
|
{ |
|
|
|
next unless ( $mysqld->{proc} eq $proc ); |
|
|
|
next unless ( $mysqld->{proc} and $mysqld->{proc} eq $proc ); |
|
|
|
|
|
|
|
# Check if crash expected by looking at the .expect file |
|
|
|
# in var/tmp |
|
|
@ -4135,6 +4182,20 @@ sub report_failure_and_restart ($) { |
|
|
|
# about what failed has been saved to file. Save the report |
|
|
|
# in tinfo |
|
|
|
$tinfo->{logfile}= mtr_fromfile($logfile); |
|
|
|
# If no newlines in the test log: |
|
|
|
# (it will contain the CURRENT_TEST written by mtr, so is not empty) |
|
|
|
if ($tinfo->{logfile} !~ /\n/) |
|
|
|
{ |
|
|
|
# Show how far it got before suddenly failing |
|
|
|
$tinfo->{comment}.= "mysqltest failed but provided no output\n"; |
|
|
|
my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log"; |
|
|
|
if (-e $log_file_name) { |
|
|
|
$tinfo->{comment}.= |
|
|
|
"The result from queries just before the failure was:". |
|
|
|
"\n< snip >\n". |
|
|
|
mtr_lastlinesfromfile($log_file_name, 20)."\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -4344,6 +4405,10 @@ sub mysqld_start ($$) { |
|
|
|
# see the exact location where valgrind complains |
|
|
|
$output= "$opt_vardir/log/".$mysqld->name().".trace"; |
|
|
|
} |
|
|
|
# Remember this log file for valgrind error report search |
|
|
|
$mysqld_logs{$output}= 1 if $opt_valgrind; |
|
|
|
# Remember data dir for gmon.out files if using gprof |
|
|
|
$gprof_dirs{$mysqld->value('datadir')}= 1 if $opt_gprof; |
|
|
|
|
|
|
|
if ( defined $exe ) |
|
|
|
{ |
|
|
@ -4893,6 +4958,10 @@ sub start_mysqltest ($) { |
|
|
|
mtr_add_arg($args, "--ssl"); |
|
|
|
} |
|
|
|
|
|
|
|
if ( $opt_max_connections ) { |
|
|
|
mtr_add_arg($args, "--max-connections=%d", $opt_max_connections); |
|
|
|
} |
|
|
|
|
|
|
|
if ( $opt_embedded_server ) |
|
|
|
{ |
|
|
|
|
|
|
@ -4993,7 +5062,7 @@ sub gdb_arguments { |
|
|
|
my $type= shift; |
|
|
|
|
|
|
|
# Write $args to gdb init file |
|
|
|
my $str= join(" ", @$$args); |
|
|
|
my $str= join " ", map { s/"/\\"/g; "\"$_\""; } @$$args; |
|
|
|
my $gdb_init_file= "$opt_vardir/tmp/gdbinit.$type"; |
|
|
|
|
|
|
|
# Remove the old gdbinit file |
|
|
@ -5057,7 +5126,7 @@ sub ddd_arguments { |
|
|
|
my $type= shift; |
|
|
|
|
|
|
|
# Write $args to ddd init file |
|
|
|
my $str= join(" ", @$$args); |
|
|
|
my $str= join " ", map { s/"/\\"/g; "\"$_\""; } @$$args; |
|
|
|
my $gdb_init_file= "$opt_vardir/tmp/gdbinit.$type"; |
|
|
|
|
|
|
|
# Remove the old gdbinit file |
|
|
@ -5121,9 +5190,9 @@ sub debugger_arguments { |
|
|
|
{ |
|
|
|
# vc[express] /debugexe exe arg1 .. argn |
|
|
|
|
|
|
|
# Add /debugexe and name of the exe before args |
|
|
|
unshift(@$$args, "/debugexe"); |
|
|
|
# Add name of the exe and /debugexe before args |
|
|
|
unshift(@$$args, "$$exe"); |
|
|
|
unshift(@$$args, "/debugexe"); |
|
|
|
|
|
|
|
# Set exe to debuggername |
|
|
|
$$exe= $debugger; |
|
|
@ -5196,6 +5265,66 @@ sub valgrind_arguments { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
# Search server logs for valgrind reports printed at mysqld termination |
|
|
|
# |
|
|
|
|
|
|
|
sub valgrind_exit_reports() { |
|
|
|
foreach my $log_file (keys %mysqld_logs) |
|
|
|
{ |
|
|
|
my @culprits= (); |
|
|
|
my $valgrind_rep= ""; |
|
|
|
my $found_report= 0; |
|
|
|
my $err_in_report= 0; |
|
|
|
|
|
|
|
my $LOGF = IO::File->new($log_file) |
|
|
|
or mtr_error("Could not open file '$log_file' for reading: $!"); |
|
|
|
|
|
|
|
while ( my $line = <$LOGF> ) |
|
|
|
{ |
|
|
|
if ($line =~ /^CURRENT_TEST: (.+)$/) |
|
|
|
{ |
|
|
|
my $testname= $1; |
|
|
|
# If we have a report, report it if needed and start new list of tests |
|
|
|
if ($found_report) |
|
|
|
{ |
|
|
|
if ($err_in_report) |
|
|
|
{ |
|
|
|
mtr_print ("Valgrind report from $log_file after tests:\n", |
|
|
|
@culprits); |
|
|
|
mtr_print_line(); |
|
|
|
print ("$valgrind_rep\n"); |
|
|
|
$err_in_report= 0; |
|
|
|
} |
|
|
|
# Make ready to collect new report |
|
|
|
@culprits= (); |
|
|
|
$found_report= 0; |
|
|
|
$valgrind_rep= ""; |
|
|
|
} |
|
|
|
push (@culprits, $testname); |
|
|
|
next; |
|
|
|
} |
|
|
|
# This line marks the start of a valgrind report |
|
|
|
$found_report= 1 if $line =~ /ERROR SUMMARY:/; |
|
|
|
|
|
|
|
if ($found_report) { |
|
|
|
$line=~ s/^==\d+== //; |
|
|
|
$valgrind_rep .= $line; |
|
|
|
$err_in_report= 1 if $line =~ /ERROR SUMMARY: [1-9]/; |
|
|
|
$err_in_report= 1 if $line =~ /definitely lost: [1-9]/; |
|
|
|
$err_in_report= 1 if $line =~ /possibly lost: [1-9]/; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$LOGF= undef; |
|
|
|
|
|
|
|
if ($err_in_report) { |
|
|
|
mtr_print ("Valgrind report from $log_file after tests:\n", @culprits); |
|
|
|
mtr_print_line(); |
|
|
|
print ("$valgrind_rep\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
# Usage |
|
|
@ -5275,6 +5404,11 @@ Options to control what test suites or cases to run |
|
|
|
|
|
|
|
Options that specify ports |
|
|
|
|
|
|
|
mtr-port-base=# Base for port numbers, ports from this number to |
|
|
|
port-base=# number+9 are reserved. Should be divisible by 10; |
|
|
|
if not it will be rounded down. May be set with |
|
|
|
environment variable MTR_PORT_BASE. If this value is |
|
|
|
set and is not "auto", it overrides build-thread. |
|
|
|
mtr-build-thread=# Specify unique number to calculate port number(s) from. |
|
|
|
build-thread=# Can be set in environment variable MTR_BUILD_THREAD. |
|
|
|
Set MTR_BUILD_THREAD="auto" to automatically aquire |
|
|
@ -5386,9 +5520,22 @@ Misc options |
|
|
|
timestamp Print timestamp before each test report line |
|
|
|
timediff With --timestamp, also print time passed since |
|
|
|
*previous* test started |
|
|
|
max-connections=N Max number of open connection to server in mysqltest |
|
|
|
|
|
|
|
HERE |
|
|
|
exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sub list_options ($) { |
|
|
|
my $hash= shift; |
|
|
|
|
|
|
|
for (keys %$hash) { |
|
|
|
s/([:=].*|[+!])$//; |
|
|
|
s/\|/\n--/g; |
|
|
|
print "--$_\n" unless /list-options/; |
|
|
|
} |
|
|
|
|
|
|
|
exit(1); |
|
|
|
} |
|
|
|
|