regression-logs.pl 6.4 KB

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