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. Implies
27 # -norunningtests Do not run the Olden benchmark suite with
28 # LARGE_PROBLEM_SIZE enabled.
29 # -nodejagnu Do not run feature or regression tests
30 # -parallel Run two parallel jobs with GNU Make.
31 # -release Build an LLVM Release version
32 # -release-asserts Build an LLVM ReleaseAsserts version
33 # -enable-llcbeta Enable testing of beta features in llc.
34 # -enable-lli Enable testing of lli (interpreter) features, default is off
35 # -disable-llc Disable LLC tests in the nightly tester.
36 # -disable-jit Disable JIT tests in the nightly tester.
37 # -disable-cbe Disable C backend tests in the nightly tester.
38 # -disable-lto Disable link time optimization.
39 # -disable-bindings Disable building LLVM bindings.
40 # -verbose Turn on some debug output
41 # -debug Print information useful only to maintainers of this script.
42 # -nice Checkout/Configure/Build with "nice" to reduce impact
44 # -f2c Next argument specifies path to F2C utility
45 # -nickname The next argument specifieds the nickname this script
46 # will submit to the nightlytest results repository.
47 # -gccpath Path to gcc/g++ used to build LLVM
48 # -cvstag Check out a specific CVS tag to build LLVM (useful for
49 # testing release branches)
50 # -usecvs Check code out from the (old) CVS Repository instead of from
51 # the standard Subversion repository.
52 # -target Specify the target triplet
53 # -cflags Next argument specifies that C compilation options that
54 # override the default.
55 # -cxxflags Next argument specifies that C++ compilation options that
56 # override the default.
57 # -ldflags Next argument specifies that linker options that override
59 # -compileflags Next argument specifies extra options passed to make when
61 # -use-gmake Use gmake instead of the default make command to build
64 # ---------------- Options to configure llvm-test ----------------------------
65 # -extraflags Next argument specifies extra options that are passed to
67 # -noexternals Do not run the external tests (for cases where povray
68 # or SPEC are not installed)
69 # -with-externals Specify a directory where the external tests are located.
70 # -submit-server Specifies a server to submit the test results too. If this
71 # option is not specified it defaults to
72 # llvm.org. This is basically just the address of the
74 # -submit-script Specifies which script to call on the submit server. If
75 # this option is not specified it defaults to
76 # /nightlytest/NightlyTestAccept.php. This is basically
77 # everything after the www.yourserver.org.
78 # -submit-aux If specified, an auxiliary script to run in addition to the
79 # normal submit script. The script will be passed the path to
80 # the "sentdata.txt" file as its sole argument.
81 # -nosubmit Do not report the test results back to a submit server.
83 # CVSROOT is the CVS repository from which the tree will be checked out,
84 # specified either in the full :method:user@host:/dir syntax, or
85 # just /dir if using a local repo.
86 # BUILDDIR is the directory where sources for this test run will be checked out
87 # AND objects for this test run will be built. This directory MUST NOT
88 # exist before the script is run; it will be created by the cvs checkout
89 # process and erased (unless -noremove is specified; see above.)
90 # WEBDIR is the directory into which the test results web page will be written,
91 # AND in which the "index.html" is assumed to be a symlink to the most recent
92 # copy of the results. This directory will be created if it does not exist.
93 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
94 # to. This is the same as you would have for a normal LLVM build.
96 ##############################################################
98 # Getting environment variables
100 ##############################################################
101 my $HOME = $ENV{'HOME'};
102 my $SVNURL = $ENV{"SVNURL"};
103 $SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
104 my $CVSRootDir = $ENV{'CVSROOT'};
105 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
106 my $BuildDir = $ENV{'BUILDDIR'};
107 $BuildDir = "$HOME/buildtest" unless $BuildDir;
108 my $WebDir = $ENV{'WEBDIR'};
109 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
111 ##############################################################
113 # Calculate the date prefix...
115 ##############################################################
117 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
118 my $DateString = strftime "%B %d, %Y", localtime;
119 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
121 ##############################################################
125 ##############################################################
132 $SUBMITSERVER = "llvm.org";
133 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
137 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
139 last if /^--$/; # Stop processing arguments on --
141 # List command line options here...
142 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
143 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
144 if (/^-noremove$/) { $NOREMOVE = 1; next; }
145 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
146 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
147 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
148 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; 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 (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
157 $CONFIGUREARGS .= " --enable-lli"; next; }
158 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
159 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
160 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
161 $CONFIGUREARGS .= " --disable-jit"; next; }
162 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
163 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
164 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
165 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
166 if (/^-verbose$/) { $VERBOSE = 1; next; }
167 if (/^-debug$/) { $DEBUG = 1; next; }
168 if (/^-nice$/) { $NICE = "nice "; next; }
169 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
171 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
173 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
174 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
175 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
176 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
177 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
178 if (/^-gccpath/) { $CONFIGUREARGS .=
179 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
180 $GCCPATH=$ARGV[0]; shift; next; }
181 else { $GCCPATH=""; }
182 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
183 else { $CVSCOOPT="";}
184 if (/^-usecvs/) { $USESVN = 0; }
185 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
187 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
189 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
191 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
193 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
194 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
195 if (/^-extraflags/) { $CONFIGUREARGS .=
196 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
197 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
198 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
199 if (/^-nobuild$/) { $NOBUILD = 1; next; }
200 print "Unknown option: $_ : ignoring!\n";
203 if ($ENV{'LLVMGCCDIR'}) {
204 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
205 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
211 if ($CONFIGUREARGS !~ /--disable-jit/) {
212 $CONFIGUREARGS .= " --enable-jit";
215 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
219 print "Must specify 0 or 3 options!";
223 $CVSRootDir = $ARGV[0];
224 $BuildDir = $ARGV[1];
228 if ($CVSRootDir eq "" or
231 die("please specify a cvs root directory, a build directory, and a ".
235 if ($nickname eq "") {
236 die ("Please invoke NewNightlyTest.pl with command line option " .
237 "\"-nickname <nickname>\"");
240 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
241 $BUILDTYPE = "debug";
244 ##############################################################
246 #define the file names we'll use
248 ##############################################################
249 my $Prefix = "$WebDir/$DATE";
250 my $BuildLog = "$Prefix-Build-Log.txt";
251 my $COLog = "$Prefix-CVS-Log.txt";
252 my $OldenTestsLog = "$Prefix-Olden-tests.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 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
450 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
452 connect SOCK, $socketaddr or die "Bad connection\n";
453 select((select(SOCK), $| = 1)[0]);
455 #creating content here
457 foreach $key (keys (%$variables)){
458 $value = $variables->{$key};
459 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
460 $content .= "$key=$value&";
463 $length = length($content);
465 my $send= "POST $file HTTP/1.0\n";
466 $send.= "Host: $host\n";
467 $send.= "Content-Type: application/x-www-form-urlencoded\n";
468 $send.= "Content-length: $length\n\n";
479 foreach $x (keys (%$variables)){
480 $value = $variables->{$x};
481 $sentdata.= "$x => $value\n";
483 WriteFile "$Prefix-sentdata.txt", $sentdata;
485 if (!($SUBMITAUX eq "")) {
486 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
492 ##############################################################
494 # Getting Start timestamp
496 ##############################################################
497 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
499 ##############################################################
501 # Create the CVS repository directory
503 ##############################################################
508 print "Build directory exists! Removing it\n";
510 system "rm -rf $BuildDir";
511 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
514 print "Build directory exists!\n";
518 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
521 ChangeDir( $BuildDir, "checkout directory" );
524 ##############################################################
526 # Check out the llvm tree, using either SVN or CVS
528 ##############################################################
530 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
532 my $SVNCMD = "$NICE svn co $SVNURL";
534 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
535 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
537 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
538 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
541 $CVSOPT = "-z3" # Use compression if going over ssh.
542 if $CVSRootDir =~ /^:ext:/;
543 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
545 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
546 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
548 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
549 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
552 ChangeDir( $BuildDir , "Checkout directory") ;
553 ChangeDir( "llvm" , "llvm source directory") ;
555 ##############################################################
557 # Get some static statistics about the current state of CVS
559 # This can probably be put on the server side
561 ##############################################################
562 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
563 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
564 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
565 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
567 my $NumFilesInCVS = 0;
568 my $NumDirsInCVS = 0;
570 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
571 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
573 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
574 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
577 ##############################################################
579 # Extract some information from the CVS history... use a hash so no duplicate
580 # stuff is stored. This gets the history from the previous days worth
581 # of cvs activity and parses it.
583 ##############################################################
585 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
586 # have to be perfect as its only used for comparing date ranges within a couple
588 sub ConvertToSeconds {
589 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
590 my $Result = ($yr - 2000) * 12;
603 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
606 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
609 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
610 # Skip very first entry because it is the XML header cruft
613 foreach $Record (@SVNHistory) {
614 my @Lines = split "\n", $Record;
615 my ($Author, $Date, $Revision);
616 # Get the date and see if its one we want to process.
617 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
618 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
619 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
621 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
622 # Get the current date and compute when "yesterday" is.
623 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
624 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
625 if (($Now - 24*60*60) > $Then) {
628 if ($Lines[1] =~ / revision="([0-9]*)">/) {
631 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
634 $UsersCommitted{$Author} = 1;
635 $Date = $Year . "-" . $Month . "-" . $Day;
636 $Time = $Hour . ":" . $Min . ":" . $Sec;
637 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
638 for ($i = 6; $i < $#Lines; $i += 2 ) {
639 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
642 } elsif ($1 == 'D') {
643 $RemovedFiles{$2} = 1;
644 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
645 $ModifiedFiles{$2} = 1;
647 print "UNMATCHABLE: $Lines[$i]\n";
653 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
654 #print join "\n", @CVSHistory; print "\n";
656 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
658 # Loop over every record from the CVS history, filling in the hashes.
659 foreach $File (@CVSHistory) {
660 my ($Type, $Date, $UID, $Rev, $Filename);
661 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
662 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
663 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
664 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
665 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
666 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
668 print "UNMATCHABLE: $File\n";
671 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
673 if ($Filename =~ /^llvm/) {
674 if ($Type eq 'M') { # Modified
675 $ModifiedFiles{$Filename} = 1;
676 $UsersCommitted{$UID} = 1;
677 } elsif ($Type eq 'A') { # Added
678 $AddedFiles{$Filename} = 1;
679 $UsersCommitted{$UID} = 1;
680 } elsif ($Type eq 'R') { # Removed
681 $RemovedFiles{$Filename} = 1;
682 $UsersCommitted{$UID} = 1;
684 $UsersUpdated{$UID} = 1;
693 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
694 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
695 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
696 my $UserCommitList = join "\n", sort keys %UsersCommitted;
697 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
699 ##############################################################
701 # Build the entire tree, saving build messages to the build log
703 ##############################################################
704 if (!$NOCHECKOUT && !$NOBUILD) {
705 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
707 print "CONFIGURE STAGE:\n";
708 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
709 "> $BuildLog 2>&1\n";
711 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
714 print "BUILD STAGE:\n";
715 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
717 # Build the entire tree, capturing the output into $BuildLog
718 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
721 ##############################################################
723 # Get some statistics about the build...
725 ##############################################################
726 #this can de done on server
727 #my @Linked = split '\n', `grep Linking $BuildLog`;
728 #my $NumExecutables = scalar(grep(/executable/, @Linked));
729 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
730 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
732 # Get the number of lines of source code. Must be here after the build is done
733 # because countloc.sh uses the llvm-config script which must be built.
734 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
736 # Get the time taken by the configure script
737 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
738 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
739 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
740 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
742 $ConfigTime=-1 unless $ConfigTime;
743 $ConfigWallTime=-1 unless $ConfigWallTime;
745 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
746 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
747 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
748 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
750 $BuildTime=-1 unless $BuildTime;
751 $BuildWallTime=-1 unless $BuildWallTime;
753 my $BuildError = 0, $BuildStatus = "OK";
755 $BuildStatus = "Skipped by user";
757 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
758 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
759 $BuildStatus = "Error: compilation aborted";
761 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
763 if ($BuildError) { $NODEJAGNU=1; }
768 print "Organizing size of .o and .a files\n"
770 ChangeDir( "$BuildDir/llvm", "Build Directory" );
771 $afiles.= `find utils/ -iname '*.a' -ls`;
772 $afiles.= `find lib/ -iname '*.a' -ls`;
773 $afiles.= `find tools/ -iname '*.a' -ls`;
774 if($BUILDTYPE eq "release"){
775 $afiles.= `find Release/ -iname '*.a' -ls`;
776 } elsif($BUILDTYPE eq "release-asserts") {
777 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
779 $afiles.= `find Debug/ -iname '*.a' -ls`;
782 $ofiles.= `find utils/ -iname '*.o' -ls`;
783 $ofiles.= `find lib/ -iname '*.o' -ls`;
784 $ofiles.= `find tools/ -iname '*.o' -ls`;
785 if($BUILDTYPE eq "release"){
786 $ofiles.= `find Release/ -iname '*.o' -ls`;
787 } elsif($BUILDTYPE eq "release-asserts") {
788 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
790 $ofiles.= `find Debug/ -iname '*.o' -ls`;
793 @AFILES = split "\n", $afiles;
795 foreach $x (@AFILES){
796 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
797 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
799 @OFILES = split "\n", $ofiles;
801 foreach $x (@OFILES){
802 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
803 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
806 $a_file_sizes="No data due to a bad build.";
807 $o_file_sizes="No data due to a bad build.";
810 ##############################################################
812 # Running dejagnu tests
814 ##############################################################
815 my $DejangnuTestResults=""; # String containing the results of the dejagnu
816 my $dejagnu_output = "$DejagnuTestsLog";
819 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
820 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
823 #Run the feature and regression tests, results are put into testrun.sum
824 #Full log in testrun.log
825 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
827 #Copy the testrun.log and testrun.sum to our webdir
828 CopyFile("test/testrun.log", $DejagnuLog);
829 CopyFile("test/testrun.sum", $DejagnuSum);
830 #can be done on server
831 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
832 $unexpfail_tests = $DejagnuTestResults;
835 #Extract time of dejagnu tests
836 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
837 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
838 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
839 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
840 $DejagnuTestResults =
841 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
842 $DejagnuTime = "0.0" unless $DejagnuTime;
843 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
845 ##############################################################
847 # Get warnings from the build
849 ##############################################################
851 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
852 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
856 foreach $Warning (@Warn) {
857 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
858 $CurDir = $1; # Keep track of directory warning is in...
859 # Remove buildir prefix if included
860 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
862 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
865 my $WarningsFile = join "\n", @Warnings;
866 $WarningsFile =~ s/:[0-9]+:/::/g;
868 # Emit the warnings file, so we can diff...
869 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
870 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
872 # Output something to stdout if something has changed
873 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
874 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
876 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
877 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
881 ##############################################################
883 # If we built the tree successfully, run the nightly programs tests...
885 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
888 ##############################################################
891 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
892 "Programs Test Subdirectory" ) || return ("", "");
894 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
896 # Run the programs tests... creating a report.nightly.csv file
899 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
900 "TEST=nightly > $ProgramTestLog 2>&1\n";
902 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
903 "TEST=nightly > $ProgramTestLog 2>&1";
904 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
908 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
910 $ProgramsTable="Error running test $SubDir\n";
911 print "ERROR TESTING\n";
912 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
914 $ProgramsTable="Makefile error running tests $SubDir!\n";
915 print "ERROR TESTING\n";
919 # Create a list of the tests which were run...
921 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
922 "| sort > $Prefix-$SubDir-Tests.txt";
924 $ProgramsTable = ReadFile "report.nightly.csv";
926 ChangeDir( "../../..", "Programs Test Parent Directory" );
927 return ($ProgramsTable, $llcbeta_options);
928 } #end sub TestDirectory
930 ##############################################################
932 # Calling sub TestDirectory
934 ##############################################################
937 print "SingleSource TEST STAGE\n";
939 ($SingleSourceProgramsTable, $llcbeta_options) =
940 TestDirectory("SingleSource");
941 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
943 print "MultiSource TEST STAGE\n";
945 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
946 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
947 if ( ! $NOEXTERNALS ) {
949 print "External TEST STAGE\n";
951 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
952 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
953 system "cat $Prefix-SingleSource-Tests.txt " .
954 "$Prefix-MultiSource-Tests.txt ".
955 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
956 system "cat $Prefix-SingleSource-Performance.txt " .
957 "$Prefix-MultiSource-Performance.txt ".
958 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
960 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
962 print "External TEST STAGE SKIPPED\n";
964 system "cat $Prefix-SingleSource-Tests.txt " .
965 "$Prefix-MultiSource-Tests.txt ".
966 " | sort > $Prefix-Tests.txt";
967 system "cat $Prefix-SingleSource-Performance.txt " .
968 "$Prefix-MultiSource-Performance.txt ".
969 " | sort > $Prefix-Performance.txt";
972 ##############################################################
975 # gathering tests added removed broken information here
978 ##############################################################
979 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
980 my @DEJAGNU = split "\n", $dejagnu_test_list;
981 my ($passes, $fails, $xfails) = "";
984 for ($x=0; $x<@DEJAGNU; $x++) {
985 if ($DEJAGNU[$x] =~ m/^PASS:/) {
986 $passes.="$DEJAGNU[$x]\n";
988 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
989 $fails.="$DEJAGNU[$x]\n";
991 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
992 $xfails.="$DEJAGNU[$x]\n";
997 } #end if !$BuildError
1000 ##############################################################
1002 # If we built the tree successfully, runs of the Olden suite with
1003 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
1005 ##############################################################
1007 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
1008 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
1009 $MachCodeSize) = ("","","","","","","");
1010 if (!$NORUNNINGTESTS) {
1011 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
1012 "Olden Test Directory");
1014 # Clean out previous results...
1015 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
1017 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1018 # GET_STABLE_NUMBERS enabled!
1020 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1021 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1022 "> /dev/null 2>&1\n";
1024 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1025 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1027 system "cp report.nightly.csv $OldenTestsLog";
1031 ##############################################################
1033 # Getting end timestamp
1035 ##############################################################
1036 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1039 ##############################################################
1041 # Place all the logs neatly into one humungous file
1043 ##############################################################
1044 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1046 $machine_data = "uname: ".`uname -a`.
1047 "hardware: ".`uname -m`.
1049 "name: ".`uname -n`.
1050 "date: ".`date \"+20%y-%m-%d\"`.
1051 "time: ".`date +\"%H:%M:%S\"`;
1055 @CVS_DATA = ReadFile "$COLog";
1056 $cvs_data = join("\n", @CVS_DATA);
1060 @BUILD_DATA = ReadFile "$BuildLog";
1061 $build_data = join("\n", @BUILD_DATA);
1063 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1064 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1065 my ($gcc_version, $gcc_version_long) = "";
1067 $gcc_version_long="";
1068 if ($GCCPATH ne "") {
1069 $gcc_version_long = `$GCCPATH/gcc --version`;
1070 } elsif ($ENV{"CC"}) {
1071 $gcc_version_long = `$ENV{"CC"} --version`;
1073 $gcc_version_long = `gcc --version`;
1075 @GCC_VERSION = split '\n', $gcc_version_long;
1076 $gcc_version = $GCC_VERSION[0];
1078 $llvmgcc_version_long="";
1079 if ($LLVMGCCPATH ne "") {
1080 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1082 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1084 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1085 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1086 $llvmgcc_versionTarget =~ /Target: (.+)/;
1090 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1091 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1092 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1093 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1095 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1096 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1099 ##############################################################
1101 # Send data via a post request
1103 ##############################################################
1105 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1107 my %hash_of_data = (
1108 'machine_data' => $machine_data,
1109 'build_data' => $build_data,
1110 'gcc_version' => $gcc_version,
1111 'nickname' => $nickname,
1112 'dejagnutime_wall' => $DejagnuWallTime,
1113 'dejagnutime_cpu' => $DejagnuTime,
1114 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1115 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1116 'configtime_wall' => $ConfigWallTime,
1117 'configtime_cpu'=> $ConfigTime,
1118 'buildtime_wall' => $BuildWallTime,
1119 'buildtime_cpu' => $BuildTime,
1120 'warnings' => $WarningsFile,
1121 'cvsusercommitlist' => $UserCommitList,
1122 'cvsuserupdatelist' => $UserUpdateList,
1123 'cvsaddedfiles' => $CVSAddedFiles,
1124 'cvsmodifiedfiles' => $CVSModifiedFiles,
1125 'cvsremovedfiles' => $CVSRemovedFiles,
1126 'lines_of_code' => $LOC,
1127 'cvs_file_count' => $NumFilesInCVS,
1128 'cvs_dir_count' => $NumDirsInCVS,
1129 'buildstatus' => $BuildStatus,
1130 'singlesource_programstable' => $SingleSourceProgramsTable,
1131 'multisource_programstable' => $MultiSourceProgramsTable,
1132 'externalsource_programstable' => $ExternalProgramsTable,
1133 'llcbeta_options' => $multisource_llcbeta_options,
1134 'warnings_removed' => $WarningsRemoved,
1135 'warnings_added' => $WarningsAdded,
1136 'passing_tests' => $passes,
1137 'expfail_tests' => $xfails,
1138 'unexpfail_tests' => $fails,
1139 'all_tests' => $dejagnu_test_list,
1141 'removed_tests' => "",
1142 'dejagnutests_results' => $DejagnuTestResults,
1143 'dejagnutests_log' => $dejagnulog_full,
1144 'starttime' => $starttime,
1145 'endtime' => $endtime,
1146 'o_file_sizes' => $o_file_sizes,
1147 'a_file_sizes' => $a_file_sizes,
1148 'target_triple' => $targetTriple
1152 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1153 if( $VERBOSE) { print "============================\n$response"; }
1155 print "============================\n";
1156 foreach $x(keys %hash_of_data){
1157 print "$x => $hash_of_data{$x}\n";
1161 ##############################################################
1163 # Remove the cvs tree...
1165 ##############################################################
1166 system ( "$NICE rm -rf $BuildDir")
1167 if (!$NOCHECKOUT and !$NOREMOVE);
1168 system ( "$NICE rm -rf $WebDir")
1169 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);