aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest/ktest.pl
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2020-07-01 18:34:10 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2020-07-02 09:55:04 -0400
commitf986900209093f5de887d6c342139df6ebec04ac (patch)
tree57e56a4800e83feec60a90775fe8a678821fa29f /tools/testing/ktest/ktest.pl
parentktest.pl: Add the log of last test in email on failure (diff)
downloadlinux-dev-f986900209093f5de887d6c342139df6ebec04ac.tar.xz
linux-dev-f986900209093f5de887d6c342139df6ebec04ac.zip
ktest.pl: Add MAIL_MAX_SIZE to limit the amount of log emailed
Add the ktest config option MAIL_MAX_SIZE that will limit the size of the log file that is placed into the email on failure. Link: https://lore.kernel.org/r/20200701231756.790637968@goodmis.org Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-xtools/testing/ktest/ktest.pl12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 8a4a33492952..36db5b0b3647 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -227,6 +227,7 @@ my $dirname = $FindBin::Bin;
my $mailto;
my $mailer;
my $mail_path;
+my $mail_max_size;
my $mail_command;
my $email_on_error;
my $email_when_finished;
@@ -263,6 +264,7 @@ my %option_map = (
"MAILTO" => \$mailto,
"MAILER" => \$mailer,
"MAIL_PATH" => \$mail_path,
+ "MAIL_MAX_SIZE" => \$mail_max_size,
"MAIL_COMMAND" => \$mail_command,
"EMAIL_ON_ERROR" => \$email_on_error,
"EMAIL_WHEN_FINISHED" => \$email_when_finished,
@@ -1497,10 +1499,18 @@ sub dodie {
my $log_file;
if (defined($opt{"LOG_FILE"})) {
+ my $size = 0;
+ if (defined($mail_max_size)) {
+ my $log_size = tell LOG;
+ $log_size -= $test_log_start;
+ if ($log_size > $mail_max_size) {
+ $size = $log_size - $mail_max_size;
+ }
+ }
$log_file = "$tmpdir/log";
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";
- seek(L, $test_log_start, 0);
+ seek(L, $test_log_start + $size, 0);
while (<L>) {
print O;
}