~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/lib/mtr_gcov.pl

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- cperl -*-
 
2
# Copyright (C) 2004, 2006 MySQL AB
 
3
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 2 of the License.
 
7
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
16
 
 
17
# This is a library file used by the Perl version of mysql-test-run,
 
18
# and is part of the translation of the Bourne shell script with the
 
19
# same name.
 
20
 
 
21
use strict;
 
22
 
 
23
sub gcov_prepare ($) {
 
24
  my ($dir)= @_;
 
25
  print "Purging gcov information from '$dir'...\n";
 
26
 
 
27
  system("find $dir -name \*.gcov -o -name \*.da"
 
28
             . " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
 
29
}
 
30
 
 
31
#
 
32
# Collect gcov statistics.
 
33
# Arguments:
 
34
#   $dir       basedir, normally source directory
 
35
#   $gcov      gcov utility program [path] name
 
36
#   $gcov_msg  message file name
 
37
#   $gcov_err  error file name
 
38
#
 
39
sub gcov_collect ($$$) {
 
40
  my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
 
41
 
 
42
  # Get current directory to return to later.
 
43
  my $start_dir= cwd();
 
44
 
 
45
  print "Collecting source coverage info using '$gcov'...\n";
 
46
  -f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg");
 
47
  -f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err");
 
48
 
 
49
  my @dirs= `find "$dir" -type d -print | sort`;
 
50
  #print "List of directories:\n@dirs\n";
 
51
 
 
52
  foreach my $d ( @dirs ) {
 
53
    my $dir_reported= 0;
 
54
    chomp($d);
 
55
    chdir($d) or next;
 
56
 
 
57
    foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) {
 
58
      $f =~ /(.*)\.[ch]c?/;
 
59
      -f "$1.gcno" or next;
 
60
      if (!$dir_reported) {
 
61
        print "Collecting in '$d'...\n";
 
62
        $dir_reported= 1;
 
63
      }
 
64
      system("$gcov $f 2>>$start_dir/$gcov_err >>$start_dir/$gcov_msg");
 
65
    }
 
66
    chdir($start_dir);
 
67
  }
 
68
  print "gcov info in $gcov_msg, errors in $gcov_err\n";
 
69
}
 
70
 
 
71
 
 
72
1;