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 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
17 # OPTIONS may include one or more of the following:
18 # -nocheckout Do not create, checkout, update, or configure
20 # -noremove Do not remove the BUILDDIR after it has been built.
21 # -noremoveresults Do not remove the WEBDIR after it has been built.
22 # -nobuild Do not build llvm. If tests are enabled perform them
23 # on the llvm build specified in the build directory
24 # -notest Do not even attempt to run the test programs.
25 # -nodejagnu Do not run feature or regression tests
26 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
27 # -parallel-jobs The number of parallel Make jobs to use (default is two).
28 # -with-clang Checkout Clang source into tools/clang.
29 # -release Build an LLVM Release version
30 # -release-asserts Build an LLVM ReleaseAsserts version
31 # -enable-llcbeta Enable testing of beta features in llc.
32 # -enable-lli Enable testing of lli (interpreter) features, default is off
33 # -disable-pic Disable building with Position Independent Code.
34 # -disable-llc Disable LLC tests in the nightly tester.
35 # -disable-jit Disable JIT tests in the nightly tester.
36 # -disable-cbe Disable C backend tests in the nightly tester.
37 # -disable-lto Disable link time optimization.
38 # -disable-bindings Disable building LLVM bindings.
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 # -usecvs Check code out from the (old) CVS Repository instead of from
50 # the standard Subversion repository.
51 # -target Specify the target triplet
52 # -cflags Next argument specifies that C compilation options that
53 # override the default.
54 # -cxxflags Next argument specifies that C++ compilation options that
55 # override the default.
56 # -ldflags Next argument specifies that linker options that override
58 # -compileflags Next argument specifies extra options passed to make when
60 # -use-gmake Use gmake instead of the default make command to build
63 # ---------------- Options to configure llvm-test ----------------------------
64 # -extraflags Next argument specifies extra options that are passed to
66 # -noexternals Do not run the external tests (for cases where povray
67 # or SPEC are not installed)
68 # -with-externals Specify a directory where the external tests are located.
69 # -submit-server Specifies a server to submit the test results too. If this
70 # option is not specified it defaults to
71 # llvm.org. This is basically just the address of the
73 # -submit-script Specifies which script to call on the submit server. If
74 # this option is not specified it defaults to
75 # /nightlytest/NightlyTestAccept.php. This is basically
76 # everything after the www.yourserver.org.
77 # -submit-aux If specified, an auxiliary script to run in addition to the
78 # normal submit script. The script will be passed the path to
79 # the "sentdata.txt" file as its sole argument.
80 # -nosubmit Do not report the test results back to a submit server.
82 # CVSROOT is the CVS repository from which the tree will be checked out,
83 # specified either in the full :method:user@host:/dir syntax, or
84 # just /dir if using a local repo.
85 # BUILDDIR is the directory where sources for this test run will be checked out
86 # AND objects for this test run will be built. This directory MUST NOT
87 # exist before the script is run; it will be created by the cvs checkout
88 # process and erased (unless -noremove is specified; see above.)
89 # WEBDIR is the directory into which the test results web page will be written,
90 # AND in which the "index.html" is assumed to be a symlink to the most recent
91 # copy of the results. This directory will be created if it does not exist.
92 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
93 # to. This is the same as you would have for a normal LLVM build.
95 ##############################################################
97 # Getting environment variables
99 ##############################################################
100 my $HOME = $ENV{'HOME'};
101 my $SVNURL = $ENV{"SVNURL"};
102 $SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
103 my $TestSVNURL = $ENV{"TestSVNURL"};
104 $TestSVNURL = 'https://llvm.org/svn/llvm-project' unless $TestSVNURL;
105 my $CVSRootDir = $ENV{'CVSROOT'};
106 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
107 my $BuildDir = $ENV{'BUILDDIR'};
108 $BuildDir = "$HOME/buildtest" unless $BuildDir;
109 my $WebDir = $ENV{'WEBDIR'};
110 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
112 my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
113 $LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
114 my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
115 $LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
116 my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
117 $LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
119 ##############################################################
121 # Calculate the date prefix...
123 ##############################################################
125 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
126 my $DateString = strftime "%B %d, %Y", localtime;
127 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
129 ##############################################################
133 ##############################################################
139 $SUBMITSERVER = "llvm.org";
140 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
145 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
147 last if /^--$/; # Stop processing arguments on --
149 # List command line options here...
150 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
151 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
152 if (/^-noremove$/) { $NOREMOVE = 1; next; }
153 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
154 if (/^-notest$/) { $NOTEST = 1; next; }
155 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
156 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
157 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
158 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
159 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
160 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
161 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
162 "DISABLE_ASSERTIONS=1 ".
163 "OPTIMIZE_OPTION=-O2";
164 $BUILDTYPE="release-asserts"; next;}
165 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
166 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
167 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
168 $CONFIGUREARGS .= " --enable-lli"; next; }
169 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
170 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
171 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
172 $CONFIGUREARGS .= " --disable-jit"; next; }
173 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
174 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
175 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
176 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
177 if (/^-verbose$/) { $VERBOSE = 1; next; }
178 if (/^-teelogs$/) { $TEELOGS = 1; next; }
179 if (/^-debug$/) { $DEBUG = 1; next; }
180 if (/^-nice$/) { $NICE = "nice "; next; }
181 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
183 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
185 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
186 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
187 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
188 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
189 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
190 if (/^-gccpath/) { $CONFIGUREARGS .=
191 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
192 $GCCPATH=$ARGV[0]; shift; next; }
193 else { $GCCPATH=""; }
194 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
195 else { $CVSCOOPT="";}
196 if (/^-usecvs/) { $USESVN = 0; }
197 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
199 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
201 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
203 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
205 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
206 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
207 if (/^-extraflags/) { $CONFIGUREARGS .=
208 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
209 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
210 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
211 if (/^-nobuild$/) { $NOBUILD = 1; next; }
212 print "Unknown option: $_ : ignoring!\n";
215 if ($ENV{'LLVMGCCDIR'}) {
216 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
217 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
223 if ($CONFIGUREARGS !~ /--disable-jit/) {
224 $CONFIGUREARGS .= " --enable-jit";
227 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
231 print "Must specify 0 or 3 options!";
235 $CVSRootDir = $ARGV[0];
236 $BuildDir = $ARGV[1];
240 if ($CVSRootDir eq "" or
243 die("please specify a cvs root directory, a build directory, and a ".
247 if ($nickname eq "") {
248 die ("Please invoke NewNightlyTest.pl with command line option " .
249 "\"-nickname <nickname>\"");
252 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
253 $BUILDTYPE = "debug";
256 ##############################################################
258 #define the file names we'll use
260 ##############################################################
261 my $Prefix = "$WebDir/$DATE";
262 my $BuildLog = "$Prefix-Build-Log.txt";
263 my $COLog = "$Prefix-CVS-Log.txt";
264 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
265 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
266 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
267 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
268 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
269 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
273 warn "$WebDir did not exist; creating it.\n";
278 print "INITIALIZED\n";
280 print "SVN URL = $SVNURL\n";
282 print "CVS Root = $CVSRootDir\n";
284 print "COLog = $COLog\n";
285 print "BuildDir = $BuildDir\n";
286 print "WebDir = $WebDir\n";
287 print "Prefix = $Prefix\n";
288 print "BuildLog = $BuildLog\n";
291 ##############################################################
295 ##############################################################
299 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
304 sub RunLoggedCommand {
311 print "$Command 2>&1 | tee $Log\n";
313 system "$Command 2>&1 | tee $Log";
317 print "$Command 2>&1 > $Log\n";
319 system "$Command 2>&1 > $Log";
323 sub RunAppendingLoggedCommand {
330 print "$Command 2>&1 | tee -a $Log\n";
332 system "$Command 2>&1 | tee -a $Log";
336 print "$Command 2>&1 > $Log\n";
338 system "$Command 2>&1 >> $Log";
342 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344 # DiffFiles - Diff the current version of the file against the last version of
345 # the file, reporting things added and removed. This is used to report, for
346 # example, added and removed warnings. This returns a pair (added, removed)
348 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351 my @Others = GetDir $Suffix;
352 if (@Others == 0) { # No other files? We added all entries...
353 return (`cat $WebDir/$DATE$Suffix`, "");
355 # Diff the files now...
356 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
357 my $Added = join "\n", grep /^</, @Diffs;
358 my $Removed = join "\n", grep /^>/, @Diffs;
360 $Removed =~ s/^> //gm;
361 return ($Added, $Removed);
364 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366 sub GetRegex { # (Regex with ()'s, value)
373 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376 my ($Regex, $Num, $Regex2, $File) = @_;
377 my @Items = split "\n", `grep '$Regex' $File`;
378 return GetRegex $Regex2, $Items[$Num];
381 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383 sub ChangeDir { # directory, logical name
384 my ($dir,$name) = @_;
386 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
387 $result = chdir($dir);
389 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
395 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 if (open (FILE, $_[0])) {
405 print "Could not open file '$_[0]' for reading!\n";
410 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412 sub WriteFile { # (filename, contents)
413 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
418 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
419 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420 sub CopyFile { #filename, newfile
421 my ($file, $newfile) = @_;
423 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
424 copy($file, $newfile);
427 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430 my ($Val, $Filename,$WebDir) = @_;
432 if (open FILE, "$WebDir/$Filename") {
433 @Records = grep !/$DATE/, split "\n", <FILE>;
436 push @Records, "$DATE: $Val";
437 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
440 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
442 # FormatTime - Convert a time from 1m23.45 into 83.45
444 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
447 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
448 $Time = sprintf("%7.4f", $1*60.0+$2);
453 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455 # This function is meant to read in the dejagnu sum file and
456 # return a string with only the results (i.e. PASS/FAIL/XPASS/
459 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
460 sub GetDejagnuTestResults { # (filename, log)
461 my ($filename, $DejagnuLog) = @_;
463 $/ = "\n"; #Make sure we're going line at a time.
465 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
467 if (open SRCHFILE, $filename) {
468 # Process test results
469 while ( <SRCHFILE> ) {
470 if ( length($_) > 1 ) {
472 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
473 push(@lines, "$1: test/$2");
480 my $content = join("\n", @lines);
486 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
488 # This function acts as a mini web browswer submitting data
489 # to our central server via the post method
491 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
497 # Write out the "...-sentdata.txt" file.
500 foreach $x (keys (%$variables)){
501 $value = $variables->{$x};
502 $sentdata.= "$x => $value\n";
504 WriteFile "$Prefix-sentdata.txt", $sentdata;
506 if (!($SUBMITAUX eq "")) {
507 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
510 # Create the content to send to the server.
513 foreach $key (keys (%$variables)){
514 $value = $variables->{$key};
515 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
516 $content .= "$key=$value&";
519 # Send the data to the server.
521 # FIXME: This code should be more robust?
524 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
525 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
527 connect SOCK, $socketaddr or die "Bad connection\n";
528 select((select(SOCK), $| = 1)[0]);
530 $length = length($content);
532 my $send= "POST $file HTTP/1.0\n";
533 $send.= "Host: $host\n";
534 $send.= "Content-Type: application/x-www-form-urlencoded\n";
535 $send.= "Content-length: $length\n\n";
548 ##############################################################
550 # Getting Start timestamp
552 ##############################################################
553 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
555 ##############################################################
557 # Create the CVS repository directory
559 ##############################################################
564 print "Build directory exists! Removing it\n";
566 system "rm -rf $BuildDir";
567 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
570 print "Build directory exists!\n";
574 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
579 ##############################################################
581 # Check out the llvm tree, using either SVN or CVS
583 ##############################################################
585 ChangeDir( $BuildDir, "checkout directory" );
587 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
588 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
589 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
590 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
593 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
594 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
599 $CVSOPT = "-z3" # Use compression if going over ssh.
600 if $CVSRootDir =~ /^:ext:/;
601 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
602 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
603 "$CVSCMD llvm-test )", $COLog,
604 "CHECKOUT LLVM-TEST");
607 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
609 ##############################################################
611 # Get some static statistics about the current state of CVS
613 # This can probably be put on the server side
615 ##############################################################
616 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
617 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
618 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
619 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
621 my $NumFilesInCVS = 0;
622 my $NumDirsInCVS = 0;
624 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
625 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
627 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
628 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
631 ##############################################################
633 # Extract some information from the CVS history... use a hash so no duplicate
634 # stuff is stored. This gets the history from the previous days worth
635 # of cvs activity and parses it.
637 ##############################################################
639 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
640 # have to be perfect as its only used for comparing date ranges within a couple
642 sub ConvertToSeconds {
643 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
644 my $Result = ($yr - 2000) * 12;
657 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
660 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
663 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
664 # Skip very first entry because it is the XML header cruft
667 foreach $Record (@SVNHistory) {
668 my @Lines = split "\n", $Record;
669 my ($Author, $Date, $Revision);
670 # Get the date and see if its one we want to process.
671 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
672 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
673 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
675 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
676 # Get the current date and compute when "yesterday" is.
677 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
678 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
679 if (($Now - 24*60*60) > $Then) {
682 if ($Lines[1] =~ / revision="([0-9]*)">/) {
685 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
688 $UsersCommitted{$Author} = 1;
689 $Date = $Year . "-" . $Month . "-" . $Day;
690 $Time = $Hour . ":" . $Min . ":" . $Sec;
691 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
692 for ($i = 6; $i < $#Lines; $i += 2 ) {
693 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
696 } elsif ($1 == 'D') {
697 $RemovedFiles{$2} = 1;
698 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
699 $ModifiedFiles{$2} = 1;
701 print "UNMATCHABLE: $Lines[$i]\n";
707 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
708 #print join "\n", @CVSHistory; print "\n";
710 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
712 # Loop over every record from the CVS history, filling in the hashes.
713 foreach $File (@CVSHistory) {
714 my ($Type, $Date, $UID, $Rev, $Filename);
715 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
716 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
717 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
718 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
719 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
720 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
722 print "UNMATCHABLE: $File\n";
725 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
727 if ($Filename =~ /^llvm/) {
728 if ($Type eq 'M') { # Modified
729 $ModifiedFiles{$Filename} = 1;
730 $UsersCommitted{$UID} = 1;
731 } elsif ($Type eq 'A') { # Added
732 $AddedFiles{$Filename} = 1;
733 $UsersCommitted{$UID} = 1;
734 } elsif ($Type eq 'R') { # Removed
735 $RemovedFiles{$Filename} = 1;
736 $UsersCommitted{$UID} = 1;
738 $UsersUpdated{$UID} = 1;
747 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
748 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
749 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
750 my $UserCommitList = join "\n", sort keys %UsersCommitted;
751 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
753 ##############################################################
755 # Build the entire tree, saving build messages to the build log
757 ##############################################################
758 if (!$NOCHECKOUT && !$NOBUILD) {
759 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
760 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
761 $BuildLog, "CONFIGURE");
762 # Build the entire tree, capturing the output into $BuildLog
763 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
764 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
767 ##############################################################
769 # Get some statistics about the build...
771 ##############################################################
772 #this can de done on server
773 #my @Linked = split '\n', `grep Linking $BuildLog`;
774 #my $NumExecutables = scalar(grep(/executable/, @Linked));
775 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
776 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
778 # Get the number of lines of source code. Must be here after the build is done
779 # because countloc.sh uses the llvm-config script which must be built.
780 my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
782 # Get the time taken by the configure script
783 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
784 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
785 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
786 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
788 $ConfigTime=-1 unless $ConfigTime;
789 $ConfigWallTime=-1 unless $ConfigWallTime;
791 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
792 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
793 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
794 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
796 $BuildTime=-1 unless $BuildTime;
797 $BuildWallTime=-1 unless $BuildWallTime;
799 my $BuildError = 0, $BuildStatus = "OK";
801 $BuildStatus = "Skipped by user";
803 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
804 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
805 $BuildStatus = "Error: compilation aborted";
807 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
809 if ($BuildError) { $NODEJAGNU=1; }
814 print "Organizing size of .o and .a files\n"
816 ChangeDir( "$LLVMObjDir", "Build Directory" );
818 my @dirs = ('utils', 'lib', 'tools');
819 if($BUILDTYPE eq "release"){
820 push @dirs, 'Release';
821 } elsif($BUILDTYPE eq "release-asserts") {
822 push @dirs, 'Release-Asserts';
828 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
829 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
832 $a_file_sizes="No data due to a bad build.";
833 $o_file_sizes="No data due to a bad build.";
836 ##############################################################
838 # Running dejagnu tests
840 ##############################################################
841 my $DejangnuTestResults=""; # String containing the results of the dejagnu
842 my $dejagnu_output = "$DejagnuTestsLog";
844 #Run the feature and regression tests, results are put into testrun.sum
845 #Full log in testrun.log
846 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
848 #Copy the testrun.log and testrun.sum to our webdir
849 CopyFile("test/testrun.log", $DejagnuLog);
850 CopyFile("test/testrun.sum", $DejagnuSum);
851 #can be done on server
852 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
853 $unexpfail_tests = $DejagnuTestResults;
856 #Extract time of dejagnu tests
857 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
858 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
859 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
860 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
861 $DejagnuTestResults =
862 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
863 $DejagnuTime = "0.0" unless $DejagnuTime;
864 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
866 ##############################################################
868 # Get warnings from the build
870 ##############################################################
872 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
873 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
877 foreach $Warning (@Warn) {
878 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
879 $CurDir = $1; # Keep track of directory warning is in...
880 # Remove buildir prefix if included
881 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
883 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
886 my $WarningsFile = join "\n", @Warnings;
887 $WarningsFile =~ s/:[0-9]+:/::/g;
889 # Emit the warnings file, so we can diff...
890 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
891 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
893 # Output something to stdout if something has changed
894 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
895 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
897 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
898 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
902 ##############################################################
904 # If we built the tree successfully, run the nightly programs tests...
906 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
909 ##############################################################
913 ChangeDir( "$LLVMTestDir/$SubDir",
914 "Programs Test Subdirectory" ) || return ("", "");
916 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
918 # Run the programs tests... creating a report.nightly.csv file
921 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
922 "TEST=nightly > $ProgramTestLog 2>&1\n";
924 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
925 "TEST=nightly", $ProgramTestLog, "TEST DIRECTORY $SubDir");
926 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
930 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
932 $ProgramsTable="Error running test $SubDir\n";
933 print "ERROR TESTING\n";
934 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
936 $ProgramsTable="Makefile error running tests $SubDir!\n";
937 print "ERROR TESTING\n";
941 # Create a list of the tests which were run...
943 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
944 "| sort > $Prefix-$SubDir-Tests.txt";
946 $ProgramsTable = ReadFile "report.nightly.csv";
948 ChangeDir( "../../..", "Programs Test Parent Directory" );
949 return ($ProgramsTable, $llcbeta_options);
950 } #end sub TestDirectory
952 ##############################################################
954 # Calling sub TestDirectory
956 ##############################################################
958 ($SingleSourceProgramsTable, $llcbeta_options) =
959 TestDirectory("SingleSource");
960 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
961 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
962 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
963 if ( ! $NOEXTERNALS ) {
964 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
965 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
966 system "cat $Prefix-SingleSource-Tests.txt " .
967 "$Prefix-MultiSource-Tests.txt ".
968 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
969 system "cat $Prefix-SingleSource-Performance.txt " .
970 "$Prefix-MultiSource-Performance.txt ".
971 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
973 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
975 print "External TEST STAGE SKIPPED\n";
977 system "cat $Prefix-SingleSource-Tests.txt " .
978 "$Prefix-MultiSource-Tests.txt ".
979 " | sort > $Prefix-Tests.txt";
980 system "cat $Prefix-SingleSource-Performance.txt " .
981 "$Prefix-MultiSource-Performance.txt ".
982 " | sort > $Prefix-Performance.txt";
985 ##############################################################
988 # gathering tests added removed broken information here
991 ##############################################################
992 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
993 my @DEJAGNU = split "\n", $dejagnu_test_list;
994 my ($passes, $fails, $xfails) = "";
997 for ($x=0; $x<@DEJAGNU; $x++) {
998 if ($DEJAGNU[$x] =~ m/^PASS:/) {
999 $passes.="$DEJAGNU[$x]\n";
1001 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1002 $fails.="$DEJAGNU[$x]\n";
1004 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1005 $xfails.="$DEJAGNU[$x]\n";
1010 } #end if !$BuildError
1012 ##############################################################
1014 # Getting end timestamp
1016 ##############################################################
1017 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1020 ##############################################################
1022 # Place all the logs neatly into one humungous file
1024 ##############################################################
1025 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1027 $machine_data = "uname: ".`uname -a`.
1028 "hardware: ".`uname -m`.
1030 "name: ".`uname -n`.
1031 "date: ".`date \"+20%y-%m-%d\"`.
1032 "time: ".`date +\"%H:%M:%S\"`;
1036 @CVS_DATA = ReadFile "$COLog";
1037 $cvs_data = join("\n", @CVS_DATA);
1041 @BUILD_DATA = ReadFile "$BuildLog";
1042 $build_data = join("\n", @BUILD_DATA);
1044 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1045 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1046 my ($gcc_version, $gcc_version_long) = "";
1048 $gcc_version_long="";
1049 if ($GCCPATH ne "") {
1050 $gcc_version_long = `$GCCPATH/gcc --version`;
1051 } elsif ($ENV{"CC"}) {
1052 $gcc_version_long = `$ENV{"CC"} --version`;
1054 $gcc_version_long = `gcc --version`;
1056 @GCC_VERSION = split '\n', $gcc_version_long;
1057 $gcc_version = $GCC_VERSION[0];
1059 $llvmgcc_version_long="";
1060 if ($LLVMGCCPATH ne "") {
1061 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1063 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1065 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1066 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1067 $llvmgcc_versionTarget =~ /Target: (.+)/;
1071 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1072 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1073 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1074 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1076 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1077 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1080 ##############################################################
1082 # Send data via a post request
1084 ##############################################################
1086 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1088 my %hash_of_data = (
1089 'machine_data' => $machine_data,
1090 'build_data' => $build_data,
1091 'gcc_version' => $gcc_version,
1092 'nickname' => $nickname,
1093 'dejagnutime_wall' => $DejagnuWallTime,
1094 'dejagnutime_cpu' => $DejagnuTime,
1095 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1096 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1097 'configtime_wall' => $ConfigWallTime,
1098 'configtime_cpu'=> $ConfigTime,
1099 'buildtime_wall' => $BuildWallTime,
1100 'buildtime_cpu' => $BuildTime,
1101 'warnings' => $WarningsFile,
1102 'cvsusercommitlist' => $UserCommitList,
1103 'cvsuserupdatelist' => $UserUpdateList,
1104 'cvsaddedfiles' => $CVSAddedFiles,
1105 'cvsmodifiedfiles' => $CVSModifiedFiles,
1106 'cvsremovedfiles' => $CVSRemovedFiles,
1107 'lines_of_code' => $LOC,
1108 'cvs_file_count' => $NumFilesInCVS,
1109 'cvs_dir_count' => $NumDirsInCVS,
1110 'buildstatus' => $BuildStatus,
1111 'singlesource_programstable' => $SingleSourceProgramsTable,
1112 'multisource_programstable' => $MultiSourceProgramsTable,
1113 'externalsource_programstable' => $ExternalProgramsTable,
1114 'llcbeta_options' => $multisource_llcbeta_options,
1115 'warnings_removed' => $WarningsRemoved,
1116 'warnings_added' => $WarningsAdded,
1117 'passing_tests' => $passes,
1118 'expfail_tests' => $xfails,
1119 'unexpfail_tests' => $fails,
1120 'all_tests' => $dejagnu_test_list,
1122 'removed_tests' => "",
1123 'dejagnutests_results' => $DejagnuTestResults,
1124 'dejagnutests_log' => $dejagnulog_full,
1125 'starttime' => $starttime,
1126 'endtime' => $endtime,
1127 'o_file_sizes' => $o_file_sizes,
1128 'a_file_sizes' => $a_file_sizes,
1129 'target_triple' => $targetTriple
1133 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1134 if( $VERBOSE) { print "============================\n$response"; }
1136 print "============================\n";
1137 foreach $x(keys %hash_of_data){
1138 print "$x => $hash_of_data{$x}\n";
1142 ##############################################################
1144 # Remove the cvs tree...
1146 ##############################################################
1147 system ( "$NICE rm -rf $BuildDir")
1148 if (!$NOCHECKOUT and !$NOREMOVE);
1149 system ( "$NICE rm -rf $WebDir")
1150 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);