Commit 4ce4968b authored by unknown's avatar unknown

mtr_timer.pl, mtr_report.pl, mtr_process.pl, mysql-test-run.pl:

  Backporting from 5.0


mysql-test/mysql-test-run.pl:
  Backporting from 5.0
mysql-test/lib/mtr_process.pl:
  Backporting from 5.0
mysql-test/lib/mtr_report.pl:
  Backporting from 5.0
mysql-test/lib/mtr_timer.pl:
  Backporting from 5.0
parent c65bd03f
...@@ -12,16 +12,17 @@ use strict; ...@@ -12,16 +12,17 @@ use strict;
#use POSIX ":sys_wait_h"; #use POSIX ":sys_wait_h";
use POSIX 'WNOHANG'; use POSIX 'WNOHANG';
sub mtr_run ($$$$$$); sub mtr_run ($$$$$$;$);
sub mtr_spawn ($$$$$$); sub mtr_spawn ($$$$$$;$);
sub mtr_stop_mysqld_servers ($); sub mtr_stop_mysqld_servers ($);
sub mtr_kill_leftovers (); sub mtr_kill_leftovers ();
sub mtr_record_dead_children (); sub mtr_record_dead_children ();
sub mtr_exit ($); sub mtr_exit ($);
sub sleep_until_file_created ($$$); sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
# static in C # static in C
sub spawn_impl ($$$$$$$); sub spawn_impl ($$$$$$$$);
############################################################################## ##############################################################################
# #
...@@ -32,37 +33,43 @@ sub spawn_impl ($$$$$$$); ...@@ -32,37 +33,43 @@ sub spawn_impl ($$$$$$$);
# This function try to mimic the C version used in "netware/mysql_test_run.c" # This function try to mimic the C version used in "netware/mysql_test_run.c"
# FIXME learn it to handle append mode as well, a "new" flag or a "append" # FIXME learn it to handle append mode as well, a "new" flag or a "append"
sub mtr_run ($$$$$$) { sub mtr_run ($$$$$$;$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $input= shift; my $input= shift;
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file); return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file,
$spawn_opts);
} }
sub mtr_run_test ($$$$$$) { sub mtr_run_test ($$$$$$;$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $input= shift; my $input= shift;
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file); return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file,
$spawn_opts);
} }
sub mtr_spawn ($$$$$$) { sub mtr_spawn ($$$$$$;$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $input= shift; my $input= shift;
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file); return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file,
$spawn_opts);
} }
...@@ -72,7 +79,7 @@ sub mtr_spawn ($$$$$$) { ...@@ -72,7 +79,7 @@ sub mtr_spawn ($$$$$$) {
# #
############################################################################## ##############################################################################
sub spawn_impl ($$$$$$$) { sub spawn_impl ($$$$$$$$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $mode= shift; my $mode= shift;
...@@ -80,6 +87,7 @@ sub spawn_impl ($$$$$$$) { ...@@ -80,6 +87,7 @@ sub spawn_impl ($$$$$$$) {
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; # FIXME my $pid_file= shift; # FIXME
my $spawn_opts= shift;
if ( $::opt_script_debug ) if ( $::opt_script_debug )
{ {
...@@ -89,6 +97,18 @@ sub spawn_impl ($$$$$$$) { ...@@ -89,6 +97,18 @@ sub spawn_impl ($$$$$$$) {
print STDERR "#### ", "STDOUT $output\n" if $output; print STDERR "#### ", "STDOUT $output\n" if $output;
print STDERR "#### ", "STDERR $error\n" if $error; print STDERR "#### ", "STDERR $error\n" if $error;
print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n"; print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n";
print STDERR "#### ", "spawn options:\n";
if ($spawn_opts)
{
foreach my $key (sort keys %{$spawn_opts})
{
print STDERR "#### ", " - $key: $spawn_opts->{$key}\n";
}
}
else
{
print STDERR "#### ", " none\n";
}
print STDERR "#### ", "-" x 78, "\n"; print STDERR "#### ", "-" x 78, "\n";
} }
...@@ -135,9 +155,16 @@ sub spawn_impl ($$$$$$$) { ...@@ -135,9 +155,16 @@ sub spawn_impl ($$$$$$$) {
# $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c"; # $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c";
} }
my $log_file_open_mode = '>';
if ($spawn_opts and $spawn_opts->{'append_log_file'})
{
$log_file_open_mode = '>>';
}
if ( $output ) if ( $output )
{ {
if ( ! open(STDOUT,">",$output) ) if ( ! open(STDOUT,$log_file_open_mode,$output) )
{ {
mtr_error("can't redirect STDOUT to \"$output\": $!"); mtr_error("can't redirect STDOUT to \"$output\": $!");
} }
...@@ -154,7 +181,7 @@ sub spawn_impl ($$$$$$$) { ...@@ -154,7 +181,7 @@ sub spawn_impl ($$$$$$$) {
} }
else else
{ {
if ( ! open(STDERR,">",$error) ) if ( ! open(STDERR,$log_file_open_mode,$error) )
{ {
mtr_error("can't redirect STDERR to \"$output\": $!"); mtr_error("can't redirect STDERR to \"$output\": $!");
} }
...@@ -534,16 +561,7 @@ sub mtr_stop_mysqld_servers ($) { ...@@ -534,16 +561,7 @@ sub mtr_stop_mysqld_servers ($) {
start_reap_all(); # Avoid zombies start_reap_all(); # Avoid zombies
SIGNAL: SIGNAL:
foreach my $sig (15,9) mtr_kill_processes(\keys (%mysqld_pids));
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, keys %mysqld_pids);
while ( $retries-- and kill(0, keys %mysqld_pids) )
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
}
}
stop_reap_all(); # Get into control again stop_reap_all(); # Get into control again
...@@ -826,6 +844,21 @@ sub sleep_until_file_created ($$$) { ...@@ -826,6 +844,21 @@ sub sleep_until_file_created ($$$) {
} }
sub mtr_kill_processes ($) {
my $pids = shift;
foreach my $sig (15,9)
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, @{$pids});
while ( $retries-- and kill(0, @{$pids}) )
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
}
}
}
############################################################################## ##############################################################################
# #
# When we exit, we kill off all children # When we exit, we kill off all children
...@@ -841,6 +874,7 @@ sub sleep_until_file_created ($$$) { ...@@ -841,6 +874,7 @@ sub sleep_until_file_created ($$$) {
sub mtr_exit ($) { sub mtr_exit ($) {
my $code= shift; my $code= shift;
# cluck("Called mtr_exit()"); # cluck("Called mtr_exit()");
mtr_timer_stop_all($::glob_timers);
local $SIG{HUP} = 'IGNORE'; local $SIG{HUP} = 'IGNORE';
kill('HUP', -$$); kill('HUP', -$$);
sleep 2; sleep 2;
......
...@@ -177,7 +177,7 @@ sub mtr_report_stats ($) { ...@@ -177,7 +177,7 @@ sub mtr_report_stats ($) {
"%.2f\% were successful.\n\n", $ratio; "%.2f\% were successful.\n\n", $ratio;
print print
"The log files in var/log may give you some hint\n", "The log files in var/log may give you some hint\n",
"of what when wrong.\n", "of what went wrong.\n",
"If you want to report this error, please read first ", "If you want to report this error, please read first ",
"the documentation at\n", "the documentation at\n",
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n"; "http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
...@@ -223,7 +223,8 @@ sub mtr_report_stats ($) { ...@@ -223,7 +223,8 @@ sub mtr_report_stats ($) {
if ( $tot_failed != 0 ) if ( $tot_failed != 0 )
{ {
print "mysql-test-run: *** Failing the test(s):"; my $test_mode= join(" ", @::glob_test_mode) || "default";
print "mysql-test-run in $test_mode mode: *** Failing the test(s):";
foreach my $tinfo (@$tests) foreach my $tinfo (@$tests)
{ {
......
...@@ -15,6 +15,7 @@ use POSIX 'WNOHANG'; ...@@ -15,6 +15,7 @@ use POSIX 'WNOHANG';
sub mtr_init_timers (); sub mtr_init_timers ();
sub mtr_timer_start($$$); sub mtr_timer_start($$$);
sub mtr_timer_stop($$); sub mtr_timer_stop($$);
sub mtr_timer_stop_all($);
sub mtr_timer_waitpid($$$); sub mtr_timer_waitpid($$$);
############################################################################## ##############################################################################
...@@ -113,6 +114,17 @@ sub mtr_timer_stop ($$) { ...@@ -113,6 +114,17 @@ sub mtr_timer_stop ($$) {
} }
sub mtr_timer_stop_all ($) {
my $timers= shift;
foreach my $name ( keys %{$timers->{'timers'}} )
{
mtr_timer_stop($timers, $name);
}
return 1;
}
sub mtr_timer_timeout ($$) { sub mtr_timer_timeout ($$) {
my ($timers,$pid)= @_; my ($timers,$pid)= @_;
......
...@@ -142,6 +142,7 @@ our $glob_timers= undef; ...@@ -142,6 +142,7 @@ our $glob_timers= undef;
our $glob_use_running_server= 0; our $glob_use_running_server= 0;
our $glob_use_running_ndbcluster= 0; our $glob_use_running_ndbcluster= 0;
our $glob_use_embedded_server= 0; our $glob_use_embedded_server= 0;
our @glob_test_mode;
our $glob_basedir; our $glob_basedir;
...@@ -606,6 +607,7 @@ sub command_line_setup () { ...@@ -606,6 +607,7 @@ sub command_line_setup () {
if ( $opt_embedded_server ) if ( $opt_embedded_server )
{ {
$glob_use_embedded_server= 1; $glob_use_embedded_server= 1;
push(@glob_test_mode, "embedded");
$opt_skip_rpl= 1; # We never run replication with embedded $opt_skip_rpl= 1; # We never run replication with embedded
if ( $opt_extern ) if ( $opt_extern )
...@@ -614,6 +616,11 @@ sub command_line_setup () { ...@@ -614,6 +616,11 @@ sub command_line_setup () {
} }
} }
if ( $opt_ps_protocol )
{
push(@glob_test_mode, "ps-protocol");
}
# FIXME don't understand what this is # FIXME don't understand what this is
# if ( $opt_local_master ) # if ( $opt_local_master )
# { # {
...@@ -999,25 +1006,19 @@ sub kill_and_cleanup () { ...@@ -999,25 +1006,19 @@ sub kill_and_cleanup () {
# FIXME do we really need to create these all, or are they # FIXME do we really need to create these all, or are they
# created for us when tables are created? # created for us when tables are created?
rmtree("$master->[0]->{'path_myddir'}"); my @data_dir_lst = (
mkpath("$master->[0]->{'path_myddir'}/mysql"); $master->[0]->{'path_myddir'},
mkpath("$master->[0]->{'path_myddir'}/test"); $master->[1]->{'path_myddir'},
$slave->[0]->{'path_myddir'},
rmtree("$master->[1]->{'path_myddir'}"); $slave->[1]->{'path_myddir'},
mkpath("$master->[1]->{'path_myddir'}/mysql"); $slave->[2]->{'path_myddir'});
mkpath("$master->[1]->{'path_myddir'}/test");
foreach my $data_dir (@data_dir_lst)
rmtree("$slave->[0]->{'path_myddir'}"); {
mkpath("$slave->[0]->{'path_myddir'}/mysql"); rmtree("$data_dir");
mkpath("$slave->[0]->{'path_myddir'}/test"); mkpath("$data_dir/mysql");
mkpath("$data_dir/test");
rmtree("$slave->[1]->{'path_myddir'}"); }
mkpath("$slave->[1]->{'path_myddir'}/mysql");
mkpath("$slave->[1]->{'path_myddir'}/test");
rmtree("$slave->[2]->{'path_myddir'}");
mkpath("$slave->[2]->{'path_myddir'}/mysql");
mkpath("$slave->[2]->{'path_myddir'}/test");
# To make some old test cases work, we create a soft # To make some old test cases work, we create a soft
# link from the old "var" location to the new one # link from the old "var" location to the new one
...@@ -1565,8 +1566,9 @@ sub report_failure_and_restart ($) { ...@@ -1565,8 +1566,9 @@ sub report_failure_and_restart ($) {
print "\n"; print "\n";
if ( ! $opt_force ) if ( ! $opt_force )
{ {
print "Aborting: $tinfo->{'name'} failed. To continue, re-run with '--force'."; my $test_mode= join(" ", @::glob_test_mode) || "default";
print "\n"; print "Aborting: $tinfo->{'name'} failed in $test_mode mode. ";
print "To continue, re-run with '--force'.\n";
if ( ! $opt_gdb and ! $glob_use_running_server and if ( ! $opt_gdb and ! $glob_use_running_server and
! $opt_ddd and ! $glob_use_embedded_server ) ! $opt_ddd and ! $glob_use_embedded_server )
{ {
...@@ -1612,6 +1614,7 @@ sub do_before_start_master ($$) { ...@@ -1612,6 +1614,7 @@ sub do_before_start_master ($$) {
} }
} }
# FIXME only remove the ones that are tied to this master
# Remove old master.info and relay-log.info files # Remove old master.info and relay-log.info files
unlink("$master->[0]->{'path_myddir'}/master.info"); unlink("$master->[0]->{'path_myddir'}/master.info");
unlink("$master->[0]->{'path_myddir'}/relay-log.info"); unlink("$master->[0]->{'path_myddir'}/relay-log.info");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment