From aa7087e15deb8fccebf8ab2a467914d069e8eacc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Mar 2007 10:24:33 +0200 Subject: Dont' redirect stderr in ActiveState perl Improve comments --- mysql-test/lib/mtr_process.pl | 45 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'mysql-test/lib') diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 690ca8313dd..53bf37bcc83 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -38,8 +38,8 @@ sub mtr_kill_processes ($); sub mtr_ping_with_timeout($); sub mtr_ping_port ($); -# static in C -sub spawn_impl ($$$$$$$$); +# Local function +sub spawn_impl ($$$$$$$); ############################################################################## # @@ -47,18 +47,16 @@ sub spawn_impl ($$$$$$$$); # ############################################################################## -# This function try to mimic the C version used in "netware/mysql_test_run.c" - sub mtr_run ($$$$$$;$) { my $path= shift; my $arg_list_t= shift; my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; + my $pid_file= shift; # Not used 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, $spawn_opts); } @@ -68,10 +66,10 @@ sub mtr_run_test ($$$$$$;$) { my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; + my $pid_file= shift; # Not used 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, $spawn_opts); } @@ -81,28 +79,22 @@ sub mtr_spawn ($$$$$$;$) { my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; + my $pid_file= shift; # Not used 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, $spawn_opts); } -############################################################################## -# -# If $join is set, we return the error code, else we return the PID -# -############################################################################## -sub spawn_impl ($$$$$$$$) { +sub spawn_impl ($$$$$$$) { my $path= shift; my $arg_list_t= shift; my $mode= shift; my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; # FIXME my $spawn_opts= shift; if ( $::opt_script_debug ) @@ -155,10 +147,6 @@ sub spawn_impl ($$$$$$$$) { else { # Child, redirect output and exec - # FIXME I tried POSIX::setsid() here to detach and, I hoped, - # avoid zombies. But everything went wild, somehow the parent - # became a deamon as well, and was hard to kill ;-) - # Need to catch SIGCHLD and do waitpid or something instead...... $SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't @@ -196,7 +184,15 @@ sub spawn_impl ($$$$$$$$) { } else { - if ( ! open(STDERR,$log_file_open_mode,$error) ) + if ( $::glob_win32_perl ) + { + # Don't redirect stdout on ActiveState perl since this is + # just another thread in the same process. + # Should be fixed so that the thread that is created with fork + # executes the exe in another process and wait's for it to return. + # In the meanwhile, we get all the output from mysqld's to screen + } + elsif ( ! open(STDERR,$log_file_open_mode,$error) ) { mtr_child_error("can't redirect STDERR to \"$error\": $!"); } @@ -259,9 +255,7 @@ sub spawn_parent_impl { # We do blocking waitpid() until we get the return from the # "mysqltest" call. But if a mysqld process dies that we # started, we take this as an error, and kill mysqltest. - # - # FIXME is this as it should be? Can't mysqld terminate - # normally from running a test case? + my $exit_value= -1; my $saved_exit_value; @@ -450,7 +444,6 @@ sub mtr_kill_leftovers () { # We scan the "var/run/" directory for other process id's to kill - # FIXME $path_run_dir or something my $rundir= "$::opt_vardir/run"; mtr_debug("Processing PID files in directory '$rundir'..."); -- cgit v1.2.1 From 73d1a711b7eef270c19ad7a224dca657afcb7ccf Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Mar 2007 11:31:50 +0200 Subject: Make the script detect --default-storage-engine=x and mark the test as requiring that storage engine(if we need to do that) Make --ndb and --with-ndbcluster and alias for --mysqld=--default-storage-engine=ndbcluster --- mysql-test/lib/mtr_cases.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mysql-test/lib') diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 22290a88d39..28c78fbffeb 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -498,6 +498,17 @@ sub collect_one_test_case($$$$$$$) { { mtr_options_from_test_file($tinfo,"$testdir/${tname}.test"); + if ( defined $::used_default_engine ) + { + # Different default engine is used + # tag test to require that engine + $tinfo->{'ndb_test'}= 1 + if ( $::used_default_engine =~ /^ndb/i ); + + $tinfo->{'innodb_test'}= 1 + if ( $::used_default_engine =~ /^innodb/i ); + } + if ( $tinfo->{'big_test'} and ! $::opt_big_test ) { $tinfo->{'skip'}= 1; -- cgit v1.2.1 From 0c953269d96e8e5bac1fd2f591f9e1fa1888fdf5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Mar 2007 15:43:36 +0200 Subject: Bug#25657 mysql-test-run.pl kill itself under ActiveState perl - Read the pid from pidfile in order to be able to kill the real process instead of the pseudo process. Most platforms will have the same real_pid as pid - Kill using the real pid mysql-test/lib/mtr_process.pl: Kill using the "real_pid" mysql-test/mysql-test-run.pl: Read the pid from pidfile in order to be able to kill the real process instead of the pseudo process. Most platforms will have the same real_pid as pid --- mysql-test/lib/mtr_process.pl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'mysql-test/lib') diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 53bf37bcc83..b20c9b65dd5 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -562,7 +562,7 @@ sub mtr_check_stop_servers ($) { # Return if no processes are defined return if ! @$spec; - #mtr_report("mtr_check_stop_servers"); + mtr_verbose("mtr_check_stop_servers"); mtr_ping_with_timeout(\@$spec); @@ -605,7 +605,10 @@ sub mtr_check_stop_servers ($) { { if ( $srv->{'pid'} ) { - $mysqld_pids{$srv->{'pid'}}= 1; + # Add the process pid to list of pids to kill + # if the process has a "real_pid" use it + $mysqld_pids{$srv->{'real_pid'} ? + $srv->{'real_pid'} : $srv->{'pid'}}= 1; } else { @@ -638,13 +641,9 @@ sub mtr_check_stop_servers ($) { # that for true Win32 processes, kill(0,$pid) will not return 1. # ---------------------------------------------------------------------- - start_reap_all(); # Avoid zombies - my @mysqld_pids= keys %mysqld_pids; mtr_kill_processes(\@mysqld_pids); - stop_reap_all(); # Get into control again - # ---------------------------------------------------------------------- # Now, we check if all we can find using kill(0,$pid) are dead, # and just assume the rest are. We cleanup socket and PID files. @@ -654,14 +653,15 @@ sub mtr_check_stop_servers ($) { my $errors= 0; foreach my $srv ( @$spec ) { - if ( $srv->{'pid'} ) + my $pid= $srv->{'real_pid'} ? $srv->{'real_pid'} : $srv->{'pid'}; + if ( $pid ) { - if ( kill(0,$srv->{'pid'}) ) + if ( kill(0, $pid) ) { # FIXME In Cygwin there seem to be some fast reuse # of PIDs, so dying may not be the right thing to do. $errors++; - mtr_warning("can't kill process $srv->{'pid'}"); + mtr_warning("can't kill process $pid"); } else { @@ -682,6 +682,8 @@ sub mtr_check_stop_servers ($) { mtr_warning("couldn't delete $file"); } } + # Reap the child + waitpid($srv->{'pid'},&WNOHANG); $srv->{'pid'}= 0; } } @@ -1063,7 +1065,10 @@ sub sleep_until_file_created ($$$) { { if ( -r $pidfile ) { - return $pid; + # Read real pid from pidfile + my $real_pid= mtr_fromfile($pidfile); + mtr_verbose("pid: $pid, real_pid: $real_pid"); + return $real_pid; } # Check if it died after the fork() was successful -- cgit v1.2.1 From b7483a0255432b53c447e76fa57fc56ee37d6567 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Mar 2007 16:43:15 +0200 Subject: Cset exclude: msvensson@shellback.(none)|ChangeSet|20070330134336|02280 mysql-test/lib/mtr_process.pl: Exclude mysql-test/mysql-test-run.pl: Exclude --- mysql-test/lib/mtr_process.pl | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'mysql-test/lib') diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index b20c9b65dd5..53bf37bcc83 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -562,7 +562,7 @@ sub mtr_check_stop_servers ($) { # Return if no processes are defined return if ! @$spec; - mtr_verbose("mtr_check_stop_servers"); + #mtr_report("mtr_check_stop_servers"); mtr_ping_with_timeout(\@$spec); @@ -605,10 +605,7 @@ sub mtr_check_stop_servers ($) { { if ( $srv->{'pid'} ) { - # Add the process pid to list of pids to kill - # if the process has a "real_pid" use it - $mysqld_pids{$srv->{'real_pid'} ? - $srv->{'real_pid'} : $srv->{'pid'}}= 1; + $mysqld_pids{$srv->{'pid'}}= 1; } else { @@ -641,9 +638,13 @@ sub mtr_check_stop_servers ($) { # that for true Win32 processes, kill(0,$pid) will not return 1. # ---------------------------------------------------------------------- + start_reap_all(); # Avoid zombies + my @mysqld_pids= keys %mysqld_pids; mtr_kill_processes(\@mysqld_pids); + stop_reap_all(); # Get into control again + # ---------------------------------------------------------------------- # Now, we check if all we can find using kill(0,$pid) are dead, # and just assume the rest are. We cleanup socket and PID files. @@ -653,15 +654,14 @@ sub mtr_check_stop_servers ($) { my $errors= 0; foreach my $srv ( @$spec ) { - my $pid= $srv->{'real_pid'} ? $srv->{'real_pid'} : $srv->{'pid'}; - if ( $pid ) + if ( $srv->{'pid'} ) { - if ( kill(0, $pid) ) + if ( kill(0,$srv->{'pid'}) ) { # FIXME In Cygwin there seem to be some fast reuse # of PIDs, so dying may not be the right thing to do. $errors++; - mtr_warning("can't kill process $pid"); + mtr_warning("can't kill process $srv->{'pid'}"); } else { @@ -682,8 +682,6 @@ sub mtr_check_stop_servers ($) { mtr_warning("couldn't delete $file"); } } - # Reap the child - waitpid($srv->{'pid'},&WNOHANG); $srv->{'pid'}= 0; } } @@ -1065,10 +1063,7 @@ sub sleep_until_file_created ($$$) { { if ( -r $pidfile ) { - # Read real pid from pidfile - my $real_pid= mtr_fromfile($pidfile); - mtr_verbose("pid: $pid, real_pid: $real_pid"); - return $real_pid; + return $pid; } # Check if it died after the fork() was successful -- cgit v1.2.1