Commit 820f53e8 authored by msvensson@pilot.(none)'s avatar msvensson@pilot.(none)

Merge 192.168.0.7:mysql/mtr_log/my50-mtr_log

into  pilot.(none):/data/msvensson/mysql/mysql-5.0-maint
parents ea692e90 b3db4671
...@@ -99,25 +99,26 @@ sub spawn_impl ($$$$$$$) { ...@@ -99,25 +99,26 @@ sub spawn_impl ($$$$$$$) {
if ( $::opt_script_debug ) if ( $::opt_script_debug )
{ {
print STDERR "\n"; mtr_report("");
print STDERR "#### ", "-" x 78, "\n"; mtr_debug("-" x 73);
print STDERR "#### ", "STDIN $input\n" if $input; mtr_debug("STDIN $input") if $input;
print STDERR "#### ", "STDOUT $output\n" if $output; mtr_debug("STDOUT $output") if $output;
print STDERR "#### ", "STDERR $error\n" if $error; mtr_debug("STDERR $error") if $error;
print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n"; mtr_debug("$mode: $path ", join(" ",@$arg_list_t));
print STDERR "#### ", "spawn options:\n"; mtr_debug("spawn options:");
if ($spawn_opts) if ($spawn_opts)
{ {
foreach my $key (sort keys %{$spawn_opts}) foreach my $key (sort keys %{$spawn_opts})
{ {
print STDERR "#### ", " - $key: $spawn_opts->{$key}\n"; mtr_debug(" - $key: $spawn_opts->{$key}");
} }
} }
else 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; mtr_error("Can't spawn with empty \"path\"") unless defined $path;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# same name. # same name.
use strict; use strict;
use warnings;
sub mtr_report_test_name($); sub mtr_report_test_name($);
sub mtr_report_test_passed($); sub mtr_report_test_passed($);
...@@ -100,6 +101,7 @@ sub mtr_show_failed_diff ($) { ...@@ -100,6 +101,7 @@ sub mtr_show_failed_diff ($) {
sub mtr_report_test_name ($) { sub mtr_report_test_name ($) {
my $tinfo= shift; my $tinfo= shift;
_mtr_log("$tinfo->{name}");
printf "%-30s ", $tinfo->{'name'}; printf "%-30s ", $tinfo->{'name'};
} }
...@@ -109,15 +111,15 @@ sub mtr_report_test_skipped ($) { ...@@ -109,15 +111,15 @@ sub mtr_report_test_skipped ($) {
$tinfo->{'result'}= 'MTR_RES_SKIPPED'; $tinfo->{'result'}= 'MTR_RES_SKIPPED';
if ( $tinfo->{'disable'} ) if ( $tinfo->{'disable'} )
{ {
print "[ disabled ] $tinfo->{'comment'}\n"; mtr_report("[ disabled ] $tinfo->{'comment'}");
} }
elsif ( $tinfo->{'comment'} ) elsif ( $tinfo->{'comment'} )
{ {
print "[ skipped ] $tinfo->{'comment'}\n"; mtr_report("[ skipped ] $tinfo->{'comment'}");
} }
else else
{ {
print "[ skipped ]\n"; mtr_report("[ skipped ]");
} }
} }
...@@ -149,7 +151,7 @@ sub mtr_report_test_passed ($) { ...@@ -149,7 +151,7 @@ sub mtr_report_test_passed ($) {
$timer= sprintf "%12s", $timer; $timer= sprintf "%12s", $timer;
} }
$tinfo->{'result'}= 'MTR_RES_PASSED'; $tinfo->{'result'}= 'MTR_RES_PASSED';
print "[ pass ] $timer\n"; mtr_report("[ pass ] $timer");
} }
sub mtr_report_test_failed ($) { sub mtr_report_test_failed ($) {
...@@ -158,17 +160,17 @@ sub mtr_report_test_failed ($) { ...@@ -158,17 +160,17 @@ sub mtr_report_test_failed ($) {
$tinfo->{'result'}= 'MTR_RES_FAILED'; $tinfo->{'result'}= 'MTR_RES_FAILED';
if ( defined $tinfo->{'timeout'} ) if ( defined $tinfo->{'timeout'} )
{ {
print "[ fail ] timeout\n"; mtr_report("[ fail ] timeout");
return; return;
} }
else else
{ {
print "[ fail ]\n"; mtr_report("[ fail ]");
} }
if ( $tinfo->{'comment'} ) if ( $tinfo->{'comment'} )
{ {
print "\nERROR: $tinfo->{'comment'}\n"; mtr_report("\nERROR: $tinfo->{'comment'}");
} }
elsif ( -f $::path_timefile ) elsif ( -f $::path_timefile )
{ {
...@@ -178,7 +180,7 @@ sub mtr_report_test_failed ($) { ...@@ -178,7 +180,7 @@ sub mtr_report_test_failed ($) {
} }
else else
{ {
print "\nUnexpected termination, probably when starting mysqld\n"; mtr_report("\nUnexpected termination, probably when starting mysqld");;
} }
} }
...@@ -402,35 +404,66 @@ sub mtr_print_header () { ...@@ -402,35 +404,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 (@) { sub mtr_report (@) {
# Print message to screen and log
_mtr_log(@_);
print join(" ", @_),"\n"; print join(" ", @_),"\n";
} }
sub mtr_warning (@) { sub mtr_warning (@) {
# Print message to screen and log
_mtr_log("WARNING: ", @_);
print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n"; print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
} }
sub mtr_error (@) { sub mtr_error (@) {
# Print message to screen and log
_mtr_log("ERROR: ", @_);
print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n"; print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
mtr_exit(1); mtr_exit(1);
} }
sub mtr_child_error (@) { sub mtr_child_error (@) {
# Print message to screen and log
_mtr_log("ERROR(child): ", @_);
print STDERR "mysql-test-run: *** ERROR(child): ",join(" ", @_),"\n"; print STDERR "mysql-test-run: *** ERROR(child): ",join(" ", @_),"\n";
exit(1); exit(1);
} }
sub mtr_debug (@) { sub mtr_debug (@) {
# Only print if --script-debug is used
if ( $::opt_script_debug ) if ( $::opt_script_debug )
{ {
_mtr_log("###: ", @_);
print STDERR "####: ",join(" ", @_),"\n"; print STDERR "####: ",join(" ", @_),"\n";
} }
} }
sub mtr_verbose (@) { sub mtr_verbose (@) {
# Always print to log, print to screen only when --verbose is used
_mtr_log("> ",@_);
if ( $::opt_verbose ) if ( $::opt_verbose )
{ {
print STDERR "> ",join(" ", @_),"\n"; print STDERR "> ",join(" ", @_),"\n";
......
...@@ -2902,6 +2902,9 @@ sub initialize_servers () { ...@@ -2902,6 +2902,9 @@ sub initialize_servers () {
} }
} }
check_running_as_root(); check_running_as_root();
mtr_log_init("$opt_vardir/log/mysql-test-run.log");
} }
sub mysql_install_db () { sub mysql_install_db () {
...@@ -3623,13 +3626,13 @@ sub report_failure_and_restart ($) { ...@@ -3623,13 +3626,13 @@ sub report_failure_and_restart ($) {
# Restore the snapshot of the installed test db # Restore the snapshot of the installed test db
restore_installed_db($tinfo->{'name'}); restore_installed_db($tinfo->{'name'});
print "Resuming Tests\n\n"; mtr_report("Resuming Tests\n");
return; return;
} }
my $test_mode= join(" ", @::glob_test_mode) || "default"; my $test_mode= join(" ", @::glob_test_mode) || "default";
print "Aborting: $tinfo->{'name'} failed in $test_mode mode. "; mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
print "To continue, re-run with '--force'.\n"; mtr_report("To continue, re-run with '--force'.");
if ( ! $glob_debugger and if ( ! $glob_debugger and
! $opt_extern and ! $opt_extern and
! $glob_use_embedded_server ) ! $glob_use_embedded_server )
...@@ -4087,11 +4090,11 @@ sub mysqld_start ($$$) { ...@@ -4087,11 +4090,11 @@ sub mysqld_start ($$$) {
sub stop_all_servers () { sub stop_all_servers () {
print "Stopping All Servers\n"; mtr_report("Stopping All Servers");
if ( ! $opt_skip_im ) if ( ! $opt_skip_im )
{ {
print "Shutting-down Instance Manager\n"; mtr_report("Shutting-down Instance Manager");
unless (mtr_im_stop($instance_manager, "stop_all_servers")) unless (mtr_im_stop($instance_manager, "stop_all_servers"))
{ {
mtr_error("Failed to stop Instance Manager.") mtr_error("Failed to stop Instance Manager.")
......
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