* Fix indentation of Regression Test Results by making sure the
[oota-llvm.git] / utils / NightlyTest.pl
1 #!/usr/bin/perl -w
2 #
3 # Program:  NightlyTest.pl
4 #
5 # Synopsis: Perform a series of tests which are designed to be run nightly.
6 #           This is used to keep track of the status of the LLVM tree, tracking
7 #           regressions and performance changes.  This generates one web page a
8 #           day which can be used to access this information.
9 #
10 # Syntax:   NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
11 #   where
12 # OPTIONS may include one or more of the following:
13 #  -nocheckout      Do not create, checkout, update, or configure
14 #                   the source tree.
15 #  -noremove        Do not remove the BUILDDIR after it has been built.
16 #  -nofeaturetests  Do not run the feature tests.
17 #  -noregressiontests Do not run the regression tests.
18 #  -notest          Do not even attempt to run the test programs. Implies
19 #                   -norunningtests.
20 #  -norunningtests  Do not run the Olden benchmark suite with
21 #                   LARGE_PROBLEM_SIZE enabled.
22 #  -parallel        Run two parallel jobs with GNU Make.
23 #  -enable-linscan  Enable linearscan tests
24 #  -disable-codegen Disable LLC and JIT tests in the nightly tester.
25 #  -verbose         Turn on some debug output
26 #  -debug           Print information useful only to maintainers of this script.
27 #
28 # CVSROOT is the CVS repository from which the tree will be checked out,
29 #  specified either in the full :method:user@host:/dir syntax, or
30 #  just /dir if using a local repo.
31 # BUILDDIR is the directory where sources for this test run will be checked out
32 #  AND objects for this test run will be built. This directory MUST NOT
33 #  exist before the script is run; it will be created by the cvs checkout
34 #  process and erased (unless -noremove is specified; see above.)
35 # WEBDIR is the directory into which the test results web page will be written,
36 #  AND in which the "index.html" is assumed to be a symlink to the most recent
37 #  copy of the results. This directory MUST exist before the script is run.
38 #
39 use POSIX qw(strftime);
40
41 my $HOME = $ENV{'HOME'};
42 my $CVSRootDir = $ENV{'CVSROOT'};
43    $CVSRootDir = "/home/vadve/shared/PublicCVS"
44      unless $CVSRootDir;
45 my $BuildDir   = $ENV{'BUILDDIR'};
46    $BuildDir   = "$HOME/buildtest"
47      unless $BuildDir;
48 my $WebDir     = $ENV{'WEBDIR'};
49    $WebDir     = "$HOME/cvs/testresults-X86"
50      unless $WebDir;
51
52 # Calculate the date prefix...
53 @TIME = localtime;
54 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
55 my $DateString = strftime "%B %d, %Y", localtime;
56
57 sub ReadFile {
58   undef $/;
59   if (open (FILE, $_[0])) {
60     my $Ret = <FILE>;
61     close FILE;
62     return $Ret;
63   } else {
64     print "Could not open file '$_[0]' for reading!";
65     return "";
66   }
67 }
68
69 sub WriteFile {  # (filename, contents)
70   open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
71   print FILE $_[1];
72   close FILE;
73 }
74
75 sub GetRegex {   # (Regex with ()'s, value)
76   $_[1] =~ /$_[0]/m;
77   if (defined($1)) {
78     return $1;
79   }
80   return "?";
81 }
82
83 sub AddPreTag {  # Add pre tags around nonempty list, or convert to "none"
84   $_ = shift;
85   if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
86 }
87
88 sub GetDir {
89   my $Suffix = shift;
90   opendir DH, $WebDir;
91   my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
92   closedir DH;
93   return @Result;
94 }
95
96 # DiffFiles - Diff the current version of the file against the last version of
97 # the file, reporting things added and removed.  This is used to report, for
98 # example, added and removed warnings.  This returns a pair (added, removed)
99 #
100 sub DiffFiles {
101   my $Suffix = shift;
102   my @Others = GetDir $Suffix;
103   if (@Others == 0) {  # No other files?  We added all entries...
104     return (`cat $WebDir/$DATE$Suffix`, "");
105   }
106   # Diff the files now...
107   my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
108   my $Added   = join "\n", grep /^</, @Diffs;
109   my $Removed = join "\n", grep /^>/, @Diffs;
110   $Added =~ s/^< //gm;
111   $Removed =~ s/^> //gm;
112   return ($Added, $Removed);
113 }
114
115 # FormatTime - Convert a time from 1m23.45 into 83.45
116 sub FormatTime {
117   my $Time = shift;
118   if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
119     $Time = sprintf("%7.4f", $1*60.0+$2);
120   }
121   return $Time;
122 }
123
124
125 # Command line argument settings...
126 my $NOCHECKOUT = 0;
127 my $NOREMOVE   = 0;
128 my $NOFEATURES = 0;
129 my $NOREGRESSIONS = 0;
130 my $NOTEST     = 0;
131 my $NORUNNINGTESTS = 0;
132 my $MAKEOPTS   = "";
133 my $PROGTESTOPTS = "";
134 my $VERBOSE  = 0;
135 my $DEBUG = 0;
136 my $CONFIGUREARGS = "--enable-jit";
137
138 # Parse arguments... 
139 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
140   shift;
141   last if /^--$/;  # Stop processing arguments on --
142
143   # List command line options here...
144   if (/^-nocheckout$/)     { $NOCHECKOUT = 1; next; }
145   if (/^-noremove$/)       { $NOREMOVE   = 1; next; }
146   if (/^-nofeaturetests$/) { $NOFEATURES = 1; next; }
147   if (/^-noregressiontests$/){ $NOREGRESSIONS = 1; next; }
148   if (/^-notest$/)         { $NOTEST     = 1; $NORUNNINGTESTS = 1; next; }
149   if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
150   if (/^-parallel$/)       { $MAKEOPTS   = "-j2 -l3.0"; next; }
151   if (/^-enable-linscan$/) { $PROGTESTOPTS .= " ENABLE_LINEARSCAN=1"; next; }
152   if (/^-disable-codegen$/){ $PROGTESTOPTS .= " DISABLE_JIT=1 DISABLE_LLC=1";
153                              $CONFIGUREARGS="--disable-jit --disable-llc_diffs";
154                              next; }
155   if (/^-verbose$/)        { $VERBOSE  = 1; next; }
156   if (/^-debug$/)          { $DEBUG  = 1; next; }
157
158   print "Unknown option: $_ : ignoring!\n";
159 }
160
161 if ($ENV{'LLVMGCCDIR'}) {
162   $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
163 }
164
165 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
166
167 if (@ARGV == 3) {
168   $CVSRootDir = $ARGV[0];
169   $BuildDir   = $ARGV[1];
170   $WebDir     = $ARGV[2];
171 }
172
173
174 my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
175 my $Prefix = "$WebDir/$DATE";
176
177 if ($VERBOSE) {
178   print "INITIALIZED\n";
179   print "CVS Root = $CVSRootDir\n";
180   print "BuildDir = $BuildDir\n";
181   print "WebDir   = $WebDir\n";
182   print "Prefix   = $Prefix\n";
183 }
184
185
186 #
187 # Create the CVS repository directory
188 #
189 if (!$NOCHECKOUT) {
190   if (-d $BuildDir) {
191     if (!$NOREMOVE) {
192       system "rm -rf $BuildDir"; 
193     } else {
194        die "CVS checkout directory $BuildDir already exists!";
195     }
196   }
197   mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
198 }
199 chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
200
201
202 #
203 # Check out the llvm tree, saving CVS messages to the cvs log...
204 #
205 $CVSOPT = "";
206 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
207 if (!$NOCHECKOUT) {
208   if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
209   system "(time -p cvs $CVSOPT -d $CVSRootDir co llvm) > $Prefix-CVS-Log.txt 2>&1";
210 }
211
212 chdir "llvm" or die "Could not change into llvm directory!";
213
214 if (!$NOCHECKOUT) {
215   if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
216   system "cvs update -P -d > /dev/null 2>&1" ;
217 }
218
219 # Read in the HTML template file...
220 my $TemplateContents = ReadFile $Template;
221
222
223 #
224 # Get some static statistics about the current state of CVS
225 #
226 my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
227 my $NumFilesInCVS = `egrep '^U' $Prefix-CVS-Log.txt | wc -l` + 0;
228 my $NumDirsInCVS  = `egrep '^cvs (checkout|server|update):' $Prefix-CVS-Log.txt | wc -l` + 0;
229 $LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
230
231 #
232 # Build the entire tree, saving build messages to the build log
233 #
234 if (!$NOCHECKOUT) {
235   if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
236   system "(time -p ./configure $CONFIGUREARGS --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
237
238   if ( $VERBOSE ) { print "BUILD STAGE\n"; }
239   # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
240   system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
241 }
242
243
244 sub GetRegexNum {
245   my ($Regex, $Num, $Regex2, $File) = @_;
246   my @Items = split "\n", `grep '$Regex' $File`;
247   return GetRegex $Regex2, $Items[$Num];
248 }
249
250 #
251 # Get some statistics about the build...
252 #
253 my @Linked = split '\n', `grep Linking $Prefix-Build-Log.txt`;
254 my $NumExecutables = scalar(grep(/executable/, @Linked));
255 my $NumLibraries   = scalar(grep(!/executable/, @Linked));
256 my $NumObjects     = `grep '^Compiling' $Prefix-Build-Log.txt | wc -l` + 0;
257
258 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
259 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
260 my $ConfigTime  = $ConfigTimeU+$ConfigTimeS;  # ConfigTime = User+System
261 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$Prefix-Build-Log.txt";
262
263 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
264 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
265 my $BuildTime  = $BuildTimeU+$BuildTimeS;  # BuildTime = User+System
266 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
267
268 my $BuildError = "";
269 if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
270     `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
271   $BuildError = "<h3><font color='red'>Build error: compilation " .
272                 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
273   print "BUILD ERROR\n";
274 }
275
276 sub GetQMTestResults { # (filename)
277   my ($filename) = @_;
278   my @lines;
279   my $firstline;
280   $/ = "\n"; #Make sure we're going line at a time.
281   if (open SRCHFILE, $filename) {
282     # Skip stuff before ---TEST RESULTS
283     while ( <SRCHFILE> ) {
284       if ( m/^--- TEST RESULTS/ ) { last; }
285     }
286     # Process test results
287     push(@lines,"<h3>TEST RESULTS</h3><ol><li>\n");
288     my $first_list = 1;
289     my $should_break = 1;
290     my $nocopy = 0;
291     while ( <SRCHFILE> ) {
292       if ( length($_) > 1 ) { 
293         chomp($_);
294         if ( ! m/: PASS[ ]*$/ &&
295              ! m/^    qmtest.target:/ && 
296              ! m/^      local/ &&
297              ! m/^gmake:/ ) {
298           if ( m/: XFAIL/ ) {
299             $nocopy = 1;
300           } elsif ( m/: XPASS/ || m/: FAIL/ ) {
301             $nocopy = 0;
302             if ( $first_list ) {
303               $first_list = 0;
304               $should_break = 1;
305               push(@lines,"<b>$_</b><br/>\n");
306             } else {
307               push(@lines,"</li><li><b>$_</b><br/>\n");
308             }
309           } elsif ( m/^--- STATISTICS/ ) {
310             if ( $first_list ) { push(@lines,"<b>PERFECT!</b>"); }
311             push(@lines,"</li></ol><h3>STATISTICS</h3><pre>\n");
312             $should_break = 0;
313             $nocopy = 0;
314           } elsif ( m/^--- TESTS WITH/ ) {
315             $should_break = 1;
316             $first_list = 1;
317             $nocopy = 0;
318             push(@lines,"</pre><h3>TESTS WITH UNEXPECTED RESULTS</h3><ol><li>\n");
319           } elsif ( m/^real / ) {
320             last;
321           } elsif (!$nocopy) {
322             if ( $should_break ) {
323               push(@lines,"$_<br/>\n");
324             } else {
325               push(@lines,"$_\n");
326             }
327           }
328         }
329       }
330     }
331     close SRCHFILE;
332   }
333   my $content = join("",@lines);
334   return "$content</li></ol>\n";
335
336
337 # Get results of feature tests.
338 my $FeatureTestResults; # String containing the results of the feature tests
339 my $FeatureTime;        # System+CPU Time for feature tests
340 my $FeatureWallTime;    # Wall Clock Time for feature tests
341 if (!$NOFEATURES) {
342   if ( $VERBOSE ) { print "FEATURE TEST STAGE\n"; }
343   my $feature_output = "$Prefix-FeatureTests-Log.txt";
344
345   # Run the feature tests so we can summarize the results
346   system "(time -p gmake -C test Feature.t) > $feature_output 2>&1";
347
348   # Extract test results
349   $FeatureTestResults = GetQMTestResults("$feature_output");
350
351   # Extract time of feature tests
352   my $FeatureTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$feature_output";
353   my $FeatureTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$feature_output";
354   $FeatureTime  = $FeatureTimeU+$FeatureTimeS;  # FeatureTime = User+System
355   $FeatureWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$feature_output";
356   # Run the regression tests so we can summarize the results
357 } else {
358   $FeatureTestResults = "Skipped by user choice.";
359   $FeatureTime     = "0.0";
360   $FeatureWallTime = "0.0";
361 }
362
363 if (!$NOREGRESSIONS) {
364   if ( $VERBOSE ) { print "REGRESSION TEST STAGE\n"; }
365   my $regression_output = "$Prefix-RegressionTests-Log.txt";
366
367   # Run the regression tests so we can summarize the results
368   system "(time -p gmake -C test Regression.t) > $regression_output 2>&1";
369
370   # Extract test results
371   $RegressionTestResults = GetQMTestResults("$regression_output");
372
373   # Extract time of regressions tests
374   my $RegressionTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$regression_output";
375   my $RegressionTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$regression_output";
376   $RegressionTime  = $RegressionTimeU+$RegressionTimeS;  # RegressionTime = User+System
377   $RegressionWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$regression_output";
378 } else {
379   $RegressionTestResults = "Skipped by user choice.";
380   $RegressionTime     = "0.0";
381   $RegressionWallTime = "0.0";
382 }
383
384 if ($DEBUG) {
385   print $FeatureTestResults;
386   print $RegressionTestResults;
387 }
388
389 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
390 #
391 # Get warnings from the build
392 #
393 my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
394 my @Warnings;
395 my $CurDir = "";
396
397 foreach $Warning (@Warn) {
398   if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
399     $CurDir = $1;                 # Keep track of directory warning is in...
400     if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
401       $CurDir = $1;
402     }
403   } else {
404     push @Warnings, "$CurDir/$Warning";     # Add directory to warning...
405   }
406 }
407 my $WarningsFile =  join "\n", @Warnings;
408 my $WarningsList = AddPreTag $WarningsFile;
409 $WarningsFile =~ s/:[0-9]+:/::/g;
410
411 # Emit the warnings file, so we can diff...
412 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
413 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
414
415 # Output something to stdout if something has changed
416 print "ADDED   WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
417 print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
418
419 $WarningsAdded = AddPreTag $WarningsAdded;
420 $WarningsRemoved = AddPreTag $WarningsRemoved;
421
422 #
423 # Get some statistics about CVS commits over the current day...
424 #
425 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
426 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
427 #print join "\n", @CVSHistory; print "\n";
428
429 # Extract some information from the CVS history... use a hash so no duplicate
430 # stuff is stored.
431 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
432
433 my $DateRE = "[-:0-9 ]+\\+[0-9]+";
434
435 # Loop over every record from the CVS history, filling in the hashes.
436 foreach $File (@CVSHistory) {
437   my ($Type, $Date, $UID, $Rev, $Filename);
438   if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
439     ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
440   } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
441     ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
442   } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
443     ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
444   } else {
445     print "UNMATCHABLE: $File\n";
446   }
447   # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
448
449   if ($Filename =~ /^llvm/) {
450     if ($Type eq 'M') {        # Modified
451       $ModifiedFiles{$Filename} = 1;
452       $UsersCommitted{$UID} = 1;
453     } elsif ($Type eq 'A') {   # Added
454       $AddedFiles{$Filename} = 1;
455       $UsersCommitted{$UID} = 1;
456     } elsif ($Type eq 'R') {   # Removed
457       $RemovedFiles{$Filename} = 1;
458       $UsersCommitted{$UID} = 1;
459     } else {
460       $UsersUpdated{$UID} = 1;
461     }
462   }
463 }
464
465 my $UserCommitList = join "\n", keys %UsersCommitted;
466 my $UserUpdateList = join "\n", keys %UsersUpdated;
467 my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
468 my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
469 my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
470
471 my $TestError = 1;
472 my $SingleSourceProgramsTable;
473 my $MultiSourceProgramsTable;
474 my $ExternalProgramsTable;
475
476
477 sub TestDirectory {
478   my $SubDir = shift;
479
480   chdir "test/Programs/$SubDir" or
481     die "Could not change into test/Programs/$SubDir testdir!";
482
483   # Run the programs tests... creating a report.nightly.html file
484   if (!$NOTEST) {
485     system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
486          . "TEST=nightly > $Prefix-$SubDir-ProgramTest.txt 2>&1";
487   } else {
488     system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
489   }
490
491   my $ProgramsTable;
492   if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
493     $TestError = 1;
494     $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
495     print "ERROR TESTING\n";
496   } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
497     $TestError = 1;
498     $ProgramsTable =
499       "<font color=white><h2>Makefile error running tests!</h2></font>";
500     print "ERROR TESTING\n";
501   } else {
502     $TestError = 0;
503     $ProgramsTable = ReadFile "report.nightly.html";
504
505     #
506     # Create a list of the tests which were run...
507     #
508     system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
509          . "| sort > $Prefix-$SubDir-Tests.txt";
510   }
511
512   # Compress the test output
513   system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
514   chdir "../../.." or die "Cannot return to parent directory!";
515   return $ProgramsTable;
516 }
517
518 # If we build the tree successfully, run the nightly programs tests...
519 if ($BuildError eq "") {
520   if ( $VERBOSE ) {
521     print "SingleSource TEST STAGE\n";
522   }
523   $SingleSourceProgramsTable = TestDirectory("SingleSource");
524   if ( $VERBOSE ) {
525     print "MultiSource TEST STAGE\n";
526   }
527   $MultiSourceProgramsTable = TestDirectory("MultiSource");
528   if ( $VERBOSE ) {
529     print "External TEST STAGE\n";
530   }
531   $ExternalProgramsTable = TestDirectory("External");
532   system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
533          " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
534 }
535
536 if ( $VERBOSE ) {
537   print "TEST INFORMATION COLLECTION STAGE\n";
538 }
539 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
540
541 if ($TestError) {
542   $TestsAdded   = "<b>error testing</b><br>";
543   $TestsRemoved = "<b>error testing</b><br>";
544   $TestsFixed   = "<b>error testing</b><br>";
545   $TestsBroken  = "<b>error testing</b><br>";
546 } else {
547   my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
548
549   my @RawTestsAddedArray = split '\n', $RTestsAdded;
550   my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
551
552   my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
553     @RawTestsRemovedArray;
554   my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
555     @RawTestsAddedArray;
556
557   foreach $Test (keys %NewTests) {
558     if (!exists $OldTests{$Test}) {  # TestAdded if in New but not old
559       $TestsAdded = "$TestsAdded$Test\n";
560     } else {
561       if ($OldTests{$Test} =~ /TEST-PASS/) {  # Was the old one a pass?
562         $TestsBroken = "$TestsBroken$Test\n";  # New one must be a failure
563       } else {
564         $TestsFixed = "$TestsFixed$Test\n";    # No, new one is a pass.
565       }
566     }
567   }
568   foreach $Test (keys %OldTests) {  # TestRemoved if in Old but not New
569     $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
570   }
571
572   print "\nTESTS ADDED:  \n\n$TestsAdded\n\n"   if (length $TestsAdded);
573   print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
574   print "\nTESTS FIXED:  \n\n$TestsFixed\n\n"   if (length $TestsFixed);
575   print "\nTESTS BROKEN: \n\n$TestsBroken\n\n"  if (length $TestsBroken);
576
577   $TestsAdded   = AddPreTag $TestsAdded;
578   $TestsRemoved = AddPreTag $TestsRemoved;
579   $TestsFixed   = AddPreTag $TestsFixed;
580   $TestsBroken  = AddPreTag $TestsBroken;
581 }
582
583
584 # If we built the tree successfully, runs of the Olden suite with
585 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
586 if ($BuildError eq "") {
587   my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
588       $MachCodeSize) = ("","","","","","","");
589   if (!$NORUNNINGTESTS) {
590     chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
591
592     # Clean out previous results...
593     system "gmake $MAKEOPTS clean > /dev/null 2>&1";
594
595     # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
596     system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
597            " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
598     system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
599   } else {
600     system "gunzip $Prefix-Olden-tests.txt.gz";
601   }
602
603   # Now we know we have $Prefix-Olden-tests.txt as the raw output file.  Split
604   # it up into records and read the useful information.
605   my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
606   shift @Records;  # Delete the first (garbage) record
607
608   # Loop over all of the records, summarizing them into rows for the running
609   # totals file.
610   my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
611   foreach $Rec (@Records) {
612     my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
613     my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
614     my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
615     my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
616     my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
617     my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
618     my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
619
620     $NATTime .= " " . FormatTime($rNATTime);
621     $CBETime .= " " . FormatTime($rCBETime);
622     $LLCTime .= " " . FormatTime($rLLCTime);
623     $JITTime .= " " . FormatTime($rJITTime);
624     $OptTime .= " $rOptTime";
625     $BytecodeSize .= " $rBytecodeSize";
626     $MachCodeSize .= " $rMachCodeSize";
627   }
628
629   # Now that we have all of the numbers we want, add them to the running totals
630   # files.
631   AddRecord($NATTime, "running_Olden_nat_time.txt");
632   AddRecord($CBETime, "running_Olden_cbe_time.txt");
633   AddRecord($LLCTime, "running_Olden_llc_time.txt");
634   AddRecord($JITTime, "running_Olden_jit_time.txt");
635   AddRecord($OptTime, "running_Olden_opt_time.txt");
636   AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
637   AddRecord($MachCodeSize, "running_Olden_machcode.txt");
638
639   system "gzip -f $Prefix-Olden-tests.txt";
640 }
641
642
643
644
645 #
646 # Get a list of the previous days that we can link to...
647 #
648 my @PrevDays = map {s/.html//; $_} GetDir ".html";
649
650 splice @PrevDays, 20;  # Trim down list to something reasonable...
651
652 my $PrevDaysList =     # Format list for sidebar
653   join "\n  ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
654
655 #
656 # Start outputing files into the web directory
657 #
658 chdir $WebDir or die "Could not change into web directory!";
659
660 # Add information to the files which accumulate information for graphs...
661 AddRecord($LOC, "running_loc.txt");
662 AddRecord($BuildTime, "running_build_time.txt");
663
664 if ( $VERBOSE ) {
665   print "GRAPH GENERATION STAGE\n";
666 }
667 #
668 # Rebuild the graphs now...
669 #
670 $GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
671 $GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
672 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
673 system ($GNUPLOT, $PlotScriptFilename);
674
675 #
676 # Remove the cvs tree...
677 #
678 system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
679
680 #
681 # Print out information...
682 #
683 if ($VERBOSE) {
684   print "DateString: $DateString\n";
685   print "CVS Checkout: $CVSCheckoutTime seconds\n";
686   print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
687   print "Build Time: $BuildTime seconds\n";
688   print "Feature Test Time: $FeatureTime seconds\n";
689   print "Regression Test Time: $RegressionTime seconds\n";
690   print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
691
692   print "WARNINGS:\n  $WarningsList\n";
693
694   print "Users committed: $UserCommitList\n";
695   print "Added Files: \n  $AddedFilesList\n";
696   print "Modified Files: \n  $ModifiedFilesList\n";
697   print "Removed Files: \n  $RemovedFilesList\n";
698
699   print "Previous Days =\n  $PrevDaysList\n";
700 }
701
702
703 #
704 # Output the files...
705 #
706
707 if ( $VERBOSE ) {
708   print "OUTPUT STAGE\n";
709 }
710 # Main HTML file...
711 my $Output;
712 eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
713 WriteFile "$DATE.html", $Output;
714
715 # Change the index.html symlink...
716 system "ln -sf $DATE.html index.html";
717
718 sub AddRecord {
719   my ($Val, $Filename) = @_;
720   my @Records;
721   if (open FILE, "$WebDir/$Filename") {
722     @Records = grep !/$DATE/, split "\n", <FILE>;
723     close FILE;
724   }
725   push @Records, "$DATE: $Val";
726   WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
727   return @Records;
728 }