Added the ability to xfail based on llvmgcc version
[llvm-complete.git] / utils / NightlyTest.pl
blobf2a8de0bc577c4838a31f971f3e325c5532aacb6
1 #!/usr/bin/perl -w
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]
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 # -notest Do not even attempt to run the test programs. Implies
17 # -norunningtests.
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 # -nodejagnu Do not run feature or regression tests
23 # -parallel Run two parallel jobs with GNU Make.
24 # -release Build an LLVM Release version
25 # -enable-llcbeta Enable testing of beta features in llc.
26 # -disable-llc Disable LLC tests in the nightly tester.
27 # -disable-jit Disable JIT tests in the nightly tester.
28 # -verbose Turn on some debug output
29 # -debug Print information useful only to maintainers of this script.
30 # -nice Checkout/Configure/Build with "nice" to reduce impact
31 # on busy servers.
32 # -f2c Next argument specifies path to F2C utility
33 # -gnuplotscript Next argument specifies gnuplot script to use
34 # -templatefile Next argument specifies template file to use
35 # -gccpath Path to gcc/g++ used to build LLVM
36 # -cvstag Check out a specific CVS tag to build LLVM (useful for
37 # testing release branches)
38 # -target Specify the target triplet
39 # -cflags Next argument specifies that C compilation options that
40 # override the default.
41 # -cxxflags Next argument specifies that C++ compilation options that
42 # override the default.
43 # -ldflags Next argument specifies that linker options that override
44 # the default.
46 # ---------------- Options to configure llvm-test ----------------------------
47 # -spec2000path Path to the benchspec directory in the SPEC 2000 distro
48 # -spec95path Path to the benchspec directory in the SPEC 95 distro.
49 # -povraypath Path to the povray sources
50 # -namdpath Path to the namd sources
52 # CVSROOT is the CVS repository from which the tree will be checked out,
53 # specified either in the full :method:user@host:/dir syntax, or
54 # just /dir if using a local repo.
55 # BUILDDIR is the directory where sources for this test run will be checked out
56 # AND objects for this test run will be built. This directory MUST NOT
57 # exist before the script is run; it will be created by the cvs checkout
58 # process and erased (unless -noremove is specified; see above.)
59 # WEBDIR is the directory into which the test results web page will be written,
60 # AND in which the "index.html" is assumed to be a symlink to the most recent
61 # copy of the results. This directory will be created if it does not exist.
62 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
63 # to. This is the same as you would have for a normal LLVM build.
65 use POSIX qw(strftime);
66 use File::Copy;
68 my $HOME = $ENV{'HOME'};
69 my $CVSRootDir = $ENV{'CVSROOT'};
70 $CVSRootDir = "/home/vadve/shared/PublicCVS"
71 unless $CVSRootDir;
72 my $BuildDir = $ENV{'BUILDDIR'};
73 $BuildDir = "$HOME/buildtest"
74 unless $BuildDir;
75 my $WebDir = $ENV{'WEBDIR'};
76 $WebDir = "$HOME/cvs/testresults-X86"
77 unless $WebDir;
79 # Calculate the date prefix...
80 @TIME = localtime;
81 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
82 my $DateString = strftime "%B %d, %Y", localtime;
83 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
85 # Command line argument settings...
86 my $NOCHECKOUT = 0;
87 my $NOREMOVE = 0;
88 my $NOTEST = 0;
89 my $NORUNNINGTESTS = 0;
90 my $NOEXTERNALS = 0;
91 my $MAKEOPTS = "";
92 my $PROGTESTOPTS = "";
93 my $VERBOSE = 0;
94 my $DEBUG = 0;
95 my $CONFIGUREARGS = "";
96 my $CVSCOOPT = "-APR";
97 my $NICE = "";
98 my $NODEJAGNU = 0;
100 my $LLVMTESTCONFIGARGS = "";
102 sub ReadFile {
103 if (open (FILE, $_[0])) {
104 undef $/;
105 my $Ret = <FILE>;
106 close FILE;
107 $/ = '\n';
108 return $Ret;
109 } else {
110 print "Could not open file '$_[0]' for reading!";
111 return "";
115 sub WriteFile { # (filename, contents)
116 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
117 print FILE $_[1];
118 close FILE;
121 sub GetRegex { # (Regex with ()'s, value)
122 $_[1] =~ /$_[0]/m;
123 if (defined($1)) {
124 return $1;
126 return "0";
129 sub Touch {
130 my @files = @_;
131 my $now = time;
132 foreach my $file (@files) {
133 if (! -f $file) {
134 open (FILE, ">$file") or warn "Could not create new file $file";
135 close FILE;
137 utime $now, $now, $file;
141 sub AddRecord {
142 my ($Val, $Filename) = @_;
143 my @Records;
144 if (open FILE, "$WebDir/$Filename") {
145 @Records = grep !/$DATE/, split "\n", <FILE>;
146 close FILE;
148 push @Records, "$DATE: $Val";
149 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
152 sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
153 $_ = shift;
154 if (length) { return "<pre>$_</pre>"; } else { "<b>none</b><br>"; }
157 sub ArrayToList { # Add <li> tags around nonempty list or convert to "none"
158 my $result = "";
159 if (scalar @_) {
160 $result = "<ul>";
161 foreach $item (@_) {
162 $result .= "<li><tt>$item</tt></li>";
164 $result .= "</ul>";
165 } else {
166 $result = "<p><b>none</b></p>";
168 return $result;
171 sub ChangeDir { # directory, logical name
172 my ($dir,$name) = @_;
173 chomp($dir);
174 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
175 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
178 sub CopyFile { #filename, newfile
179 my ($file, $newfile) = @_;
180 chomp($file);
181 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
182 copy($file, $newfile);
185 sub GetDir {
186 my $Suffix = shift;
187 opendir DH, $WebDir;
188 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
189 closedir DH;
190 return @Result;
193 # DiffFiles - Diff the current version of the file against the last version of
194 # the file, reporting things added and removed. This is used to report, for
195 # example, added and removed warnings. This returns a pair (added, removed)
197 sub DiffFiles {
198 my $Suffix = shift;
199 my @Others = GetDir $Suffix;
200 if (@Others == 0) { # No other files? We added all entries...
201 return (`cat $WebDir/$DATE$Suffix`, "");
203 # Diff the files now...
204 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
205 my $Added = join "\n", grep /^</, @Diffs;
206 my $Removed = join "\n", grep /^>/, @Diffs;
207 $Added =~ s/^< //gm;
208 $Removed =~ s/^> //gm;
209 return ($Added, $Removed);
212 # FormatTime - Convert a time from 1m23.45 into 83.45
213 sub FormatTime {
214 my $Time = shift;
215 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
216 $Time = sprintf("%7.4f", $1*60.0+$2);
218 return $Time;
221 sub GetRegexNum {
222 my ($Regex, $Num, $Regex2, $File) = @_;
223 my @Items = split "\n", `grep '$Regex' $File`;
224 return GetRegex $Regex2, $Items[$Num];
227 sub GetDejagnuTestResults { # (filename, log)
228 my ($filename, $DejagnuLog) = @_;
229 my @lines;
230 my $firstline;
231 $/ = "\n"; #Make sure we're going line at a time.
233 print "DEJAGNU TEST RESULTS:\n";
235 if (open SRCHFILE, $filename) {
236 # Process test results
237 my $first_list = 1;
238 my $should_break = 1;
239 my $nocopy = 0;
240 my $readingsum = 0;
241 while ( <SRCHFILE> ) {
242 if ( length($_) > 1 ) {
243 chomp($_);
244 if ( m/^XPASS:/ || m/^FAIL:/ ) {
245 $nocopy = 0;
246 if ( $first_list ) {
247 push(@lines, "<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
248 $first_list = 0;
249 $should_break = 1;
250 push(@lines, "<b>$_</b><br/>\n");
251 print " $_\n";
252 } else {
253 push(@lines, "</li><li><b>$_</b><br/>\n");
254 print " $_\n";
256 } elsif ( m/Summary/ ) {
257 if ( $first_list ) {
258 push(@lines, "<b>PERFECT!</b>");
259 print " PERFECT!\n";
260 } else {
261 push(@lines, "</li></ol>\n");
263 push(@lines, "<h3>STATISTICS</h3><pre>\n");
264 print "\nDEJAGNU STATISTICS:\n";
265 $should_break = 0;
266 $nocopy = 0;
267 $readingsum = 1;
268 } elsif ( $readingsum ) {
269 push(@lines,"$_\n");
270 print " $_\n";
275 push(@lines, "</pre>\n");
276 close SRCHFILE;
278 my $content = join("", @lines);
279 return "$content</li></ol>\n";
283 #####################################################################
284 ## MAIN PROGRAM
285 #####################################################################
287 my $Template = "";
288 my $PlotScriptFilename = "";
290 # Parse arguments...
291 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
292 shift;
293 last if /^--$/; # Stop processing arguments on --
295 # List command line options here...
296 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
297 if (/^-noremove$/) { $NOREMOVE = 1; next; }
298 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
299 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
300 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
301 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
302 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
303 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
304 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
305 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
306 $CONFIGUREARGS .= " --disable-jit"; next; }
307 if (/^-verbose$/) { $VERBOSE = 1; next; }
308 if (/^-debug$/) { $DEBUG = 1; next; }
309 if (/^-nice$/) { $NICE = "nice "; next; }
310 if (/^-f2c$/) {
311 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
313 if (/^-gnuplotscript$/) { $PlotScriptFilename = $ARGV[0]; shift; next; }
314 if (/^-templatefile$/) { $Template = $ARGV[0]; shift; next; }
315 if (/^-gccpath/) {
316 $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;
318 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
319 if (/^-target/) {
320 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
322 if (/^-cflags/) {
323 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
325 if (/^-cxxflags/) {
326 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
328 if (/^-ldflags/) {
329 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
331 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
332 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
333 if (/^-spec2000path$/) {
334 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
336 if (/^-spec95path$/) {
337 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
339 if (/^-povraypath$/) {
340 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
342 if (/^-namdpath$/) {
343 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
345 print "Unknown option: $_ : ignoring!\n";
348 if ($ENV{'LLVMGCCDIR'}) {
349 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
351 if ($CONFIGUREARGS !~ /--disable-jit/) {
352 $CONFIGUREARGS .= " --enable-jit";
355 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
357 if (@ARGV == 3) {
358 $CVSRootDir = $ARGV[0];
359 $BuildDir = $ARGV[1];
360 $WebDir = $ARGV[2];
363 my $Prefix = "$WebDir/$DATE";
365 #define the file names we'll use
366 my $BuildLog = "$Prefix-Build-Log.txt";
367 my $CVSLog = "$Prefix-CVS-Log.txt";
368 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
369 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
370 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
371 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
372 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
373 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
374 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
376 if ($VERBOSE) {
377 print "INITIALIZED\n";
378 print "CVS Root = $CVSRootDir\n";
379 print "BuildDir = $BuildDir\n";
380 print "WebDir = $WebDir\n";
381 print "Prefix = $Prefix\n";
382 print "CVSLog = $CVSLog\n";
383 print "BuildLog = $BuildLog\n";
386 if (! -d $WebDir) {
387 mkdir $WebDir, 0777;
388 warn "Warning: $WebDir did not exist; creating it.\n";
392 # Create the CVS repository directory
394 if (!$NOCHECKOUT) {
395 if (-d $BuildDir) {
396 if (!$NOREMOVE) {
397 system "rm -rf $BuildDir";
398 } else {
399 die "CVS checkout directory $BuildDir already exists!";
402 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
405 ChangeDir( $BuildDir, "CVS checkout directory" );
409 # Check out the llvm tree, saving CVS messages to the cvs log...
411 my $CVSOPT = "";
412 # Use compression if going over ssh.
413 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
414 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
415 if (!$NOCHECKOUT) {
416 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
417 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
418 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
419 ChangeDir( $BuildDir , "CVS Checkout directory") ;
422 ChangeDir( "llvm" , "llvm source directory") ;
424 if (!$NOCHECKOUT) {
425 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
426 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
429 if ( $Template eq "" ) {
430 $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
432 die "Template file $Template is not readable" if ( ! -r "$Template" );
434 if ( $PlotScriptFilename eq "" ) {
435 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
437 die "GNUPlot Script $PlotScriptFilename is not readable" if ( ! -r "$PlotScriptFilename" );
439 # Read in the HTML template file...
440 if ( $VERBOSE ) { print "READING TEMPLATE\n"; }
441 my $TemplateContents = ReadFile $Template;
444 # Get some static statistics about the current state of CVS
446 my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
447 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
448 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
449 $LOC = `utils/countloc.sh`;
452 # Build the entire tree, saving build messages to the build log
454 if (!$NOCHECKOUT) {
455 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
456 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
457 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
459 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
460 # Build the entire tree, capturing the output into $BuildLog
461 system "(time -p $NICE gmake $MAKEOPTS) >> $BuildLog 2>&1";
466 # Get some statistics about the build...
468 my @Linked = split '\n', `grep Linking $BuildLog`;
469 my $NumExecutables = scalar(grep(/executable/, @Linked));
470 my $NumLibraries = scalar(grep(!/executable/, @Linked));
471 my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
473 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
474 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
475 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
476 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
478 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
479 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
480 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
481 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
483 my $BuildError = 0, $BuildStatus = "OK";
484 if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
485 `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
486 $BuildStatus = "<h3><font color='red'>error: compilation " .
487 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
488 $BuildError = 1;
489 print "\n***ERROR BUILDING TREE\n\n";
492 if ($BuildError) { $NODEJAGNU=1; }
494 my $DejangnuTestResults; # String containing the results of the dejagnu
495 if(!$NODEJAGNU) {
496 if($VERBOSE) { print "DEJAGNU FEATURE/REGRESSION TEST STAGE\n"; }
498 my $dejagnu_output = "$DejagnuTestsLog";
500 #Run the feature and regression tests, results are put into testrun.sum
501 #Full log in testrun.log
502 system "(time -p gmake $MAKEOPTS check) > $dejagnu_output 2>&1";
504 #Extract time of dejagnu tests
505 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
506 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
507 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
508 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
510 #Copy the testrun.log and testrun.sum to our webdir
511 CopyFile("test/testrun.log", $DejagnuLog);
512 CopyFile("test/testrun.sum", $DejagnuSum);
514 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
516 } else {
517 $DejagnuTestResults = "Skipped by user choice.";
518 $DejagnuTime = "0.0";
519 $DejagnuWallTime = "0.0";
522 if ($DEBUG) {
523 print $DejagnuTestResults;
526 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
528 # Get warnings from the build
530 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
531 my @Warnings;
532 my $CurDir = "";
534 foreach $Warning (@Warn) {
535 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
536 $CurDir = $1; # Keep track of directory warning is in...
537 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
538 $CurDir = $1;
540 } else {
541 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
544 my $WarningsFile = join "\n", @Warnings;
545 my $WarningsList = ArrayToList @Warnings;
546 $WarningsFile =~ s/:[0-9]+:/::/g;
548 # Emit the warnings file, so we can diff...
549 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
550 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
552 # Output something to stdout if something has changed
553 print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
554 print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
556 my @TmpWarningsAdded = split "\n", $WarningsAdded;
557 my @TmpWarningsRemoved = split "\n", $WarningsRemoved;
558 $WarningsAdded = ArrayToList @TmpWarningsAdded;
559 $WarningsRemoved = ArrayToList @TmpWarningsRemoved;
562 # Get some statistics about CVS commits over the current day...
564 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
565 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
566 #print join "\n", @CVSHistory; print "\n";
568 # Extract some information from the CVS history... use a hash so no duplicate
569 # stuff is stored.
570 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
572 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
574 # Loop over every record from the CVS history, filling in the hashes.
575 foreach $File (@CVSHistory) {
576 my ($Type, $Date, $UID, $Rev, $Filename);
577 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
578 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
579 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
580 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
581 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
582 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
583 } else {
584 print "UNMATCHABLE: $File\n";
585 next;
587 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
589 if ($Filename =~ /^llvm/) {
590 if ($Type eq 'M') { # Modified
591 $ModifiedFiles{$Filename} = 1;
592 $UsersCommitted{$UID} = 1;
593 } elsif ($Type eq 'A') { # Added
594 $AddedFiles{$Filename} = 1;
595 $UsersCommitted{$UID} = 1;
596 } elsif ($Type eq 'R') { # Removed
597 $RemovedFiles{$Filename} = 1;
598 $UsersCommitted{$UID} = 1;
599 } else {
600 $UsersUpdated{$UID} = 1;
605 my $UserCommitList = join "\n", sort keys %UsersCommitted;
606 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
607 my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
608 my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
609 my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
611 my $TestError = 1;
612 my $SingleSourceProgramsTable = "!";
613 my $MultiSourceProgramsTable = "!";
614 my $ExternalProgramsTable = "!";
617 sub TestDirectory {
618 my $SubDir = shift;
620 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
622 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
624 # Run the programs tests... creating a report.nightly.html file
625 if (!$NOTEST) {
626 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
627 . "TEST=nightly > $ProgramTestLog 2>&1";
628 } else {
629 system "gunzip ${ProgramTestLog}.gz";
632 my $ProgramsTable;
633 if (`grep '^gmake[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
634 $TestError = 1;
635 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
636 print "ERROR TESTING\n";
637 } elsif (`grep '^gmake[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
638 $TestError = 1;
639 $ProgramsTable =
640 "<font color=white><h2>Makefile error running tests!</h2></font>";
641 print "ERROR TESTING\n";
642 } else {
643 $TestError = 0;
644 $ProgramsTable = ReadFile "report.nightly.html";
647 # Create a list of the tests which were run...
649 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
650 . "| sort > $Prefix-$SubDir-Tests.txt";
653 # Compress the test output
654 system "gzip -f $ProgramTestLog";
655 ChangeDir( "../../..", "Programs Test Parent Directory" );
656 return $ProgramsTable;
659 # If we built the tree successfully, run the nightly programs tests...
660 if (!$BuildError) {
661 if ( $VERBOSE ) {
662 print "SingleSource TEST STAGE\n";
664 $SingleSourceProgramsTable = TestDirectory("SingleSource");
665 if ( $VERBOSE ) {
666 print "MultiSource TEST STAGE\n";
668 $MultiSourceProgramsTable = TestDirectory("MultiSource");
669 if ( ! $NOEXTERNALS ) {
670 if ( $VERBOSE ) {
671 print "External TEST STAGE\n";
673 $ExternalProgramsTable = TestDirectory("External");
674 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
675 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
676 } else {
677 $ExternalProgramsTable = '<tr><td>External TEST STAGE SKIPPED</td></tr>';
678 if ( $VERBOSE ) {
679 print "External TEST STAGE SKIPPED\n";
681 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
682 " | sort > $Prefix-Tests.txt";
686 if ( $VERBOSE ) { print "TEST INFORMATION COLLECTION STAGE\n"; }
687 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
689 if ($TestError) {
690 $TestsAdded = "<b>error testing</b><br>";
691 $TestsRemoved = "<b>error testing</b><br>";
692 $TestsFixed = "<b>error testing</b><br>";
693 $TestsBroken = "<b>error testing</b><br>";
694 } else {
695 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
697 my @RawTestsAddedArray = split '\n', $RTestsAdded;
698 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
700 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
701 @RawTestsRemovedArray;
702 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
703 @RawTestsAddedArray;
705 foreach $Test (keys %NewTests) {
706 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
707 $TestsAdded = "$TestsAdded$Test\n";
708 } else {
709 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
710 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
711 } else {
712 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
716 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
717 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
720 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
721 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
722 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
723 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
725 $TestsAdded = AddPreTag $TestsAdded;
726 $TestsRemoved = AddPreTag $TestsRemoved;
727 $TestsFixed = AddPreTag $TestsFixed;
728 $TestsBroken = AddPreTag $TestsBroken;
732 # If we built the tree successfully, runs of the Olden suite with
733 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
734 if (!$BuildError) {
735 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
736 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
737 $MachCodeSize) = ("","","","","","","");
738 if (!$NORUNNINGTESTS) {
739 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
740 "Olden Test Directory");
742 # Clean out previous results...
743 system "$NICE gmake $MAKEOPTS clean > /dev/null 2>&1";
745 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
746 # GET_STABLE_NUMBERS enabled!
747 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
748 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
749 system "cp report.nightly.raw.out $OldenTestsLog";
750 } else {
751 system "gunzip ${OldenTestsLog}.gz";
754 # Now we know we have $OldenTestsLog as the raw output file. Split
755 # it up into records and read the useful information.
756 my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
757 shift @Records; # Delete the first (garbage) record
759 # Loop over all of the records, summarizing them into rows for the running
760 # totals file.
761 my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
762 foreach $Rec (@Records) {
763 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
764 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
765 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
766 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
767 my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
768 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
770 $NATTime .= " " . FormatTime($rNATTime);
771 $CBETime .= " " . FormatTime($rCBETime);
772 $LLCTime .= " " . FormatTime($rLLCTime);
773 $JITTime .= " " . FormatTime($rJITTime);
774 $OptTime .= " $rOptTime";
775 $BytecodeSize .= " $rBytecodeSize";
778 # Now that we have all of the numbers we want, add them to the running totals
779 # files.
780 AddRecord($NATTime, "running_Olden_nat_time.txt");
781 AddRecord($CBETime, "running_Olden_cbe_time.txt");
782 AddRecord($LLCTime, "running_Olden_llc_time.txt");
783 AddRecord($JITTime, "running_Olden_jit_time.txt");
784 AddRecord($OptTime, "running_Olden_opt_time.txt");
785 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
787 system "gzip -f $OldenTestsLog";
792 # Get a list of the previous days that we can link to...
794 my @PrevDays = map {s/.html//; $_} GetDir ".html";
796 if ((scalar @PrevDays) > 20) {
797 splice @PrevDays, 20; # Trim down list to something reasonable...
800 # Format list for sidebar
801 my $PrevDaysList = join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
804 # Start outputting files into the web directory
806 ChangeDir( $WebDir, "Web Directory" );
808 # Make sure we don't get errors running the nightly tester the first time
809 # because of files that don't exist.
810 Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
811 'running_loc.txt',
812 'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
813 'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
814 'running_Olden_jit_time.txt');
816 # Add information to the files which accumulate information for graphs...
817 AddRecord($LOC, "running_loc.txt");
818 AddRecord($BuildTime, "running_build_time.txt");
820 if ( $VERBOSE ) {
821 print "GRAPH GENERATION STAGE\n";
824 # Rebuild the graphs now...
826 $GNUPLOT = "/usr/bin/gnuplot";
827 $GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
828 system ("$GNUPLOT", $PlotScriptFilename);
831 # Remove the cvs tree...
833 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
835 print "\nUSERS WHO COMMITTED:\n " . (join "\n ", sort keys %UsersCommitted) . "\n"
836 if (scalar %UsersCommitted);
838 print "\nADDED FILES:\n " . (join "\n ", sort keys %AddedFiles) . "\n"
839 if (scalar %AddedFiles);
841 print "\nCHANGED FILES:\n " . (join "\n ", sort keys %ModifiedFiles) . "\n"
842 if (scalar %ModifiedFiles);
844 print "\nREMOVED FILES:\n " . (join "\n ", sort keys %RemovedFiles) . "\n"
845 if (scalar %RemovedFiles);
848 # Print out information...
850 if ($VERBOSE) {
851 print "DateString: $DateString\n";
852 print "CVS Checkout: $CVSCheckoutTime seconds\n";
853 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
854 print "Build Time: $BuildTime seconds\n";
855 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
857 print "WARNINGS:\n $WarningsList\n";
858 print "Previous Days =\n $PrevDaysList\n";
863 # Output the files...
866 if ( $VERBOSE ) {
867 print "OUTPUT STAGE\n";
869 # Main HTML file...
870 my $Output;
871 my $TestFinishTime = gmtime() . " GMT<br>" . localtime() . " (local)";
873 my $TestPlatform = `uname -a`;
874 eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
875 WriteFile "$DATE.html", $Output;
877 # Remove the symlink before creating it for systems that don't have "ln -sf".
878 system ("rm index.html");
879 system ("ln -s $DATE.html index.html");
881 # Change the index.html symlink...
883 # vim: sw=2 ai