Bug#39861:

1. mysqltest.cc - added flush to log file after each executed command in a testcase.
2. mtr shows 20 last lines from test case log file if timeout reached.
3. Optimizing the code by Magnus review.
4. It is partially fix bug#40150
This commit is contained in:
Serge Kozlov 2008-11-14 23:35:32 +03:00
commit 3e0fb46142
4 changed files with 19 additions and 11 deletions

View file

@ -688,6 +688,7 @@ sub collect_one_test_case {
my $tinfo= My::Test->new
(
name => "$suitename.$tname",
shortname => $tname,
path => "$testdir/$filename",
);

View file

@ -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= <FILE>)
{
$text= $line;
}
my @lines= reverse <FILE>;
close FILE;
return $text;
my $size= scalar(@lines);
$num_lines= $size unless ($size >= $num_lines);
return join("", reverse(splice(@lines, 0, $num_lines)));
}
1;