2 use POSIX qw(strftime);
7 # Program: NewNightlyTest.pl
9 # Synopsis: Perform a series of tests which are designed to be run nightly.
10 # This is used to keep track of the status of the LLVM tree, tracking
11 # regressions and performance changes. Submits this information
12 # to llvm.org where it is placed into the nightlytestresults database.
14 # Modified heavily by Patrick Jenkins, July 2006
16 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
18 # OPTIONS may include one or more of the following:
19 # -nocheckout Do not create, checkout, update, or configure
21 # -noremove Do not remove the BUILDDIR after it has been built.
22 # -noremoveresults Do not remove the WEBDIR after it has been built.
23 # -nobuild Do not build llvm. If tests are enabled perform them
24 # on the llvm build specified in the build directory
25 # -notest Do not even attempt to run the test programs.
26 # -nodejagnu Do not run feature or regression tests
27 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
28 # -parallel-jobs The number of parallel Make jobs to use (default is two).
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-llc Disable LLC tests in the nightly tester.
34 # -disable-jit Disable JIT tests in the nightly tester.
35 # -disable-cbe Disable C backend tests in the nightly tester.
36 # -disable-lto Disable link time optimization.
37 # -disable-bindings Disable building LLVM bindings.
38 # -verbose Turn on some debug output
39 # -debug Print information useful only to maintainers of this script.
40 # -nice Checkout/Configure/Build with "nice" to reduce impact
42 # -f2c Next argument specifies path to F2C utility
43 # -nickname The next argument specifieds the nickname this script
44 # will submit to the nightlytest results repository.
45 # -gccpath Path to gcc/g++ used to build LLVM
46 # -cvstag Check out a specific CVS tag to build LLVM (useful for
47 # testing release branches)
48 # -usecvs Check code out from the (old) CVS Repository instead of from
49 # the standard Subversion repository.
50 # -target Specify the target triplet
51 # -cflags Next argument specifies that C compilation options that
52 # override the default.
53 # -cxxflags Next argument specifies that C++ compilation options that
54 # override the default.
55 # -ldflags Next argument specifies that linker options that override
57 # -compileflags Next argument specifies extra options passed to make when
59 # -use-gmake Use gmake instead of the default make command to build
62 # ---------------- Options to configure llvm-test ----------------------------
63 # -extraflags Next argument specifies extra options that are passed to
65 # -noexternals Do not run the external tests (for cases where povray
66 # or SPEC are not installed)
67 # -with-externals Specify a directory where the external tests are located.
68 # -submit-server Specifies a server to submit the test results too. If this
69 # option is not specified it defaults to
70 # llvm.org. This is basically just the address of the
72 # -submit-script Specifies which script to call on the submit server. If
73 # this option is not specified it defaults to
74 # /nightlytest/NightlyTestAccept.php. This is basically
75 # everything after the www.yourserver.org.
76 # -submit-aux If specified, an auxiliary script to run in addition to the
77 # normal submit script. The script will be passed the path to
78 # the "sentdata.txt" file as its sole argument.
79 # -nosubmit Do not report the test results back to a submit server.
81 # CVSROOT is the CVS repository from which the tree will be checked out,
82 # specified either in the full :method:user@host:/dir syntax, or
83 # just /dir if using a local repo.
84 # BUILDDIR is the directory where sources for this test run will be checked out
85 # AND objects for this test run will be built. This directory MUST NOT
86 # exist before the script is run; it will be created by the cvs checkout
87 # process and erased (unless -noremove is specified; see above.)
88 # WEBDIR is the directory into which the test results web page will be written,
89 # AND in which the "index.html" is assumed to be a symlink to the most recent
90 # copy of the results. This directory will be created if it does not exist.
91 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
92 # to. This is the same as you would have for a normal LLVM build.
94 ##############################################################
96 # Getting environment variables
98 ##############################################################
99 my $HOME = $ENV{'HOME'};
100 my $SVNURL = $ENV{"SVNURL"};
101 $SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
102 my $CVSRootDir = $ENV{'CVSROOT'};
103 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
104 my $BuildDir = $ENV{'BUILDDIR'};
105 $BuildDir = "$HOME/buildtest" unless $BuildDir;
106 my $WebDir = $ENV{'WEBDIR'};
107 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
109 ##############################################################
111 # Calculate the date prefix...
113 ##############################################################
115 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
116 my $DateString = strftime "%B %d, %Y", localtime;
117 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
119 ##############################################################
123 ##############################################################
129 $SUBMITSERVER = "llvm.org";
130 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
135 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
137 last if /^--$/; # Stop processing arguments on --
139 # List command line options here...
140 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
141 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
142 if (/^-noremove$/) { $NOREMOVE = 1; next; }
143 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
144 if (/^-notest$/) { $NOTEST = 1; next; }
145 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
146 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
147 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
148 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
149 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
150 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
151 "DISABLE_ASSERTIONS=1 ".
152 "OPTIMIZE_OPTION=-O2";
153 $BUILDTYPE="release-asserts"; next;}
154 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
155 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
156 $CONFIGUREARGS .= " --enable-lli"; next; }
157 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
158 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
159 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
160 $CONFIGUREARGS .= " --disable-jit"; next; }
161 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
162 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
163 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
164 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
165 if (/^-verbose$/) { $VERBOSE = 1; next; }
166 if (/^-debug$/) { $DEBUG = 1; next; }
167 if (/^-nice$/) { $NICE = "nice "; next; }
168 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
170 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
172 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
173 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
174 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
175 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
176 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
177 if (/^-gccpath/) { $CONFIGUREARGS .=
178 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
179 $GCCPATH=$ARGV[0]; shift; next; }
180 else { $GCCPATH=""; }
181 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
182 else { $CVSCOOPT="";}
183 if (/^-usecvs/) { $USESVN = 0; }
184 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
186 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
188 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
190 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
192 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
193 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
194 if (/^-extraflags/) { $CONFIGUREARGS .=
195 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
196 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
197 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
198 if (/^-nobuild$/) { $NOBUILD = 1; next; }
199 print "Unknown option: $_ : ignoring!\n";
202 if ($ENV{'LLVMGCCDIR'}) {
203 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
204 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
210 if ($CONFIGUREARGS !~ /--disable-jit/) {
211 $CONFIGUREARGS .= " --enable-jit";
214 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
218 print "Must specify 0 or 3 options!";
222 $CVSRootDir = $ARGV[0];
223 $BuildDir = $ARGV[1];
227 if ($CVSRootDir eq "" or
230 die("please specify a cvs root directory, a build directory, and a ".
234 if ($nickname eq "") {
235 die ("Please invoke NewNightlyTest.pl with command line option " .
236 "\"-nickname <nickname>\"");
239 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
240 $BUILDTYPE = "debug";
243 ##############################################################
245 #define the file names we'll use
247 ##############################################################
248 my $Prefix = "$WebDir/$DATE";
249 my $BuildLog = "$Prefix-Build-Log.txt";
250 my $COLog = "$Prefix-CVS-Log.txt";
251 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
252 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
253 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
254 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
255 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
256 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
260 warn "$WebDir did not exist; creating it.\n";
265 print "INITIALIZED\n";
267 print "SVN URL = $SVNURL\n";
269 print "CVS Root = $CVSRootDir\n";
271 print "COLog = $COLog\n";
272 print "BuildDir = $BuildDir\n";
273 print "WebDir = $WebDir\n";
274 print "Prefix = $Prefix\n";
275 print "BuildLog = $BuildLog\n";
278 ##############################################################
282 ##############################################################
286 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
291 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293 # DiffFiles - Diff the current version of the file against the last version of
294 # the file, reporting things added and removed. This is used to report, for
295 # example, added and removed warnings. This returns a pair (added, removed)
297 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300 my @Others = GetDir $Suffix;
301 if (@Others == 0) { # No other files? We added all entries...
302 return (`cat $WebDir/$DATE$Suffix`, "");
304 # Diff the files now...
305 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
306 my $Added = join "\n", grep /^</, @Diffs;
307 my $Removed = join "\n", grep /^>/, @Diffs;
309 $Removed =~ s/^> //gm;
310 return ($Added, $Removed);
313 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315 sub GetRegex { # (Regex with ()'s, value)
322 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
323 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325 my ($Regex, $Num, $Regex2, $File) = @_;
326 my @Items = split "\n", `grep '$Regex' $File`;
327 return GetRegex $Regex2, $Items[$Num];
330 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
331 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332 sub ChangeDir { # directory, logical name
333 my ($dir,$name) = @_;
335 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
336 $result = chdir($dir);
338 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
344 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347 if (open (FILE, $_[0])) {
354 print "Could not open file '$_[0]' for reading!\n";
359 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361 sub WriteFile { # (filename, contents)
362 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
367 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369 sub CopyFile { #filename, newfile
370 my ($file, $newfile) = @_;
372 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
373 copy($file, $newfile);
376 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379 my ($Val, $Filename,$WebDir) = @_;
381 if (open FILE, "$WebDir/$Filename") {
382 @Records = grep !/$DATE/, split "\n", <FILE>;
385 push @Records, "$DATE: $Val";
386 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
389 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
391 # FormatTime - Convert a time from 1m23.45 into 83.45
393 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
397 $Time = sprintf("%7.4f", $1*60.0+$2);
402 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404 # This function is meant to read in the dejagnu sum file and
405 # return a string with only the results (i.e. PASS/FAIL/XPASS/
408 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409 sub GetDejagnuTestResults { # (filename, log)
410 my ($filename, $DejagnuLog) = @_;
412 $/ = "\n"; #Make sure we're going line at a time.
414 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
416 if (open SRCHFILE, $filename) {
417 # Process test results
418 while ( <SRCHFILE> ) {
419 if ( length($_) > 1 ) {
421 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
422 push(@lines, "$1: test/$2");
429 my $content = join("\n", @lines);
435 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437 # This function acts as a mini web browswer submitting data
438 # to our central server via the post method
440 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446 # Write out the "...-sentdata.txt" file.
449 foreach $x (keys (%$variables)){
450 $value = $variables->{$x};
451 $sentdata.= "$x => $value\n";
453 WriteFile "$Prefix-sentdata.txt", $sentdata;
455 if (!($SUBMITAUX eq "")) {
456 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
459 # Create the content to send to the server.
462 foreach $key (keys (%$variables)){
463 $value = $variables->{$key};
464 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
465 $content .= "$key=$value&";
468 # Send the data to the server.
470 # FIXME: This code should be more robust?
473 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
474 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
476 connect SOCK, $socketaddr or die "Bad connection\n";
477 select((select(SOCK), $| = 1)[0]);
479 $length = length($content);
481 my $send= "POST $file HTTP/1.0\n";
482 $send.= "Host: $host\n";
483 $send.= "Content-Type: application/x-www-form-urlencoded\n";
484 $send.= "Content-length: $length\n\n";
497 ##############################################################
499 # Getting Start timestamp
501 ##############################################################
502 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
504 ##############################################################
506 # Create the CVS repository directory
508 ##############################################################
513 print "Build directory exists! Removing it\n";
515 system "rm -rf $BuildDir";
516 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
519 print "Build directory exists!\n";
523 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
526 ChangeDir( $BuildDir, "checkout directory" );
529 ##############################################################
531 # Check out the llvm tree, using either SVN or CVS
533 ##############################################################
535 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
537 my $SVNCMD = "$NICE svn co $SVNURL";
539 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
540 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
542 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
543 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
546 $CVSOPT = "-z3" # Use compression if going over ssh.
547 if $CVSRootDir =~ /^:ext:/;
548 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
550 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
551 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
553 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
554 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
557 ChangeDir( $BuildDir , "Checkout directory") ;
558 ChangeDir( "llvm" , "llvm source directory") ;
560 ##############################################################
562 # Get some static statistics about the current state of CVS
564 # This can probably be put on the server side
566 ##############################################################
567 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
568 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
569 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
570 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
572 my $NumFilesInCVS = 0;
573 my $NumDirsInCVS = 0;
575 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
576 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
578 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
579 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
582 ##############################################################
584 # Extract some information from the CVS history... use a hash so no duplicate
585 # stuff is stored. This gets the history from the previous days worth
586 # of cvs activity and parses it.
588 ##############################################################
590 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
591 # have to be perfect as its only used for comparing date ranges within a couple
593 sub ConvertToSeconds {
594 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
595 my $Result = ($yr - 2000) * 12;
608 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
611 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
614 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
615 # Skip very first entry because it is the XML header cruft
618 foreach $Record (@SVNHistory) {
619 my @Lines = split "\n", $Record;
620 my ($Author, $Date, $Revision);
621 # Get the date and see if its one we want to process.
622 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
623 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
624 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
626 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
627 # Get the current date and compute when "yesterday" is.
628 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
629 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
630 if (($Now - 24*60*60) > $Then) {
633 if ($Lines[1] =~ / revision="([0-9]*)">/) {
636 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
639 $UsersCommitted{$Author} = 1;
640 $Date = $Year . "-" . $Month . "-" . $Day;
641 $Time = $Hour . ":" . $Min . ":" . $Sec;
642 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
643 for ($i = 6; $i < $#Lines; $i += 2 ) {
644 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
647 } elsif ($1 == 'D') {
648 $RemovedFiles{$2} = 1;
649 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
650 $ModifiedFiles{$2} = 1;
652 print "UNMATCHABLE: $Lines[$i]\n";
658 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
659 #print join "\n", @CVSHistory; print "\n";
661 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
663 # Loop over every record from the CVS history, filling in the hashes.
664 foreach $File (@CVSHistory) {
665 my ($Type, $Date, $UID, $Rev, $Filename);
666 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
667 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
668 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
669 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
670 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
671 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
673 print "UNMATCHABLE: $File\n";
676 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
678 if ($Filename =~ /^llvm/) {
679 if ($Type eq 'M') { # Modified
680 $ModifiedFiles{$Filename} = 1;
681 $UsersCommitted{$UID} = 1;
682 } elsif ($Type eq 'A') { # Added
683 $AddedFiles{$Filename} = 1;
684 $UsersCommitted{$UID} = 1;
685 } elsif ($Type eq 'R') { # Removed
686 $RemovedFiles{$Filename} = 1;
687 $UsersCommitted{$UID} = 1;
689 $UsersUpdated{$UID} = 1;
698 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
699 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
700 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
701 my $UserCommitList = join "\n", sort keys %UsersCommitted;
702 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
704 ##############################################################
706 # Build the entire tree, saving build messages to the build log
708 ##############################################################
709 if (!$NOCHECKOUT && !$NOBUILD) {
710 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
712 print "CONFIGURE STAGE:\n";
713 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
714 "> $BuildLog 2>&1\n";
716 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
719 print "BUILD STAGE:\n";
720 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
722 # Build the entire tree, capturing the output into $BuildLog
723 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
726 ##############################################################
728 # Get some statistics about the build...
730 ##############################################################
731 #this can de done on server
732 #my @Linked = split '\n', `grep Linking $BuildLog`;
733 #my $NumExecutables = scalar(grep(/executable/, @Linked));
734 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
735 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
737 # Get the number of lines of source code. Must be here after the build is done
738 # because countloc.sh uses the llvm-config script which must be built.
739 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
741 # Get the time taken by the configure script
742 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
743 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
744 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
745 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
747 $ConfigTime=-1 unless $ConfigTime;
748 $ConfigWallTime=-1 unless $ConfigWallTime;
750 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
751 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
752 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
753 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
755 $BuildTime=-1 unless $BuildTime;
756 $BuildWallTime=-1 unless $BuildWallTime;
758 my $BuildError = 0, $BuildStatus = "OK";
760 $BuildStatus = "Skipped by user";
762 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
763 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
764 $BuildStatus = "Error: compilation aborted";
766 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
768 if ($BuildError) { $NODEJAGNU=1; }
773 print "Organizing size of .o and .a files\n"
775 ChangeDir( "$BuildDir/llvm", "Build Directory" );
776 $afiles.= `find utils/ -iname '*.a' -ls`;
777 $afiles.= `find lib/ -iname '*.a' -ls`;
778 $afiles.= `find tools/ -iname '*.a' -ls`;
779 if($BUILDTYPE eq "release"){
780 $afiles.= `find Release/ -iname '*.a' -ls`;
781 } elsif($BUILDTYPE eq "release-asserts") {
782 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
784 $afiles.= `find Debug/ -iname '*.a' -ls`;
787 $ofiles.= `find utils/ -iname '*.o' -ls`;
788 $ofiles.= `find lib/ -iname '*.o' -ls`;
789 $ofiles.= `find tools/ -iname '*.o' -ls`;
790 if($BUILDTYPE eq "release"){
791 $ofiles.= `find Release/ -iname '*.o' -ls`;
792 } elsif($BUILDTYPE eq "release-asserts") {
793 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
795 $ofiles.= `find Debug/ -iname '*.o' -ls`;
798 @AFILES = split "\n", $afiles;
800 foreach $x (@AFILES){
801 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
802 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
804 @OFILES = split "\n", $ofiles;
806 foreach $x (@OFILES){
807 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
808 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
811 $a_file_sizes="No data due to a bad build.";
812 $o_file_sizes="No data due to a bad build.";
815 ##############################################################
817 # Running dejagnu tests
819 ##############################################################
820 my $DejangnuTestResults=""; # String containing the results of the dejagnu
821 my $dejagnu_output = "$DejagnuTestsLog";
824 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
825 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
828 #Run the feature and regression tests, results are put into testrun.sum
829 #Full log in testrun.log
830 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
832 #Copy the testrun.log and testrun.sum to our webdir
833 CopyFile("test/testrun.log", $DejagnuLog);
834 CopyFile("test/testrun.sum", $DejagnuSum);
835 #can be done on server
836 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
837 $unexpfail_tests = $DejagnuTestResults;
840 #Extract time of dejagnu tests
841 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
842 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
843 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
844 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
845 $DejagnuTestResults =
846 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
847 $DejagnuTime = "0.0" unless $DejagnuTime;
848 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
850 ##############################################################
852 # Get warnings from the build
854 ##############################################################
856 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
857 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
861 foreach $Warning (@Warn) {
862 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
863 $CurDir = $1; # Keep track of directory warning is in...
864 # Remove buildir prefix if included
865 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
867 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
870 my $WarningsFile = join "\n", @Warnings;
871 $WarningsFile =~ s/:[0-9]+:/::/g;
873 # Emit the warnings file, so we can diff...
874 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
875 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
877 # Output something to stdout if something has changed
878 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
879 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
881 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
882 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
886 ##############################################################
888 # If we built the tree successfully, run the nightly programs tests...
890 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
893 ##############################################################
896 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
897 "Programs Test Subdirectory" ) || return ("", "");
899 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
901 # Run the programs tests... creating a report.nightly.csv file
904 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
905 "TEST=nightly > $ProgramTestLog 2>&1\n";
907 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
908 "TEST=nightly > $ProgramTestLog 2>&1";
909 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
913 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
915 $ProgramsTable="Error running test $SubDir\n";
916 print "ERROR TESTING\n";
917 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
919 $ProgramsTable="Makefile error running tests $SubDir!\n";
920 print "ERROR TESTING\n";
924 # Create a list of the tests which were run...
926 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
927 "| sort > $Prefix-$SubDir-Tests.txt";
929 $ProgramsTable = ReadFile "report.nightly.csv";
931 ChangeDir( "../../..", "Programs Test Parent Directory" );
932 return ($ProgramsTable, $llcbeta_options);
933 } #end sub TestDirectory
935 ##############################################################
937 # Calling sub TestDirectory
939 ##############################################################
942 print "SingleSource TEST STAGE\n";
944 ($SingleSourceProgramsTable, $llcbeta_options) =
945 TestDirectory("SingleSource");
946 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
948 print "MultiSource TEST STAGE\n";
950 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
951 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
952 if ( ! $NOEXTERNALS ) {
954 print "External TEST STAGE\n";
956 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
957 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
958 system "cat $Prefix-SingleSource-Tests.txt " .
959 "$Prefix-MultiSource-Tests.txt ".
960 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
961 system "cat $Prefix-SingleSource-Performance.txt " .
962 "$Prefix-MultiSource-Performance.txt ".
963 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
965 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
967 print "External TEST STAGE SKIPPED\n";
969 system "cat $Prefix-SingleSource-Tests.txt " .
970 "$Prefix-MultiSource-Tests.txt ".
971 " | sort > $Prefix-Tests.txt";
972 system "cat $Prefix-SingleSource-Performance.txt " .
973 "$Prefix-MultiSource-Performance.txt ".
974 " | sort > $Prefix-Performance.txt";
977 ##############################################################
980 # gathering tests added removed broken information here
983 ##############################################################
984 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
985 my @DEJAGNU = split "\n", $dejagnu_test_list;
986 my ($passes, $fails, $xfails) = "";
989 for ($x=0; $x<@DEJAGNU; $x++) {
990 if ($DEJAGNU[$x] =~ m/^PASS:/) {
991 $passes.="$DEJAGNU[$x]\n";
993 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
994 $fails.="$DEJAGNU[$x]\n";
996 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
997 $xfails.="$DEJAGNU[$x]\n";
1002 } #end if !$BuildError
1004 ##############################################################
1006 # Getting end timestamp
1008 ##############################################################
1009 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1012 ##############################################################
1014 # Place all the logs neatly into one humungous file
1016 ##############################################################
1017 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1019 $machine_data = "uname: ".`uname -a`.
1020 "hardware: ".`uname -m`.
1022 "name: ".`uname -n`.
1023 "date: ".`date \"+20%y-%m-%d\"`.
1024 "time: ".`date +\"%H:%M:%S\"`;
1028 @CVS_DATA = ReadFile "$COLog";
1029 $cvs_data = join("\n", @CVS_DATA);
1033 @BUILD_DATA = ReadFile "$BuildLog";
1034 $build_data = join("\n", @BUILD_DATA);
1036 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1037 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1038 my ($gcc_version, $gcc_version_long) = "";
1040 $gcc_version_long="";
1041 if ($GCCPATH ne "") {
1042 $gcc_version_long = `$GCCPATH/gcc --version`;
1043 } elsif ($ENV{"CC"}) {
1044 $gcc_version_long = `$ENV{"CC"} --version`;
1046 $gcc_version_long = `gcc --version`;
1048 @GCC_VERSION = split '\n', $gcc_version_long;
1049 $gcc_version = $GCC_VERSION[0];
1051 $llvmgcc_version_long="";
1052 if ($LLVMGCCPATH ne "") {
1053 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1055 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1057 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1058 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1059 $llvmgcc_versionTarget =~ /Target: (.+)/;
1063 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1064 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1065 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1066 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1068 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1069 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1072 ##############################################################
1074 # Send data via a post request
1076 ##############################################################
1078 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1080 my %hash_of_data = (
1081 'machine_data' => $machine_data,
1082 'build_data' => $build_data,
1083 'gcc_version' => $gcc_version,
1084 'nickname' => $nickname,
1085 'dejagnutime_wall' => $DejagnuWallTime,
1086 'dejagnutime_cpu' => $DejagnuTime,
1087 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1088 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1089 'configtime_wall' => $ConfigWallTime,
1090 'configtime_cpu'=> $ConfigTime,
1091 'buildtime_wall' => $BuildWallTime,
1092 'buildtime_cpu' => $BuildTime,
1093 'warnings' => $WarningsFile,
1094 'cvsusercommitlist' => $UserCommitList,
1095 'cvsuserupdatelist' => $UserUpdateList,
1096 'cvsaddedfiles' => $CVSAddedFiles,
1097 'cvsmodifiedfiles' => $CVSModifiedFiles,
1098 'cvsremovedfiles' => $CVSRemovedFiles,
1099 'lines_of_code' => $LOC,
1100 'cvs_file_count' => $NumFilesInCVS,
1101 'cvs_dir_count' => $NumDirsInCVS,
1102 'buildstatus' => $BuildStatus,
1103 'singlesource_programstable' => $SingleSourceProgramsTable,
1104 'multisource_programstable' => $MultiSourceProgramsTable,
1105 'externalsource_programstable' => $ExternalProgramsTable,
1106 'llcbeta_options' => $multisource_llcbeta_options,
1107 'warnings_removed' => $WarningsRemoved,
1108 'warnings_added' => $WarningsAdded,
1109 'passing_tests' => $passes,
1110 'expfail_tests' => $xfails,
1111 'unexpfail_tests' => $fails,
1112 'all_tests' => $dejagnu_test_list,
1114 'removed_tests' => "",
1115 'dejagnutests_results' => $DejagnuTestResults,
1116 'dejagnutests_log' => $dejagnulog_full,
1117 'starttime' => $starttime,
1118 'endtime' => $endtime,
1119 'o_file_sizes' => $o_file_sizes,
1120 'a_file_sizes' => $a_file_sizes,
1121 'target_triple' => $targetTriple
1125 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1126 if( $VERBOSE) { print "============================\n$response"; }
1128 print "============================\n";
1129 foreach $x(keys %hash_of_data){
1130 print "$x => $hash_of_data{$x}\n";
1134 ##############################################################
1136 # Remove the cvs tree...
1138 ##############################################################
1139 system ( "$NICE rm -rf $BuildDir")
1140 if (!$NOCHECKOUT and !$NOREMOVE);
1141 system ( "$NICE rm -rf $WebDir")
1142 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);