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

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

Coverage report for $ARGV[0]

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