3 # Program: NightlyTest.pl
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.
10 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
12 # OPTIONS may include one or more of the following:
13 # -nocheckout Do not create, checkout, update, or configure
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
20 # -norunningtests Do not run the Olden benchmark suite with
21 # LARGE_PROBLEM_SIZE enabled.
22 # -noexternals Do not run the external tests (for cases where povray
23 # or SPEC are not installed)
24 # -rundejagnu Runs features and regressions using Dejagnu
25 # -parallel Run two parallel jobs with GNU Make.
26 # -release Build an LLVM Release version
27 # -pedantic Enable additional GCC warnings to detect possible errors.
28 # -enable-linscan Enable linearscan tests
29 # -disable-llc Disable LLC tests in the nightly tester.
30 # -disable-jit Disable JIT tests in the nightly tester.
31 # -verbose Turn on some debug output
32 # -debug Print information useful only to maintainers of this script.
33 # -nice Checkout/Configure/Build with "nice" to reduce impact
35 # -f2c Next argument specifies path to F2C utility
36 # -gnuplotscript Next argument specifies gnuplot script to use
37 # -templatefile Next argument specifies template file to use
38 # -gccpath Path to gcc/g++ used to build LLVM
40 # CVSROOT is the CVS repository from which the tree will be checked out,
41 # specified either in the full :method:user@host:/dir syntax, or
42 # just /dir if using a local repo.
43 # BUILDDIR is the directory where sources for this test run will be checked out
44 # AND objects for this test run will be built. This directory MUST NOT
45 # exist before the script is run; it will be created by the cvs checkout
46 # process and erased (unless -noremove is specified; see above.)
47 # WEBDIR is the directory into which the test results web page will be written,
48 # AND in which the "index.html" is assumed to be a symlink to the most recent
49 # copy of the results. This directory will be created if it does not exist.
50 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
51 # to. This is the same as you would have for a normal LLVM build.
53 use POSIX qw(strftime);
56 my $HOME = $ENV{'HOME'};
57 my $CVSRootDir = $ENV{'CVSROOT'};
58 $CVSRootDir = "/home/vadve/shared/PublicCVS"
60 my $BuildDir = $ENV{'BUILDDIR'};
61 $BuildDir = "$HOME/buildtest"
63 my $WebDir = $ENV{'WEBDIR'};
64 $WebDir = "$HOME/cvs/testresults-X86"
67 # Calculate the date prefix...
69 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
70 my $DateString = strftime "%B %d, %Y", localtime;
71 my $TestStartTime = gmtime;
73 # Command line argument settings...
77 my $NOREGRESSIONS = 0;
79 my $NORUNNINGTESTS = 0;
82 my $PROGTESTOPTS = "";
85 my $CONFIGUREARGS = "";
90 if (open (FILE, $_[0])) {
97 print "Could not open file '$_[0]' for reading!";
102 sub WriteFile { # (filename, contents)
103 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
108 sub GetRegex { # (Regex with ()'s, value)
119 foreach my $file (@files) {
121 open (FILE, ">$file") or warn "Could not create new file $file";
124 utime $now, $now, $file;
129 my ($Val, $Filename) = @_;
131 if (open FILE, "$WebDir/$Filename") {
132 @Records = grep !/$DATE/, split "\n", <FILE>;
135 push @Records, "$DATE: $Val";
136 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
139 sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
141 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
144 sub ChangeDir { # directory, logical name
145 my ($dir,$name) = @_;
147 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
148 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
151 sub CopyFile { #filename, newfile
152 my ($file, $newfile) = @_;
154 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
155 copy($file, $newfile);
161 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
166 # DiffFiles - Diff the current version of the file against the last version of
167 # the file, reporting things added and removed. This is used to report, for
168 # example, added and removed warnings. This returns a pair (added, removed)
172 my @Others = GetDir $Suffix;
173 if (@Others == 0) { # No other files? We added all entries...
174 return (`cat $WebDir/$DATE$Suffix`, "");
176 # Diff the files now...
177 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
178 my $Added = join "\n", grep /^</, @Diffs;
179 my $Removed = join "\n", grep /^>/, @Diffs;
181 $Removed =~ s/^> //gm;
182 return ($Added, $Removed);
185 # FormatTime - Convert a time from 1m23.45 into 83.45
188 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
189 $Time = sprintf("%7.4f", $1*60.0+$2);
195 my ($Regex, $Num, $Regex2, $File) = @_;
196 my @Items = split "\n", `grep '$Regex' $File`;
197 return GetRegex $Regex2, $Items[$Num];
200 sub GetQMTestResults { # (filename)
204 $/ = "\n"; #Make sure we're going line at a time.
205 if (open SRCHFILE, $filename) {
206 # Skip stuff before ---TEST RESULTS
207 while ( <SRCHFILE> ) {
208 if ( m/^--- TEST RESULTS/ ) { last; }
210 # Process test results
211 push(@lines,"<h3>TEST RESULTS</h3><ol><li>\n");
213 my $should_break = 1;
215 while ( <SRCHFILE> ) {
216 if ( length($_) > 1 ) {
218 if ( ! m/: PASS[ ]*$/ &&
219 ! m/^ qmtest.target:/ &&
224 } elsif ( m/: XPASS/ || m/: FAIL/ ) {
229 push(@lines,"<b>$_</b><br/>\n");
231 push(@lines,"</li><li><b>$_</b><br/>\n");
233 } elsif ( m/^--- STATISTICS/ ) {
234 if ( $first_list ) { push(@lines,"<b>PERFECT!</b>"); }
235 push(@lines,"</li></ol><h3>STATISTICS</h3><pre>\n");
238 } elsif ( m/^--- TESTS WITH/ ) {
242 push(@lines,"</pre><h3>TESTS WITH UNEXPECTED RESULTS</h3><ol><li>\n");
243 } elsif ( m/^real / ) {
246 if ( $should_break ) {
247 push(@lines,"$_<br/>\n");
257 my $content = join("",@lines);
258 return "$content</li></ol>\n";
261 sub GetDejagnuTestResults { # (filename, log)
262 my ($filename, $DejagnuLog) = @_;
265 $/ = "\n"; #Make sure we're going line at a time.
266 if (open SRCHFILE, $filename) {
267 # Process test results
268 push(@lines,"<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
270 my $should_break = 1;
273 while ( <SRCHFILE> ) {
274 if ( length($_) > 1 ) {
276 if ( m/^XPASS:/ || m/^FAIL:/ ) {
281 push(@lines,"<b>$_</b><br/>\n");
283 push(@lines,"</li><li><b>$_</b><br/>\n");
285 } elsif ( m/Summary/ ) {
286 if ( $first_list ) { push(@lines,"<b>PERFECT!</b>"); }
287 push(@lines,"</li></ol><h3>STATISTICS</h3><pre>\n");
291 } elsif ( $readingsum ) {
297 push(@lines, "</pre>\n");
300 #add link to complete testing log
301 push(@lines, "<p>A complete log of testing <a href=\"$DejagnuLog\">Feature and Regression</a> is available for further analysis.</p>\n");
303 my $content = join("",@lines);
304 return "$content</li></ol>\n";
308 #####################################################################
310 #####################################################################
313 my $PlotScriptFilename = "";
316 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
318 last if /^--$/; # Stop processing arguments on --
320 # List command line options here...
321 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
322 if (/^-noremove$/) { $NOREMOVE = 1; next; }
323 if (/^-nofeaturetests$/) { $NOFEATURES = 1; next; }
324 if (/^-noregressiontests$/){ $NOREGRESSIONS = 1; next; }
325 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
326 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
327 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
328 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
330 $MAKEOPTS = "$MAKEOPTS CompileOptimizeOpts='-O3 -DNDEBUG -finline-functions -Wpointer-arith -Wcast-align -Wno-deprecated -Wold-style-cast -Wabi -Woverloaded-virtual -ffor-scope'";
333 if (/^-enable-linscan$/) { $PROGTESTOPTS .= " ENABLE_LINEARSCAN=1"; next; }
334 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
335 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
336 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
337 $CONFIGUREARGS .= " --disable-jit"; next; }
338 if (/^-verbose$/) { $VERBOSE = 1; next; }
339 if (/^-debug$/) { $DEBUG = 1; next; }
340 if (/^-nice$/) { $NICE = "nice "; next; }
342 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
344 if (/^-gnuplotscript$/) { $PlotScriptFilename = $ARGV[0]; shift; next; }
345 if (/^-templatefile$/) { $Template = $ARGV[0]; shift; next; }
347 $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;
349 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
350 if(/^-runDejagnu$/) { $RUNDEJAGNU = 1; next; }
352 print "Unknown option: $_ : ignoring!\n";
355 if ($ENV{'LLVMGCCDIR'}) {
356 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
358 if ($CONFIGUREARGS !~ /--disable-jit/) {
359 $CONFIGUREARGS .= " --enable-jit";
362 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
365 $CVSRootDir = $ARGV[0];
366 $BuildDir = $ARGV[1];
370 my $Prefix = "$WebDir/$DATE";
372 #define the file names we'll use
373 my $BuildLog = "$Prefix-Build-Log.txt";
374 my $CVSLog = "$Prefix-CVS-Log.txt";
375 my $FeatureTestsLog = "$Prefix-FeatureTests-Log.txt";
376 my $RegressionTestsLog = "$Prefix-RegressionTests-Log.txt";
377 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
378 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
379 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
380 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
381 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
382 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
383 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
386 print "INITIALIZED\n";
387 print "CVS Root = $CVSRootDir\n";
388 print "BuildDir = $BuildDir\n";
389 print "WebDir = $WebDir\n";
390 print "Prefix = $Prefix\n";
391 print "CVSLog = $CVSLog\n";
392 print "BuildLog = $BuildLog\n";
397 warn "Warning: $WebDir did not exist; creating it.\n";
401 # Create the CVS repository directory
406 system "rm -rf $BuildDir";
408 die "CVS checkout directory $BuildDir already exists!";
411 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
414 ChangeDir( $BuildDir, "CVS checkout directory" );
418 # Check out the llvm tree, saving CVS messages to the cvs log...
421 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
423 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
424 system "( time -p $NICE cvs $CVSOPT -d $CVSRootDir co -APR llvm; cd llvm/projects ; " .
425 "$NICE cvs $CVSOPT -d $CVSRootDir co -APR llvm-test ) > $CVSLog 2>&1";
426 ChangeDir( $BuildDir , "CVS Checkout directory") ;
429 ChangeDir( "llvm" , "llvm source directory") ;
432 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
433 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
436 if ( $Template eq "" ) {
437 $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
439 die "Template file $Template is not readable" if ( ! -r "$Template" );
441 if ( $PlotScriptFilename eq "" ) {
442 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
444 die "GNUPlot Script $PlotScriptFilename is not readable" if ( ! -r "$PlotScriptFilename" );
446 # Read in the HTML template file...
447 if ( $VERBOSE ) { print "READING TEMPLATE\n"; }
448 my $TemplateContents = ReadFile $Template;
451 # Get some static statistics about the current state of CVS
453 my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
454 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
455 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
456 $LOC = `utils/countloc.sh`;
459 # Build the entire tree, saving build messages to the build log
462 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
463 system "(time -p $NICE ./configure $CONFIGUREARGS --enable-spec --with-objroot=.) > $BuildLog 2>&1";
465 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
466 # Build the entire tree, capturing the output into $BuildLog
467 system "(time -p $NICE gmake $MAKEOPTS) >> $BuildLog 2>&1";
472 # Get some statistics about the build...
474 my @Linked = split '\n', `grep Linking $BuildLog`;
475 my $NumExecutables = scalar(grep(/executable/, @Linked));
476 my $NumLibraries = scalar(grep(!/executable/, @Linked));
477 my $NumObjects = `grep '^Compiling' $BuildLog | wc -l` + 0;
479 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
480 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
481 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
482 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
484 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
485 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
486 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
487 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
490 if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
491 `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
492 $BuildError = "<h3><font color='red'>Build error: compilation " .
493 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
494 if ($VERBOSE) { print "BUILD ERROR\n"; }
497 if ($BuildError) { $NOFEATURES = 1; $NOREGRESSIONS = 1; $RUNDEJAGNU=0; }
499 # Get results of feature tests.
500 my $FeatureTestResults; # String containing the results of the feature tests
501 my $FeatureTime; # System+CPU Time for feature tests
502 my $FeatureWallTime; # Wall Clock Time for feature tests
504 if ( $VERBOSE ) { print "FEATURE TEST STAGE\n"; }
505 my $feature_output = "$FeatureTestsLog";
507 # Run the feature tests so we can summarize the results
508 system "(time -p gmake $MAKEOPTS -C test Feature.t) > $feature_output 2>&1";
510 # Extract test results
511 $FeatureTestResults = GetQMTestResults("$feature_output");
513 # Extract time of feature tests
514 my $FeatureTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$feature_output";
515 my $FeatureTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$feature_output";
516 $FeatureTime = $FeatureTimeU+$FeatureTimeS; # FeatureTime = User+System
517 $FeatureWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$feature_output";
518 # Run the regression tests so we can summarize the results
520 $FeatureTestResults = "Skipped by user choice.";
521 $FeatureTime = "0.0";
522 $FeatureWallTime = "0.0";
525 if (!$NOREGRESSIONS) {
526 if ( $VERBOSE ) { print "REGRESSION TEST STAGE\n"; }
527 my $regression_output = "$RegressionTestsLog";
529 # Run the regression tests so we can summarize the results
530 system "(time -p gmake $MAKEOPTS -C test Regression.t) > $regression_output 2>&1";
532 # Extract test results
533 $RegressionTestResults = GetQMTestResults("$regression_output");
535 # Extract time of regressions tests
536 my $RegressionTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$regression_output";
537 my $RegressionTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$regression_output";
538 $RegressionTime = $RegressionTimeU+$RegressionTimeS; # RegressionTime = User+System
539 $RegressionWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$regression_output";
541 $RegressionTestResults = "Skipped by user choice.";
542 $RegressionTime = "0.0";
543 $RegressionWallTime = "0.0";
546 my $DejangnuTestResults; # String containing the results of the dejagnu
548 if($VERBOSE) { print "DEJAGNU FEATURE/REGRESSION TEST STAGE\n"; }
550 my $dejagnu_output = "$DejagnuTestsLog";
552 #Run the feature and regression tests, results are put into testrun.sum
553 #Full log in testrun.log
554 system "time -p gmake $MAKEOPTS check-dejagnu >& $dejagnu_output";
556 #Extract time of dejagnu tests
557 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
558 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
559 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
560 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
562 #Copy the testrun.log and testrun.sum to our webdir
563 CopyFile("test/testrun.log", $DejagnuLog);
564 CopyFile("test/testrun.sum", $DejagnuSum);
566 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
568 $DejagnuTestResults = "Skipped by user choice.";
569 $DejagnuTime = "0.0";
570 $DejagnuWallTime = "0.0";
574 print $FeatureTestResults;
575 print $RegressionTestResults;
576 print $DejagnuTestResults;
579 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
581 # Get warnings from the build
583 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
587 foreach $Warning (@Warn) {
588 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
589 $CurDir = $1; # Keep track of directory warning is in...
590 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
594 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
597 my $WarningsFile = join "\n", @Warnings;
598 my $WarningsList = AddPreTag $WarningsFile;
599 $WarningsFile =~ s/:[0-9]+:/::/g;
601 # Emit the warnings file, so we can diff...
602 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
603 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
605 # Output something to stdout if something has changed
606 print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
607 print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
609 $WarningsAdded = AddPreTag $WarningsAdded;
610 $WarningsRemoved = AddPreTag $WarningsRemoved;
613 # Get some statistics about CVS commits over the current day...
615 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
616 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
617 #print join "\n", @CVSHistory; print "\n";
619 # Extract some information from the CVS history... use a hash so no duplicate
621 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
623 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
625 # Loop over every record from the CVS history, filling in the hashes.
626 foreach $File (@CVSHistory) {
627 my ($Type, $Date, $UID, $Rev, $Filename);
628 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
629 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
630 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
631 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
632 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
633 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
635 print "UNMATCHABLE: $File\n";
638 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
640 if ($Filename =~ /^llvm/) {
641 if ($Type eq 'M') { # Modified
642 $ModifiedFiles{$Filename} = 1;
643 $UsersCommitted{$UID} = 1;
644 } elsif ($Type eq 'A') { # Added
645 $AddedFiles{$Filename} = 1;
646 $UsersCommitted{$UID} = 1;
647 } elsif ($Type eq 'R') { # Removed
648 $RemovedFiles{$Filename} = 1;
649 $UsersCommitted{$UID} = 1;
651 $UsersUpdated{$UID} = 1;
656 my $UserCommitList = join "\n", keys %UsersCommitted;
657 my $UserUpdateList = join "\n", keys %UsersUpdated;
658 my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
659 my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
660 my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
663 my $SingleSourceProgramsTable = "!";
664 my $MultiSourceProgramsTable = "!";
665 my $ExternalProgramsTable = "!";
671 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
673 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
675 # Run the programs tests... creating a report.nightly.html file
677 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
678 . "TEST=nightly > $ProgramTestLog 2>&1";
680 system "gunzip ${ProgramTestLog}.gz";
684 if (`grep '^gmake[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
686 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
687 print "ERROR TESTING\n";
688 } elsif (`grep '^gmake[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
691 "<font color=white><h2>Makefile error running tests!</h2></font>";
692 print "ERROR TESTING\n";
695 $ProgramsTable = ReadFile "report.nightly.html";
698 # Create a list of the tests which were run...
700 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
701 . "| sort > $Prefix-$SubDir-Tests.txt";
704 # Compress the test output
705 system "gzip -f $ProgramTestLog";
706 ChangeDir( "../../..", "Programs Test Parent Directory" );
707 return $ProgramsTable;
710 # If we built the tree successfully, run the nightly programs tests...
711 if ($BuildError eq "") {
713 print "SingleSource TEST STAGE\n";
715 $SingleSourceProgramsTable = TestDirectory("SingleSource");
717 print "MultiSource TEST STAGE\n";
719 $MultiSourceProgramsTable = TestDirectory("MultiSource");
720 if ( ! $NOEXTERNALS ) {
722 print "External TEST STAGE\n";
724 $ExternalProgramsTable = TestDirectory("External");
725 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
726 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
729 print "External TEST STAGE SKIPPED\n";
731 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
732 " | sort > $Prefix-Tests.txt";
736 if ( $VERBOSE ) { print "TEST INFORMATION COLLECTION STAGE\n"; }
737 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
740 $TestsAdded = "<b>error testing</b><br>";
741 $TestsRemoved = "<b>error testing</b><br>";
742 $TestsFixed = "<b>error testing</b><br>";
743 $TestsBroken = "<b>error testing</b><br>";
745 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
747 my @RawTestsAddedArray = split '\n', $RTestsAdded;
748 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
750 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
751 @RawTestsRemovedArray;
752 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
755 foreach $Test (keys %NewTests) {
756 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
757 $TestsAdded = "$TestsAdded$Test\n";
759 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
760 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
762 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
766 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
767 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
770 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
771 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
772 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
773 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
775 $TestsAdded = AddPreTag $TestsAdded;
776 $TestsRemoved = AddPreTag $TestsRemoved;
777 $TestsFixed = AddPreTag $TestsFixed;
778 $TestsBroken = AddPreTag $TestsBroken;
782 # If we built the tree successfully, runs of the Olden suite with
783 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
784 if ($BuildError eq "") {
785 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
786 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
787 $MachCodeSize) = ("","","","","","","");
788 if (!$NORUNNINGTESTS) {
789 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
790 "Olden Test Directory");
792 # Clean out previous results...
793 system "$NICE gmake $MAKEOPTS clean > /dev/null 2>&1";
795 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
796 # GET_STABLE_NUMBERS enabled!
797 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
798 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
799 system "cp report.nightly.raw.out $OldenTestsLog";
801 system "gunzip ${OldenTestsLog}.gz";
804 # Now we know we have $OldenTestsLog as the raw output file. Split
805 # it up into records and read the useful information.
806 my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
807 shift @Records; # Delete the first (garbage) record
809 # Loop over all of the records, summarizing them into rows for the running
811 my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
812 foreach $Rec (@Records) {
813 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
814 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
815 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
816 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
817 my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
818 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
819 my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
821 $NATTime .= " " . FormatTime($rNATTime);
822 $CBETime .= " " . FormatTime($rCBETime);
823 $LLCTime .= " " . FormatTime($rLLCTime);
824 $JITTime .= " " . FormatTime($rJITTime);
825 $OptTime .= " $rOptTime";
826 $BytecodeSize .= " $rBytecodeSize";
827 $MachCodeSize .= " $rMachCodeSize";
830 # Now that we have all of the numbers we want, add them to the running totals
832 AddRecord($NATTime, "running_Olden_nat_time.txt");
833 AddRecord($CBETime, "running_Olden_cbe_time.txt");
834 AddRecord($LLCTime, "running_Olden_llc_time.txt");
835 AddRecord($JITTime, "running_Olden_jit_time.txt");
836 AddRecord($OptTime, "running_Olden_opt_time.txt");
837 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
838 AddRecord($MachCodeSize, "running_Olden_machcode.txt");
840 system "gzip -f $OldenTestsLog";
845 # Get a list of the previous days that we can link to...
847 my @PrevDays = map {s/.html//; $_} GetDir ".html";
849 if ((scalar @PrevDays) > 20) {
850 splice @PrevDays, 20; # Trim down list to something reasonable...
853 # Format list for sidebar
854 my $PrevDaysList = join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
857 # Start outputting files into the web directory
859 ChangeDir( $WebDir, "Web Directory" );
861 # Make sure we don't get errors running the nightly tester the first time
862 # because of files that don't exist.
863 Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
864 'running_loc.txt', 'running_Olden_machcode.txt',
865 'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
866 'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
867 'running_Olden_jit_time.txt');
869 # Add information to the files which accumulate information for graphs...
870 AddRecord($LOC, "running_loc.txt");
871 AddRecord($BuildTime, "running_build_time.txt");
874 print "GRAPH GENERATION STAGE\n";
877 # Rebuild the graphs now...
879 $GNUPLOT = "/usr/bin/gnuplot";
880 $GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
881 system ("$GNUPLOT", $PlotScriptFilename);
884 # Remove the cvs tree...
886 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
889 # Print out information...
892 print "DateString: $DateString\n";
893 print "CVS Checkout: $CVSCheckoutTime seconds\n";
894 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
895 print "Build Time: $BuildTime seconds\n";
896 print "Feature Test Time: $FeatureTime seconds\n";
897 print "Regression Test Time: $RegressionTime seconds\n";
898 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
900 print "WARNINGS:\n $WarningsList\n";
902 print "Users committed: $UserCommitList\n";
903 print "Added Files: \n $AddedFilesList\n";
904 print "Modified Files: \n $ModifiedFilesList\n";
905 print "Removed Files: \n $RemovedFilesList\n";
907 print "Previous Days =\n $PrevDaysList\n";
912 # Output the files...
916 print "OUTPUT STAGE\n";
920 my $TestFinishTime = gmtime;
921 my $TestPlatform = `uname -a`;
922 eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
923 WriteFile "$DATE.html", $Output;
924 system ( "ln -sf $DATE.html index.html" );
926 # Change the index.html symlink...