Commit 9573707f authored by Ingo Struewing's avatar Ingo Struewing

Bug#40446 - mysql-test-run --gcov is broken

Some variable values were missing and perl constructs failed.

Initialized the variables and refactored the gcov functions.


.bzrignore:
  Bug#40446 - mysql-test-run --gcov is broken
  Added gcov log files.
mysql-test/lib/mtr_gcov.pl:
  Bug#40446 - mysql-test-run --gcov is broken
  Refactored the gcov functions.
mysql-test/mysql-test-run.pl:
  Bug#40446 - mysql-test-run --gcov is broken
  Initialized gcov variables.
  Added usage information.
parent 4ea27a3c
...@@ -1295,6 +1295,8 @@ mysql-test/linux_sys_vars.inc ...@@ -1295,6 +1295,8 @@ mysql-test/linux_sys_vars.inc
mysql-test/load_sysvars.inc mysql-test/load_sysvars.inc
mysql-test/mtr mysql-test/mtr
mysql-test/mysql-test-run mysql-test/mysql-test-run
mysql-test/mysql-test-gcov.err
mysql-test/mysql-test-gcov.msg
mysql-test/mysql-test-run-shell mysql-test/mysql-test-run-shell
mysql-test/mysql-test-run.log mysql-test/mysql-test-run.log
mysql-test/mysql_test_run_new mysql-test/mysql_test_run_new
......
...@@ -22,40 +22,46 @@ use strict; ...@@ -22,40 +22,46 @@ use strict;
sub gcov_prepare ($) { sub gcov_prepare ($) {
my ($dir)= @_; my ($dir)= @_;
print "Purging gcov information from '$dir'...\n";
`find $dir -name \*.gcov \ system("find $dir -name \*.gcov -o -name \*.da"
-or -name \*.da | xargs rm`; . " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
} }
my @mysqld_src_dirs= #
( # Collect gcov statistics.
"strings", # Arguments:
"mysys", # $dir basedir, normally source directory
"include", # $gcov gcov utility program [path] name
"extra", # $gcov_msg message file name
"regex", # $gcov_err error file name
"isam", #
"merge",
"myisam",
"myisammrg",
"heap",
"sql",
);
sub gcov_collect ($$$) { sub gcov_collect ($$$) {
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_; my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
# Get current directory to return to later.
my $start_dir= cwd(); my $start_dir= cwd();
print "Collecting source coverage info...\n"; print "Collecting source coverage info using '$gcov'...\n";
-f $gcov_msg and unlink($gcov_msg); -f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg");
-f $gcov_err and unlink($gcov_err); -f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err");
foreach my $d ( @mysqld_src_dirs )
{ my @dirs= `find "$dir" -type d -print | sort`;
chdir("$dir/$d"); #print "List of directories:\n@dirs\n";
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
{ foreach my $d ( @dirs ) {
`$gcov $f 2>>$gcov_err >>$gcov_msg`; my $dir_reported= 0;
chomp($d);
chdir($d) or next;
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) {
$f =~ /(.*)\.[ch]c?/;
-f "$1.gcno" or next;
if (!$dir_reported) {
print "Collecting in '$d'...\n";
$dir_reported= 1;
}
system("$gcov $f 2>>$start_dir/$gcov_err >>$start_dir/$gcov_msg");
} }
chdir($start_dir); chdir($start_dir);
} }
......
...@@ -163,8 +163,9 @@ our $opt_force; ...@@ -163,8 +163,9 @@ our $opt_force;
our $opt_mem= $ENV{'MTR_MEM'}; our $opt_mem= $ENV{'MTR_MEM'};
our $opt_gcov; our $opt_gcov;
our $opt_gcov_err; our $opt_gcov_exe= "gcov";
our $opt_gcov_msg; our $opt_gcov_err= "mysql-test-gcov.msg";
our $opt_gcov_msg= "mysql-test-gcov.err";
our $glob_debugger= 0; our $glob_debugger= 0;
our $opt_gdb; our $opt_gdb;
...@@ -396,7 +397,7 @@ sub main { ...@@ -396,7 +397,7 @@ sub main {
mtr_print_line(); mtr_print_line();
if ( $opt_gcov ) { if ( $opt_gcov ) {
gcov_collect($basedir, $opt_gcov, gcov_collect($basedir, $opt_gcov_exe,
$opt_gcov_msg, $opt_gcov_err); $opt_gcov_msg, $opt_gcov_err);
} }
...@@ -5057,6 +5058,8 @@ Misc options ...@@ -5057,6 +5058,8 @@ Misc options
to turn off. to turn off.
sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time
gcov Collect coverage information after the test.
The result is a gcov file per source and header file.
HERE HERE
exit(1); exit(1);
......
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