List:Commits« Previous MessageNext Message »
From:msvensson Date:October 30 2007 9:02pm
Subject:bk commit into 5.0 tree (msvensson:1.2561)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-10-30 22:02:32+01:00, msvensson@shellback.(none) +3 -0
  Changes to use My::SafeProcess->run

  mysql-test/lib/mtr_process.pl@stripped, 2007-10-30 22:02:26+01:00, msvensson@shellback.(none) +0 -369
    Remove old mtr_run methods

  mysql-test/lib/mtr_stress.pl@stripped, 2007-10-30 22:02:26+01:00, msvensson@shellback.(none) +8 -2
    Changes to use My::SafeProcess->run

  mysql-test/mysql-test-run.pl@stripped, 2007-10-30 22:02:26+01:00, msvensson@shellback.(none) +43 -29
    Remove gprof since it doesn't work
    Change to use My::SafeProcess->run

diff -Nrup a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
--- a/mysql-test/lib/mtr_process.pl	2007-10-19 15:07:25 +02:00
+++ b/mysql-test/lib/mtr_process.pl	2007-10-30 22:02:26 +01:00
@@ -22,298 +22,11 @@ use strict;
 use Socket;
 use Errno;
 
-sub mtr_run ($$$$$$;$);
-sub mtr_spawn ($$$$$$;$);
 sub mtr_ndbmgm_start($$);
 sub mtr_mysqladmin_start($$$);
 sub sleep_until_file_created ($$$);
 sub mtr_ping_port ($);
 
-# Local function
-sub spawn_impl ($$$$$$$);
-
-##############################################################################
-#
-#  Execute an external command
-#
-##############################################################################
-
-sub mtr_run ($$$$$$;$) {
-  my $path=       shift;
-  my $arg_list_t= shift;
-  my $input=      shift;
-  my $output=     shift;
-  my $error=      shift;
-  my $pid_file=   shift; # Not used
-  my $spawn_opts= shift;
-
-  return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,
-    $spawn_opts);
-}
-
-sub mtr_spawn ($$$$$$;$) {
-  my $path=       shift;
-  my $arg_list_t= shift;
-  my $input=      shift;
-  my $output=     shift;
-  my $error=      shift;
-  my $pid_file=   shift; # Not used
-  my $spawn_opts= shift;
-
-  return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,
-    $spawn_opts);
-}
-
-
-
-sub spawn_impl ($$$$$$$) {
-  my $path=       shift;
-  my $arg_list_t= shift;
-  my $mode=       shift;
-  my $input=      shift;
-  my $output=     shift;
-  my $error=      shift;
-  my $spawn_opts= shift;
-
-  if ( $::opt_script_debug )
-  {
-    mtr_report("");
-    mtr_debug("-" x 73);
-    mtr_debug("STDIN  $input") if $input;
-    mtr_debug("STDOUT $output") if $output;
-    mtr_debug("STDERR $error") if $error;
-    mtr_debug("$mode: $path ", join(" ",@$arg_list_t));
-    mtr_debug("spawn options:");
-    if ($spawn_opts)
-    {
-      foreach my $key (sort keys %{$spawn_opts})
-      {
-        mtr_debug("  - $key: $spawn_opts->{$key}");
-      }
-    }
-    else
-    {
-      mtr_debug("  none");
-    }
-    mtr_debug("-" x 73);
-    mtr_report("");
-  }
-
-  mtr_error("Can't spawn with empty \"path\"") unless defined $path;
-
-
- FORK:
-  {
-    my $pid= fork();
-
-    if ( ! defined $pid )
-    {
-      if ( $! == $!{EAGAIN} )           # See "perldoc Errno"
-      {
-        mtr_warning("Got EAGAIN from fork(), sleep 1 second and redo");
-        sleep(1);
-        redo FORK;
-      }
-
-      mtr_error("$path ($pid) can't be forked, error: $!");
-
-    }
-
-    if ( $pid )
-    {
-      #select(STDOUT) if $::glob_win32_perl;
-      return spawn_parent_impl($pid,$mode,$path);
-    }
-    else
-    {
-      # Child, redirect output and exec
-
-      $SIG{INT}= 'DEFAULT';         # Parent do some stuff, we don't
-
-      my $log_file_open_mode = '>';
-
-      if ($spawn_opts and $spawn_opts->{'append_log_file'})
-      {
-        $log_file_open_mode = '>>';
-      }
-      if (0){
-      if ( $output )
-      {
-	if ( $::glob_win32_perl )
-	{
-	  # Don't redirect stdout on ActiveState perl since this is
-          # just another thread in the same process.
-	}
-        elsif ( ! open(STDOUT,$log_file_open_mode,$output) )
-        {
-          mtr_child_error("can't redirect STDOUT to \"$output\": $!");
-        }
-      }
-    }
-      if (0){
-      if ( $error )
-      {
-        if ( !$::glob_win32_perl and $output eq $error )
-        {
-          if ( ! open(STDERR,">&STDOUT") )
-          {
-            mtr_child_error("can't dup STDOUT: $!");
-          }
-        }
-        else
-        {
-          if ( ! open(STDERR,$log_file_open_mode,$error) )
-          {
-            mtr_child_error("can't redirect STDERR to \"$error\": $!");
-          }
-        }
-      }
-    }
-
-      if ( $input )
-      {
-        if ( ! open(STDIN,"<",$input) )
-        {
-          mtr_child_error("can't redirect STDIN to \"$input\": $!");
-        }
-      }
-
-      if ( ! exec($path,@$arg_list_t) )
-      {
-        mtr_child_error("failed to execute \"$path\": $!");
-      }
-      mtr_error("Should never come here 1!");
-    }
-    mtr_error("Should never come here 2!");
-  }
-  mtr_error("Should never come here 3!");
-}
-
-
-sub spawn_parent_impl {
-  my $pid=  shift;
-  my $mode= shift;
-  my $path= shift;
-
-  if ( $mode eq 'run' or $mode eq 'test' )
-  {
-    if ( $mode eq 'run' )
-    {
-      # Simple run of command, wait blocking for it to return
-      my $ret_pid= waitpid($pid,0);
-      if ( $ret_pid != $pid )
-      {
-	# The "simple" waitpid has failed, print debug info
-	# and try to handle the error
-        mtr_warning("waitpid($pid, 0) returned $ret_pid " .
-		    "when waiting for '$path', error: '$!'");
-	if ( $ret_pid == -1 )
-	{
-	  # waitpid returned -1, that would indicate the process
-	  # no longer exist and waitpid couldn't wait for it.
-	  return 1;
-	}
-	mtr_error("Error handling failed");
-      }
-
-      return mtr_process_exit_status($?);
-    }
-    else
-    {
-      # We run mysqltest and wait for it to return. But we try to
-      # catch dying mysqld processes as well.
-      #
-      # 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.
-
-
-      my $exit_value= -1;
-      my $saved_exit_value;
-      my $ret_pid;                      # What waitpid() returns
-
-      while ( ($ret_pid= waitpid(-1,0)) != -1 )
-      {
-        # Someone terminated, don't know who. Collect
-        # status info first before $? is lost,
-        # but not $exit_value, this is flagged from
-
-        my $timer_name= mtr_timer_timeout($::glob_timers, $ret_pid);
-        if ( $timer_name )
-        {
-          if ( $timer_name eq "suite" )
-          {
-            # We give up here
-            # FIXME we should only give up the suite, not all of the run?
-            print STDERR "\n";
-            mtr_error("Test suite timeout");
-          }
-          elsif ( $timer_name eq "testcase" )
-          {
-            $saved_exit_value=  63;       # Mark as timeout
-            kill(9, $pid);                # Kill mysqltest
-            next;                         # Go on and catch the termination
-          }
-        }
-
-        if ( $ret_pid == $pid )
-        {
-          # We got termination of mysqltest, we are done
-          $exit_value= mtr_process_exit_status($?);
-          last;
-        }
-
-        # One of the child processes died, unless this was expected
-	# mysqltest should be killed and test aborted
-
-	check_expected_crash_and_restart($ret_pid);
-      }
-
-      if ( $ret_pid != $pid )
-      {
-        # We terminated the waiting because a "mysqld" process died.
-        # Kill the mysqltest process.
-	mtr_verbose("Kill mysqltest because another process died");
-        kill(9,$pid);
-
-        $ret_pid= waitpid($pid,0);
-
-        if ( $ret_pid != $pid )
-        {
-          mtr_error("$path ($pid) got lost somehow");
-        }
-      }
-
-      return $saved_exit_value || $exit_value;
-    }
-  }
-  else
-  {
-    # We spawned a process we don't wait for
-    return $pid;
-  }
-}
-
-
-# ----------------------------------------------------------------------
-# We try to emulate how an Unix shell calculates the exit code
-# ----------------------------------------------------------------------
-
-sub mtr_process_exit_status {
-  my $raw_status= shift;
-
-  if ( $raw_status & 127 )
-  {
-    return ($raw_status & 127) + 128;  # Signal num + 128
-  }
-  else
-  {
-    return $raw_status >> 8;           # Exit code
-  }
-}
-
-
-
 
 # Start "mysqladmin <command>" for a specific host:port
 sub mtr_mysqladmin_start($$$) {
@@ -362,88 +75,6 @@ sub mtr_ndbmgm_start($$) {
 		     {});
   mtr_verbose("mtr_ndbmgm_start, pid: $pid");
   return $pid;
-
-}
-
-
-#
-# 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.
-#
-sub check_expected_crash_and_restart($)
-{
-  my $ret_pid= shift;
-
-  foreach my $mysqld (@{$::master}, @{$::slave})
-  {
-    if ( $mysqld->{'pid'} eq $ret_pid )
-    {
-      mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
-      $mysqld->{'pid'}= 0;
-
-      # Check if crash expected and restart if it was
-      my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" .
-	"$mysqld->{'idx'}" . ".expect";
-      if ( -f $expect_file )
-      {
-	mtr_verbose("Crash was expected, file $expect_file exists");
-	mysqld_start($mysqld, $mysqld->{'start_opts'},
-		     $mysqld->{'start_slave_master_info'});
-	unlink($expect_file);
-      }
-
-      return;
-    }
-  }
-
-  foreach my $cluster (@{$::clusters})
-  {
-    if ( $cluster->{'pid'} eq $ret_pid )
-    {
-      mtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
-      $cluster->{'pid'}= 0;
-
-      # Check if crash expected and restart if it was
-      my $expect_file= "$::opt_vardir/tmp/ndb_mgmd_" . "$cluster->{'type'}" .
-	".expect";
-      if ( -f $expect_file )
-      {
-	mtr_verbose("Crash was expected, file $expect_file exists");
-	ndbmgmd_start($cluster);
-	unlink($expect_file);
-      }
-      return;
-    }
-
-    foreach my $ndbd (@{$cluster->{'ndbds'}})
-    {
-      if ( $ndbd->{'pid'} eq $ret_pid )
-      {
-	mtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
-	$ndbd->{'pid'}= 0;
-
-	# Check if crash expected and restart if it was
-	my $expect_file= "$::opt_vardir/tmp/ndbd_" . "$cluster->{'type'}" .
-	  "$ndbd->{'idx'}" . ".expect";
-	if ( -f $expect_file )
-	{
-	  mtr_verbose("Crash was expected, file $expect_file exists");
-	  ndbd_start($cluster, $ndbd->{'idx'},
-		     $ndbd->{'start_extra_args'});
-	  unlink($expect_file);
-	}
-	return;
-      }
-    }
-  }
-
-  if ($::instance_manager->{'spawner_pid'} eq $ret_pid)
-  {
-    return;
-  }
-
-  mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
 
 }
 
diff -Nrup a/mysql-test/lib/mtr_stress.pl b/mysql-test/lib/mtr_stress.pl
--- a/mysql-test/lib/mtr_stress.pl	2006-12-30 18:29:18 +01:00
+++ b/mysql-test/lib/mtr_stress.pl	2007-10-30 22:02:26 +01:00
@@ -135,7 +135,7 @@ sub run_stress_test () 
   }
 
   mtr_init_args(\$args);
-  
+  mtr_add_args($args, "$::glob_mysql_test_dir/mysql-stress-test.pl");
   mtr_add_arg($args, "--server-socket=%s", $::master->[0]->{'path_sock'});
   mtr_add_arg($args, "--server-user=%s", $::opt_user);
   mtr_add_arg($args, "--server-database=%s", "test");  
@@ -181,7 +181,13 @@ sub run_stress_test () 
   }
 
   #Run stress test
-  mtr_run("$::glob_mysql_test_dir/mysql-stress-test.pl", $args, "", "", "", "");
+  My::SafeProcess->run
+      (
+       name           => "stress test",
+       path           => $^X,
+       args           => \$args,
+      );
+
   if ( ! $::glob_use_embedded_server )
   {
     stop_all_servers();
diff -Nrup a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
--- a/mysql-test/mysql-test-run.pl	2007-10-29 10:38:07 +01:00
+++ b/mysql-test/mysql-test-run.pl	2007-10-30 22:02:26 +01:00
@@ -69,7 +69,6 @@ require "lib/mtr_cases.pl";
 require "lib/mtr_process.pl";
 require "lib/mtr_io.pl";
 require "lib/mtr_gcov.pl";
-require "lib/mtr_gprof.pl";
 require "lib/mtr_report.pl";
 require "lib/mtr_match.pl";
 require "lib/mtr_misc.pl";
@@ -178,11 +177,6 @@ our $opt_mtr_build_thread;
 our $opt_debugger;
 our $opt_client_debugger;
 
-our $opt_gprof;
-our $opt_gprof_dir;
-our $opt_gprof_master;
-our $opt_gprof_slave;
-
 our $master;
 our $slave;
 our $clusters;
@@ -357,11 +351,6 @@ sub main () {
     gcov_prepare();
   }
 
-  if ( $opt_gprof )
-  {
-    gprof_prepare();
-  }
-
   if ( $opt_bench )
   {
     initialize_servers();
@@ -555,7 +544,6 @@ 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,
@@ -2285,8 +2273,15 @@ sub ndbcluster_wait_started($$){
   # 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
-  my $res= mtr_run($exe_ndb_waiter, $args,
-		   "", $path_waiter_log, $path_waiter_log, "");
+
+  my $res= My::SafeProcess->run
+    (
+     name          => "ndb_waiter $cluster->{'name'}",
+     path          => $exe_ndb_waiter,
+     args          => \$args,
+     output        => $path_waiter_log,
+     error         => $path_waiter_log,
+    );
   mtr_verbose("ndbcluster_wait_started, returns: $res") if $res;
   return $res;
 }
@@ -2483,12 +2478,22 @@ sub run_benchmarks ($) {
   if ( ! $benchmark )
   {
     mtr_add_arg($args, "--log");
-    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
+    my $res= My::SafeProcess->run
+      (
+       name          => "run-all-tests",
+       path          => "$glob_mysql_bench_dir/run-all-tests",
+       args          => \$args,
+    );
     # FIXME check result code?!
   }
   elsif ( -x $benchmark )
   {
-    mtr_run("$glob_mysql_bench_dir/$benchmark", $args, "", "", "", "");
+    my $res= My::SafeProcess->run
+      (
+       name          => "$benchmark",
+       path          => "$glob_mysql_bench_dir/$benchmark",
+       args          => \$args,
+    );
     # FIXME check result code?!
   }
   else
@@ -2547,10 +2552,6 @@ sub run_suite () {
   {
     gcov_collect(); # collect coverage information
   }
-  if ( $opt_gprof )
-  {
-    gprof_collect(); # collect coverage information
-  }
 
   mtr_report_stats($tests);
 
@@ -2859,10 +2860,16 @@ sub install_db () {
   mkpath("$data_dir/mysql");
   mkpath("$data_dir/test");
 
-  if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file,
-               $path_bootstrap_log, $path_bootstrap_log,
-	       "", { append_log_file => 1 }) != 0 )
-
+  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)
   {
     mtr_error("Error executing mysqld --bootstrap\n" .
               "Could not install system database from $bootstrap_sql_file\n" .
@@ -3433,8 +3440,12 @@ sub do_before_start_master ($) {
   # Run master initialization shell script if one exists
   if ( $init_script )
   {
-    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
-    if ( $ret != 0 )
+    if (My::SafeProcess->new
+	(
+	 name          => "master sh",
+	 path          => "/bin/sh",
+	 args          => [$init_script],
+	) != 0)
     {
       # FIXME rewrite those scripts to return 0 if successful
       # mtr_warning("$init_script exited with code $ret");
@@ -3463,8 +3474,12 @@ sub do_before_start_slave ($) {
   # Run slave initialization shell script if one exists
   if ( $init_script )
   {
-    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
-    if ( $ret != 0 )
+    if (My::SafeProcess->new
+	(
+	 name          => "master sh",
+	 path          => "/bin/sh",
+	 args          => [$init_script],
+	) != 0)
     {
       # FIXME rewrite those scripts to return 0 if successful
       # mtr_warning("$init_script exited with code $ret");
@@ -4801,7 +4816,6 @@ Options for debugging the product
 Options for coverage, profiling etc
 
   gcov                  FIXME
-  gprof                 FIXME
   valgrind              Run the "mysqltest" and "mysqld" executables using
                         valgrind with options($default_valgrind_options)
   valgrind-all          Synonym for --valgrind
Thread
bk commit into 5.0 tree (msvensson:1.2561)msvensson30 Oct