diff --git a/client/mysqltest.cc b/client/mysqltest.cc index ae68e642130..1b866085c41 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -7844,8 +7844,9 @@ int main(int argc, char **argv) if ( opt_mark_progress ) mark_progress(command, parser.current_line); - /* Write result from command to log file */ + /* Write result from command to log file immediately */ log_file.write(&ds_res); + log_file.flush(); dynstr_set(&ds_res, 0); } diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 3ca766039ec..577bc0c6438 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -688,6 +688,7 @@ sub collect_one_test_case { my $tinfo= My::Test->new ( name => "$suitename.$tname", + shortname => $tname, path => "$testdir/$filename", ); diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index 31c2e8ffb06..21581798ddc 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -19,6 +19,7 @@ # same name. use strict; +use Carp; sub mtr_fromfile ($); sub mtr_tofile ($@); @@ -26,7 +27,7 @@ sub mtr_tonewfile($@); sub mtr_appendfile_to_file ($$); sub mtr_grab_file($); sub mtr_printfile($); -sub mtr_lastlinefromfile ($); +sub mtr_lastlinesfromfile ($$); # Read a whole file, stripping leading and trailing whitespace. sub mtr_fromfile ($) { @@ -94,17 +95,16 @@ sub mtr_printfile($) { return; } -sub mtr_lastlinefromfile ($) { - my $file= shift; +sub mtr_lastlinesfromfile ($$) { + croak "usage: mtr_lastlinesfromfile(file,numlines)" unless (@_ == 2); + my ($file, $num_lines)= @_; my $text; - open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); - while (my $line= ) - { - $text= $line; - } + my @lines= reverse ; close FILE; - return $text; + my $size= scalar(@lines); + $num_lines= $size unless ($size >= $num_lines); + return join("", reverse(splice(@lines, 0, $num_lines))); } 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 213ddf71b77..344ca3e1794 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3268,8 +3268,14 @@ sub run_testcase ($) { # ---------------------------------------------------- if ( $proc eq $test_timeout_proc ) { + my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log"; $tinfo->{comment}= - "Test case timeout after $opt_testcase_timeout minute(s)\n\n"; + "Test case timeout after $opt_testcase_timeout minute(s)\n\n"; + if (-e $log_file_name) + { + $tinfo->{comment}.= + "== $log_file_name == \n" . mtr_lastlinesfromfile($log_file_name, 20)."\n"; + } $tinfo->{'timeout'}= $opt_testcase_timeout; # Mark as timeout run_on_all($tinfo, 'analyze-timeout'); report_failure_and_restart($tinfo);