Bug #69110 MTR does not allow valgrind to be run with custom tool
Submitted: 1 May 2013 0:25
Reporter: Sveta Smirnova Email Updates:
Status: Verified Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.6.12 OS:Any
Assigned to: CPU Architecture:Any
Tags: 5.6.12

[1 May 2013 0:25] Sveta Smirnova
Description:
While tried to verify bug #69075 found that MTR can not be run with option --valgrind-option=--tool=massif due error:

Server log is:
valgrind: Bad option: --leak-check=yes
valgrind: Use --help for more information or consult the user manual.

This happened, because MTR added this option regardless if I specified my own.

How to repeat:
See description.

Suggested fix:
Very easy fix can be:

=== modified file 'mysql-test/mysql-test-run.pl'
--- mysql-test/mysql-test-run.pl	2013-04-02 09:43:08 +0000
+++ mysql-test/mysql-test-run.pl	2013-05-01 00:23:52 +0000
@@ -6205,8 +6205,11 @@
   }
   else
   {
-    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
-    mtr_add_arg($args, "--leak-check=yes");
+    if (!@valgrind_args)
+    {
+      mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
+      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";

But, this, probably, is not very desirable, because one can want to have both custom options and options for default tool.
[1 May 2013 0:36] Sveta Smirnova
Probably better fix:

=== modified file 'mysql-test/mysql-test-run.pl'
--- mysql-test/mysql-test-run.pl	2013-04-02 09:43:08 +0000
+++ mysql-test/mysql-test-run.pl	2013-05-01 00:34:31 +0000
@@ -6205,8 +6205,11 @@
   }
   else
   {
-    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
-    mtr_add_arg($args, "--leak-check=yes");
+    if (!@valgrind_args || !(join(",", @valgrind_args)=~ m/--tool=/))
+    {
+      mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
+      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";