mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
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:
parent
46118a40ec
commit
3e0fb46142
4 changed files with 19 additions and 11 deletions
|
@ -7844,8 +7844,9 @@ int main(int argc, char **argv)
|
||||||
if ( opt_mark_progress )
|
if ( opt_mark_progress )
|
||||||
mark_progress(command, parser.current_line);
|
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.write(&ds_res);
|
||||||
|
log_file.flush();
|
||||||
dynstr_set(&ds_res, 0);
|
dynstr_set(&ds_res, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -688,6 +688,7 @@ sub collect_one_test_case {
|
||||||
my $tinfo= My::Test->new
|
my $tinfo= My::Test->new
|
||||||
(
|
(
|
||||||
name => "$suitename.$tname",
|
name => "$suitename.$tname",
|
||||||
|
shortname => $tname,
|
||||||
path => "$testdir/$filename",
|
path => "$testdir/$filename",
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
# same name.
|
# same name.
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Carp;
|
||||||
|
|
||||||
sub mtr_fromfile ($);
|
sub mtr_fromfile ($);
|
||||||
sub mtr_tofile ($@);
|
sub mtr_tofile ($@);
|
||||||
|
@ -26,7 +27,7 @@ sub mtr_tonewfile($@);
|
||||||
sub mtr_appendfile_to_file ($$);
|
sub mtr_appendfile_to_file ($$);
|
||||||
sub mtr_grab_file($);
|
sub mtr_grab_file($);
|
||||||
sub mtr_printfile($);
|
sub mtr_printfile($);
|
||||||
sub mtr_lastlinefromfile ($);
|
sub mtr_lastlinesfromfile ($$);
|
||||||
|
|
||||||
# Read a whole file, stripping leading and trailing whitespace.
|
# Read a whole file, stripping leading and trailing whitespace.
|
||||||
sub mtr_fromfile ($) {
|
sub mtr_fromfile ($) {
|
||||||
|
@ -94,17 +95,16 @@ sub mtr_printfile($) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub mtr_lastlinefromfile ($) {
|
sub mtr_lastlinesfromfile ($$) {
|
||||||
my $file= shift;
|
croak "usage: mtr_lastlinesfromfile(file,numlines)" unless (@_ == 2);
|
||||||
|
my ($file, $num_lines)= @_;
|
||||||
my $text;
|
my $text;
|
||||||
|
|
||||||
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
||||||
while (my $line= <FILE>)
|
my @lines= reverse <FILE>;
|
||||||
{
|
|
||||||
$text= $line;
|
|
||||||
}
|
|
||||||
close 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;
|
1;
|
||||||
|
|
|
@ -3268,8 +3268,14 @@ sub run_testcase ($) {
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
if ( $proc eq $test_timeout_proc )
|
if ( $proc eq $test_timeout_proc )
|
||||||
{
|
{
|
||||||
|
my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log";
|
||||||
$tinfo->{comment}=
|
$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
|
$tinfo->{'timeout'}= $opt_testcase_timeout; # Mark as timeout
|
||||||
run_on_all($tinfo, 'analyze-timeout');
|
run_on_all($tinfo, 'analyze-timeout');
|
||||||
report_failure_and_restart($tinfo);
|
report_failure_and_restart($tinfo);
|
||||||
|
|
Loading…
Reference in a new issue