Commit 60bc49cf authored by kent@mysql.com's avatar kent@mysql.com

mysql-test-run.pl:

  Enabled --valgrind to work (bug#13280)
parent 21636f1c
...@@ -237,8 +237,10 @@ our $opt_ps_protocol; ...@@ -237,8 +237,10 @@ our $opt_ps_protocol;
our $opt_sleep_time_after_restart= 1; our $opt_sleep_time_after_restart= 1;
our $opt_sleep_time_for_delete= 10; our $opt_sleep_time_for_delete= 10;
our $opt_testcase_timeout= 5; # 5 min max our $opt_testcase_timeout;
our $opt_suite_timeout= 120; # 2 hours max our $opt_suite_timeout;
my $default_testcase_timeout= 10; # 10 min max
my $default_suite_timeout= 120; # 2 hours max
our $opt_socket; our $opt_socket;
...@@ -509,8 +511,8 @@ sub command_line_setup () { ...@@ -509,8 +511,8 @@ sub command_line_setup () {
# Coverage, profiling etc # Coverage, profiling etc
'gcov' => \$opt_gcov, 'gcov' => \$opt_gcov,
'gprof' => \$opt_gprof, 'gprof' => \$opt_gprof,
'valgrind' => \$opt_valgrind, 'valgrind:s' => \$opt_valgrind,
'valgrind-all' => \$opt_valgrind_all, 'valgrind-all:s' => \$opt_valgrind_all,
'valgrind-options=s' => \$opt_valgrind_options, 'valgrind-options=s' => \$opt_valgrind_options,
# Misc # Misc
...@@ -688,29 +690,36 @@ sub command_line_setup () { ...@@ -688,29 +690,36 @@ sub command_line_setup () {
$opt_with_ndbcluster= 0; $opt_with_ndbcluster= 0;
} }
# FIXME # The ":s" in the argument spec, means we have three different cases
#
# undefined option not set
# "" option set with no argument
# "somestring" option is name/path of valgrind executable
if ( defined $opt_valgrind_all and ! $opt_valgrind )
{
$opt_valgrind= $opt_valgrind_all;
}
if ( ! $opt_testcase_timeout )
{
$opt_testcase_timeout= $default_testcase_timeout;
$opt_testcase_timeout*= 10 if defined $opt_valgrind;
}
if ( ! $opt_suite_timeout )
{
$opt_suite_timeout= $default_suite_timeout;
$opt_suite_timeout*= 4 if defined $opt_valgrind;
}
#if ( $opt_valgrind or $opt_valgrind_all ) if ( defined $opt_valgrind )
#{ {
# VALGRIND=`which valgrind` # this will print an error if not found FIXME $opt_sleep_time_after_restart= 10;
# Give good warning to the user and stop $opt_sleep_time_for_delete= 60;
# if ( ! $VALGRIND )
# {
# print "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://valgrind.kde.org.\n"
# exit 1
# }
# >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr # >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr
# valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && VALGRIND="$VALGRIND --tool=memcheck" # valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && VALGRIND="$VALGRIND --tool=memcheck"
# VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16" }
# $opt_extra_mysqld_opt.= " --skip-safemalloc --skip-bdb";
# SLEEP_TIME_AFTER_RESTART=10
# $opt_sleep_time_for_delete= 60
# $glob_use_running_server= ""
# if ( "$1"= "--valgrind-all" )
# {
# VALGRIND="$VALGRIND -v --show-reachable=yes"
# }
#}
if ( ! $opt_user ) if ( ! $opt_user )
{ {
...@@ -1703,7 +1712,7 @@ sub mysqld_arguments ($$$$$) { ...@@ -1703,7 +1712,7 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--language=%s", $prefix, $path_language); mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
if ( $opt_valgrind ) if ( defined $opt_valgrind )
{ {
mtr_add_arg($args, "%s--skip-safemalloc", $prefix); mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
mtr_add_arg($args, "%s--skip-bdb", $prefix); mtr_add_arg($args, "%s--skip-bdb", $prefix);
...@@ -1928,29 +1937,9 @@ sub mysqld_start ($$$$) { ...@@ -1928,29 +1937,9 @@ sub mysqld_start ($$$$) {
mtr_init_args(\$args); mtr_init_args(\$args);
if ( $opt_valgrind ) if ( defined $opt_valgrind )
{ {
valgrind_arguments($args, \$exe);
mtr_add_arg($args, "--tool=memcheck");
mtr_add_arg($args, "--alignment=8");
mtr_add_arg($args, "--leak-check=yes");
mtr_add_arg($args, "--num-callers=16");
if ( $opt_valgrind_all )
{
mtr_add_arg($args, "-v");
mtr_add_arg($args, "--show-reachable=yes");
}
if ( $opt_valgrind_options )
{
# FIXME split earlier and put into @glob_valgrind_*
mtr_add_arg($args, split(' ', $opt_valgrind_options));
}
mtr_add_arg($args, $exe);
$exe= $opt_valgrind;
} }
mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info); mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info);
...@@ -2121,6 +2110,11 @@ sub run_mysqltest ($) { ...@@ -2121,6 +2110,11 @@ sub run_mysqltest ($) {
mtr_init_args(\$args); mtr_init_args(\$args);
if ( defined $opt_valgrind )
{
valgrind_arguments($args, \$exe);
}
mtr_add_arg($args, "--no-defaults"); mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_mysock'}); mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_mysock'});
mtr_add_arg($args, "--database=test"); mtr_add_arg($args, "--database=test");
...@@ -2205,6 +2199,34 @@ sub run_mysqltest ($) { ...@@ -2205,6 +2199,34 @@ sub run_mysqltest ($) {
return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,""); return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,"");
} }
sub valgrind_arguments {
my $args= shift;
my $exe= shift;
mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
mtr_add_arg($args, "--alignment=8");
mtr_add_arg($args, "--leak-check=yes");
mtr_add_arg($args, "--num-callers=16");
if ( defined $opt_valgrind_all )
{
mtr_add_arg($args, "-v");
mtr_add_arg($args, "--show-reachable=yes");
}
if ( $opt_valgrind_options )
{
# FIXME split earlier and put into @glob_valgrind_*
mtr_add_arg($args, split(' ', $opt_valgrind_options));
}
mtr_add_arg($args, $$exe);
$$exe= $opt_valgrind || "valgrind";
}
############################################################################## ##############################################################################
# #
# Usage # Usage
...@@ -2271,7 +2293,9 @@ Options for coverage, profiling etc ...@@ -2271,7 +2293,9 @@ Options for coverage, profiling etc
gcov FIXME gcov FIXME
gprof FIXME gprof FIXME
valgrind FIXME valgrind[=exe] Run the "mysqltest" executable as well as the "mysqld"
server using valgrind, optionally specifying the
executable path/name
valgrind-all FIXME valgrind-all FIXME
valgrind-options=ARGS Extra options to give valgrind valgrind-options=ARGS Extra options to give valgrind
......
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