2 use POSIX qw(strftime);
8 # Program: NewNightlyTest.pl
10 # Synopsis: Perform a series of tests which are designed to be run nightly.
11 # This is used to keep track of the status of the LLVM tree, tracking
12 # regressions and performance changes. Submits this information
13 # to llvm.org where it is placed into the nightlytestresults database.
15 # Modified heavily by Patrick Jenkins, July 2006
17 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
19 # OPTIONS may include one or more of the following:
20 # -nocheckout Do not create, checkout, update, or configure
22 # -noremove Do not remove the BUILDDIR after it has been built.
23 # -noremoveresults Do not remove the WEBDIR after it has been built.
24 # -nobuild Do not build llvm. If tests are enabled perform them
25 # on the llvm build specified in the build directory
26 # -notest Do not even attempt to run the test programs. Implies
28 # -norunningtests Do not run the Olden benchmark suite with
29 # LARGE_PROBLEM_SIZE enabled.
30 # -nodejagnu Do not run feature or regression tests
31 # -parallel Run two parallel jobs with GNU Make.
32 # -release Build an LLVM Release version
33 # -release-asserts Build an LLVM ReleaseAsserts version
34 # -enable-llcbeta Enable testing of beta features in llc.
35 # -enable-lli Enable testing of lli (interpreter) features, default is off
36 # -disable-llc Disable LLC tests in the nightly tester.
37 # -disable-jit Disable JIT tests in the nightly tester.
38 # -disable-cbe Disable C backend tests in the nightly tester.
39 # -verbose Turn on some debug output
40 # -debug Print information useful only to maintainers of this script.
41 # -nice Checkout/Configure/Build with "nice" to reduce impact
43 # -f2c Next argument specifies path to F2C utility
44 # -nickname The next argument specifieds the nickname this script
45 # will submit to the nightlytest results repository.
46 # -gccpath Path to gcc/g++ used to build LLVM
47 # -cvstag Check out a specific CVS tag to build LLVM (useful for
48 # testing release branches)
49 # -usesvn Check code out from a subversion repository. With no
50 # argument, use the standard repository. An argument specifies
51 # the repository URL to use.
52 # -svnurl Specify the SVN URL where LLVM can be found
53 # -target Specify the target triplet
54 # -cflags Next argument specifies that C compilation options that
55 # override the default.
56 # -cxxflags Next argument specifies that C++ compilation options that
57 # override the default.
58 # -ldflags Next argument specifies that linker options that override
60 # -compileflags Next argument specifies extra options passed to make when
62 # -use-gmake Use gmake instead of the default make command to build
65 # ---------------- Options to configure llvm-test ----------------------------
66 # -extraflags Next argument specifies extra options that are passed to
68 # -noexternals Do not run the external tests (for cases where povray
69 # or SPEC are not installed)
70 # -with-externals Specify a directory where the external tests are located.
71 # -submit-server Specifies a server to submit the test results too. If this
72 # option is not specified it defaults to
73 # llvm.org. This is basically just the address of the
75 # -submit-script Specifies which script to call on the submit server. If
76 # this option is not specified it defaults to
77 # /nightlytest/NightlyTestAccept.php. This is basically
78 # everything after the www.yourserver.org.
80 # CVSROOT is the CVS repository from which the tree will be checked out,
81 # specified either in the full :method:user@host:/dir syntax, or
82 # just /dir if using a local repo.
83 # BUILDDIR is the directory where sources for this test run will be checked out
84 # AND objects for this test run will be built. This directory MUST NOT
85 # exist before the script is run; it will be created by the cvs checkout
86 # process and erased (unless -noremove is specified; see above.)
87 # WEBDIR is the directory into which the test results web page will be written,
88 # AND in which the "index.html" is assumed to be a symlink to the most recent
89 # copy of the results. This directory will be created if it does not exist.
90 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
91 # to. This is the same as you would have for a normal LLVM build.
93 ##############################################################
95 # Getting environment variables
97 ##############################################################
98 my $HOME = $ENV{'HOME'};
99 my $SVNURL = $ENV{"SVNURL"};
100 $SVNURL = 'svn://anon@hlvm.org:3691/llvm.svn' unless $SVNURL;
101 my $CVSRootDir = $ENV{'CVSROOT'};
102 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
103 my $BuildDir = $ENV{'BUILDDIR'};
104 $BuildDir = "$HOME/buildtest" unless $BuildDir;
105 my $WebDir = $ENV{'WEBDIR'};
106 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
108 ##############################################################
110 # Calculate the date prefix...
112 ##############################################################
114 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
115 my $DateString = strftime "%B %d, %Y", localtime;
116 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
118 ##############################################################
122 ##############################################################
129 $SUBMITSERVER = "llvm.org";
130 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
132 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
134 last if /^--$/; # Stop processing arguments on --
136 # List command line options here...
137 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
138 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
139 if (/^-noremove$/) { $NOREMOVE = 1; next; }
140 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
141 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
142 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
143 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
144 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
145 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
146 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
147 "DISABLE-ASSERTIONS=1 ".
148 "OPTIMIZE_OPTION=-O2";
149 $BUILDTYPE="release-asserts"; next;}
150 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
151 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
152 $CONFIGUREARGS .= " --enable-lli"; next; }
153 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
154 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
155 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
156 $CONFIGUREARGS .= " --disable-jit"; next; }
157 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
158 if (/^-verbose$/) { $VERBOSE = 1; next; }
159 if (/^-debug$/) { $DEBUG = 1; next; }
160 if (/^-nice$/) { $NICE = "nice "; next; }
161 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
163 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
165 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
166 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
167 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
168 if (/^-gccpath/) { $CONFIGUREARGS .=
169 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
170 $GCCPATH=$ARGV[0]; shift; next; }
171 else { $GCCPATH=""; }
172 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
173 else { $CVSCOOPT="";}
174 if (/^-usesvn/) { $USESVN = 1; }
175 if (/^-svnurl/) { $SVNURL = $ARGV[0]; shift; next; }
176 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
178 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
180 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
182 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
184 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
185 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
186 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
187 if (/^-extraflags/) { $CONFIGUREARGS .=
188 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
189 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
190 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
191 if (/^-nobuild$/) { $NOBUILD = 1; next; }
192 print "Unknown option: $_ : ignoring!\n";
195 if ($ENV{'LLVMGCCDIR'}) {
196 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
198 if ($CONFIGUREARGS !~ /--disable-jit/) {
199 $CONFIGUREARGS .= " --enable-jit";
202 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
206 print "Must specify 0 or 3 options!";
210 $CVSRootDir = $ARGV[0];
211 $BuildDir = $ARGV[1];
215 if ($CVSRootDir eq "" or
218 die("please specify a cvs root directory, a build directory, and a ".
222 if ($nickname eq "") {
223 die ("Please invoke NewNightlyTest.pl with command line option " .
224 "\"-nickname <nickname>\"");
227 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
228 $BUILDTYPE = "debug";
231 ##############################################################
233 #define the file names we'll use
235 ##############################################################
236 my $Prefix = "$WebDir/$DATE";
237 my $BuildLog = "$Prefix-Build-Log.txt";
238 my $COLog = "$Prefix-CVS-Log.txt";
239 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
240 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
241 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
242 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
243 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
244 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
245 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
249 warn "$WebDir did not exist; creating it.\n";
254 print "INITIALIZED\n";
256 print "SVN URL = $SVNURL\n";
258 print "CVS Root = $CVSRootDir\n";
260 print "COLog = $COLog\n";
261 print "BuildDir = $BuildDir\n";
262 print "WebDir = $WebDir\n";
263 print "Prefix = $Prefix\n";
264 print "BuildLog = $BuildLog\n";
267 ##############################################################
271 ##############################################################
275 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
280 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
282 # DiffFiles - Diff the current version of the file against the last version of
283 # the file, reporting things added and removed. This is used to report, for
284 # example, added and removed warnings. This returns a pair (added, removed)
286 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289 my @Others = GetDir $Suffix;
290 if (@Others == 0) { # No other files? We added all entries...
291 return (`cat $WebDir/$DATE$Suffix`, "");
293 # Diff the files now...
294 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
295 my $Added = join "\n", grep /^</, @Diffs;
296 my $Removed = join "\n", grep /^>/, @Diffs;
298 $Removed =~ s/^> //gm;
299 return ($Added, $Removed);
302 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304 sub GetRegex { # (Regex with ()'s, value)
311 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 my ($Regex, $Num, $Regex2, $File) = @_;
315 my @Items = split "\n", `grep '$Regex' $File`;
316 return GetRegex $Regex2, $Items[$Num];
319 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321 sub ChangeDir { # directory, logical name
322 my ($dir,$name) = @_;
324 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
325 $result = chdir($dir);
327 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
333 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336 if (open (FILE, $_[0])) {
343 print "Could not open file '$_[0]' for reading!\n";
348 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350 sub WriteFile { # (filename, contents)
351 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
356 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 sub CopyFile { #filename, newfile
359 my ($file, $newfile) = @_;
361 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
362 copy($file, $newfile);
365 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 my ($Val, $Filename,$WebDir) = @_;
370 if (open FILE, "$WebDir/$Filename") {
371 @Records = grep !/$DATE/, split "\n", <FILE>;
374 push @Records, "$DATE: $Val";
375 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
378 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380 # FormatTime - Convert a time from 1m23.45 into 83.45
382 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
385 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
386 $Time = sprintf("%7.4f", $1*60.0+$2);
391 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393 # This function is meant to read in the dejagnu sum file and
394 # return a string with only the results (i.e. PASS/FAIL/XPASS/
397 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 sub GetDejagnuTestResults { # (filename, log)
399 my ($filename, $DejagnuLog) = @_;
401 $/ = "\n"; #Make sure we're going line at a time.
403 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
405 if (open SRCHFILE, $filename) {
406 # Process test results
407 while ( <SRCHFILE> ) {
408 if ( length($_) > 1 ) {
410 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
411 push(@lines, "$1: test/$2");
418 my $content = join("\n", @lines);
424 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
426 # This function acts as a mini web browswer submitting data
427 # to our central server via the post method
429 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
437 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
439 connect SOCK, $socketaddr or die "Bad connection\n";
440 select((select(SOCK), $| = 1)[0]);
442 #creating content here
444 foreach $key (keys (%$variables)){
445 $value = $variables->{$key};
446 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
447 $content .= "$key=$value&";
450 $length = length($content);
452 my $send= "POST $file HTTP/1.0\n";
453 $send.= "Content-Type: application/x-www-form-urlencoded\n";
454 $send.= "Content-length: $length\n\n";
465 foreach $x (keys (%$variables)){
466 $value = $variables->{$x};
467 $sentdata.= "$x => $value\n";
469 WriteFile "$Prefix-sentdata.txt", $sentdata;
475 ##############################################################
477 # Getting Start timestamp
479 ##############################################################
480 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
482 ##############################################################
484 # Create the CVS repository directory
486 ##############################################################
491 print "Build directory exists! Removing it\n";
493 system "rm -rf $BuildDir";
494 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
497 print "Build directory exists!\n";
501 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
504 ChangeDir( $BuildDir, "checkout directory" );
507 ##############################################################
509 # Check out the llvm tree, using either SVN or CVS
511 ##############################################################
514 print "CHECKOUT STAGE:\n";
517 my $SVNCMD = "$NICE svn co $SVNURL";
519 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
520 "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
521 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
522 "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
526 $CVSOPT = "-z3" # Use compression if going over ssh.
527 if $CVSRootDir =~ /^:ext:/;
528 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
529 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
530 "$CVSCMD llvm-test ) > $COLog 2>&1";
531 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
532 "$CVSCMD llvm-test ) > $COLog 2>&1";
535 ChangeDir( $BuildDir , "Checkout directory") ;
536 ChangeDir( "llvm" , "llvm source directory") ;
538 ##############################################################
540 # Get some static statistics about the current state of CVS
542 # This can probably be put on the server side
544 ##############################################################
545 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
546 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
547 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
548 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
550 my $NumFilesInCVS = 0;
551 my $NumDirsInCVS = 0;
553 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
554 $NumDirsInCVS = `sed -e 's#/[^/]*$##' $COLog | sort | uniq | wc -l` + 0;
556 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
557 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
560 ##############################################################
562 # Extract some information from the CVS history... use a hash so no duplicate
563 # stuff is stored. This gets the history from the previous days worth
564 # of cvs activity and parses it.
566 ##############################################################
568 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
571 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
574 my $delimiter = "----------------------------------------------------" .
575 "--------------------\n";
576 @SVNHistory = split $delimiter, `svn log --verbose -r{$DATE}:HEAD`;
578 # Skip very first entry.
580 foreach $Record (@SVNHistory) {
581 my (@Lines, @Fields);
582 my ($Rev, $Author, $StrTime, $LogLines, $Time);
583 @Lines = split "\n", $Record;
584 # print join"\n", @Lines;
586 ($Rev, $Author, $StrTime, $LogLines) = split ' \| ', $Lines[0];
587 $Time = str2time($StrTime);
588 if (time() - $Time > 24*3600) {
592 $UsersCommitted{$Author} = 1;
594 #print $Rev, $Author, $Time, $LogLines, "\n";
597 while ($Lines[$i] ne '') {
598 my ($Type, $Filename, $FromFile, $FromRev);
599 #print $Lines[$i], "\n";
601 if ($Lines[$i] =~ / ([MAD]) ([^ ]+) \(from ([^ ]+):([^ ]+)\)/) {
602 ($Type, $Filename, $FromFile, $FromRev) = ($1, $2, $3, $4);
603 } elsif ($Lines[$i] =~ / ([MAD]) ([^ ]+)/) {
604 ($Type, $Filename, $FromFile, $FromRev) = ($1, $2, "", "");
606 print "UNMATCHABLE: $Lines[$i]\n";
609 if ($Type eq 'M') { # Modified
610 $ModifiedFiles{$Filename} = 1;
611 } elsif ($Type eq 'A') { # Added
612 if ($FromFile eq "") { # File was added
613 $AddedFiles{$Filename} = 1;
614 } else { #File was added from another file - moved or copied.
615 $MovedFiles{$Filename} = 1;
617 } elsif ($Type eq 'D') { # Removed
618 $RemovedFiles{$Filename} = 1;
620 print "INVALID TYPE: $Type";
623 #print $Filename, "\n";
624 #print $Type, $File, $FromFile, $FromRev, "\n";
629 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
630 #print join "\n", @CVSHistory; print "\n";
632 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
634 # Loop over every record from the CVS history, filling in the hashes.
635 foreach $File (@CVSHistory) {
636 my ($Type, $Date, $UID, $Rev, $Filename);
637 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
638 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
639 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
640 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
641 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
642 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
644 print "UNMATCHABLE: $File\n";
647 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
649 if ($Filename =~ /^llvm/) {
650 if ($Type eq 'M') { # Modified
651 $ModifiedFiles{$Filename} = 1;
652 $UsersCommitted{$UID} = 1;
653 } elsif ($Type eq 'A') { # Added
654 $AddedFiles{$Filename} = 1;
655 $UsersCommitted{$UID} = 1;
656 } elsif ($Type eq 'R') { # Removed
657 $RemovedFiles{$Filename} = 1;
658 $UsersCommitted{$UID} = 1;
660 $UsersUpdated{$UID} = 1;
669 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
670 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
671 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
672 my $UserCommitList = join "\n", sort keys %UsersCommitted;
673 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
675 ##############################################################
677 # Build the entire tree, saving build messages to the build log
679 ##############################################################
680 if (!$NOCHECKOUT && !$NOBUILD) {
681 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
683 print "CONFIGURE STAGE:\n";
684 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
685 "> $BuildLog 2>&1\n";
687 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
690 print "BUILD STAGE:\n";
691 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
693 # Build the entire tree, capturing the output into $BuildLog
694 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
697 ##############################################################
699 # Get some statistics about the build...
701 ##############################################################
702 #this can de done on server
703 #my @Linked = split '\n', `grep Linking $BuildLog`;
704 #my $NumExecutables = scalar(grep(/executable/, @Linked));
705 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
706 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
708 # Get the number of lines of source code. Must be here after the build is done
709 # because countloc.sh uses the llvm-config script which must be built.
710 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
712 # Get the time taken by the configure script
713 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
714 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
715 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
716 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
718 $ConfigTime=-1 unless $ConfigTime;
719 $ConfigWallTime=-1 unless $ConfigWallTime;
721 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
722 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
723 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
724 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
726 $BuildTime=-1 unless $BuildTime;
727 $BuildWallTime=-1 unless $BuildWallTime;
729 my $BuildError = 0, $BuildStatus = "OK";
731 $BuildStatus = "Skipped by user";
734 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
735 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
736 $BuildStatus = "Error: compilation aborted";
738 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
740 if ($BuildError) { $NODEJAGNU=1; }
745 print "Organizing size of .o and .a files\n"
747 ChangeDir( "$BuildDir/llvm", "Build Directory" );
748 $afiles.= `find utils/ -iname '*.a' -ls`;
749 $afiles.= `find lib/ -iname '*.a' -ls`;
750 $afiles.= `find tools/ -iname '*.a' -ls`;
751 if($BUILDTYPE eq "release"){
752 $afiles.= `find Release/ -iname '*.a' -ls`;
753 } elsif($BUILDTYPE eq "release-asserts") {
754 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
756 $afiles.= `find Debug/ -iname '*.a' -ls`;
759 $ofiles.= `find utils/ -iname '*.o' -ls`;
760 $ofiles.= `find lib/ -iname '*.o' -ls`;
761 $ofiles.= `find tools/ -iname '*.o' -ls`;
762 if($BUILDTYPE eq "release"){
763 $ofiles.= `find Release/ -iname '*.o' -ls`;
764 } elsif($BUILDTYPE eq "release-asserts") {
765 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
767 $ofiles.= `find Debug/ -iname '*.o' -ls`;
770 @AFILES = split "\n", $afiles;
772 foreach $x (@AFILES){
773 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
774 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
776 @OFILES = split "\n", $ofiles;
778 foreach $x (@OFILES){
779 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
780 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
783 $a_file_sizes="No data due to a bad build.";
784 $o_file_sizes="No data due to a bad build.";
787 ##############################################################
789 # Running dejagnu tests
791 ##############################################################
792 my $DejangnuTestResults=""; # String containing the results of the dejagnu
793 my $dejagnu_output = "$DejagnuTestsLog";
796 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
797 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
800 #Run the feature and regression tests, results are put into testrun.sum
801 #Full log in testrun.log
802 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
804 #Copy the testrun.log and testrun.sum to our webdir
805 CopyFile("test/testrun.log", $DejagnuLog);
806 CopyFile("test/testrun.sum", $DejagnuSum);
807 #can be done on server
808 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
809 $unexpfail_tests = $DejagnuTestResults;
812 #Extract time of dejagnu tests
813 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
814 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
815 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
816 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
817 $DejagnuTestResults =
818 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
819 $DejagnuTime = "0.0" unless $DejagnuTime;
820 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
822 ##############################################################
824 # Get warnings from the build
826 ##############################################################
828 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
829 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
833 foreach $Warning (@Warn) {
834 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
835 $CurDir = $1; # Keep track of directory warning is in...
836 # Remove buildir prefix if included
837 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
839 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
842 my $WarningsFile = join "\n", @Warnings;
843 $WarningsFile =~ s/:[0-9]+:/::/g;
845 # Emit the warnings file, so we can diff...
846 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
847 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
849 # Output something to stdout if something has changed
850 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
851 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
853 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
854 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
858 ##############################################################
860 # If we built the tree successfully, run the nightly programs tests...
862 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
865 ##############################################################
868 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
869 "Programs Test Subdirectory" ) || return ("", "");
871 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
873 # Run the programs tests... creating a report.nightly.csv file
876 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
877 "TEST=nightly > $ProgramTestLog 2>&1\n";
879 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
880 "TEST=nightly > $ProgramTestLog 2>&1";
881 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
885 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
887 $ProgramsTable="Error running test $SubDir\n";
888 print "ERROR TESTING\n";
889 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
891 $ProgramsTable="Makefile error running tests $SubDir!\n";
892 print "ERROR TESTING\n";
896 # Create a list of the tests which were run...
898 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
899 "| sort > $Prefix-$SubDir-Tests.txt";
901 $ProgramsTable = ReadFile "report.nightly.csv";
903 ChangeDir( "../../..", "Programs Test Parent Directory" );
904 return ($ProgramsTable, $llcbeta_options);
905 } #end sub TestDirectory
907 ##############################################################
909 # Calling sub TestDirectory
911 ##############################################################
914 print "SingleSource TEST STAGE\n";
916 ($SingleSourceProgramsTable, $llcbeta_options) =
917 TestDirectory("SingleSource");
918 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
920 print "MultiSource TEST STAGE\n";
922 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
923 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
924 if ( ! $NOEXTERNALS ) {
926 print "External TEST STAGE\n";
928 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
929 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
930 system "cat $Prefix-SingleSource-Tests.txt " .
931 "$Prefix-MultiSource-Tests.txt ".
932 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
933 system "cat $Prefix-SingleSource-Performance.txt " .
934 "$Prefix-MultiSource-Performance.txt ".
935 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
937 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
939 print "External TEST STAGE SKIPPED\n";
941 system "cat $Prefix-SingleSource-Tests.txt " .
942 "$Prefix-MultiSource-Tests.txt ".
943 " | sort > $Prefix-Tests.txt";
944 system "cat $Prefix-SingleSource-Performance.txt " .
945 "$Prefix-MultiSource-Performance.txt ".
946 " | sort > $Prefix-Performance.txt";
949 ##############################################################
952 # gathering tests added removed broken information here
955 ##############################################################
956 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
957 my @DEJAGNU = split "\n", $dejagnu_test_list;
958 my ($passes, $fails, $xfails) = "";
961 for ($x=0; $x<@DEJAGNU; $x++) {
962 if ($DEJAGNU[$x] =~ m/^PASS:/) {
963 $passes.="$DEJAGNU[$x]\n";
965 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
966 $fails.="$DEJAGNU[$x]\n";
968 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
969 $xfails.="$DEJAGNU[$x]\n";
974 } #end if !$BuildError
977 ##############################################################
979 # If we built the tree successfully, runs of the Olden suite with
980 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
982 ##############################################################
984 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
985 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
986 $MachCodeSize) = ("","","","","","","");
987 if (!$NORUNNINGTESTS) {
988 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
989 "Olden Test Directory");
991 # Clean out previous results...
992 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
994 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
995 # GET_STABLE_NUMBERS enabled!
997 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
998 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
999 "> /dev/null 2>&1\n";
1001 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1002 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1004 system "cp report.nightly.csv $OldenTestsLog";
1008 ##############################################################
1010 # Getting end timestamp
1012 ##############################################################
1013 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1016 ##############################################################
1018 # Place all the logs neatly into one humungous file
1020 ##############################################################
1021 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1023 $machine_data = "uname: ".`uname -a`.
1024 "hardware: ".`uname -m`.
1026 "name: ".`uname -n`.
1027 "date: ".`date \"+20%y-%m-%d\"`.
1028 "time: ".`date +\"%H:%M:%S\"`;
1032 @CVS_DATA = ReadFile "$COLog";
1033 $cvs_data = join("\n", @CVS_DATA);
1037 @BUILD_DATA = ReadFile "$BuildLog";
1038 $build_data = join("\n", @BUILD_DATA);
1040 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1041 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1042 my ($gcc_version, $gcc_version_long) = "";
1044 $gcc_version_long="";
1045 if ($GCCPATH ne "") {
1046 $gcc_version_long = `$GCCPATH/gcc --version`;
1048 $gcc_version_long = `gcc --version`;
1050 @GCC_VERSION = split '\n', $gcc_version_long;
1051 $gcc_version = $GCC_VERSION[0];
1054 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1055 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1056 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1057 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1059 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1060 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1063 ##############################################################
1065 # Send data via a post request
1067 ##############################################################
1069 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1071 my %hash_of_data = (
1072 'machine_data' => $machine_data,
1073 'build_data' => $build_data,
1074 'gcc_version' => $gcc_version,
1075 'nickname' => $nickname,
1076 'dejagnutime_wall' => $DejagnuWallTime,
1077 'dejagnutime_cpu' => $DejagnuTime,
1078 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1079 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1080 'configtime_wall' => $ConfigWallTime,
1081 'configtime_cpu'=> $ConfigTime,
1082 'buildtime_wall' => $BuildWallTime,
1083 'buildtime_cpu' => $BuildTime,
1084 'warnings' => $WarningsFile,
1085 'cvsusercommitlist' => $UserCommitList,
1086 'cvsuserupdatelist' => $UserUpdateList,
1087 'cvsaddedfiles' => $CVSAddedFiles,
1088 'cvsmodifiedfiles' => $CVSModifiedFiles,
1089 'cvsremovedfiles' => $CVSRemovedFiles,
1090 'lines_of_code' => $LOC,
1091 'cvs_file_count' => $NumFilesInCVS,
1092 'cvs_dir_count' => $NumDirsInCVS,
1093 'buildstatus' => $BuildStatus,
1094 'singlesource_programstable' => $SingleSourceProgramsTable,
1095 'multisource_programstable' => $MultiSourceProgramsTable,
1096 'externalsource_programstable' => $ExternalProgramsTable,
1097 'llcbeta_options' => $multisource_llcbeta_options,
1098 'warnings_removed' => $WarningsRemoved,
1099 'warnings_added' => $WarningsAdded,
1100 'passing_tests' => $passes,
1101 'expfail_tests' => $xfails,
1102 'unexpfail_tests' => $fails,
1103 'all_tests' => $dejagnu_test_list,
1105 'removed_tests' => "",
1106 'dejagnutests_results' => $DejagnuTestResults,
1107 'dejagnutests_log' => $dejagnulog_full,
1108 'starttime' => $starttime,
1109 'endtime' => $endtime,
1110 'o_file_sizes' => $o_file_sizes,
1111 'a_file_sizes' => $a_file_sizes
1117 print "============================\n";
1118 foreach $x(keys %hash_of_data){
1119 print "$x => $hash_of_data{$x}\n";
1122 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1123 if( $VERBOSE) { print "============================\n$response"; }
1126 ##############################################################
1128 # Remove the cvs tree...
1130 ##############################################################
1131 system ( "$NICE rm -rf $BuildDir")
1132 if (!$NOCHECKOUT and !$NOREMOVE);
1133 system ( "$NICE rm -rf $WebDir")
1134 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);