regression-logs.pl 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/usr/bin/perl
  2. # Copyright (C) 2003, Rene Rivera. Permission to copy, use, modify, sell and
  3. # distribute this software is granted provided this copyright notice appears in
  4. # all copies. This software is provided "as is" without express or implied
  5. # warranty, and with no claim as to its suitability for any purpose.
  6. # This the cgi script that generates the live summary page for the regression
  7. # logs located at http://boost.sourceforge.net/regression-logs
  8. #
  9. # Per SourceForge requirements this script needs to be located in the cgi-bin
  10. # directory (/home/groups/b/bo/boost/cgi-bin) for it to be recognized as a script.
  11. #
  12. # This script only generates the summary table of the test. It doesn not generate
  13. # the entire HTML page. For the complete page this script is called, with SSI, from
  14. # the "index.shtml" page which contains the wrapping page. This makes it easier to
  15. # mainting the table independently of the rest of the page.
  16. use FileHandle;
  17. use Time::Local;
  18. print "Content-type: text/html\r\n\r\n";
  19. # Generate an individual result item, Pass, Warn, and Fail columns.
  20. # Use as: result_info(html-color,result-count,total-count)
  21. #
  22. sub result_info
  23. {
  24. my ($color,$result,$total) = @_;
  25. my $percent = int (($result/$total)*100+0.5);
  26. return "<font color=\"$color\"><font size=\"+1\">$percent%</font><br>($result)</font>";
  27. }
  28. # Generate an age highlighted run date string.
  29. # Use as: data_info(run-date-html)
  30. #
  31. sub date_info
  32. {
  33. my %m = ('January',0,'February',1,'March',2,'April',3,'May',4,'June',5,
  34. 'July',6,'August',7,'September',8,'October',9,'November',10,'December',11);
  35. my @d = split(/ |:/,$_[0]);
  36. my ($hour,$min,$sec,$day,$month,$year) = ($d[0],$d[1],$d[2],$d[4],$m{$d[5]},$d[6]);
  37. #print "<!-- $hour.$min.$sec.$day.$month.$year -->\n";
  38. my $test_t = timegm($sec,$min,$hour,$day,$month,$year);
  39. my $age = time-$test_t;
  40. my $age_days = $age/(60*60*24);
  41. #print "<!-- $age_days days old -->\n";
  42. my $age = "<font>";
  43. if ($age_days <= 2) { }
  44. elsif ($age_days <= 14) { $age = "<font color=\"#FF9900\">"; }
  45. else { $age = "<font color=\"#FF0000\">"; }
  46. return $age.$_[0]."</font>";
  47. }
  48. # Generate an age string based on the run date.
  49. # Use as: age_info(run-date-html)
  50. #
  51. sub age_info
  52. {
  53. my %m = ('January',0,'February',1,'March',2,'April',3,'May',4,'June',5,
  54. 'July',6,'August',7,'September',8,'October',9,'November',10,'December',11);
  55. my @d = split(/ |:/,$_[0]);
  56. my ($hour,$min,$sec,$day,$month,$year) = ($d[0],$d[1],$d[2],$d[4],$m{$d[5]},$d[6]);
  57. #print "<!-- $hour.$min.$sec.$day.$month.$year -->\n";
  58. my $test_t = timegm($sec,$min,$hour,$day,$month,$year);
  59. my $age = time-$test_t;
  60. my $age_days = $age/(60*60*24);
  61. #print "<!-- $age_days days old -->\n";
  62. my $age = "<font>";
  63. if ($age_days <= 2) { }
  64. elsif ($age_days <= 14) { $age = "<font color=\"#FF9900\">"; }
  65. else { $age = "<font color=\"#FF0000\">"; }
  66. if ($age_days <= 1) { $age = $age."today"; }
  67. elsif ($age_days <= 2) { $age = $age."yesterday"; }
  68. elsif ($age_days < 14) { my $days = int $age_days; $age = $age.$days." days"; }
  69. elsif ($age_days < 7*8) { my $weeks = int $age_days/7; $age = $age.$weeks." weeks"; }
  70. else { my $months = int $age_days/28; $age = $age.$months." months"; }
  71. return $age."</font>";
  72. }
  73. opendir LOGS, "/home/groups/b/bo/boost/htdocs/regression-logs";
  74. my @logs = grep /.*links[^.]*\.html$/, readdir LOGS;
  75. closedir LOGS;
  76. my @bgcolor = ( "bgcolor=\"#EEEEFF\"", "" );
  77. my $row = 0;
  78. print "<table>\n";
  79. print "<tr>\n",
  80. "<th align=\"left\" bgcolor=\"#DDDDDD\">Platform</th>\n",
  81. "<th align=\"left\" bgcolor=\"#DDDDDD\">Run Date</th>\n",
  82. "<th align=\"left\" bgcolor=\"#DDDDDD\">Age</th>\n",
  83. "<th align=\"left\" bgcolor=\"#DDDDDD\">Compilers</th>\n",
  84. "<th align=\"left\" bgcolor=\"#DDDDDD\">Pass</th>\n",
  85. "<th align=\"left\" bgcolor=\"#DDDDDD\">Warn</th>\n",
  86. "<th align=\"left\" bgcolor=\"#DDDDDD\">Fail</th>\n",
  87. "</tr>\n";
  88. foreach $l (sort { lc($a) cmp lc($b) } @logs)
  89. {
  90. my $log = $l;
  91. $log =~ s/-links//s;
  92. my ($spec) = ($log =~ /cs-([^\.]+)/);
  93. my $fh = new FileHandle;
  94. if ($fh->open("</home/groups/b/bo/boost/htdocs/regression-logs/$log"))
  95. {
  96. my $content = join('',$fh->getlines());
  97. $fh->close;
  98. my ($status) = ($content =~ /(<h1>Compiler(.(?!<\/td>))+.)/si);
  99. my ($platform) = ($status =~ /Status: ([^<]+)/si);
  100. my ($run_date) = ($status =~ /Date:<\/b> ([^<]+)/si);
  101. $run_date =~ s/, /<br>/g;
  102. my ($compilers) = ($content =~ /Test Type<\/a><\/td>((.(?!<\/tr>))+.)/si);
  103. if ($compilers eq "") { next; }
  104. $compilers =~ s/-<br>//g;
  105. $compilers =~ s/<\/td>//g;
  106. my @compiler = ($compilers =~ /<td>(.*)$/gim);
  107. my $count = @compiler;
  108. my @results = ($content =~ /(>Pass<|>Warn<|>Fail<)/gi);
  109. my $test_count = (scalar @results)/$count;
  110. my @pass = map { 0 } (1..$count);
  111. my @warn = map { 0 } (1..$count);
  112. my @fail = map { 0 } (1..$count);
  113. my @total = map { 0 } (1..$count);
  114. for my $t (1..$test_count)
  115. {
  116. my @r = @results[(($t-1)*$count)..(($t-1)*$count+$count-1)];
  117. for my $c (1..$count)
  118. {
  119. if ($r[$c-1] =~ /Pass/i) { ++$pass[$c-1]; }
  120. elsif ($r[$c-1] =~ /Warn/i) { ++$warn[$c-1]; }
  121. elsif ($r[$c-1] =~ /Fail/i) { ++$fail[$c-1]; }
  122. ++$total[$c-1];
  123. }
  124. }
  125. for my $comp (1..(scalar @compiler))
  126. {
  127. my @lines = split(/<br>/,$compiler[$comp-1]);
  128. if (@lines > 2) { $compiler[$comp-1] = join(' ',@lines[0..(scalar @lines)-2])."<br>".$lines[(scalar @lines)-1]; }
  129. }
  130. print
  131. "<tr>\n",
  132. "<td rowspan=\"$count\" valign=\"top\"><font size=\"+1\">$platform</font><br>(<a href=\"../regression-logs/$log\">$spec</a>)</td>\n",
  133. "<td rowspan=\"$count\" valign=\"top\">",$run_date,"</td>\n",
  134. "<td rowspan=\"$count\" valign=\"top\">",age_info($run_date),"</td>\n",
  135. "<td valign=\"top\" ",$bgcolor[$row],">",$compiler[0],"</td>\n",
  136. "<td valign=\"top\" ",$bgcolor[$row],">",result_info("#000000",$pass[0],$total[0]),"</td>\n",
  137. "<td valign=\"top\" ",$bgcolor[$row],">",result_info("#FF9900",$warn[0],$total[0]),"</td>\n",
  138. "<td valign=\"top\" ",$bgcolor[$row],">",result_info("#FF0000",$fail[0],$total[0]),"</td>\n",
  139. "</tr>\n";
  140. $row = ($row+1)%2;
  141. foreach my $c (1..($count-1))
  142. {
  143. print
  144. "<tr>\n",
  145. "<td valign=\"top\" ",$bgcolor[$row],">",$compiler[$c],"</td>\n",
  146. "<td valign=\"top\" ",$bgcolor[$row],">",result_info("#000000",$pass[$c],$total[$c]),"</td>\n",
  147. "<td valign=\"top\" ",$bgcolor[$row],">",result_info("#FF9900",$warn[$c],$total[$c]),"</td>\n",
  148. "<td valign=\"top\" ",$bgcolor[$row],">",result_info("#FF0000",$fail[$c],$total[$c]),"</td>\n",
  149. "</tr>\n";
  150. $row = ($row+1)%2;
  151. }
  152. print
  153. "<tr>\n",
  154. "<td colspan=\"7\"><hr size=\"1\" noshade></td>\n",
  155. "</tr>\n";
  156. }
  157. }
  158. print "</table>\n";
粤ICP备19079148号