summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/mtr_cases.pl290
-rw-r--r--mysql-test/lib/mtr_gcov.pl18
-rw-r--r--mysql-test/lib/mtr_io.pl26
-rw-r--r--mysql-test/lib/mtr_misc.pl37
-rw-r--r--mysql-test/lib/mtr_process.pl116
-rw-r--r--mysql-test/lib/mtr_report.pl52
-rw-r--r--mysql-test/lib/mtr_timer.pl29
7 files changed, 346 insertions, 222 deletions
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index bb92730444c..d270d72d526 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -59,7 +59,9 @@ sub collect_test_cases ($) {
if ( @::opt_cases )
{
- foreach my $tname ( @::opt_cases ) { # Run in specified order, no sort
+ foreach my $tname ( @::opt_cases )
+ {
+ # Run in specified order, no sort
my $elem= undef;
my $component_id= undef;
@@ -85,7 +87,7 @@ sub collect_test_cases ($) {
# If target component is known, check that the specified test case
# exists.
- #
+ #
# Otherwise, try to guess the target component.
if ( $component_id )
@@ -127,7 +129,8 @@ sub collect_test_cases ($) {
}
else
{
- foreach my $elem ( sort readdir(TESTDIR) ) {
+ foreach my $elem ( sort readdir(TESTDIR) )
+ {
my $component_id= undef;
my $tname= undef;
@@ -143,8 +146,10 @@ sub collect_test_cases ($) {
{
next;
}
-
- next if $::opt_do_test and ! defined mtr_match_prefix($elem,$::opt_do_test);
+
+ # Skip tests that does not match the --do-test= filter
+ next if $::opt_do_test and
+ ! defined mtr_match_prefix($elem,$::opt_do_test);
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled,
$component_id);
@@ -152,43 +157,79 @@ sub collect_test_cases ($) {
closedir TESTDIR;
}
- # To speed things up, we sort first in if the test require a restart
- # or not, second in alphanumeric order.
-
+ # Reorder the test cases in an order that will make them faster to run
if ( $::opt_reorder )
{
my %sort_criteria;
- my $tinfo;
# Make a mapping of test name to a string that represents how that test
# should be sorted among the other tests. Put the most important criterion
# first, then a sub-criterion, then sub-sub-criterion, et c.
- foreach $tinfo (@$cases)
+ foreach my $tinfo (@$cases)
{
- my @this_criteria = ();
-
- # Append the criteria for sorting, in order of importance.
- push(@this_criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~"); # Ending with "~" makes empty sort later than filled
- push(@this_criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
- push(@this_criteria, "restart=" . ($tinfo->{'master_restart'} ? "1" : "0"));
- push(@this_criteria, "big_test=" . ($tinfo->{'big_test'} ? "1" : "0"));
- push(@this_criteria, join("|", sort keys %{$tinfo})); # Group similar things together. The values may differ substantially. FIXME?
- push(@this_criteria, $tinfo->{'name'}); # Finally, order by the name
-
- $sort_criteria{$tinfo->{"name"}} = join(" ", @this_criteria);
+ my @criteria = ();
+
+ # Look for tests that muct be in run in a defined order
+ # that is defined by test having the same name except for
+ # the ending digit
+
+ # Put variables into hash
+ my $test_name= $tinfo->{'name'};
+ my $depend_on_test_name;
+ if ( $test_name =~ /^([\D]+)([0-9]{1})$/ )
+ {
+ my $base_name= $1;
+ my $idx= $2;
+ mtr_verbose("$test_name => $base_name idx=$idx");
+ if ( $idx > 1 )
+ {
+ $idx-= 1;
+ $base_name= "$base_name$idx";
+ mtr_verbose("New basename $base_name");
+ }
+
+ foreach my $tinfo2 (@$cases)
+ {
+ if ( $tinfo2->{'name'} eq $base_name )
+ {
+ mtr_verbose("found dependent test $tinfo2->{'name'}");
+ $depend_on_test_name=$base_name;
+ }
+ }
+ }
+
+ if ( defined $depend_on_test_name )
+ {
+ mtr_verbose("Giving $test_name same critera as $depend_on_test_name");
+ $sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name};
+ }
+ else
+ {
+ #
+ # Append the criteria for sorting, in order of importance.
+ #
+ push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
+ # Group test with equal options together.
+ # Ending with "~" makes empty sort later than filled
+ push(@criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~");
+
+ $sort_criteria{$test_name} = join(" ", @criteria);
+ }
}
- @$cases = sort { $sort_criteria{$a->{"name"}} cmp $sort_criteria{$b->{"name"}}; } @$cases;
+ @$cases = sort {
+ $sort_criteria{$a->{'name'}} . $a->{'name'} cmp
+ $sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
-### For debugging the sort-order
-# foreach $tinfo (@$cases)
-# {
-# print $sort_criteria{$tinfo->{"name"}};
-# print " -> \t";
-# print $tinfo->{"name"};
-# print "\n";
-# }
+ if ( $::opt_script_debug )
+ {
+ # For debugging the sort-order
+ foreach my $tinfo (@$cases)
+ {
+ print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
+ }
+ }
}
return $cases;
@@ -222,9 +263,6 @@ sub collect_one_test_case($$$$$$$) {
return;
}
- # ----------------------------------------------------------------------
- # Skip some tests but include in list, just mark them to skip
- # ----------------------------------------------------------------------
my $tinfo= {};
$tinfo->{'name'}= $tname;
@@ -232,6 +270,10 @@ sub collect_one_test_case($$$$$$$) {
$tinfo->{'component_id'} = $component_id;
push(@$cases, $tinfo);
+ # ----------------------------------------------------------------------
+ # Skip some tests but include in list, just mark them to skip
+ # ----------------------------------------------------------------------
+
if ( $::opt_skip_test and defined mtr_match_prefix($tname,$::opt_skip_test) )
{
$tinfo->{'skip'}= 1;
@@ -245,6 +287,7 @@ sub collect_one_test_case($$$$$$$) {
$tinfo->{'path'}= $path;
$tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work
+ $tinfo->{'slave_num'}= 0; # Default, no slave
if ( defined mtr_match_prefix($tname,"rpl") )
{
if ( $::opt_skip_rpl )
@@ -254,7 +297,8 @@ sub collect_one_test_case($$$$$$$) {
return;
}
- $tinfo->{'slave_num'}= 1; # Default, use one slave
+
+ $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' )
{
@@ -268,40 +312,6 @@ sub collect_one_test_case($$$$$$$) {
$tinfo->{'slave_num'}= 1;
}
- if ( $::opt_with_ndbcluster or defined mtr_match_substring($tname,"ndb") )
- {
- # This is an ndb test or all tests should be run with ndb cluster started
- $tinfo->{'ndb_test'}= 1;
- if ( $::opt_skip_ndbcluster )
- {
- # All ndb test's should be skipped
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "No ndbcluster test(--skip-ndbcluster)";
- return;
- }
- if ( ! $::opt_ndbcluster_supported )
- {
- # Ndb is not supported, skip them
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "No ndbcluster support";
- return;
- }
- }
- else
- {
- # This is not a ndb test
- $tinfo->{'ndb_test'}= 0;
- if ( $::opt_with_ndbcluster_only )
- {
- # Only the ndb test should be run, all other should be skipped
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "Only ndbcluster tests(--with-ndbcluster-only)";
- return;
- }
- }
-
- # FIXME what about embedded_server + ndbcluster, skip ?!
-
my $master_opt_file= "$testdir/$tname-master.opt";
my $slave_opt_file= "$testdir/$tname-slave.opt";
my $slave_mi_file= "$testdir/$tname.slave-mi";
@@ -316,57 +326,59 @@ sub collect_one_test_case($$$$$$$) {
if ( -f $master_opt_file )
{
- $tinfo->{'master_restart'}= 1; # We think so for now
- MASTER_OPT:
- {
- my $master_opt= mtr_get_opts_from_file($master_opt_file);
+ my $master_opt= mtr_get_opts_from_file($master_opt_file);
- foreach my $opt ( @$master_opt )
- {
- my $value;
+ foreach my $opt ( @$master_opt )
+ {
+ my $value;
- # This is a dirty hack from old mysql-test-run, we use the opt
- # file to flag other things as well, it is not a opt list at
- # all
+ # The opt file is used both to send special options to the mysqld
+ # as well as pass special test case specific options to this
+ # script
- $value= mtr_match_prefix($opt, "--timezone=");
- if ( defined $value )
- {
- $tinfo->{'timezone'}= $value;
- last MASTER_OPT;
- }
+ $value= mtr_match_prefix($opt, "--timezone=");
+ if ( defined $value )
+ {
+ $tinfo->{'timezone'}= $value;
+ next;
+ }
- $value= mtr_match_prefix($opt, "--result-file=");
- if ( defined $value )
- {
- $tinfo->{'result_file'}= "r/$value.result";
- if ( $::opt_result_ext and $::opt_record or
- -f "$tinfo->{'result_file'}$::opt_result_ext")
- {
- $tinfo->{'result_file'}.= $::opt_result_ext;
- }
- $tinfo->{'master_restart'}= 0;
- last MASTER_OPT;
- }
+ $value= mtr_match_prefix($opt, "--result-file=");
+ if ( defined $value )
+ {
+ # Specifies the file mysqltest should compare
+ # output against
+ $tinfo->{'result_file'}= "r/$value.result";
+ next;
+ }
- # If we set default time zone, remove the one we have
- $value= mtr_match_prefix($opt, "--default-time-zone=");
- if ( defined $value )
- {
- $tinfo->{'master_opt'}= [];
- }
+ # If we set default time zone, remove the one we have
+ $value= mtr_match_prefix($opt, "--default-time-zone=");
+ if ( defined $value )
+ {
+ # Set timezone for this test case to something different
+ $tinfo->{'timezone'}= "GMT-8";
+ # Fallthrough, add the --default-time-zone option
+ }
+ # The --restart option forces a restart even if no special
+ # option is set. If the options are the same as next testcase
+ # there is no need to restart after the testcase
+ # has completed
+ if ( $opt eq "--force-restart" )
+ {
+ $tinfo->{'force_restart'}= 1;
+ next;
}
- # Ok, this was a real option list, add it
- push(@{$tinfo->{'master_opt'}}, @$master_opt);
+ # Ok, this was a real option, add it
+ push(@{$tinfo->{'master_opt'}}, $opt);
}
}
if ( -f $slave_opt_file )
{
- $tinfo->{'slave_restart'}= 1;
my $slave_opt= mtr_get_opts_from_file($slave_opt_file);
foreach my $opt ( @$slave_opt )
@@ -381,7 +393,6 @@ sub collect_one_test_case($$$$$$$) {
if ( -f $slave_mi_file )
{
$tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
- $tinfo->{'slave_restart'}= 1;
}
if ( -f $master_sh )
@@ -395,7 +406,6 @@ sub collect_one_test_case($$$$$$$) {
else
{
$tinfo->{'master_sh'}= $master_sh;
- $tinfo->{'master_restart'}= 1;
}
}
@@ -410,7 +420,6 @@ sub collect_one_test_case($$$$$$$) {
else
{
$tinfo->{'slave_sh'}= $slave_sh;
- $tinfo->{'slave_restart'}= 1;
}
}
@@ -514,18 +523,50 @@ sub collect_one_test_case($$$$$$$) {
$tinfo->{'comment'}= "Test need debug binaries";
return;
}
- }
- # We can't restart a running server that may be in use
+ if ( $tinfo->{'ndb_test'} )
+ {
+ # This is a NDB test
+ if ( ! $::glob_ndbcluster_supported )
+ {
+ # Ndb is not supported, skip it
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No ndbcluster support";
+ return;
+ }
+ elsif ( $::opt_skip_ndbcluster )
+ {
+ # All ndb test's should be skipped
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No ndbcluster tests(--skip-ndbcluster)";
+ return;
+ }
+ }
+ else
+ {
+ # This is not a ndb test
+ if ( $::opt_with_ndbcluster_only )
+ {
+ # Only the ndb test should be run, all other should be skipped
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Only ndbcluster tests(--with-ndbcluster-only)";
+ return;
+ }
+ }
+
+ if ( $tinfo->{'innodb_test'} )
+ {
+ # This is a test that need inndob
+ if ( $::mysqld_variables{'innodb'} eq "FALSE" )
+ {
+ # innodb is not supported, skip it
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No innodb support";
+ return;
+ }
+ }
- if ( $::glob_use_running_server and
- ( $tinfo->{'master_restart'} or $tinfo->{'slave_restart'} ) )
- {
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "Can't restart a running server";
- return;
}
-
}
@@ -536,8 +577,10 @@ our @tags=
["include/have_innodb.inc", "innodb_test", 1],
["include/have_binlog_format_row.inc", "binlog_format", "row"],
["include/have_binlog_format_statement.inc", "binlog_format", "stmt"],
+ ["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"],
["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1],
+ ["include/have_ndb.inc", "ndb_test", 1],
["include/have_ndb_extra.inc", "ndb_extra", 1],
["require_manager", "require_manager", 1],
);
@@ -550,8 +593,6 @@ sub mtr_options_from_test_file($$) {
while ( my $line= <$F> )
{
- next if ( $line !~ /^--/ );
-
# Match this line against tag in "tags" array
foreach my $tag (@tags)
{
@@ -563,14 +604,21 @@ sub mtr_options_from_test_file($$) {
}
# If test sources another file, open it as well
- if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ )
+ if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ or
+ $line =~ /^([[:space:]]*)source(.*);$/ )
{
my $value= $2;
$value =~ s/^\s+//; # Remove leading space
$value =~ s/[[:space:]]+$//; # Remove ending space
my $sourced_file= "$::glob_mysql_test_dir/$value";
- mtr_options_from_test_file($tinfo, $sourced_file);
+ if ( -f $sourced_file )
+ {
+ # Only source the file if it exists, we may get
+ # false positives in the regexes above if someone
+ # writes "source nnnn;" in a test case(such as mysqltest.test)
+ mtr_options_from_test_file($tinfo, $sourced_file);
+ }
}
}
diff --git a/mysql-test/lib/mtr_gcov.pl b/mysql-test/lib/mtr_gcov.pl
index 07aac1d2017..71d3d6a2a43 100644
--- a/mysql-test/lib/mtr_gcov.pl
+++ b/mysql-test/lib/mtr_gcov.pl
@@ -23,12 +23,28 @@ sub gcov_prepare () {
-or -name \*.da | xargs rm`;
}
+# Used by gcov
+our @mysqld_src_dirs=
+ (
+ "strings",
+ "mysys",
+ "include",
+ "extra",
+ "regex",
+ "isam",
+ "merge",
+ "myisam",
+ "myisammrg",
+ "heap",
+ "sql",
+ );
+
sub gcov_collect () {
print "Collecting source coverage info...\n";
-f $::opt_gcov_msg and unlink($::opt_gcov_msg);
-f $::opt_gcov_err and unlink($::opt_gcov_err);
- foreach my $d ( @::mysqld_src_dirs )
+ foreach my $d ( @mysqld_src_dirs )
{
chdir("$::glob_basedir/$d");
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl
index e8dcb0262c9..984d834486c 100644
--- a/mysql-test/lib/mtr_io.pl
+++ b/mysql-test/lib/mtr_io.pl
@@ -12,6 +12,7 @@ sub mtr_fromfile ($);
sub mtr_tofile ($@);
sub mtr_tonewfile($@);
sub mtr_lastlinefromfile($);
+sub mtr_appendfile_to_file ($$);
##############################################################################
#
@@ -36,18 +37,16 @@ sub mtr_get_pid_from_file ($) {
open(FILE, '<', $pid_file_path)
or mtr_error("can't open file \"$pid_file_path\": $!");
+ # Read pid number from file
my $pid= <FILE>;
-
- chomp($pid) if defined $pid;
-
close FILE;
- return $pid if defined $pid && $pid ne '';
+ return $pid if $pid=~ /^(\d+)/;
- mtr_debug("Pid file '$pid_file_path' is empty. " .
- "Sleeping $timeout second(s)...");
+ mtr_debug("Pid file '$pid_file_path' does not yet contain pid number.\n" .
+ "Sleeping $timeout second(s) more...");
- sleep(1);
+ sleep($timeout);
}
mtr_error("Pid file '$pid_file_path' is corrupted. " .
@@ -170,4 +169,17 @@ sub mtr_tonewfile ($@) {
close FILE;
}
+sub mtr_appendfile_to_file ($$) {
+ my $from_file= shift;
+ my $to_file= shift;
+
+ open(TOFILE,">>",$to_file) or mtr_error("can't open file \"$to_file\": $!");
+ open(FROMFILE,"<",$from_file)
+ or mtr_error("can't open file \"$from_file\": $!");
+ print TOFILE while (<FROMFILE>);
+ close FROMFILE;
+ close TOFILE;
+}
+
+
1;
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index dd9d24ebc8e..ea163eeba22 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -14,6 +14,7 @@ sub mtr_path_exists(@);
sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@);
+sub mtr_exe_maybe_exists(@);
sub mtr_copy_dir($$);
sub mtr_same_opts($$);
sub mtr_cmp_opts($$);
@@ -65,6 +66,9 @@ sub mtr_add_arg ($$@) {
##############################################################################
+# Note - More specific paths should be given before less specific. For examle
+# /client/debug should be listed before /client
+
sub mtr_path_exists (@) {
foreach my $path ( @_ )
{
@@ -80,6 +84,9 @@ sub mtr_path_exists (@) {
}
}
+# Note - More specific paths should be given before less specific. For examle
+# /client/debug should be listed before /client
+
sub mtr_script_exists (@) {
foreach my $path ( @_ )
{
@@ -110,8 +117,23 @@ sub mtr_file_exists (@) {
return "";
}
-sub mtr_exe_exists (@) {
+# Note - More specific paths should be given before less specific. For examle
+# /client/debug should be listed before /client
+
+sub mtr_file_exists (@) {
+ foreach my $path ( @_ )
+ {
+ return $path if -e $path;
+ }
+ return "";
+}
+
+# Note - More specific paths should be given before less specific. For examle
+# /client/debug should be listed before /client
+
+sub mtr_exe_maybe_exists (@) {
my @path= @_;
+
map {$_.= ".exe"} @path if $::glob_win32;
foreach my $path ( @path )
{
@@ -124,6 +146,19 @@ sub mtr_exe_exists (@) {
return $path if -x $path;
}
}
+ return "";
+}
+
+# Note - More specific paths should be given before less specific. For examle
+# /client/debug should be listed before /client
+
+sub mtr_exe_exists (@) {
+ my @path= @_;
+ if (my $path= mtr_exe_maybe_exists(@path))
+ {
+ return $path;
+ }
+ # Could not find exe, show error
if ( @path == 1 )
{
mtr_error("Could not find $path[0]");
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 868b6d4f1ec..048c336f8a3 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -4,12 +4,10 @@
# and is part of the translation of the Bourne shell script with the
# same name.
-#use Carp qw(cluck);
use Socket;
use Errno;
use strict;
-#use POSIX ":sys_wait_h";
use POSIX 'WNOHANG';
sub mtr_run ($$$$$$;$);
@@ -93,8 +91,6 @@ sub spawn_impl ($$$$$$$$) {
my $pid_file= shift; # FIXME
my $spawn_opts= shift;
- mtr_error("Can't spawn with empty \"path\"") unless defined $path;
-
if ( $::opt_script_debug )
{
print STDERR "\n";
@@ -118,6 +114,9 @@ sub spawn_impl ($$$$$$$$) {
print STDERR "#### ", "-" x 78, "\n";
}
+ mtr_error("Can't spawn with empty \"path\"") unless defined $path;
+
+
FORK:
{
my $pid= fork();
@@ -339,19 +338,6 @@ sub mtr_kill_leftovers () {
mtr_report("Killing Possible Leftover Processes");
mtr_debug("mtr_kill_leftovers(): started.");
- mkpath("$::opt_vardir/log"); # Needed for mysqladmin log
-
- # Stop or kill Instance Manager and all its children. If we failed to do
- # that, we can only abort -- there is nothing left to do.
-
- mtr_error("Failed to stop Instance Manager.")
- unless mtr_im_stop($::instance_manager);
-
- # Start shutdown of masters and slaves. Don't touch IM-managed mysqld
- # instances -- they should be stopped by mtr_im_stop().
-
- mtr_debug("Shutting down mysqld-instances...");
-
my @kill_pids;
my %admin_pids;
@@ -377,40 +363,41 @@ sub mtr_kill_leftovers () {
$srv->{'pid'}= 0; # Assume we are done with it
}
- # Start shutdown of clusters.
-
- mtr_debug("Shutting down cluster...");
-
- foreach my $cluster (@{$::clusters})
+ if ( ! $::opt_skip_ndbcluster )
{
- mtr_debug(" - cluster " .
- "(pid: $cluster->{pid}; " .
- "pid file: '$cluster->{path_pid})");
-
- my $pid= mtr_ndbmgm_start($cluster, "shutdown");
-
- # Save the pid of the ndb_mgm process
- $admin_pids{$pid}= 1;
+ # Start shutdown of clusters.
+ mtr_debug("Shutting down cluster...");
- push(@kill_pids,{
- pid => $cluster->{'pid'},
- pidfile => $cluster->{'path_pid'}
- });
+ foreach my $cluster (@{$::clusters})
+ {
+ mtr_debug(" - cluster " .
+ "(pid: $cluster->{pid}; " .
+ "pid file: '$cluster->{path_pid})");
- $cluster->{'pid'}= 0; # Assume we are done with it
+ my $pid= mtr_ndbmgm_start($cluster, "shutdown");
-
- foreach my $ndbd (@{$cluster->{'ndbds'}})
- {
- mtr_debug(" - ndbd " .
- "(pid: $ndbd->{pid}; " .
- "pid file: '$ndbd->{path_pid})");
+ # Save the pid of the ndb_mgm process
+ $admin_pids{$pid}= 1;
push(@kill_pids,{
- pid => $ndbd->{'pid'},
- pidfile => $ndbd->{'path_pid'},
+ pid => $cluster->{'pid'},
+ pidfile => $cluster->{'path_pid'}
});
- $ndbd->{'pid'}= 0; # Assume we are done with it
+
+ $cluster->{'pid'}= 0; # Assume we are done with it
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
+ {
+ mtr_debug(" - ndbd " .
+ "(pid: $ndbd->{pid}; " .
+ "pid file: '$ndbd->{path_pid})");
+
+ push(@kill_pids,{
+ pid => $ndbd->{'pid'},
+ pidfile => $ndbd->{'path_pid'},
+ });
+ $ndbd->{'pid'}= 0; # Assume we are done with it
+ }
}
}
@@ -451,25 +438,35 @@ sub mtr_kill_leftovers () {
while ( my $elem= readdir(RUNDIR) )
{
- my $pidfile= "$rundir/$elem";
-
- if ( -f $pidfile )
+ # Only read pid from files that end with .pid
+ if ( $elem =~ /.*[.]pid$/)
{
- mtr_debug("Processing PID file: '$pidfile'...");
- my $pid= mtr_get_pid_from_file($pidfile);
+ my $pidfile= "$rundir/$elem";
- mtr_debug("Got pid: $pid from file '$pidfile'");
+ if ( -f $pidfile )
+ {
+ mtr_debug("Processing PID file: '$pidfile'...");
- if ( $::glob_cygwin_perl or kill(0, $pid) )
- {
- mtr_debug("There is process with pid $pid -- scheduling for kill.");
- push(@pids, $pid); # We know (cygwin guess) it exists
- }
- else
- {
- mtr_debug("There is no process with pid $pid -- skipping.");
- }
+ my $pid= mtr_get_pid_from_file($pidfile);
+
+ mtr_debug("Got pid: $pid from file '$pidfile'");
+
+ if ( $::glob_cygwin_perl or kill(0, $pid) )
+ {
+ mtr_debug("There is process with pid $pid -- scheduling for kill.");
+ push(@pids, $pid); # We know (cygwin guess) it exists
+ }
+ else
+ {
+ mtr_debug("There is no process with pid $pid -- skipping.");
+ }
+ }
+ }
+ else
+ {
+ mtr_warning("Found non pid file $elem in $rundir");
+ next;
}
}
closedir(RUNDIR);
@@ -1100,7 +1097,6 @@ sub mtr_kill_processes ($) {
sub mtr_exit ($) {
my $code= shift;
-# cluck("Called mtr_exit()");
mtr_timer_stop_all($::glob_timers);
local $SIG{HUP} = 'IGNORE';
# ToDo: Signalling -$$ will only work if we are the process group
diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl
index 6e3796133f2..8d7de9d1a4b 100644
--- a/mysql-test/lib/mtr_report.pl
+++ b/mysql-test/lib/mtr_report.pl
@@ -53,13 +53,6 @@ sub mtr_show_failed_diff ($) {
{
$result_file= $eval_file;
}
- elsif ( $::opt_result_ext and
- ( $::opt_record or -f "$result_file$::opt_result_ext" ))
- {
- # If we have an special externsion for result files we use it if we are
- # recording or a result file with that extension exists.
- $result_file= "$result_file$::opt_result_ext";
- }
my $diffopts= $::opt_udiff ? "-u" : "-c";
@@ -137,13 +130,9 @@ sub mtr_report_test_failed ($) {
my $tinfo= shift;
$tinfo->{'result'}= 'MTR_RES_FAILED';
- if ( $tinfo->{'timeout'} )
+ if ( defined $tinfo->{'timeout'} )
{
print "[ fail ] timeout\n";
- }
- elsif ( $tinfo->{'ndb_test'} and $::cluster->[0]->{'installed_ok'} eq "NO")
- {
- print "[ fail ] ndbcluster start failure\n";
return;
}
else
@@ -151,9 +140,11 @@ sub mtr_report_test_failed ($) {
print "[ fail ]\n";
}
- # FIXME Instead of this test, and meaningless error message in 'else'
- # we should write out into $::path_timefile when the error occurs.
- if ( -f $::path_timefile )
+ if ( $tinfo->{'comment'} )
+ {
+ print "\nERROR: $tinfo->{'comment'}\n";
+ }
+ elsif ( -f $::path_timefile )
{
print "\nErrors are (from $::path_timefile) :\n";
print mtr_fromfile($::path_timefile); # FIXME print_file() instead
@@ -177,7 +168,7 @@ sub mtr_report_stats ($) {
my $tot_failed= 0;
my $tot_tests= 0;
my $tot_restarts= 0;
- my $found_problems= 0; # Some warnings are errors...
+ my $found_problems= 0; # Some warnings in the logfiles are errors...
foreach my $tinfo (@$tests)
{
@@ -212,8 +203,9 @@ sub mtr_report_stats ($) {
else
{
my $ratio= $tot_passed * 100 / $tot_tests;
- printf "Failed $tot_failed/$tot_tests tests, " .
- "%.2f\% were successful.\n\n", $ratio;
+ print "Failed $tot_failed/$tot_tests tests, ";
+ printf("%.2f", $ratio);
+ print "\% were successful.\n\n";
print
"The log files in var/log may give you some hint\n",
"of what went wrong.\n",
@@ -288,6 +280,7 @@ sub mtr_report_stats ($) {
print "\n";
+ # Print a list of testcases that failed
if ( $tot_failed != 0 )
{
my $test_mode= join(" ", @::glob_test_mode) || "default";
@@ -301,7 +294,30 @@ sub mtr_report_stats ($) {
}
}
print "\n";
+
+ }
+
+ # Print a list of check_testcases that failed(if any)
+ if ( $::opt_check_testcases )
+ {
+ my @check_testcases= ();
+
+ foreach my $tinfo (@$tests)
+ {
+ if ( defined $tinfo->{'check_testcase_failed'} )
+ {
+ push(@check_testcases, $tinfo->{'name'});
+ }
+ }
+
+ if ( @check_testcases )
+ {
+ print "Check of testcase failed for: ";
+ print join(" ", @check_testcases);
+ print "\n\n";
+ }
}
+
if ( $tot_failed != 0 || $found_problems)
{
mtr_error("there where failing test cases");
diff --git a/mysql-test/lib/mtr_timer.pl b/mysql-test/lib/mtr_timer.pl
index a85ab8c6122..06374716c62 100644
--- a/mysql-test/lib/mtr_timer.pl
+++ b/mysql-test/lib/mtr_timer.pl
@@ -4,23 +4,19 @@
# and is part of the translation of the Bourne shell script with the
# same name.
-use Carp qw(cluck);
use Socket;
use Errno;
use strict;
-#use POSIX ":sys_wait_h";
-use POSIX 'WNOHANG';
-
sub mtr_init_timers ();
sub mtr_timer_start($$$);
sub mtr_timer_stop($$);
sub mtr_timer_stop_all($);
-sub mtr_timer_waitpid($$$);
+
##############################################################################
#
-# Initiate a structure shared by all timers
+# Initiate the structure shared by all timers
#
##############################################################################
@@ -35,17 +31,19 @@ sub mtr_init_timers () {
# Start, stop and poll a timer
#
# As alarm() isn't portable to Windows, we use separate processes to
-# implement timers. That is why there is a mtr_timer_waitpid(), as this
-# is where we catch a timeout.
+# implement timers.
#
##############################################################################
sub mtr_timer_start($$$) {
my ($timers,$name,$duration)= @_;
+ mtr_verbose("mtr_timer_start: $name, $duration");
+
if ( exists $timers->{'timers'}->{$name} )
{
# We have an old running timer, kill it
+ mtr_verbose("There is an old timer running");
mtr_timer_stop($timers,$name);
}
@@ -57,7 +55,7 @@ sub mtr_timer_start($$$) {
{
if ( $! == $!{EAGAIN} ) # See "perldoc Errno"
{
- mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo");
+ mtr_warning("Got EAGAIN from fork(), sleep 1 second and redo");
sleep(1);
redo FORK;
}
@@ -70,6 +68,7 @@ sub mtr_timer_start($$$) {
if ( $tpid )
{
# Parent, record the information
+ mtr_verbose("timer parent, record info($name, $tpid, $duration)");
$timers->{'timers'}->{$name}->{'pid'}= $tpid;
$timers->{'timers'}->{$name}->{'duration'}= $duration;
$timers->{'pids'}->{$tpid}= $name;
@@ -85,6 +84,7 @@ sub mtr_timer_start($$$) {
$SIG{INT}= 'DEFAULT';
$0= "mtr_timer(timers,$name,$duration)";
+ mtr_verbose("timer child $name, sleep $duration");
sleep($duration);
exit(0);
}
@@ -95,9 +95,12 @@ sub mtr_timer_start($$$) {
sub mtr_timer_stop ($$) {
my ($timers,$name)= @_;
+ mtr_verbose("mtr_timer_stop: $name");
+
if ( exists $timers->{'timers'}->{$name} )
{
my $tpid= $timers->{'timers'}->{$name}->{'pid'};
+ mtr_verbose("Stopping timer with pid $tpid");
# FIXME as Cygwin reuses pids fast, maybe check that is
# the expected process somehow?!
@@ -114,7 +117,7 @@ sub mtr_timer_stop ($$) {
}
else
{
- mtr_debug("Asked to stop timer \"$name\" not started");
+ mtr_error("Asked to stop timer \"$name\" not started");
return 0;
}
}
@@ -136,10 +139,8 @@ sub mtr_timer_timeout ($$) {
return "" unless exists $timers->{'pids'}->{$pid};
- # We got a timeout
- my $name= $timers->{'pids'}->{$pid};
- mtr_timer_stop($timers, $timers->{'timers'}->{$name});
- return $name;
+ # We got a timeout, return the name ot the timer
+ return $timers->{'pids'}->{$pid};
}
1;