From 403cbe2032ba200d797a41095c59fa174219d937 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 22 Jul 2016 11:06:08 +1000 Subject: [PATCH 1/3] bug-82093: restructure mtr to allow --valgrind-option=--tool=XXX Previously this added --tool=memcheck by default. Also the valgrind --base argument used --tool=callgrind got removed a while ago. Signed-off-by: Daniel Black --- mysql-test/mysql-test-run.pl | 46 +++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 79a2262..02d9d65 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -303,7 +303,6 @@ END my $opt_valgrind_mysqld= 0; my $opt_valgrind_clients= 0; my $opt_valgrind_mysqltest= 0; -my @default_valgrind_args= ("--show-reachable=yes"); my @valgrind_args; my $opt_valgrind_path; my $valgrind_reports= 0; @@ -1777,6 +1776,7 @@ sub command_line_setup { # Set special valgrind options unless options passed on command line push(@valgrind_args, "--trace-children=yes") unless @valgrind_args; + unshift(@valgrind_args, "--tool=callgrind"); } if ( $opt_trace_protocol ) @@ -1786,13 +1786,28 @@ sub command_line_setup { push(@opt_extra_mysqld_opt, "--optimizer-trace-max-mem-size=1000000"); } - if ( $opt_valgrind ) + # default to --tool=memcheck + if ($opt_valgrind && ! grep(/^--tool=/i, @valgrind_args)) { - # Set valgrind_options to default unless already defined - push(@valgrind_args, @default_valgrind_args) - unless @valgrind_args; + # Set valgrind_option unless already defined + push(@valgrind_args, ("--num-callers=16", "--show-reachable=yes")) + unless @valgrind_args; + if($daemonize_mysqld) + { + push(@valgrind_args, "--leak-check=no") + } + else + { + push(@valgrind_args, "--leak-check=yes") + } + unshift(@valgrind_args, "--tool=memcheck"); + } + if ( $opt_valgrind ) + { # Don't add --quiet; you will loose the summary reports. + push(@valgrind_args, "--suppressions=${glob_mysql_test_dir}/valgrind.supp") + if -f "$glob_mysql_test_dir/valgrind.supp"; mtr_report("Running valgrind with options \"", join(" ", @valgrind_args), "\""); @@ -6832,27 +6847,6 @@ sub valgrind_arguments { my $args= shift; my $exe= shift; - if ( $opt_callgrind) - { - mtr_add_arg($args, "--tool=callgrind"); - mtr_add_arg($args, "--base=$opt_vardir/log"); - } - else - { - mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option - if($daemonize_mysqld) - { - mtr_add_arg($args, "--leak-check=no"); - } - else - { - mtr_add_arg($args, "--leak-check=yes"); - } - mtr_add_arg($args, "--num-callers=16"); - mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir) - if -f "$glob_mysql_test_dir/valgrind.supp"; - } - # Add valgrind options, can be overriden by user mtr_add_arg($args, '%s', $_) for (@valgrind_args); From 450e3bdb576b93a91c60b034df0ba222511df080 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 22 Jul 2016 11:08:38 +1000 Subject: [PATCH 2/3] MTR: move trace-protocol out of the valgrind code The arguement handling for trace-protocl was in the middle of the code used for handling valgrind arguements. Moved this to earlier for neatness. --- mysql-test/mysql-test-run.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 02d9d65..130934b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1734,6 +1734,16 @@ sub command_line_setup { if ($opt_suite_timeout <= 0); # -------------------------------------------------------------------------- + # Check trace protocol option + # -------------------------------------------------------------------------- + if ( $opt_trace_protocol ) + { + push(@opt_extra_mysqld_opt, "--optimizer_trace=enabled=on,one_line=off"); + # some queries yield big traces: + push(@opt_extra_mysqld_opt, "--optimizer-trace-max-mem-size=1000000"); + } + + # -------------------------------------------------------------------------- # Check valgrind arguments # -------------------------------------------------------------------------- if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args) @@ -1779,13 +1789,6 @@ sub command_line_setup { unshift(@valgrind_args, "--tool=callgrind"); } - if ( $opt_trace_protocol ) - { - push(@opt_extra_mysqld_opt, "--optimizer_trace=enabled=on,one_line=off"); - # some queries yield big traces: - push(@opt_extra_mysqld_opt, "--optimizer-trace-max-mem-size=1000000"); - } - # default to --tool=memcheck if ($opt_valgrind && ! grep(/^--tool=/i, @valgrind_args)) { From 8bc2220022b3cd7c9ccb54fc1248100dee117961 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 22 Jul 2016 11:09:06 +1000 Subject: [PATCH 3/3] Add MTR_TEST_NAME to env, so valgrind can be wrapped A use case here where you need valgrind tool to output per testname. --- mysql-test/mysql-test-run.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 130934b..c5a5c4b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4378,6 +4378,7 @@ ($) my $print_freq=20; mtr_verbose("Running test:", $tinfo->{name}); + $ENV{'MTR_TEST_NAME'} = $tinfo->{name}; resfile_report_test($tinfo) if $opt_resfile; # Allow only alpanumerics pluss _ - + . in combination names,