summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Struewing <ingo.struewing@sun.com>2009-02-27 12:20:53 +0100
committerIngo Struewing <ingo.struewing@sun.com>2009-02-27 12:20:53 +0100
commit9573707ffa3c52cfa2a552c03b2b7d884940e979 (patch)
tree7461b1189623c29f6a7385ff1e6cbaba2d920527
parent4ea27a3cdfc4d218cb54a07a8d769a58528e0e2e (diff)
downloadmariadb-git-9573707ffa3c52cfa2a552c03b2b7d884940e979.tar.gz
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.
-rw-r--r--.bzrignore2
-rw-r--r--mysql-test/lib/mtr_gcov.pl58
-rwxr-xr-xmysql-test/mysql-test-run.pl9
3 files changed, 40 insertions, 29 deletions
diff --git a/.bzrignore b/.bzrignore
index 01ef6f2ffef..fad758b54b8 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1295,6 +1295,8 @@ mysql-test/linux_sys_vars.inc
mysql-test/load_sysvars.inc
mysql-test/mtr
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.log
mysql-test/mysql_test_run_new
diff --git a/mysql-test/lib/mtr_gcov.pl b/mysql-test/lib/mtr_gcov.pl
index 5049fdd6063..f531889b08d 100644
--- a/mysql-test/lib/mtr_gcov.pl
+++ b/mysql-test/lib/mtr_gcov.pl
@@ -22,40 +22,46 @@ use strict;
sub gcov_prepare ($) {
my ($dir)= @_;
+ print "Purging gcov information from '$dir'...\n";
- `find $dir -name \*.gcov \
- -or -name \*.da | xargs rm`;
+ system("find $dir -name \*.gcov -o -name \*.da"
+ . " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
}
-my @mysqld_src_dirs=
- (
- "strings",
- "mysys",
- "include",
- "extra",
- "regex",
- "isam",
- "merge",
- "myisam",
- "myisammrg",
- "heap",
- "sql",
- );
-
+#
+# Collect gcov statistics.
+# Arguments:
+# $dir basedir, normally source directory
+# $gcov gcov utility program [path] name
+# $gcov_msg message file name
+# $gcov_err error file name
+#
sub gcov_collect ($$$) {
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
+ # Get current directory to return to later.
my $start_dir= cwd();
- print "Collecting source coverage info...\n";
- -f $gcov_msg and unlink($gcov_msg);
- -f $gcov_err and unlink($gcov_err);
- foreach my $d ( @mysqld_src_dirs )
- {
- chdir("$dir/$d");
- foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
- {
- `$gcov $f 2>>$gcov_err >>$gcov_msg`;
+ print "Collecting source coverage info using '$gcov'...\n";
+ -f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg");
+ -f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err");
+
+ my @dirs= `find "$dir" -type d -print | sort`;
+ #print "List of directories:\n@dirs\n";
+
+ foreach my $d ( @dirs ) {
+ 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);
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 50617428d0f..b0b044b67f4 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -163,8 +163,9 @@ our $opt_force;
our $opt_mem= $ENV{'MTR_MEM'};
our $opt_gcov;
-our $opt_gcov_err;
-our $opt_gcov_msg;
+our $opt_gcov_exe= "gcov";
+our $opt_gcov_err= "mysql-test-gcov.msg";
+our $opt_gcov_msg= "mysql-test-gcov.err";
our $glob_debugger= 0;
our $opt_gdb;
@@ -396,7 +397,7 @@ sub main {
mtr_print_line();
if ( $opt_gcov ) {
- gcov_collect($basedir, $opt_gcov,
+ gcov_collect($basedir, $opt_gcov_exe,
$opt_gcov_msg, $opt_gcov_err);
}
@@ -5057,6 +5058,8 @@ Misc options
to turn off.
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
exit(1);