~ubuntu-branches/ubuntu/feisty/gst-plugins-good0.10/feisty-security

« back to all changes in this revision

Viewing changes to common/coverage/coverage-report.pl

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-15 02:58:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060815025826-h1sa4q0uxwqgzwki
Tags: 0.10.4-0ubuntu1
* Sync with Debian (pkg-gstreamer SVN, rev 470):
  + debian/rules,
    debian/control.in:
    - Add a -dbg package again

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# Copyright (C) 2006 Daniel Berrange
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
use warnings;
 
20
use strict;
 
21
 
 
22
my %coverage = ( functions => {}, files => {} );
 
23
 
 
24
my %filemap;
 
25
 
 
26
my $type;
 
27
my $name;
 
28
 
 
29
my @functions;
 
30
 
 
31
while (<>) {
 
32
    if (/^Function '(.*)'\s*$/) {
 
33
        $type = "function";
 
34
        $name = $1;
 
35
        $coverage{$type}->{$name} = {};
 
36
        push @functions, $name;
 
37
    } elsif (/^File '(.*?)'\s*$/) {
 
38
        $type = "file";
 
39
        $name = $1;
 
40
        $coverage{$type}->{$name} = {};
 
41
        
 
42
        foreach my $func (@functions) {
 
43
            $coverage{"function"}->{$func}->{file} = $name;
 
44
        }
 
45
        @functions = ();
 
46
    } elsif (/^Lines executed:(.*)%\s*of\s*(\d+)\s*$/) {
 
47
        $coverage{$type}->{$name}->{lines} = $2;
 
48
        $coverage{$type}->{$name}->{linesCoverage} = $1;
 
49
    } elsif (/^Branches executed:(.*)%\s*of\s*(\d+)\s*$/) {
 
50
        $coverage{$type}->{$name}->{branches} = $2;
 
51
        $coverage{$type}->{$name}->{branchesCoverage} = $1;
 
52
    } elsif (/^Taken at least once:(.*)%\s*of\s*(\d+)\s*$/) {
 
53
        $coverage{$type}->{$name}->{conds} = $2;
 
54
        $coverage{$type}->{$name}->{condsCoverage} = $1;
 
55
    } elsif (/^Calls executed:(.*)%\s*of\s*(\d+)\s*$/) {
 
56
        $coverage{$type}->{$name}->{calls} = $2;
 
57
        $coverage{$type}->{$name}->{callsCoverage} = $1;
 
58
    } elsif (/^No branches$/) {
 
59
        $coverage{$type}->{$name}->{branches} = 0;
 
60
        $coverage{$type}->{$name}->{branchesCoverage} = "100.00";
 
61
        $coverage{$type}->{$name}->{conds} = 0;
 
62
        $coverage{$type}->{$name}->{condsCoverage} = "100.00";
 
63
    } elsif (/^No calls$/) {
 
64
        $coverage{$type}->{$name}->{calls} = 0;
 
65
        $coverage{$type}->{$name}->{callsCoverage} = "100.00";
 
66
    } elsif (/^\s*(.*):creating '(.*)'\s*$/) {
 
67
        $filemap{$1} = $2;
 
68
    } elsif (/^\s*$/) {
 
69
        # nada
 
70
    } else {
 
71
        warn "Shit [$_]\n";
 
72
    }
 
73
}
 
74
 
 
75
my %summary;
 
76
foreach my $type ("function", "file") {
 
77
    $summary{$type} = {};
 
78
    foreach my $m ("lines", "branches", "conds", "calls") {
 
79
        my $totalGot = 0;
 
80
        my $totalMiss = 0;
 
81
        my $count = 0;
 
82
        foreach my $func (keys %{$coverage{function}}) {
 
83
            $count++;
 
84
            my $got = $coverage{function}->{$func}->{$m};
 
85
            $totalGot += $got;
 
86
            my $miss = $got * $coverage{function}->{$func}->{$m ."Coverage"} / 100;
 
87
            $totalMiss += $miss;
 
88
        }
 
89
        $summary{$type}->{$m} = sprintf("%d", $totalGot);
 
90
        $summary{$type}->{$m . "Coverage"} = sprintf("%.2f", $totalMiss / $totalGot * 100);
 
91
    }
 
92
}
 
93
 
 
94
 
 
95
 
 
96
print "<coverage>\n";
 
97
 
 
98
foreach my $type ("function", "file") {
 
99
    printf "<%ss>\n", $type;
 
100
    foreach my $name (sort { $a cmp $b } keys %{$coverage{$type}}) {
 
101
        my $rec = $coverage{$type}->{$name};
 
102
        printf "  <entry name=\"%s\" details=\"%s\">\n", $name, ($type eq "file" ? $filemap{$name} : $filemap{$rec->{file}});
 
103
        printf "    <lines count=\"%s\" coverage=\"%s\"/>\n", $rec->{lines}, $rec->{linesCoverage};
 
104
        if (exists $rec->{branches}) {
 
105
            printf "    <branches count=\"%s\" coverage=\"%s\"/>\n", $rec->{branches}, $rec->{branchesCoverage};
 
106
        }
 
107
        if (exists $rec->{conds}) {
 
108
            printf "    <conditions count=\"%s\" coverage=\"%s\"/>\n", $rec->{conds}, $rec->{condsCoverage};
 
109
        }
 
110
        if (exists $rec->{calls}) {
 
111
            printf "    <calls count=\"%s\" coverage=\"%s\"/>\n", $rec->{calls}, $rec->{callsCoverage};
 
112
        }
 
113
        print  "  </entry>\n";
 
114
    }
 
115
    
 
116
    printf "  <summary>\n";
 
117
    printf "    <lines count=\"%s\" coverage=\"%s\"/>\n", $summary{$type}->{lines}, $summary{$type}->{linesCoverage};
 
118
    printf "    <branches count=\"%s\" coverage=\"%s\"/>\n", $summary{$type}->{branches}, $summary{$type}->{branchesCoverage};
 
119
    printf "    <conditions count=\"%s\" coverage=\"%s\"/>\n", $summary{$type}->{conds}, $summary{$type}->{condsCoverage};
 
120
    printf "    <calls count=\"%s\" coverage=\"%s\"/>\n", $summary{$type}->{calls}, $summary{$type}->{callsCoverage};
 
121
    printf  "  </summary>\n";
 
122
    printf "</%ss>\n", $type;
 
123
}
 
124
 
 
125
print "</coverage>\n";