#At file:///home/ksm/sun/repo/bug39861/mysql-5.1-rpl/
2698 Serge Kozlov 2008-11-14
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
modified:
client/mysqltest.cc
mysql-test/lib/mtr_cases.pm
mysql-test/lib/mtr_io.pl
mysql-test/mysql-test-run.pl
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc 2008-11-14 10:08:09 +0000
+++ b/client/mysqltest.cc 2008-11-14 20:35:32 +0000
@@ -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);
}
=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm 2008-10-23 19:27:09 +0000
+++ b/mysql-test/lib/mtr_cases.pm 2008-11-14 20:35:32 +0000
@@ -688,6 +688,7 @@ sub collect_one_test_case {
my $tinfo= My::Test->new
(
name => "$suitename.$tname",
+ shortname => $tname,
path => "$testdir/$filename",
);
=== modified file 'mysql-test/lib/mtr_io.pl'
--- a/mysql-test/lib/mtr_io.pl 2008-08-09 09:16:12 +0000
+++ b/mysql-test/lib/mtr_io.pl 2008-11-14 20:35:32 +0000
@@ -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;
=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl 2008-11-14 12:19:37 +0000
+++ b/mysql-test/mysql-test-run.pl 2008-11-14 20:35:32 +0000
@@ -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);
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (skozlov:2698) Bug#39861 Bug#40150 | Serge Kozlov | 14 Nov |