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 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
16 # OPTIONS may include one or more of the following:
17 # -nocheckout Do not create, checkout, update, or configure
19 # -noremove Do not remove the BUILDDIR after it has been built.
20 # -noremoveresults Do not remove the WEBDIR after it has been built.
21 # -nobuild Do not build llvm. If tests are enabled perform them
22 # on the llvm build specified in the build directory
23 # -notest Do not even attempt to run the test programs.
24 # -nodejagnu Do not run feature or regression tests
25 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
26 # -parallel-jobs The number of parallel Make jobs to use (default is two).
27 # -with-clang Checkout Clang source into tools/clang.
28 # -release Build an LLVM Release version
29 # -release-asserts Build an LLVM ReleaseAsserts version
30 # -enable-llcbeta Enable testing of beta features in llc.
31 # -enable-lli Enable testing of lli (interpreter) features, default is off
32 # -disable-pic Disable building with Position Independent Code.
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 = 'http://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 (/^-with-clang$/) { $WITHCLANG = 1; next; }
149 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
150 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
151 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
152 "DISABLE_ASSERTIONS=1 ".
153 "OPTIMIZE_OPTION=-O2";
154 $BUILDTYPE="release-asserts"; next;}
155 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
156 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
157 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
158 $CONFIGUREARGS .= " --enable-lli"; next; }
159 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
160 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
161 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
162 $CONFIGUREARGS .= " --disable-jit"; next; }
163 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
164 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
165 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
166 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
167 if (/^-verbose$/) { $VERBOSE = 1; next; }
168 if (/^-debug$/) { $DEBUG = 1; next; }
169 if (/^-nice$/) { $NICE = "nice "; next; }
170 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
172 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
174 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
175 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
176 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
177 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
178 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
179 if (/^-gccpath/) { $CONFIGUREARGS .=
180 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
181 $GCCPATH=$ARGV[0]; shift; next; }
182 else { $GCCPATH=""; }
183 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
184 else { $CVSCOOPT="";}
185 if (/^-usecvs/) { $USESVN = 0; }
186 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
188 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
190 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
192 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
194 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
195 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
196 if (/^-extraflags/) { $CONFIGUREARGS .=
197 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
198 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
199 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
200 if (/^-nobuild$/) { $NOBUILD = 1; next; }
201 print "Unknown option: $_ : ignoring!\n";
204 if ($ENV{'LLVMGCCDIR'}) {
205 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
206 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
212 if ($CONFIGUREARGS !~ /--disable-jit/) {
213 $CONFIGUREARGS .= " --enable-jit";
216 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
220 print "Must specify 0 or 3 options!";
224 $CVSRootDir = $ARGV[0];
225 $BuildDir = $ARGV[1];
229 if ($CVSRootDir eq "" or
232 die("please specify a cvs root directory, a build directory, and a ".
236 if ($nickname eq "") {
237 die ("Please invoke NewNightlyTest.pl with command line option " .
238 "\"-nickname <nickname>\"");
241 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
242 $BUILDTYPE = "debug";
245 ##############################################################
247 #define the file names we'll use
249 ##############################################################
250 my $Prefix = "$WebDir/$DATE";
251 my $BuildLog = "$Prefix-Build-Log.txt";
252 my $COLog = "$Prefix-CVS-Log.txt";
253 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
254 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
255 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
256 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
257 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
258 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
262 warn "$WebDir did not exist; creating it.\n";
267 print "INITIALIZED\n";
269 print "SVN URL = $SVNURL\n";
271 print "CVS Root = $CVSRootDir\n";
273 print "COLog = $COLog\n";
274 print "BuildDir = $BuildDir\n";
275 print "WebDir = $WebDir\n";
276 print "Prefix = $Prefix\n";
277 print "BuildLog = $BuildLog\n";
280 ##############################################################
284 ##############################################################
288 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
293 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295 # DiffFiles - Diff the current version of the file against the last version of
296 # the file, reporting things added and removed. This is used to report, for
297 # example, added and removed warnings. This returns a pair (added, removed)
299 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302 my @Others = GetDir $Suffix;
303 if (@Others == 0) { # No other files? We added all entries...
304 return (`cat $WebDir/$DATE$Suffix`, "");
306 # Diff the files now...
307 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
308 my $Added = join "\n", grep /^</, @Diffs;
309 my $Removed = join "\n", grep /^>/, @Diffs;
311 $Removed =~ s/^> //gm;
312 return ($Added, $Removed);
315 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 sub GetRegex { # (Regex with ()'s, value)
324 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327 my ($Regex, $Num, $Regex2, $File) = @_;
328 my @Items = split "\n", `grep '$Regex' $File`;
329 return GetRegex $Regex2, $Items[$Num];
332 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334 sub ChangeDir { # directory, logical name
335 my ($dir,$name) = @_;
337 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
338 $result = chdir($dir);
340 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
346 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349 if (open (FILE, $_[0])) {
356 print "Could not open file '$_[0]' for reading!\n";
361 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363 sub WriteFile { # (filename, contents)
364 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
369 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 sub CopyFile { #filename, newfile
372 my ($file, $newfile) = @_;
374 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
375 copy($file, $newfile);
378 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381 my ($Val, $Filename,$WebDir) = @_;
383 if (open FILE, "$WebDir/$Filename") {
384 @Records = grep !/$DATE/, split "\n", <FILE>;
387 push @Records, "$DATE: $Val";
388 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
391 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393 # FormatTime - Convert a time from 1m23.45 into 83.45
395 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
399 $Time = sprintf("%7.4f", $1*60.0+$2);
404 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406 # This function is meant to read in the dejagnu sum file and
407 # return a string with only the results (i.e. PASS/FAIL/XPASS/
410 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411 sub GetDejagnuTestResults { # (filename, log)
412 my ($filename, $DejagnuLog) = @_;
414 $/ = "\n"; #Make sure we're going line at a time.
416 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
418 if (open SRCHFILE, $filename) {
419 # Process test results
420 while ( <SRCHFILE> ) {
421 if ( length($_) > 1 ) {
423 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
424 push(@lines, "$1: test/$2");
431 my $content = join("\n", @lines);
437 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439 # This function acts as a mini web browswer submitting data
440 # to our central server via the post method
442 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
448 # Write out the "...-sentdata.txt" file.
451 foreach $x (keys (%$variables)){
452 $value = $variables->{$x};
453 $sentdata.= "$x => $value\n";
455 WriteFile "$Prefix-sentdata.txt", $sentdata;
457 if (!($SUBMITAUX eq "")) {
458 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
461 # Create the content to send to the server.
464 foreach $key (keys (%$variables)){
465 $value = $variables->{$key};
466 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
467 $content .= "$key=$value&";
470 # Send the data to the server.
472 # FIXME: This code should be more robust?
475 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
476 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
478 connect SOCK, $socketaddr or die "Bad connection\n";
479 select((select(SOCK), $| = 1)[0]);
481 $length = length($content);
483 my $send= "POST $file HTTP/1.0\n";
484 $send.= "Host: $host\n";
485 $send.= "Content-Type: application/x-www-form-urlencoded\n";
486 $send.= "Content-length: $length\n\n";
499 ##############################################################
501 # Getting Start timestamp
503 ##############################################################
504 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
506 ##############################################################
508 # Create the CVS repository directory
510 ##############################################################
515 print "Build directory exists! Removing it\n";
517 system "rm -rf $BuildDir";
518 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
521 print "Build directory exists!\n";
525 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
528 ChangeDir( $BuildDir, "checkout directory" );
531 ##############################################################
533 # Check out the llvm tree, using either SVN or CVS
535 ##############################################################
537 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
539 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
541 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
542 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
544 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
545 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
547 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
549 print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
551 system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
555 $CVSOPT = "-z3" # Use compression if going over ssh.
556 if $CVSRootDir =~ /^:ext:/;
557 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
559 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
560 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
562 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
563 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
566 ChangeDir( $BuildDir , "Checkout directory") ;
567 ChangeDir( "llvm" , "llvm source directory") ;
569 ##############################################################
571 # Get some static statistics about the current state of CVS
573 # This can probably be put on the server side
575 ##############################################################
576 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
577 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
578 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
579 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
581 my $NumFilesInCVS = 0;
582 my $NumDirsInCVS = 0;
584 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
585 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
587 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
588 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
591 ##############################################################
593 # Extract some information from the CVS history... use a hash so no duplicate
594 # stuff is stored. This gets the history from the previous days worth
595 # of cvs activity and parses it.
597 ##############################################################
599 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
600 # have to be perfect as its only used for comparing date ranges within a couple
602 sub ConvertToSeconds {
603 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
604 my $Result = ($yr - 2000) * 12;
617 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
620 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
623 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
624 # Skip very first entry because it is the XML header cruft
627 foreach $Record (@SVNHistory) {
628 my @Lines = split "\n", $Record;
629 my ($Author, $Date, $Revision);
630 # Get the date and see if its one we want to process.
631 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
632 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
633 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
635 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
636 # Get the current date and compute when "yesterday" is.
637 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
638 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
639 if (($Now - 24*60*60) > $Then) {
642 if ($Lines[1] =~ / revision="([0-9]*)">/) {
645 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
648 $UsersCommitted{$Author} = 1;
649 $Date = $Year . "-" . $Month . "-" . $Day;
650 $Time = $Hour . ":" . $Min . ":" . $Sec;
651 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
652 for ($i = 6; $i < $#Lines; $i += 2 ) {
653 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
656 } elsif ($1 == 'D') {
657 $RemovedFiles{$2} = 1;
658 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
659 $ModifiedFiles{$2} = 1;
661 print "UNMATCHABLE: $Lines[$i]\n";
667 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
668 #print join "\n", @CVSHistory; print "\n";
670 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
672 # Loop over every record from the CVS history, filling in the hashes.
673 foreach $File (@CVSHistory) {
674 my ($Type, $Date, $UID, $Rev, $Filename);
675 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
676 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
677 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
678 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
679 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
680 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
682 print "UNMATCHABLE: $File\n";
685 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
687 if ($Filename =~ /^llvm/) {
688 if ($Type eq 'M') { # Modified
689 $ModifiedFiles{$Filename} = 1;
690 $UsersCommitted{$UID} = 1;
691 } elsif ($Type eq 'A') { # Added
692 $AddedFiles{$Filename} = 1;
693 $UsersCommitted{$UID} = 1;
694 } elsif ($Type eq 'R') { # Removed
695 $RemovedFiles{$Filename} = 1;
696 $UsersCommitted{$UID} = 1;
698 $UsersUpdated{$UID} = 1;
707 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
708 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
709 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
710 my $UserCommitList = join "\n", sort keys %UsersCommitted;
711 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
713 ##############################################################
715 # Build the entire tree, saving build messages to the build log
717 ##############################################################
718 if (!$NOCHECKOUT && !$NOBUILD) {
719 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
721 print "CONFIGURE STAGE:\n";
722 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
723 "> $BuildLog 2>&1\n";
725 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
728 print "BUILD STAGE:\n";
729 print "(time -p $NICE $MAKECMD clean) >> $BuildLog 2>&1\n";
730 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
732 # Build the entire tree, capturing the output into $BuildLog
733 system "(time -p $NICE $MAKECMD clean) >> $BuildLog 2>&1";
734 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
737 ##############################################################
739 # Get some statistics about the build...
741 ##############################################################
742 #this can de done on server
743 #my @Linked = split '\n', `grep Linking $BuildLog`;
744 #my $NumExecutables = scalar(grep(/executable/, @Linked));
745 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
746 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
748 # Get the number of lines of source code. Must be here after the build is done
749 # because countloc.sh uses the llvm-config script which must be built.
750 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
752 # Get the time taken by the configure script
753 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
754 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
755 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
756 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
758 $ConfigTime=-1 unless $ConfigTime;
759 $ConfigWallTime=-1 unless $ConfigWallTime;
761 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
762 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
763 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
764 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
766 $BuildTime=-1 unless $BuildTime;
767 $BuildWallTime=-1 unless $BuildWallTime;
769 my $BuildError = 0, $BuildStatus = "OK";
771 $BuildStatus = "Skipped by user";
773 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
774 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
775 $BuildStatus = "Error: compilation aborted";
777 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
779 if ($BuildError) { $NODEJAGNU=1; }
784 print "Organizing size of .o and .a files\n"
786 ChangeDir( "$BuildDir/llvm", "Build Directory" );
787 $afiles.= `find utils/ -iname '*.a' -ls`;
788 $afiles.= `find lib/ -iname '*.a' -ls`;
789 $afiles.= `find tools/ -iname '*.a' -ls`;
790 if($BUILDTYPE eq "release"){
791 $afiles.= `find Release/ -iname '*.a' -ls`;
792 } elsif($BUILDTYPE eq "release-asserts") {
793 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
795 $afiles.= `find Debug/ -iname '*.a' -ls`;
798 $ofiles.= `find utils/ -iname '*.o' -ls`;
799 $ofiles.= `find lib/ -iname '*.o' -ls`;
800 $ofiles.= `find tools/ -iname '*.o' -ls`;
801 if($BUILDTYPE eq "release"){
802 $ofiles.= `find Release/ -iname '*.o' -ls`;
803 } elsif($BUILDTYPE eq "release-asserts") {
804 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
806 $ofiles.= `find Debug/ -iname '*.o' -ls`;
809 @AFILES = split "\n", $afiles;
811 foreach $x (@AFILES){
812 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
813 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
815 @OFILES = split "\n", $ofiles;
817 foreach $x (@OFILES){
818 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
819 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
822 $a_file_sizes="No data due to a bad build.";
823 $o_file_sizes="No data due to a bad build.";
826 ##############################################################
828 # Running dejagnu tests
830 ##############################################################
831 my $DejangnuTestResults=""; # String containing the results of the dejagnu
832 my $dejagnu_output = "$DejagnuTestsLog";
835 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
836 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
839 #Run the feature and regression tests, results are put into testrun.sum
840 #Full log in testrun.log
841 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
843 #Copy the testrun.log and testrun.sum to our webdir
844 CopyFile("test/testrun.log", $DejagnuLog);
845 CopyFile("test/testrun.sum", $DejagnuSum);
846 #can be done on server
847 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
848 $unexpfail_tests = $DejagnuTestResults;
851 #Extract time of dejagnu tests
852 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
853 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
854 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
855 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
856 $DejagnuTestResults =
857 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
858 $DejagnuTime = "0.0" unless $DejagnuTime;
859 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
861 ##############################################################
863 # Get warnings from the build
865 ##############################################################
867 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
868 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
872 foreach $Warning (@Warn) {
873 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
874 $CurDir = $1; # Keep track of directory warning is in...
875 # Remove buildir prefix if included
876 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
878 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
881 my $WarningsFile = join "\n", @Warnings;
882 $WarningsFile =~ s/:[0-9]+:/::/g;
884 # Emit the warnings file, so we can diff...
885 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
886 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
888 # Output something to stdout if something has changed
889 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
890 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
892 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
893 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
897 ##############################################################
899 # If we built the tree successfully, run the nightly programs tests...
901 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
904 ##############################################################
907 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
908 "Programs Test Subdirectory" ) || return ("", "");
910 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
912 # Run the programs tests... creating a report.nightly.csv file
915 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
916 "TEST=nightly > $ProgramTestLog 2>&1\n";
918 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
919 "TEST=nightly > $ProgramTestLog 2>&1";
920 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
924 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
926 $ProgramsTable="Error running test $SubDir\n";
927 print "ERROR TESTING\n";
928 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
930 $ProgramsTable="Makefile error running tests $SubDir!\n";
931 print "ERROR TESTING\n";
935 # Create a list of the tests which were run...
937 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
938 "| sort > $Prefix-$SubDir-Tests.txt";
940 $ProgramsTable = ReadFile "report.nightly.csv";
942 ChangeDir( "../../..", "Programs Test Parent Directory" );
943 return ($ProgramsTable, $llcbeta_options);
944 } #end sub TestDirectory
946 ##############################################################
948 # Calling sub TestDirectory
950 ##############################################################
953 print "SingleSource TEST STAGE\n";
955 ($SingleSourceProgramsTable, $llcbeta_options) =
956 TestDirectory("SingleSource");
957 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
959 print "MultiSource TEST STAGE\n";
961 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
962 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
963 if ( ! $NOEXTERNALS ) {
965 print "External TEST STAGE\n";
967 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
968 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
969 system "cat $Prefix-SingleSource-Tests.txt " .
970 "$Prefix-MultiSource-Tests.txt ".
971 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
972 system "cat $Prefix-SingleSource-Performance.txt " .
973 "$Prefix-MultiSource-Performance.txt ".
974 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
976 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
978 print "External TEST STAGE SKIPPED\n";
980 system "cat $Prefix-SingleSource-Tests.txt " .
981 "$Prefix-MultiSource-Tests.txt ".
982 " | sort > $Prefix-Tests.txt";
983 system "cat $Prefix-SingleSource-Performance.txt " .
984 "$Prefix-MultiSource-Performance.txt ".
985 " | sort > $Prefix-Performance.txt";
988 ##############################################################
991 # gathering tests added removed broken information here
994 ##############################################################
995 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
996 my @DEJAGNU = split "\n", $dejagnu_test_list;
997 my ($passes, $fails, $xfails) = "";
1000 for ($x=0; $x<@DEJAGNU; $x++) {
1001 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1002 $passes.="$DEJAGNU[$x]\n";
1004 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1005 $fails.="$DEJAGNU[$x]\n";
1007 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1008 $xfails.="$DEJAGNU[$x]\n";
1013 } #end if !$BuildError
1015 ##############################################################
1017 # Getting end timestamp
1019 ##############################################################
1020 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1023 ##############################################################
1025 # Place all the logs neatly into one humungous file
1027 ##############################################################
1028 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1030 $machine_data = "uname: ".`uname -a`.
1031 "hardware: ".`uname -m`.
1033 "name: ".`uname -n`.
1034 "date: ".`date \"+20%y-%m-%d\"`.
1035 "time: ".`date +\"%H:%M:%S\"`;
1039 @CVS_DATA = ReadFile "$COLog";
1040 $cvs_data = join("\n", @CVS_DATA);
1044 @BUILD_DATA = ReadFile "$BuildLog";
1045 $build_data = join("\n", @BUILD_DATA);
1047 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1048 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1049 my ($gcc_version, $gcc_version_long) = "";
1051 $gcc_version_long="";
1052 if ($GCCPATH ne "") {
1053 $gcc_version_long = `$GCCPATH/gcc --version`;
1054 } elsif ($ENV{"CC"}) {
1055 $gcc_version_long = `$ENV{"CC"} --version`;
1057 $gcc_version_long = `gcc --version`;
1059 @GCC_VERSION = split '\n', $gcc_version_long;
1060 $gcc_version = $GCC_VERSION[0];
1062 $llvmgcc_version_long="";
1063 if ($LLVMGCCPATH ne "") {
1064 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1066 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1068 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1069 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1070 $llvmgcc_versionTarget =~ /Target: (.+)/;
1074 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1075 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1076 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1077 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1079 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1080 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1083 ##############################################################
1085 # Send data via a post request
1087 ##############################################################
1089 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1091 my %hash_of_data = (
1092 'machine_data' => $machine_data,
1093 'build_data' => $build_data,
1094 'gcc_version' => $gcc_version,
1095 'nickname' => $nickname,
1096 'dejagnutime_wall' => $DejagnuWallTime,
1097 'dejagnutime_cpu' => $DejagnuTime,
1098 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1099 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1100 'configtime_wall' => $ConfigWallTime,
1101 'configtime_cpu'=> $ConfigTime,
1102 'buildtime_wall' => $BuildWallTime,
1103 'buildtime_cpu' => $BuildTime,
1104 'warnings' => $WarningsFile,
1105 'cvsusercommitlist' => $UserCommitList,
1106 'cvsuserupdatelist' => $UserUpdateList,
1107 'cvsaddedfiles' => $CVSAddedFiles,
1108 'cvsmodifiedfiles' => $CVSModifiedFiles,
1109 'cvsremovedfiles' => $CVSRemovedFiles,
1110 'lines_of_code' => $LOC,
1111 'cvs_file_count' => $NumFilesInCVS,
1112 'cvs_dir_count' => $NumDirsInCVS,
1113 'buildstatus' => $BuildStatus,
1114 'singlesource_programstable' => $SingleSourceProgramsTable,
1115 'multisource_programstable' => $MultiSourceProgramsTable,
1116 'externalsource_programstable' => $ExternalProgramsTable,
1117 'llcbeta_options' => $multisource_llcbeta_options,
1118 'warnings_removed' => $WarningsRemoved,
1119 'warnings_added' => $WarningsAdded,
1120 'passing_tests' => $passes,
1121 'expfail_tests' => $xfails,
1122 'unexpfail_tests' => $fails,
1123 'all_tests' => $dejagnu_test_list,
1125 'removed_tests' => "",
1126 'dejagnutests_results' => $DejagnuTestResults,
1127 'dejagnutests_log' => $dejagnulog_full,
1128 'starttime' => $starttime,
1129 'endtime' => $endtime,
1130 'o_file_sizes' => $o_file_sizes,
1131 'a_file_sizes' => $a_file_sizes,
1132 'target_triple' => $targetTriple
1136 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1137 if( $VERBOSE) { print "============================\n$response"; }
1139 print "============================\n";
1140 foreach $x(keys %hash_of_data){
1141 print "$x => $hash_of_data{$x}\n";
1145 ##############################################################
1147 # Remove the cvs tree...
1149 ##############################################################
1150 system ( "$NICE rm -rf $BuildDir")
1151 if (!$NOCHECKOUT and !$NOREMOVE);
1152 system ( "$NICE rm -rf $WebDir")
1153 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);