[llvm-commits] CVS: llvm/test/Programs/GenerateReport.pl Makefile

Chris Lattner lattner at cs.uiuc.edu
Tue Jan 21 10:25:03 PST 2003


Changes in directory llvm/test/Programs:

GenerateReport.pl updated: 1.4 -> 1.5
Makefile updated: 1.8 -> 1.9

---
Log message:

Implement generation of HTML reports


---
Diffs of the changes:

Index: llvm/test/Programs/GenerateReport.pl
diff -u llvm/test/Programs/GenerateReport.pl:1.4 llvm/test/Programs/GenerateReport.pl:1.5
--- llvm/test/Programs/GenerateReport.pl:1.4	Fri Jan 17 16:52:15 2003
+++ llvm/test/Programs/GenerateReport.pl	Tue Jan 21 10:24:42 2003
@@ -1,4 +1,31 @@
 #!/usr/dcs/software/supported/bin/perl -w
+#
+# Program:  GenerateReport.pl
+#
+# Synopsis: Summarize a big log file into a table of values, commonly used for
+#           testing.  This can generate either a plaintext table or HTML table
+#           depending on whether the -html option is specified.
+#
+#           This script reads a report description file to specify the fields
+#           and descriptions for the columns of interest.  In reads the raw log
+#           input from stdin and writes the table to stdout.
+#
+# Syntax:   GenerateReport.pl [-html] <ReportDesc> < Input > Output
+#
+
+# Default values for arguments
+$HTML = 0;
+
+# Parse arguments...
+while ($_ = $ARGV[0], /^[-+]/) {
+  shift;
+  last if /^--$/;  # Stop processing arguments on --
+
+  # List command line options here...
+  if (/^-html$/) { $HTML = 1; next; }
+
+  print "Unknown option: $_ : ignoring!\n";
+}
 
 #
 # Parameters which may be overriden by the report description file.
@@ -86,7 +113,7 @@
 @Values = reverse @Values if ($SortReverse);
 
 #
-# Add the header for the report to the table after sorting...
+# Condense the header into an easier to access array...
 #
 my @Header;
 for $Row (@Fields) {
@@ -96,29 +123,61 @@
     push @Header, "|";
   }
 }
-unshift @Values, [@Header];
 
-#
-# Figure out how wide each field should be...
-#
-my @FieldWidths = (0) x scalar(@Fields);
-foreach $Value (@Values) {
-  for ($i = 0; $i < @$Value-1; $i++) {
-    if (length($$Value[$i]) > $FieldWidths[$i]) {
-      $FieldWidths[$i] = length($$Value[$i])
+if ($HTML) {
+  sub printCell {
+    my $Str = shift;
+    if ($Str eq '|') {
+      print "<td bgcolor='black' width='1'></td>";
+    } else {
+      print "<td><table border='0' cellspacing='0' cellpadding='3'><tr><td>$Str</td></tr></table></td>\n";
+    }; "";
+  }
+
+  print "<table border='0' cellspacing='0' cellpadding='0'>\n";
+  print "<tr bgcolor=#FFCC99>\n";
+  map { $_ = "<b><a href=\"#$_\">$_</a></b>" if $_ ne "|"; printCell $_ } @Header;
+  print "\n</tr><tr bgcolor='black'>";
+  print "<td height=1></td>" x @Header;
+  print "</tr>\n";
+  my $RowCount = 0;
+  foreach $Row (@Values) {
+    if (++$RowCount <= 2) {
+      print "<tr bgcolor='white'>\n";
+    } else {
+      print "<tr bgcolor='#CCCCCC'>\n";
+      $RowCount = 0 if ($RowCount > 3);
+    }
+    map { printCell $_ } @$Row;
+    print "\n</tr>\n";
+  }
+  print "\n</table>\n";
+} else {
+  # Add the header for the report to the table after sorting...
+  unshift @Values, [@Header];
+
+  #
+  # Figure out how wide each field should be...
+  #
+  my @FieldWidths = (0) x scalar(@Fields);
+  foreach $Value (@Values) {
+    for ($i = 0; $i < @$Value-1; $i++) {
+      if (length($$Value[$i]) > $FieldWidths[$i]) {
+        $FieldWidths[$i] = length($$Value[$i])
+      }
     }
   }
-}
 
 
-#
-# Print out the table now...
-#
-foreach $Value (@Values) {
-  for ($i = 0; $i < @$Value-1; $i++) {
-    printf "%-$FieldWidths[$i]s ", $$Value[$i];
-  }
+  #
+  # Print out the table now...
+  #
+  foreach $Value (@Values) {
+    for ($i = 0; $i < @$Value-1; $i++) {
+      printf "%-$FieldWidths[$i]s ", $$Value[$i];
+    }
 
-  # Print the assertion message if existant...
-  print "$$Value[@$Value-1]\n";
+    # Print the assertion message if existant...
+    print "$$Value[@$Value-1]\n";
+  }
 }


Index: llvm/test/Programs/Makefile
diff -u llvm/test/Programs/Makefile:1.8 llvm/test/Programs/Makefile:1.9
--- llvm/test/Programs/Makefile:1.8	Fri Jan 17 16:58:49 2003
+++ llvm/test/Programs/Makefile	Tue Jan 21 10:24:42 2003
@@ -28,6 +28,7 @@
 	gmake TEST=$(TEST) 2>&1 | tee $@
 
 report: report.$(TEST).raw.out
+	./GenerateReport.pl -html TEST.$(TEST).report < $< > report.$(TEST).html
 	./GenerateReport.pl TEST.$(TEST).report < $< | tee report.$(TEST).txt
 
 clean::





More information about the llvm-commits mailing list