ktest.pl: Fix the logic for truncating the size of the log file for email

The logic for truncating the log file for emailing based on the
MAIL_MAX_SIZE option is confusing and incorrect. Simplify it and have the
tail of the log file truncated to the max size specified in the config.

Cc: stable@vger.kernel.org
Fixes: 855d8abd ("ktest.pl: Change the logic to control the size of the log file emailed")
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 8cd6bc03
...@@ -1499,17 +1499,16 @@ sub dodie { ...@@ -1499,17 +1499,16 @@ sub dodie {
my $log_file; my $log_file;
if (defined($opt{"LOG_FILE"})) { if (defined($opt{"LOG_FILE"})) {
my $whence = 0; # beginning of file my $whence = 2; # End of file
my $pos = $test_log_start; my $log_size = tell LOG;
my $size = $log_size - $test_log_start;
if (defined($mail_max_size)) { if (defined($mail_max_size)) {
my $log_size = tell LOG; if ($size > $mail_max_size) {
$log_size -= $test_log_start; $size = $mail_max_size;
if ($log_size > $mail_max_size) {
$whence = 2; # end of file
$pos = - $mail_max_size;
} }
} }
my $pos = - $size;
$log_file = "$tmpdir/log"; $log_file = "$tmpdir/log";
open (L, "$opt{LOG_FILE}") or die "Can't open $opt{LOG_FILE} to read)"; open (L, "$opt{LOG_FILE}") or die "Can't open $opt{LOG_FILE} to read)";
open (O, "> $tmpdir/log") or die "Can't open $tmpdir/log\n"; open (O, "> $tmpdir/log") or die "Can't open $tmpdir/log\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment