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 )
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -688,6 +688,7 @@ sub collect_one_test_case {
|
|||
my $tinfo= My::Test->new
|
||||
(
|
||||
name => "$suitename.$tname",
|
||||
shortname => $tname,
|
||||
path => "$testdir/$filename",
|
||||
|
||||
);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue