Blame common/coverage/coverage-report-entry.pl

Packit 8ff292
#!/usr/bin/perl
Packit 8ff292
#
Packit 8ff292
# Copyright (C) 2006 Daniel Berrange
Packit 8ff292
#
Packit 8ff292
# This program is free software; you can redistribute it and/or modify
Packit 8ff292
# it under the terms of the GNU General Public License as published by
Packit 8ff292
# the Free Software Foundation; either version 2 of the License, or
Packit 8ff292
# (at your option) any later version.
Packit 8ff292
#
Packit 8ff292
# This program is distributed in the hope that it will be useful,
Packit 8ff292
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8ff292
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8ff292
# GNU General Public License for more details.
Packit 8ff292
#
Packit 8ff292
# You should have received a copy of the GNU General Public License
Packit 8ff292
# along with this program; if not, write to the Free Software
Packit 8ff292
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Packit 8ff292
Packit 8ff292
Packit 8ff292
print <
Packit 8ff292
<html>
Packit 8ff292
<head>
Packit 8ff292
<title>Coverage report for $ARGV[0]</title>
Packit 8ff292
<style type="text/css">
Packit 8ff292
          span.perfect {
Packit 8ff292
            background: rgb(0,255,0);
Packit 8ff292
          }
Packit 8ff292
          span.terrible {
Packit 8ff292
            background: rgb(255,0,0);
Packit 8ff292
          }
Packit 8ff292
</style>
Packit 8ff292
</head>
Packit 8ff292
<body>
Packit 8ff292

Coverage report for $ARGV[0]

Packit 8ff292
Packit 8ff292
Packit 8ff292
EOF
Packit 8ff292
Packit 8ff292
Packit 8ff292
while (<>) {
Packit 8ff292
    s/&/&/g;
Packit 8ff292
    s/</</g;
Packit 8ff292
    s/>/>/g;
Packit 8ff292
Packit 8ff292
    if (/^\s*function (\S+) called (\d+) returned \d+% blocks executed \d+%/) {
Packit 8ff292
	my $class = $2 > 0 ? "perfect" : "terrible";
Packit 8ff292
	$_ = "$_";
Packit 8ff292
    } elsif (/^\s*branch\s+\d+\s+taken\s+(\d+)%\s+.*$/) {
Packit 8ff292
	my $class = $1 > 0 ? "perfect" : "terrible";
Packit 8ff292
	$_ = "$_";
Packit 8ff292
    } elsif (/^\s*branch\s+\d+\s+never executed.*$/) {
Packit 8ff292
	my $class = "terrible";
Packit 8ff292
	$_ = "$_";
Packit 8ff292
    } elsif (/^\s*call\s+\d+\s+never executed.*$/) {
Packit 8ff292
	my $class = "terrible";
Packit 8ff292
	$_ = "$_";
Packit 8ff292
    } elsif (/^\s*call\s+\d+\s+returned\s+(\d+)%.*$/) {
Packit 8ff292
	my $class = $1 > 0 ? "perfect" : "terrible";
Packit 8ff292
	$_ = "$_";
Packit 8ff292
    }
Packit 8ff292
Packit 8ff292
    print;
Packit 8ff292
}
Packit 8ff292
Packit 8ff292
print <
Packit 8ff292
Packit 8ff292
</body>
Packit 8ff292
</html>
Packit 8ff292
EOF