summaryrefslogtreecommitdiff
path: root/mysql-test/mysql-test-run.pl
diff options
context:
space:
mode:
authorBjorn Munch <Bjorn.Munch@sun.com>2009-11-12 11:04:01 +0100
committerBjorn Munch <Bjorn.Munch@sun.com>2009-11-12 11:04:01 +0100
commitf1b4be2a21c55ca69ba99c27f4fd8f66cfa7e4f8 (patch)
treec153eb62903ce0cc8ce4904376e69267f6231e98 /mysql-test/mysql-test-run.pl
parent7bfd110102c62ee3b9811814e37872166961b280 (diff)
downloadmariadb-git-f1b4be2a21c55ca69ba99c27f4fd8f66cfa7e4f8.tar.gz
Bug #43418 MTR2: does not notice a memory leak occuring at shutdown of mysqld w/ --valgrind
Checking is done before server is terminated Adds post processing of server logs if --valgrind Also had to remove --quiet option to valgrind
Diffstat (limited to 'mysql-test/mysql-test-run.pl')
-rwxr-xr-xmysql-test/mysql-test-run.pl71
1 files changed, 68 insertions, 3 deletions
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index c91a74570bd..4ac3beff0a6 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -226,6 +226,7 @@ my @default_valgrind_args= ("--show-reachable=yes");
my @valgrind_args;
my $opt_valgrind_path;
my $opt_callgrind;
+my %mysqld_logs;
my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions.
our $opt_warnings= 1;
@@ -741,6 +742,9 @@ sub run_worker ($) {
elsif ($line eq 'BYE'){
mtr_report("Server said BYE");
stop_all_servers($opt_shutdown_timeout);
+ if ($opt_valgrind_mysqld) {
+ valgrind_exit_reports();
+ }
exit(0);
}
else {
@@ -1340,8 +1344,7 @@ sub command_line_setup {
push(@valgrind_args, @default_valgrind_args)
unless @valgrind_args;
- # Make valgrind run in quiet mode so it only print errors
- push(@valgrind_args, "--quiet" );
+ # Don't add --quiet; you will loose the summary reports.
mtr_report("Running valgrind with options \"",
join(" ", @valgrind_args), "\"");
@@ -3690,7 +3693,7 @@ sub extract_warning_lines ($$) {
(
qr/^Warning:|mysqld: Warning|\[Warning\]/,
qr/^Error:|\[ERROR\]/,
- qr/^==\d*==/, # valgrind errors
+ qr/^==\d+==\s+\S/, # valgrind errors
qr/InnoDB: Warning|InnoDB: Error/,
qr/^safe_mutex:|allocated at line/,
qr/missing DBUG_RETURN/,
@@ -4296,6 +4299,8 @@ sub mysqld_start ($$) {
# see the exact location where valgrind complains
$output= "$opt_vardir/log/".$mysqld->name().".trace";
}
+ # Remember this log file for valgrind error report search
+ $mysqld_logs{$output}= 1 if $opt_valgrind;
if ( defined $exe )
{
@@ -5148,6 +5153,66 @@ sub valgrind_arguments {
}
}
+#
+# Search server logs for valgrind reports printed at mysqld termination
+#
+
+sub valgrind_exit_reports() {
+ foreach my $log_file (keys %mysqld_logs)
+ {
+ my @culprits= ();
+ my $valgrind_rep= "";
+ my $found_report= 0;
+ my $err_in_report= 0;
+
+ my $LOGF = IO::File->new($log_file)
+ or mtr_error("Could not open file '$log_file' for reading: $!");
+
+ while ( my $line = <$LOGF> )
+ {
+ if ($line =~ /^CURRENT_TEST: (.+)$/)
+ {
+ my $testname= $1;
+ # If we have a report, report it if needed and start new list of tests
+ if ($found_report)
+ {
+ if ($err_in_report)
+ {
+ mtr_print ("Valgrind report from $log_file after tests:\n",
+ @culprits);
+ mtr_print_line();
+ print ("$valgrind_rep\n");
+ $err_in_report= 0;
+ }
+ # Make ready to collect new report
+ @culprits= ();
+ $found_report= 0;
+ $valgrind_rep= "";
+ }
+ push (@culprits, $testname);
+ next;
+ }
+ # This line marks the start of a valgrind report
+ $found_report= 1 if $line =~ /ERROR SUMMARY:/;
+
+ if ($found_report) {
+ $line=~ s/^==\d+== //;
+ $valgrind_rep .= $line;
+ $err_in_report= 1 if $line =~ /ERROR SUMMARY: [1-9]/;
+ $err_in_report= 1 if $line =~ /definitely lost: [1-9]/;
+ $err_in_report= 1 if $line =~ /possibly lost: [1-9]/;
+ }
+ }
+
+ $LOGF= undef;
+
+ if ($err_in_report) {
+ mtr_print ("Valgrind report from $log_file after tests:\n", @culprits);
+ mtr_print_line();
+ print ("$valgrind_rep\n");
+ }
+ }
+}
#
# Usage