1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#!/usr/bin/perl
# $Id: gsum2html.pl 2657 2005-01-17 04:37:20Z renierm $
# (C) Copyright IBM Corp. 2004
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
# file and program are licensed under a BSD style license. See
# the Copying file included with the OpenHPI distribution for
# full licensing terms.
# Authors:
# Sean Dague <http://dague.net/sean>
use strict;
use HTML::Entities;
foreach my $file (@ARGV) {
# my $outfile = $file . ".html";
open(IN,"$file");
my @lines = <IN>;
close(IN);
my $html = make_html_head($file);
$html .= make_html_body(@lines);
$html .= make_html_tail();
if(scalar(@lines) > 5) {
print $html;
}
# open(OUT,">$outfile");
# print OUT $html;
# close(OUT);
}
sub make_html_head {
my $title = shift;
$title =~ s/.*\/(.*)\.summary$/$1/;
return <<END;
<html>
<head><title>GCOV Report for $title</title>
<link rel="stylesheet" href="/openhpi.css" type="text/css">
</head>
<body>
<div id="banner"><div><h1>The OpenHPI Project</h1><small>Open Hardware Platform Interface</small></div></div>
<table>
<tr>
<!--#include virtual="/sidebar.html" -->
<td id="maincolumn"><div class="mainsegment">
<h3>GCOV Summary for $title</h3>
<div>
END
}
sub make_html_tail {
return <<END;
</table></div>
</div></td></tr></table>
</body>
</html>
END
}
sub set_status {
my $exec = shift;
if($exec eq "-") {
return "na";
} elsif($exec eq "#####") {
return "notexec";
} elsif($exec < 10) {
return "low";
} else {
return "good";
}
}
sub make_html_body {
my @lines = @_;
my $html;
my $count = 0;
foreach my $line (@lines) {
if ($line =~ /^No/) {
$html .= "<tr class='na'><td>$line</td></tr>\n";
if (($count%4) == 3) {
# close the last table
$html .= "</table>\n";
}
if ($line =~ /^No branches/) { $count = $count + 1; }
$count = $count + 1;
} elsif ($line =~ /(\d+\.\d{2})%/) {
my $per = $1;
my $status = "bad";
my $boundary;
if ($line =~ /(in function )(.+)$/) {
$boundary .= "<h4 class='function'>$2</h4>\n<table class='report'>\n";
} elsif ($line =~ /(in file )(.+)$/) {
$boundary .= "<h4 class='file'>$2</h4>\n<table class='report'>\n"
}
$line =~ s/$1$2//;
if (($count%4) == 0) {
$html .= $boundary;
}
if($per >= 100) {
$status = "great";
} elsif($per > 80) {
$status = "good";
} elsif($per > 50) {
$status = "ok";
}
$html .= "<tr class='$status'><td>$line</td></tr>\n";
if (($count%4) == 3) {
# close the last table
$html .= "</table>\n";
}
$count = $count + 1;
}
}
return $html;
}
|