| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | #~ Copyright 2003, Rene Rivera. |
|---|
| 4 | #~ Use, modification and distribution are subject to the Boost Software |
|---|
| 5 | #~ License Version 1.0. (See accompanying file LICENSE_1_0.txt or |
|---|
| 6 | #~ http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 7 | |
|---|
| 8 | use FileHandle; |
|---|
| 9 | use Time::Local; |
|---|
| 10 | |
|---|
| 11 | # Get the whle percent value |
|---|
| 12 | # |
|---|
| 13 | sub percent_value |
|---|
| 14 | { |
|---|
| 15 | my ($count,$total) = @_; |
|---|
| 16 | my $percent = int (($count/$total)*100+0.5); |
|---|
| 17 | if ($count > 0 && $percent == 0) { $percent = 1; } |
|---|
| 18 | if ($count < $total && $percent == 100) { $percent = 99; } |
|---|
| 19 | return $percent; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | # Generate item html for the pass column. |
|---|
| 23 | # |
|---|
| 24 | sub result_info_pass |
|---|
| 25 | { |
|---|
| 26 | my ($color,$pass,$warn,$fail,$missing) = @_; |
|---|
| 27 | my $percent = 100-percent_value($fail+$missing,$pass+$warn+$fail+$missing); |
|---|
| 28 | return "<font color=\"$color\"><font size=\"+1\">$percent%</font><br>($warn warnings)</font>"; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | # Generate item html for the fail column. |
|---|
| 32 | # |
|---|
| 33 | sub result_info_fail |
|---|
| 34 | { |
|---|
| 35 | my ($color,$pass,$warn,$fail,$missing) = @_; |
|---|
| 36 | my $percent = percent_value($fail+$missing,$pass+$warn+$fail+$missing); |
|---|
| 37 | return "<font color=\"$color\"><font size=\"+1\">$percent%</font><br>($fail)</font>"; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | # Generate an age highlighted run date string. |
|---|
| 41 | # Use as: data_info(run-date-html) |
|---|
| 42 | # |
|---|
| 43 | sub date_info |
|---|
| 44 | { |
|---|
| 45 | my %m = ('January',0,'February',1,'March',2,'April',3,'May',4,'June',5, |
|---|
| 46 | 'July',6,'August',7,'September',8,'October',9,'November',10,'December',11); |
|---|
| 47 | my @d = split(/ |:/,$_[0]); |
|---|
| 48 | my ($hour,$min,$sec,$day,$month,$year) = ($d[0],$d[1],$d[2],$d[4],$m{$d[5]},$d[6]); |
|---|
| 49 | #print "<!-- $hour.$min.$sec.$day.$month.$year -->\n"; |
|---|
| 50 | my $test_t = timegm($sec,$min,$hour,$day,$month,$year); |
|---|
| 51 | my $age = time-$test_t; |
|---|
| 52 | my $age_days = $age/(60*60*24); |
|---|
| 53 | #print "<!-- $age_days days old -->\n"; |
|---|
| 54 | my $age_html = "<font>"; |
|---|
| 55 | if ($age_days <= 2) { } |
|---|
| 56 | elsif ($age_days <= 14) { $age_html = "<font color=\"#FF9900\">"; } |
|---|
| 57 | else { $age_html = "<font color=\"#FF0000\">"; } |
|---|
| 58 | return $age_html.$_[0]."</font>"; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | # Generate an age string based on the run date. |
|---|
| 62 | # Use as: age_info(run-date-html) |
|---|
| 63 | # |
|---|
| 64 | sub age_info |
|---|
| 65 | { |
|---|
| 66 | my %m = ('January',0,'February',1,'March',2,'April',3,'May',4,'June',5, |
|---|
| 67 | 'July',6,'August',7,'September',8,'October',9,'November',10,'December',11); |
|---|
| 68 | my @d = split(/ |:/,$_[0]); |
|---|
| 69 | my ($hour,$min,$sec,$day,$month,$year) = ($d[0],$d[1],$d[2],$d[4],$m{$d[5]},$d[6]); |
|---|
| 70 | #print "<!-- $hour.$min.$sec.$day.$month.$year -->\n"; |
|---|
| 71 | my $test_t = timegm($sec,$min,$hour,$day,$month,$year); |
|---|
| 72 | my $age = time-$test_t; |
|---|
| 73 | my $age_days = $age/(60*60*24); |
|---|
| 74 | #print "<!-- $age_days days old -->\n"; |
|---|
| 75 | my $age_html = "<font>"; |
|---|
| 76 | if ($age_days <= 2) { } |
|---|
| 77 | elsif ($age_days <= 14) { $age_html = "<font color=\"#FF9900\">"; } |
|---|
| 78 | else { $age_html = "<font color=\"#FF0000\">"; } |
|---|
| 79 | if ($age_days <= 1) { $age_html = $age_html."today"; } |
|---|
| 80 | elsif ($age_days <= 2) { $age_html = $age_html."yesterday"; } |
|---|
| 81 | elsif ($age_days < 14) { my $days = int $age_days; $age_html = $age_html.$days." days"; } |
|---|
| 82 | elsif ($age_days < 7*8) { my $weeks = int $age_days/7; $age_html = $age_html.$weeks." weeks"; } |
|---|
| 83 | else { my $months = int $age_days/28; $age_html = $age_html.$months." months"; } |
|---|
| 84 | return $age_html."</font>"; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | #~ foreach my $k (sort keys %ENV) |
|---|
| 88 | #~ { |
|---|
| 89 | #~ print "<!-- $k = $ENV{$k} -->\n"; |
|---|
| 90 | #~ } |
|---|
| 91 | my $logdir = "$ENV{PWD}"; |
|---|
| 92 | #~ my $logdir = "C:\\CVSROOTs\\Boost\\boost\\status"; |
|---|
| 93 | opendir LOGS, "$logdir"; |
|---|
| 94 | my @logs = grep /.*links[^.]*\.html$/, readdir LOGS; |
|---|
| 95 | closedir LOGS; |
|---|
| 96 | my @bgcolor = ( "bgcolor=\"#EEEEFF\"", "" ); |
|---|
| 97 | my $row = 0; |
|---|
| 98 | print "<table>\n"; |
|---|
| 99 | print "<tr>\n", |
|---|
| 100 | "<th align=\"left\" bgcolor=\"#DDDDDD\">Platform</th>\n", |
|---|
| 101 | "<th align=\"left\" bgcolor=\"#DDDDDD\">Run Date</th>\n", |
|---|
| 102 | "<th align=\"left\" bgcolor=\"#DDDDDD\">Age</th>\n", |
|---|
| 103 | "<th align=\"left\" bgcolor=\"#DDDDDD\">Compilers</th>\n", |
|---|
| 104 | "<th align=\"left\" bgcolor=\"#DDDDDD\">Pass</th>\n", |
|---|
| 105 | "<th align=\"left\" bgcolor=\"#DDDDDD\">Fail</th>\n", |
|---|
| 106 | "</tr>\n"; |
|---|
| 107 | foreach $l (sort { lc($a) cmp lc($b) } @logs) |
|---|
| 108 | { |
|---|
| 109 | my $log = $l; |
|---|
| 110 | $log =~ s/-links//s; |
|---|
| 111 | my ($spec) = ($log =~ /cs-([^\.]+)/); |
|---|
| 112 | my $fh = new FileHandle; |
|---|
| 113 | if ($fh->open("<$logdir/$log")) |
|---|
| 114 | { |
|---|
| 115 | my $content = join('',$fh->getlines()); |
|---|
| 116 | $fh->close; |
|---|
| 117 | my ($status) = ($content =~ /(<h1>Compiler(.(?!<\/td>))+.)/si); |
|---|
| 118 | my ($platform) = ($status =~ /Status: ([^<]+)/si); |
|---|
| 119 | my ($run_date) = ($status =~ /Date:<\/b> ([^<]+)/si); |
|---|
| 120 | $run_date =~ s/, /<br>/g; |
|---|
| 121 | my ($compilers) = ($content =~ /Test Type<\/a><\/t[dh]>((.(?!<\/tr>))+.)/si); |
|---|
| 122 | if ($compilers eq "") { next; } |
|---|
| 123 | $compilers =~ s/-<br>//g; |
|---|
| 124 | $compilers =~ s/<\/td>//g; |
|---|
| 125 | my @compiler = ($compilers =~ /<td>(.*)$/gim); |
|---|
| 126 | my $count = @compiler; |
|---|
| 127 | my @results = ($content =~ /(>Pass<|>Warn<|>Fail<|>Missing<)/gi); |
|---|
| 128 | my $test_count = (scalar @results)/$count; |
|---|
| 129 | my @pass = map { 0 } (1..$count); |
|---|
| 130 | my @warn = map { 0 } (1..$count); |
|---|
| 131 | my @fail = map { 0 } (1..$count); |
|---|
| 132 | my @missing = map { 0 } (1..$count); |
|---|
| 133 | my @total = map { 0 } (1..$count); |
|---|
| 134 | #~ print "<!-- ", |
|---|
| 135 | #~ "pass = ",join(',',@pass)," ", |
|---|
| 136 | #~ "warn = ",join(',',@warn)," ", |
|---|
| 137 | #~ "fail = ",join(',',@fail)," ", |
|---|
| 138 | #~ "missing = ",join(',',@missing)," ", |
|---|
| 139 | #~ "total = ",join(',',@total)," ", |
|---|
| 140 | #~ " -->\n"; |
|---|
| 141 | for my $t (1..$test_count) |
|---|
| 142 | { |
|---|
| 143 | my $r0 = (($t-1)*$count); |
|---|
| 144 | my $r1 = (($t-1)*$count+$count-1); |
|---|
| 145 | my @r = @results[(($t-1)*$count)..(($t-1)*$count+$count-1)]; |
|---|
| 146 | #~ print "<!-- ", |
|---|
| 147 | #~ "result = ",join(',',@r)," ", |
|---|
| 148 | #~ "range = ",$r0,"..",$r1," (",(scalar @results),")", |
|---|
| 149 | #~ " -->\n"; |
|---|
| 150 | for my $c (1..$count) |
|---|
| 151 | { |
|---|
| 152 | if ($r[$c-1] =~ /Pass/i) { ++$pass[$c-1]; } |
|---|
| 153 | elsif ($r[$c-1] =~ /Warn/i) { ++$warn[$c-1]; } |
|---|
| 154 | elsif ($r[$c-1] =~ /Fail/i) { ++$fail[$c-1]; } |
|---|
| 155 | elsif ($r[$c-1] =~ /Missing/i) { ++$missing[$c-1]; } |
|---|
| 156 | ++$total[$c-1]; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | #~ print "<!-- ", |
|---|
| 160 | #~ "pass = ",join(',',@pass)," ", |
|---|
| 161 | #~ "warn = ",join(',',@warn)," ", |
|---|
| 162 | #~ "fail = ",join(',',@fail)," ", |
|---|
| 163 | #~ "missing = ",join(',',@missing)," ", |
|---|
| 164 | #~ "total = ",join(',',@total)," ", |
|---|
| 165 | #~ " -->\n"; |
|---|
| 166 | for my $comp (1..(scalar @compiler)) |
|---|
| 167 | { |
|---|
| 168 | my @lines = split(/<br>/,$compiler[$comp-1]); |
|---|
| 169 | if (@lines > 2) { $compiler[$comp-1] = join(' ',@lines[0..(scalar @lines)-2])."<br>".$lines[(scalar @lines)-1]; } |
|---|
| 170 | } |
|---|
| 171 | print |
|---|
| 172 | "<tr>\n", |
|---|
| 173 | "<td rowspan=\"$count\" valign=\"top\"><font size=\"+1\">$platform</font><br>(<a href=\"./$log\">$spec</a>)</td>\n", |
|---|
| 174 | "<td rowspan=\"$count\" valign=\"top\">",$run_date,"</td>\n", |
|---|
| 175 | "<td rowspan=\"$count\" valign=\"top\">",age_info($run_date),"</td>\n", |
|---|
| 176 | "<td valign=\"top\" ",$bgcolor[$row],">",$compiler[0],"</td>\n", |
|---|
| 177 | "<td valign=\"top\" ",$bgcolor[$row],">",result_info_pass("#000000",$pass[0],$warn[0],$fail[0],$missing[0]),"</td>\n", |
|---|
| 178 | "<td valign=\"top\" ",$bgcolor[$row],">",result_info_fail("#FF0000",$pass[0],$warn[0],$fail[0],$missing[0]),"</td>\n", |
|---|
| 179 | "</tr>\n"; |
|---|
| 180 | $row = ($row+1)%2; |
|---|
| 181 | foreach my $c (1..($count-1)) |
|---|
| 182 | { |
|---|
| 183 | print |
|---|
| 184 | "<tr>\n", |
|---|
| 185 | "<td valign=\"top\" ",$bgcolor[$row],">",$compiler[$c],"</td>\n", |
|---|
| 186 | "<td valign=\"top\" ",$bgcolor[$row],">",result_info_pass("#000000",$pass[$c],$warn[$c],$fail[$c],$missing[$c]),"</td>\n", |
|---|
| 187 | "<td valign=\"top\" ",$bgcolor[$row],">",result_info_fail("#FF0000",$pass[$c],$warn[$c],$fail[$c],$missing[$c]),"</td>\n", |
|---|
| 188 | "</tr>\n"; |
|---|
| 189 | $row = ($row+1)%2; |
|---|
| 190 | } |
|---|
| 191 | print |
|---|
| 192 | "<tr>\n", |
|---|
| 193 | "<td colspan=\"7\"><hr size=\"1\" noshade></td>\n", |
|---|
| 194 | "</tr>\n"; |
|---|
| 195 | } |
|---|
| 196 | } |
|---|
| 197 | print "</table>\n"; |
|---|