regression-logs.pl 7.8 KB

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