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 # -notest Do not even attempt to run the test programs. Implies
18 # -norunningtests Do not run the Olden benchmark suite with
19 # LARGE_PROBLEM_SIZE enabled.
20 # -noexternals Do not run the external tests (for cases where povray
21 # or SPEC are not installed)
22 # -with-externals Specify a directory where the external tests are located.
23 # -nodejagnu Do not run feature or regression tests
24 # -parallel Run two parallel jobs with GNU Make.
25 # -release Build an LLVM Release version
26 # -enable-llcbeta Enable testing of beta features in llc.
27 # -disable-llc Disable LLC tests in the nightly tester.
28 # -disable-jit Disable JIT tests in the nightly tester.
29 # -verbose Turn on some debug output
30 # -debug Print information useful only to maintainers of this script.
31 # -nice Checkout/Configure/Build with "nice" to reduce impact
33 # -f2c Next argument specifies path to F2C utility
34 # -gnuplotscript Next argument specifies gnuplot script to use
35 # -templatefile Next argument specifies template file to use
36 # -gccpath Path to gcc/g++ used to build LLVM
37 # -cvstag Check out a specific CVS tag to build LLVM (useful for
38 # testing release branches)
39 # -target Specify the target triplet
40 # -cflags Next argument specifies that C compilation options that
41 # override the default.
42 # -cxxflags Next argument specifies that C++ compilation options that
43 # override the default.
44 # -ldflags Next argument specifies that linker options that override
47 # ---------------- Options to configure llvm-test ----------------------------
48 # -spec2000path Path to the benchspec directory in the SPEC 2000 distro
49 # -spec95path Path to the benchspec directory in the SPEC 95 distro.
50 # -povraypath Path to the povray sources
51 # -namdpath Path to the namd sources
53 # CVSROOT is the CVS repository from which the tree will be checked out,
54 # specified either in the full :method:user@host:/dir syntax, or
55 # just /dir if using a local repo.
56 # BUILDDIR is the directory where sources for this test run will be checked out
57 # AND objects for this test run will be built. This directory MUST NOT
58 # exist before the script is run; it will be created by the cvs checkout
59 # process and erased (unless -noremove is specified; see above.)
60 # WEBDIR is the directory into which the test results web page will be written,
61 # AND in which the "index.html" is assumed to be a symlink to the most recent
62 # copy of the results. This directory will be created if it does not exist.
63 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
64 # to. This is the same as you would have for a normal LLVM build.
66 use POSIX qw(strftime);
69 my $HOME = $ENV{'HOME'};
70 my $CVSRootDir = $ENV{'CVSROOT'};
71 $CVSRootDir = "/home/vadve/shared/PublicCVS"
73 my $BuildDir = $ENV{'BUILDDIR'};
74 $BuildDir = "$HOME/buildtest"
76 my $WebDir = $ENV{'WEBDIR'};
77 $WebDir = "$HOME/cvs/testresults-X86"
80 # Calculate the date prefix...
82 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
83 my $DateString = strftime "%B %d, %Y", localtime;
84 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
86 # Command line argument settings...
90 my $NORUNNINGTESTS = 0;
93 my $PROGTESTOPTS = "";
96 my $CONFIGUREARGS = "";
97 my $CVSCOOPT = "-APR";
101 my $LLVMTESTCONFIGARGS = "";
104 if (open (FILE, $_[0])) {
111 print "Could not open file '$_[0]' for reading!";
116 sub WriteFile { # (filename, contents)
117 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
122 sub GetRegex { # (Regex with ()'s, value)
133 foreach my $file (@files) {
135 open (FILE, ">$file") or warn "Could not create new file $file";
138 utime $now, $now, $file;
143 my ($Val, $Filename) = @_;
145 if (open FILE, "$WebDir/$Filename") {
146 @Records = grep !/$DATE/, split "\n", <FILE>;
149 push @Records, "$DATE: $Val";
150 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
153 sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
155 if (length) { return "<pre>$_</pre>"; } else { "<b>none</b><br>"; }
158 sub ArrayToList { # Add <li> tags around nonempty list or convert to "none"
163 $result .= "<li><tt>$item</tt></li>";
167 $result = "<p><b>none</b></p>";
172 sub ChangeDir { # directory, logical name
173 my ($dir,$name) = @_;
175 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
176 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
179 sub CopyFile { #filename, newfile
180 my ($file, $newfile) = @_;
182 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
183 copy($file, $newfile);
189 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
194 # DiffFiles - Diff the current version of the file against the last version of
195 # the file, reporting things added and removed. This is used to report, for
196 # example, added and removed warnings. This returns a pair (added, removed)
200 my @Others = GetDir $Suffix;
201 if (@Others == 0) { # No other files? We added all entries...
202 return (`cat $WebDir/$DATE$Suffix`, "");
204 # Diff the files now...
205 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
206 my $Added = join "\n", grep /^</, @Diffs;
207 my $Removed = join "\n", grep /^>/, @Diffs;
209 $Removed =~ s/^> //gm;
210 return ($Added, $Removed);
213 # FormatTime - Convert a time from 1m23.45 into 83.45
216 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
217 $Time = sprintf("%7.4f", $1*60.0+$2);
223 my ($Regex, $Num, $Regex2, $File) = @_;
224 my @Items = split "\n", `grep '$Regex' $File`;
225 return GetRegex $Regex2, $Items[$Num];
228 sub GetDejagnuTestResults { # (filename, log)
229 my ($filename, $DejagnuLog) = @_;
232 $/ = "\n"; #Make sure we're going line at a time.
234 print "DEJAGNU TEST RESULTS:\n";
236 if (open SRCHFILE, $filename) {
237 # Process test results
239 my $should_break = 1;
242 while ( <SRCHFILE> ) {
243 if ( length($_) > 1 ) {
245 if ( m/^XPASS:/ || m/^FAIL:/ ) {
248 push(@lines, "<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
251 push(@lines, "<b>$_</b><br/>\n");
254 push(@lines, "</li><li><b>$_</b><br/>\n");
257 } elsif ( m/Summary/ ) {
259 push(@lines, "<b>PERFECT!</b>");
262 push(@lines, "</li></ol>\n");
264 push(@lines, "<h3>STATISTICS</h3><pre>\n");
265 print "\nDEJAGNU STATISTICS:\n";
269 } elsif ( $readingsum ) {
276 push(@lines, "</pre>\n");
279 my $content = join("", @lines);
280 return "$content</li></ol>\n";
284 #####################################################################
286 #####################################################################
289 my $PlotScriptFilename = "";
292 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
294 last if /^--$/; # Stop processing arguments on --
296 # List command line options here...
297 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
298 if (/^-noremove$/) { $NOREMOVE = 1; next; }
299 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
300 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
301 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
302 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
303 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
304 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
305 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
306 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
307 $CONFIGUREARGS .= " --disable-jit"; next; }
308 if (/^-verbose$/) { $VERBOSE = 1; next; }
309 if (/^-debug$/) { $DEBUG = 1; next; }
310 if (/^-nice$/) { $NICE = "nice "; next; }
312 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
314 if (/^-with-externals/) {
315 $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next
317 if (/^-gnuplotscript$/) { $PlotScriptFilename = $ARGV[0]; shift; next; }
318 if (/^-templatefile$/) { $Template = $ARGV[0]; shift; next; }
320 $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;
322 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
324 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
327 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
330 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
333 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
335 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
336 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
337 if (/^-spec2000path$/) {
338 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
340 if (/^-spec95path$/) {
341 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
343 if (/^-povraypath$/) {
344 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
347 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
349 print "Unknown option: $_ : ignoring!\n";
352 if ($ENV{'LLVMGCCDIR'}) {
353 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
355 if ($CONFIGUREARGS !~ /--disable-jit/) {
356 $CONFIGUREARGS .= " --enable-jit";
359 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
362 $CVSRootDir = $ARGV[0];
363 $BuildDir = $ARGV[1];
367 my $Prefix = "$WebDir/$DATE";
369 #define the file names we'll use
370 my $BuildLog = "$Prefix-Build-Log.txt";
371 my $CVSLog = "$Prefix-CVS-Log.txt";
372 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
373 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
374 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
375 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
376 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
377 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
378 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
381 print "INITIALIZED\n";
382 print "CVS Root = $CVSRootDir\n";
383 print "BuildDir = $BuildDir\n";
384 print "WebDir = $WebDir\n";
385 print "Prefix = $Prefix\n";
386 print "CVSLog = $CVSLog\n";
387 print "BuildLog = $BuildLog\n";
392 warn "Warning: $WebDir did not exist; creating it.\n";
396 # Create the CVS repository directory
401 system "rm -rf $BuildDir";
403 die "CVS checkout directory $BuildDir already exists!";
406 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
409 ChangeDir( $BuildDir, "CVS checkout directory" );
413 # Check out the llvm tree, saving CVS messages to the cvs log...
416 # Use compression if going over ssh.
417 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
418 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
420 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
421 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
422 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
423 ChangeDir( $BuildDir , "CVS Checkout directory") ;
426 ChangeDir( "llvm" , "llvm source directory") ;
429 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
430 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
433 if ( $Template eq "" ) {
434 $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
436 die "Template file $Template is not readable" if ( ! -r "$Template" );
438 if ( $PlotScriptFilename eq "" ) {
439 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
441 die "GNUPlot Script $PlotScriptFilename is not readable" if ( ! -r "$PlotScriptFilename" );
443 # Read in the HTML template file...
444 if ( $VERBOSE ) { print "READING TEMPLATE\n"; }
445 my $TemplateContents = ReadFile $Template;
448 # Get some static statistics about the current state of CVS
450 my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
451 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
452 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
453 $LOC = `utils/countloc.sh`;
456 # Build the entire tree, saving build messages to the build log
459 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
460 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
461 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
463 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
464 # Build the entire tree, capturing the output into $BuildLog
465 system "(time -p $NICE gmake $MAKEOPTS) >> $BuildLog 2>&1";
470 # Get some statistics about the build...
472 my @Linked = split '\n', `grep Linking $BuildLog`;
473 my $NumExecutables = scalar(grep(/executable/, @Linked));
474 my $NumLibraries = scalar(grep(!/executable/, @Linked));
475 my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
477 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
478 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
479 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
480 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
482 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
483 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
484 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
485 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
487 my $BuildError = 0, $BuildStatus = "OK";
488 if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
489 `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
490 $BuildStatus = "<h3><font color='red'>error: compilation " .
491 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
493 print "\n***ERROR BUILDING TREE\n\n";
496 if ($BuildError) { $NODEJAGNU=1; }
498 my $DejangnuTestResults; # String containing the results of the dejagnu
500 if($VERBOSE) { print "DEJAGNU FEATURE/REGRESSION TEST STAGE\n"; }
502 my $dejagnu_output = "$DejagnuTestsLog";
504 #Run the feature and regression tests, results are put into testrun.sum
505 #Full log in testrun.log
506 system "(time -p gmake $MAKEOPTS check) > $dejagnu_output 2>&1";
508 #Extract time of dejagnu tests
509 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
510 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
511 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
512 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
514 #Copy the testrun.log and testrun.sum to our webdir
515 CopyFile("test/testrun.log", $DejagnuLog);
516 CopyFile("test/testrun.sum", $DejagnuSum);
518 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
521 $DejagnuTestResults = "Skipped by user choice.";
522 $DejagnuTime = "0.0";
523 $DejagnuWallTime = "0.0";
527 print $DejagnuTestResults;
530 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
532 # Get warnings from the build
534 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
538 foreach $Warning (@Warn) {
539 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
540 $CurDir = $1; # Keep track of directory warning is in...
541 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
545 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
548 my $WarningsFile = join "\n", @Warnings;
549 my $WarningsList = ArrayToList @Warnings;
550 $WarningsFile =~ s/:[0-9]+:/::/g;
552 # Emit the warnings file, so we can diff...
553 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
554 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
556 # Output something to stdout if something has changed
557 print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
558 print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
560 my @TmpWarningsAdded = split "\n", $WarningsAdded;
561 my @TmpWarningsRemoved = split "\n", $WarningsRemoved;
562 $WarningsAdded = ArrayToList @TmpWarningsAdded;
563 $WarningsRemoved = ArrayToList @TmpWarningsRemoved;
566 # Get some statistics about CVS commits over the current day...
568 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
569 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
570 #print join "\n", @CVSHistory; print "\n";
572 # Extract some information from the CVS history... use a hash so no duplicate
574 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
576 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
578 # Loop over every record from the CVS history, filling in the hashes.
579 foreach $File (@CVSHistory) {
580 my ($Type, $Date, $UID, $Rev, $Filename);
581 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
582 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
583 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
584 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
585 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
586 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
588 print "UNMATCHABLE: $File\n";
591 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
593 if ($Filename =~ /^llvm/) {
594 if ($Type eq 'M') { # Modified
595 $ModifiedFiles{$Filename} = 1;
596 $UsersCommitted{$UID} = 1;
597 } elsif ($Type eq 'A') { # Added
598 $AddedFiles{$Filename} = 1;
599 $UsersCommitted{$UID} = 1;
600 } elsif ($Type eq 'R') { # Removed
601 $RemovedFiles{$Filename} = 1;
602 $UsersCommitted{$UID} = 1;
604 $UsersUpdated{$UID} = 1;
609 my $UserCommitList = join "\n", sort keys %UsersCommitted;
610 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
611 my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
612 my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
613 my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
616 my $SingleSourceProgramsTable = "!";
617 my $MultiSourceProgramsTable = "!";
618 my $ExternalProgramsTable = "!";
624 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
626 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
628 # Run the programs tests... creating a report.nightly.html file
630 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
631 . "TEST=nightly > $ProgramTestLog 2>&1";
633 system "gunzip ${ProgramTestLog}.gz";
637 if (`grep '^gmake[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
639 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
640 print "ERROR TESTING\n";
641 } elsif (`grep '^gmake[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
644 "<font color=white><h2>Makefile error running tests!</h2></font>";
645 print "ERROR TESTING\n";
648 $ProgramsTable = ReadFile "report.nightly.html";
651 # Create a list of the tests which were run...
653 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
654 . "| sort > $Prefix-$SubDir-Tests.txt";
657 # Compress the test output
658 system "gzip -f $ProgramTestLog";
659 ChangeDir( "../../..", "Programs Test Parent Directory" );
660 return $ProgramsTable;
663 # If we built the tree successfully, run the nightly programs tests...
666 print "SingleSource TEST STAGE\n";
668 $SingleSourceProgramsTable = TestDirectory("SingleSource");
670 print "MultiSource TEST STAGE\n";
672 $MultiSourceProgramsTable = TestDirectory("MultiSource");
673 if ( ! $NOEXTERNALS ) {
675 print "External TEST STAGE\n";
677 $ExternalProgramsTable = TestDirectory("External");
678 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
679 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
681 $ExternalProgramsTable = '<tr><td>External TEST STAGE SKIPPED</td></tr>';
683 print "External TEST STAGE SKIPPED\n";
685 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
686 " | sort > $Prefix-Tests.txt";
690 if ( $VERBOSE ) { print "TEST INFORMATION COLLECTION STAGE\n"; }
691 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
694 $TestsAdded = "<b>error testing</b><br>";
695 $TestsRemoved = "<b>error testing</b><br>";
696 $TestsFixed = "<b>error testing</b><br>";
697 $TestsBroken = "<b>error testing</b><br>";
699 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
701 my @RawTestsAddedArray = split '\n', $RTestsAdded;
702 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
704 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
705 @RawTestsRemovedArray;
706 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
709 foreach $Test (keys %NewTests) {
710 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
711 $TestsAdded = "$TestsAdded$Test\n";
713 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
714 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
716 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
720 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
721 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
724 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
725 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
726 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
727 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
729 $TestsAdded = AddPreTag $TestsAdded;
730 $TestsRemoved = AddPreTag $TestsRemoved;
731 $TestsFixed = AddPreTag $TestsFixed;
732 $TestsBroken = AddPreTag $TestsBroken;
736 # If we built the tree successfully, runs of the Olden suite with
737 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
739 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
740 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
741 $MachCodeSize) = ("","","","","","","");
742 if (!$NORUNNINGTESTS) {
743 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
744 "Olden Test Directory");
746 # Clean out previous results...
747 system "$NICE gmake $MAKEOPTS clean > /dev/null 2>&1";
749 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
750 # GET_STABLE_NUMBERS enabled!
751 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
752 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
753 system "cp report.nightly.raw.out $OldenTestsLog";
755 system "gunzip ${OldenTestsLog}.gz";
758 # Now we know we have $OldenTestsLog as the raw output file. Split
759 # it up into records and read the useful information.
760 my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
761 shift @Records; # Delete the first (garbage) record
763 # Loop over all of the records, summarizing them into rows for the running
765 my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
766 foreach $Rec (@Records) {
767 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
768 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
769 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
770 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
771 my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
772 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
774 $NATTime .= " " . FormatTime($rNATTime);
775 $CBETime .= " " . FormatTime($rCBETime);
776 $LLCTime .= " " . FormatTime($rLLCTime);
777 $JITTime .= " " . FormatTime($rJITTime);
778 $OptTime .= " $rOptTime";
779 $BytecodeSize .= " $rBytecodeSize";
782 # Now that we have all of the numbers we want, add them to the running totals
784 AddRecord($NATTime, "running_Olden_nat_time.txt");
785 AddRecord($CBETime, "running_Olden_cbe_time.txt");
786 AddRecord($LLCTime, "running_Olden_llc_time.txt");
787 AddRecord($JITTime, "running_Olden_jit_time.txt");
788 AddRecord($OptTime, "running_Olden_opt_time.txt");
789 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
791 system "gzip -f $OldenTestsLog";
796 # Get a list of the previous days that we can link to...
798 my @PrevDays = map {s/.html//; $_} GetDir ".html";
800 if ((scalar @PrevDays) > 20) {
801 splice @PrevDays, 20; # Trim down list to something reasonable...
804 # Format list for sidebar
805 my $PrevDaysList = join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
808 # Start outputting files into the web directory
810 ChangeDir( $WebDir, "Web Directory" );
812 # Make sure we don't get errors running the nightly tester the first time
813 # because of files that don't exist.
814 Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
816 'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
817 'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
818 'running_Olden_jit_time.txt');
820 # Add information to the files which accumulate information for graphs...
821 AddRecord($LOC, "running_loc.txt");
822 AddRecord($BuildTime, "running_build_time.txt");
825 print "GRAPH GENERATION STAGE\n";
828 # Rebuild the graphs now...
830 $GNUPLOT = "/usr/bin/gnuplot";
831 $GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
832 system ("$GNUPLOT", $PlotScriptFilename);
835 # Remove the cvs tree...
837 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
839 print "\nUSERS WHO COMMITTED:\n " . (join "\n ", sort keys %UsersCommitted) . "\n"
840 if (scalar %UsersCommitted);
842 print "\nADDED FILES:\n " . (join "\n ", sort keys %AddedFiles) . "\n"
843 if (scalar %AddedFiles);
845 print "\nCHANGED FILES:\n " . (join "\n ", sort keys %ModifiedFiles) . "\n"
846 if (scalar %ModifiedFiles);
848 print "\nREMOVED FILES:\n " . (join "\n ", sort keys %RemovedFiles) . "\n"
849 if (scalar %RemovedFiles);
852 # Print out information...
855 print "DateString: $DateString\n";
856 print "CVS Checkout: $CVSCheckoutTime seconds\n";
857 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
858 print "Build Time: $BuildTime seconds\n";
859 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
861 print "WARNINGS:\n $WarningsList\n";
862 print "Previous Days =\n $PrevDaysList\n";
867 # Output the files...
871 print "OUTPUT STAGE\n";
875 my $TestFinishTime = gmtime() . " GMT<br>" . localtime() . " (local)";
877 my $TestPlatform = `uname -a`;
878 eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
879 WriteFile "$DATE.html", $Output;
881 # Remove the symlink before creating it for systems that don't have "ln -sf".
882 system ("rm index.html");
883 system ("ln -s $DATE.html index.html");
885 # Change the index.html symlink...