Commit 86ef148e authored by tsmith@ramayana.hindu.god's avatar tsmith@ramayana.hindu.god
Browse files

Merge ramayana.hindu.god:/home/tsmith/m/bk/50

into  ramayana.hindu.god:/home/tsmith/m/bk/maint/50
parents 0670af94 f9c24561
Loading
Loading
Loading
Loading
+42 −30
Original line number Diff line number Diff line
@@ -342,12 +342,6 @@ static my_bool get_full_path_to_executable(char* path)

/*
  Look for the tool in the same directory as mysql_upgrade.

  When running in a not yet installed build the the program
  will exist but it need to be invoked via it's libtool wrapper.
  Check if the found tool can executed and if not look in the
  directory one step higher up where the libtool wrapper normally
  is found
*/

static void find_tool(char *tool_path, const char *tool_name)
@@ -385,16 +379,32 @@ static void find_tool(char *tool_path, const char *tool_name)
      path[0]= 0;
    }
  }
  do
  {
    DBUG_PRINT("enter", ("path: %s", path));

    /* Chop off last char(since it might be a /) */
    path[max((strlen(path)-1), 0)]= 0;
  DBUG_PRINT("info", ("path: '%s'", path));

    /* Chop off last dir part */
  /* Chop off binary name (i.e mysql-upgrade) from path */
  dirname_part(path, path);

  /*
    When running in a not yet installed build and using libtool,
    the program(mysql_upgrade) will be in .libs/ and executed
    through a libtool wrapper in order to use the dynamic libraries
    from this build. The same must be done for the tools(mysql and
    mysqlcheck). Thus if path ends in .libs/, step up one directory
    and execute the tools from there
  */
  path[max((strlen(path)-1), 0)]= 0;   /* Chop off last / */
  if (strncmp(path + dirname_length(path), ".libs", 5) == 0)
  {
    DBUG_PRINT("info", ("Chopping off .libs from '%s'", path));

    /* Chop off .libs */
    dirname_part(path, path);
  }


  DBUG_PRINT("info", ("path: '%s'", path));

  /* Format name of the tool to search for */
  fn_format(tool_path, tool_name,
            path, "", MYF(MY_REPLACE_DIR));
@@ -406,16 +416,15 @@ static void find_tool(char *tool_path, const char *tool_name)
    die("Can't find '%s'", tool_path);

  /*
      Make sure it can be executed, otherwise try again
      in higher level directory
    Make sure it can be executed
  */
  }
  while(run_tool(tool_path,
  if (run_tool(tool_path,
               &ds_tmp, /* Get output from command, discard*/
               "--help",
               "2>&1",
               IF_WIN("> NUL", "> /dev/null"),
                 NULL));
               NULL))
    die("Can't execute '%s'", tool_path);

  dynstr_free(&ds_tmp);

@@ -446,6 +455,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,

  ret= run_tool(mysql_path,
                ds_res,
                "--no-defaults",
                ds_args.str,
                "--database=mysql",
                "--batch", /* Turns off pager etc. */
@@ -457,6 +467,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
                NULL);

  my_close(fd, MYF(0));
  my_delete(query_file_path, MYF(0));

  DBUG_RETURN(ret);
}
@@ -607,6 +618,7 @@ static int run_mysqlcheck_upgrade(void)
  verbose("Running 'mysqlcheck'...");
  return run_tool(mysqlcheck_path,
                  NULL, /* Send output from mysqlcheck directly to screen */
                  "--no-defaults",
                  ds_args.str,
                  "--check-upgrade",
                  "--all-databases",
+559 −187

File changed.

Preview size limit exceeded, changes collapsed.

+0 −26
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@

use strict;

sub mtr_full_hostname ();
sub mtr_short_hostname ();
sub mtr_native_path($);
sub mtr_init_args ($);
sub mtr_add_arg ($$@);
@@ -40,30 +38,6 @@ sub mtr_cmp_opts($$);
#
##############################################################################

# We want the fully qualified host name and hostname() may have returned
# only the short name. So we use the resolver to find out.
# Note that this might fail on some platforms

sub mtr_full_hostname () {

  my $hostname=  hostname();
  if ( $hostname !~ /\./ )
  {
    my $address=   gethostbyname($hostname)
      or mtr_error("Couldn't resolve $hostname : $!");
    my $fullname=  gethostbyaddr($address, AF_INET);
    $hostname= $fullname if $fullname; 
  }
  return $hostname;
}

sub mtr_short_hostname () {

  my $hostname=  hostname();
  $hostname =~ s/\..+$//;
  return $hostname;
}

# Convert path to OS native format
sub mtr_native_path($)
{
+11 −10
Original line number Diff line number Diff line
@@ -99,25 +99,26 @@ sub spawn_impl ($$$$$$$) {

  if ( $::opt_script_debug )
  {
    print STDERR "\n";
    print STDERR "#### ", "-" x 78, "\n";
    print STDERR "#### ", "STDIN  $input\n" if $input;
    print STDERR "#### ", "STDOUT $output\n" if $output;
    print STDERR "#### ", "STDERR $error\n" if $error;
    print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n";
    print STDERR "#### ", "spawn options:\n";
    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})
      {
        print STDERR "#### ", "  - $key: $spawn_opts->{$key}\n";
        mtr_debug("  - $key: $spawn_opts->{$key}");
      }
    }
    else
    {
      print STDERR "#### ", "  none\n";
      mtr_debug("  none");
    }
    print STDERR "#### ", "-" x 78, "\n";
    mtr_debug("-" x 73);
    mtr_report("");
  }

  mtr_error("Can't spawn with empty \"path\"") unless defined $path;
+59 −64
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
# same name.

use strict;
use warnings;

sub mtr_report_test_name($);
sub mtr_report_test_passed($);
@@ -26,7 +27,6 @@ sub mtr_report_test_failed($);
sub mtr_report_test_skipped($);
sub mtr_report_test_not_skipped_though_disabled($);

sub mtr_show_failed_diff ($);
sub mtr_report_stats ($);
sub mtr_print_line ();
sub mtr_print_thick_line ();
@@ -38,6 +38,9 @@ sub mtr_child_error (@);
sub mtr_debug (@);
sub mtr_verbose (@);

my $tot_real_time= 0;



##############################################################################
#
@@ -45,58 +48,10 @@ sub mtr_verbose (@);
#
##############################################################################

# We can't use diff -u or diff -a as these are not portable

sub mtr_show_failed_diff ($) {
  my $result_file_name=  shift;

  # The reject and log files have been dumped to
  # to filenames based on the result_file's name
  my $tname= basename($result_file_name);
  $tname=~ s/\..*$//;

  my $reject_file=  "r/$tname.reject";
  my $result_file=  "r/$tname.result";
  my $log_file=  "r/$tname.log";
  my $eval_file=    "r/$tname.eval";

  if ( $::opt_suite ne "main" )
  {
    $reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file";
    $result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file";
    $eval_file=   "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file";
    $log_file=   "$::glob_mysql_test_dir/suite/$::opt_suite/$log_file";
  }

  if ( -f $eval_file )
  {
    $result_file=  $eval_file;
  }

  my $diffopts= $::opt_udiff ? "-u" : "-c";

  if ( -f $reject_file )
  {
    print "Below are the diffs between actual and expected results:\n";
    print "-------------------------------------------------------\n";
    # FIXME check result code?!
    mtr_run("diff",[$diffopts,$result_file,$reject_file], "", "", "", "");
    print "-------------------------------------------------------\n";
    print "Please follow the instructions outlined at\n";
    print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n";
    print "to find the reason to this problem and how to report this.\n\n";
  }

  if ( -f $log_file )
  {
    print "Result from queries before failure can be found in $log_file\n";
    # FIXME Maybe a tail -f -n 10 $log_file here
  }
}

sub mtr_report_test_name ($) {
  my $tinfo= shift;

  _mtr_log("$tinfo->{name}");
  printf "%-30s ", $tinfo->{'name'};
}

@@ -106,15 +61,15 @@ sub mtr_report_test_skipped ($) {
  $tinfo->{'result'}= 'MTR_RES_SKIPPED';
  if ( $tinfo->{'disable'} )
  {
    print "[ disabled ]  $tinfo->{'comment'}\n";
    mtr_report("[ disabled ]  $tinfo->{'comment'}");
  }
  elsif ( $tinfo->{'comment'} )
  {
    print "[ skipped ]   $tinfo->{'comment'}\n";
    mtr_report("[ skipped ]   $tinfo->{'comment'}");
  }
  else
  {
    print "[ skipped ]\n";
    mtr_report("[ skipped ]");
  }
}

@@ -142,11 +97,11 @@ sub mtr_report_test_passed ($) {
  if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
  {
    $timer= mtr_fromfile("$::opt_vardir/log/timer");
    $::glob_tot_real_time += ($timer/1000);
    $tot_real_time += ($timer/1000);
    $timer= sprintf "%12s", $timer;
  }
  $tinfo->{'result'}= 'MTR_RES_PASSED';
  print "[ pass ]   $timer\n";
  mtr_report("[ pass ]   $timer");
}

sub mtr_report_test_failed ($) {
@@ -155,27 +110,34 @@ sub mtr_report_test_failed ($) {
  $tinfo->{'result'}= 'MTR_RES_FAILED';
  if ( defined $tinfo->{'timeout'} )
  {
    print "[ fail ]  timeout\n";
    mtr_report("[ fail ]  timeout");
    return;
  }
  else
  {
    print "[ fail ]\n";
    mtr_report("[ fail ]");
  }

  if ( $tinfo->{'comment'} )
  {
    print "\nERROR: $tinfo->{'comment'}\n";
    # The test failure has been detected by mysql-test-run.pl
    # when starting the servers or due to other error, the reason for
    # failing the test is saved in "comment"
    mtr_report("\nERROR: $tinfo->{'comment'}");
  }
  elsif ( -f $::path_timefile )
  {
    print "\nErrors are (from $::path_timefile) :\n";
    # Test failure was detected by test tool and it's report
    # about what failed has been saved to file. Display the report.
    print "\n";
    print mtr_fromfile($::path_timefile); # FIXME print_file() instead
    print "\n(the last lines may be the most important ones)\n";
    print "\n";
  }
  else
  {
    print "\nUnexpected termination, probably when starting mysqld\n";
    # Neither this script or the test tool has recorded info
    # about why the test has failed. Should be debugged.
    mtr_report("\nUnexpected termination, probably when starting mysqld");;
  }
}

@@ -243,8 +205,10 @@ sub mtr_report_stats ($) {

  if ( $::opt_timer )
  {
    print
      "Spent $::glob_tot_real_time seconds actually executing testcases\n"
    use English;

    mtr_report("Spent", sprintf("%.3f", $tot_real_time),"of",
	       time - $BASETIME, "seconds executing testcases");
  }

  # ----------------------------------------------------------------------
@@ -397,35 +361,66 @@ sub mtr_print_header () {

##############################################################################
#
#  Misc
#  Log and reporting functions
#
##############################################################################

use IO::File;

my $log_file_ref= undef;

sub mtr_log_init ($) {
  my ($filename)= @_;

  mtr_error("Log is already open") if defined $log_file_ref;

  $log_file_ref= IO::File->new($filename, "a") or
    mtr_warning("Could not create logfile $filename: $!");
}

sub _mtr_log (@) {
  print $log_file_ref join(" ", @_),"\n"
    if defined $log_file_ref;
}

sub mtr_report (@) {
  # Print message to screen and log
  _mtr_log(@_);
  print join(" ", @_),"\n";
}

sub mtr_warning (@) {
  # Print message to screen and log
  _mtr_log("WARNING: ", @_);
  print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
}

sub mtr_error (@) {
  # Print message to screen and log
  _mtr_log("ERROR: ", @_);
  print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
  mtr_exit(1);
}

sub mtr_child_error (@) {
  # Print message to screen and log
  _mtr_log("ERROR(child): ", @_);
  print STDERR "mysql-test-run: *** ERROR(child): ",join(" ", @_),"\n";
  exit(1);
}

sub mtr_debug (@) {
  # Only print if --script-debug is used
  if ( $::opt_script_debug )
  {
    _mtr_log("###: ", @_);
    print STDERR "####: ",join(" ", @_),"\n";
  }
}

sub mtr_verbose (@) {
  # Always print to log, print to screen only when --verbose is used
  _mtr_log("> ",@_);
  if ( $::opt_verbose )
  {
    print STDERR "> ",join(" ", @_),"\n";
Loading