2 use POSIX qw(strftime);
8 # Program: NewNightlyTest.pl
10 # Synopsis: Perform a series of tests which are designed to be run nightly.
11 # This is used to keep track of the status of the LLVM tree, tracking
12 # regressions and performance changes. Submits this information
13 # to llvm.org where it is placed into the nightlytestresults database.
15 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
17 # OPTIONS may include one or more of the following:
20 # -config LLVMPATH If specified, use an existing LLVM build and only run and
21 # report the test information. The LLVMCONFIG argument should
22 # be the path to the llvm-config executable in the LLVM build.
23 # This should be the first argument if given. NOT YET
25 # -nickname NAME The NAME argument specifieds the nickname this script
26 # will submit to the nightlytest results repository.
27 # -submit-server Specifies a server to submit the test results too. If this
28 # option is not specified it defaults to
29 # llvm.org. This is basically just the address of the
31 # -submit-script Specifies which script to call on the submit server. If
32 # this option is not specified it defaults to
33 # /nightlytest/NightlyTestAccept.php. This is basically
34 # everything after the www.yourserver.org.
35 # -submit-aux If specified, an auxiliary script to run in addition to the
36 # normal submit script. The script will be passed the path to
37 # the "sentdata.txt" file as its sole argument.
38 # -nosubmit Do not report the test results back to a submit server.
41 # BUILD OPTIONS (not used with -config):
42 # -nocheckout Do not create, checkout, update, or configure
44 # -noremove Do not remove the BUILDDIR after it has been built.
45 # -noremoveresults Do not remove the WEBDIR after it has been built.
46 # -nobuild Do not build llvm. If tests are enabled perform them
47 # on the llvm build specified in the build directory
48 # -release Build an LLVM Release version
49 # -release-asserts Build an LLVM ReleaseAsserts version
50 # -disable-bindings Disable building LLVM bindings.
51 # -cvstag Check out a specific CVS tag to build LLVM (useful for
52 # testing release branches)
53 # -usecvs Check code out from the (old) CVS Repository instead of from
54 # the standard Subversion repository.
55 # -with-clang Checkout Clang source into tools/clang.
56 # -compileflags Next argument specifies extra options passed to make when
58 # -use-gmake Use gmake instead of the default make command to build
62 # -notest Do not even attempt to run the test programs.
63 # -nodejagnu Do not run feature or regression tests
64 # -enable-llcbeta Enable testing of beta features in llc.
65 # -enable-lli Enable testing of lli (interpreter) features, default is off
66 # -disable-pic Disable building with Position Independent Code.
67 # -disable-llc Disable LLC tests in the nightly tester.
68 # -disable-jit Disable JIT tests in the nightly tester.
69 # -disable-cbe Disable C backend tests in the nightly tester.
70 # -disable-lto Disable link time optimization.
71 # -test-cflags Next argument specifies that C compilation options that
72 # override the default when running the testsuite.
73 # -test-cxxflags Next argument specifies that C++ compilation options that
74 # override the default when running the testsuite.
75 # -extraflags Next argument specifies extra options that are passed to
77 # -noexternals Do not run the external tests (for cases where povray
78 # or SPEC are not installed)
79 # -with-externals Specify a directory where the external tests are located.
82 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
83 # -parallel-jobs The number of parallel Make jobs to use (default is two).
84 # -verbose Turn on some debug output
85 # -nice Checkout/Configure/Build with "nice" to reduce impact
87 # -f2c Next argument specifies path to F2C utility
88 # -gccpath Path to gcc/g++ used to build LLVM
89 # -target Specify the target triplet
90 # -cflags Next argument specifies that C compilation options that
91 # override the default.
92 # -cxxflags Next argument specifies that C++ compilation options that
93 # override the default.
94 # -ldflags Next argument specifies that linker options that override
97 # CVSROOT is the CVS repository from which the tree will be checked out,
98 # specified either in the full :method:user@host:/dir syntax, or
99 # just /dir if using a local repo.
100 # BUILDDIR is the directory where sources for this test run will be checked out
101 # AND objects for this test run will be built. This directory MUST NOT
102 # exist before the script is run; it will be created by the cvs checkout
103 # process and erased (unless -noremove is specified; see above.)
104 # WEBDIR is the directory into which the test results web page will be written,
105 # AND in which the "index.html" is assumed to be a symlink to the most recent
106 # copy of the results. This directory will be created if it does not exist.
107 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
108 # to. This is the same as you would have for a normal LLVM build.
110 ##############################################################
112 # Getting environment variables
114 ##############################################################
115 my $HOME = $ENV{'HOME'};
116 my $SVNURL = $ENV{"SVNURL"};
117 $SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
118 my $TestSVNURL = $ENV{"TestSVNURL"};
119 $TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
120 my $CVSRootDir = $ENV{'CVSROOT'};
121 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
122 my $BuildDir = $ENV{'BUILDDIR'};
123 $BuildDir = "$HOME/buildtest" unless $BuildDir;
124 my $WebDir = $ENV{'WEBDIR'};
125 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
127 my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
128 $LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
129 my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
130 $LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
131 my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
132 $LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
134 ##############################################################
136 # Calculate the date prefix...
138 ##############################################################
140 my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
142 ##############################################################
146 ##############################################################
153 $SUBMITSERVER = "llvm.org";
154 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
160 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
162 last if /^--$/; # Stop processing arguments on --
164 # List command line options here...
165 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
166 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
167 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
168 if (/^-noremove$/) { $NOREMOVE = 1; next; }
169 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
170 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
171 if (/^-notest$/) { $NOTEST = 1; next; }
172 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
173 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
174 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
175 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
176 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
177 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
178 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
179 "DISABLE_ASSERTIONS=1 ".
180 "OPTIMIZE_OPTION=-O2";
181 $BUILDTYPE="release-asserts"; next;}
182 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
183 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
184 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
185 $CONFIGUREARGS .= " --enable-lli"; next; }
186 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
187 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
188 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
189 $CONFIGUREARGS .= " --disable-jit"; next; }
190 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
191 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
192 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
193 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
194 if (/^-verbose$/) { $VERBOSE = 1; next; }
195 if (/^-teelogs$/) { $TEELOGS = 1; next; }
196 if (/^-nice$/) { $NICE = "nice "; next; }
197 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
199 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
201 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
203 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
204 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
205 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
206 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
207 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
208 if (/^-gccpath/) { $CONFIGUREARGS .=
209 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
210 $GCCPATH=$ARGV[0]; shift; next; }
211 else { $GCCPATH=""; }
212 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
213 else { $CVSCOOPT="";}
214 if (/^-usecvs/) { $USESVN = 0; }
215 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
217 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
219 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
221 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
223 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
225 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
227 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
228 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
229 if (/^-extraflags/) { $CONFIGUREARGS .=
230 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
231 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
232 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
233 if (/^-nobuild$/) { $NOBUILD = 1; next; }
234 print "Unknown option: $_ : ignoring!\n";
237 if (!($CONFIG_PATH eq "")) {
238 die "error: -config mode is not yet implemented,";
241 if ($ENV{'LLVMGCCDIR'}) {
242 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
243 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
249 if ($CONFIGUREARGS !~ /--disable-jit/) {
250 $CONFIGUREARGS .= " --enable-jit";
253 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
257 print "Must specify 0 or 3 options!";
261 $CVSRootDir = $ARGV[0];
262 $BuildDir = $ARGV[1];
266 if ($CVSRootDir eq "" or
269 die("please specify a cvs root directory, a build directory, and a ".
273 if ($nickname eq "") {
274 die ("Please invoke NewNightlyTest.pl with command line option " .
275 "\"-nickname <nickname>\"");
278 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
279 $BUILDTYPE = "debug";
282 ##############################################################
284 # Define the file names we'll use
286 ##############################################################
287 my $Prefix = "$WebDir/$DATE";
288 my $BuildLog = "$Prefix-Build-Log.txt";
289 my $COLog = "$Prefix-CVS-Log.txt";
290 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
291 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
292 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
293 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
294 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
295 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
299 warn "$WebDir did not exist; creating it.\n";
304 print "INITIALIZED\n";
306 print "SVN URL = $SVNURL\n";
308 print "CVS Root = $CVSRootDir\n";
310 print "COLog = $COLog\n";
311 print "BuildDir = $BuildDir\n";
312 print "WebDir = $WebDir\n";
313 print "Prefix = $Prefix\n";
314 print "BuildLog = $BuildLog\n";
317 ##############################################################
321 ##############################################################
326 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
331 sub RunLoggedCommand {
338 print "$Command 2>&1 | tee $Log\n";
340 system "$Command 2>&1 | tee $Log";
344 print "$Command 2>&1 > $Log\n";
346 system "$Command 2>&1 > $Log";
350 sub RunAppendingLoggedCommand {
357 print "$Command 2>&1 | tee -a $Log\n";
359 system "$Command 2>&1 | tee -a $Log";
363 print "$Command 2>&1 > $Log\n";
365 system "$Command 2>&1 >> $Log";
369 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 # DiffFiles - Diff the current version of the file against the last version of
372 # the file, reporting things added and removed. This is used to report, for
373 # example, added and removed warnings. This returns a pair (added, removed)
375 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
378 my @Others = GetDir $Suffix;
379 if (@Others == 0) { # No other files? We added all entries...
380 return (`cat $WebDir/$DATE$Suffix`, "");
382 # Diff the files now...
383 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
384 my $Added = join "\n", grep /^</, @Diffs;
385 my $Removed = join "\n", grep /^>/, @Diffs;
387 $Removed =~ s/^> //gm;
388 return ($Added, $Removed);
391 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393 sub GetRegex { # (Regex with ()'s, value)
400 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
401 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
403 my ($Regex, $Num, $Regex2, $File) = @_;
404 my @Items = split "\n", `grep '$Regex' $File`;
405 return GetRegex $Regex2, $Items[$Num];
408 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410 sub ChangeDir { # directory, logical name
411 my ($dir,$name) = @_;
413 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
414 $result = chdir($dir);
416 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
422 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
423 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425 if (open (FILE, $_[0])) {
432 print "Could not open file '$_[0]' for reading!\n";
437 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439 sub WriteFile { # (filename, contents)
440 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
445 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
447 sub CopyFile { #filename, newfile
448 my ($file, $newfile) = @_;
450 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
451 copy($file, $newfile);
454 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
457 my ($Val, $Filename,$WebDir) = @_;
459 if (open FILE, "$WebDir/$Filename") {
460 @Records = grep !/$DATE/, split "\n", <FILE>;
463 push @Records, "$DATE: $Val";
464 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
467 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
469 # FormatTime - Convert a time from 1m23.45 into 83.45
471 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
474 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
475 $Time = sprintf("%7.4f", $1*60.0+$2);
480 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
482 # This function is meant to read in the dejagnu sum file and
483 # return a string with only the results (i.e. PASS/FAIL/XPASS/
486 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
487 sub GetDejagnuTestResults { # (filename, log)
488 my ($filename, $DejagnuLog) = @_;
490 $/ = "\n"; #Make sure we're going line at a time.
492 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
494 if (open SRCHFILE, $filename) {
495 # Process test results
496 while ( <SRCHFILE> ) {
497 if ( length($_) > 1 ) {
499 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
500 push(@lines, "$1: test/$2");
507 my $content = join("\n", @lines);
513 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
515 # This function acts as a mini web browswer submitting data
516 # to our central server via the post method
518 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
524 # Write out the "...-sentdata.txt" file.
527 foreach $x (keys (%$variables)){
528 $value = $variables->{$x};
529 $sentdata.= "$x => $value\n";
531 WriteFile "$Prefix-sentdata.txt", $sentdata;
533 if (!($SUBMITAUX eq "")) {
534 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
538 return "Skipped standard submit.\n";
541 # Create the content to send to the server.
544 foreach $key (keys (%$variables)){
545 $value = $variables->{$key};
546 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
547 $content .= "$key=$value&";
550 # Send the data to the server.
552 # FIXME: This code should be more robust?
555 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
556 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
558 connect SOCK, $socketaddr or die "Bad connection\n";
559 select((select(SOCK), $| = 1)[0]);
561 $length = length($content);
563 my $send= "POST $file HTTP/1.0\n";
564 $send.= "Host: $host\n";
565 $send.= "Content-Type: application/x-www-form-urlencoded\n";
566 $send.= "Content-length: $length\n\n";
579 ##############################################################
581 # Getting Start timestamp
583 ##############################################################
584 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
586 ##############################################################
588 # Create the CVS repository directory
590 ##############################################################
595 print "Build directory exists! Removing it\n";
597 system "rm -rf $BuildDir";
598 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
601 print "Build directory exists!\n";
605 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
610 ##############################################################
612 # Check out the llvm tree, using either SVN or CVS
614 ##############################################################
616 ChangeDir( $BuildDir, "checkout directory" );
618 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
619 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
620 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
621 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
624 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
625 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
630 $CVSOPT = "-z3" # Use compression if going over ssh.
631 if $CVSRootDir =~ /^:ext:/;
632 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
633 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
634 "$CVSCMD llvm-test )", $COLog,
635 "CHECKOUT LLVM-TEST");
638 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
640 ##############################################################
642 # Get some static statistics about the current state of CVS
644 # This can probably be put on the server side
646 ##############################################################
647 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
648 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
649 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
650 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
652 my $NumFilesInCVS = 0;
653 my $NumDirsInCVS = 0;
655 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
656 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
658 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
659 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
662 ##############################################################
664 # Extract some information from the CVS history... use a hash so no duplicate
665 # stuff is stored. This gets the history from the previous days worth
666 # of cvs activity and parses it.
668 ##############################################################
670 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
671 # have to be perfect as its only used for comparing date ranges within a couple
673 sub ConvertToSeconds {
674 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
675 my $Result = ($yr - 2000) * 12;
688 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
691 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
694 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
695 # Skip very first entry because it is the XML header cruft
698 foreach $Record (@SVNHistory) {
699 my @Lines = split "\n", $Record;
700 my ($Author, $Date, $Revision);
701 # Get the date and see if its one we want to process.
702 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
703 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
704 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
706 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
707 # Get the current date and compute when "yesterday" is.
708 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
709 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
710 if (($Now - 24*60*60) > $Then) {
713 if ($Lines[1] =~ / revision="([0-9]*)">/) {
716 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
719 $UsersCommitted{$Author} = 1;
720 $Date = $Year . "-" . $Month . "-" . $Day;
721 $Time = $Hour . ":" . $Min . ":" . $Sec;
722 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
723 for ($i = 6; $i < $#Lines; $i += 2 ) {
724 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
727 } elsif ($1 == 'D') {
728 $RemovedFiles{$2} = 1;
729 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
730 $ModifiedFiles{$2} = 1;
732 print "UNMATCHABLE: $Lines[$i]\n";
738 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
739 #print join "\n", @CVSHistory; print "\n";
741 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
743 # Loop over every record from the CVS history, filling in the hashes.
744 foreach $File (@CVSHistory) {
745 my ($Type, $Date, $UID, $Rev, $Filename);
746 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
747 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
748 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
749 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
750 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
751 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
753 print "UNMATCHABLE: $File\n";
756 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
758 if ($Filename =~ /^llvm/) {
759 if ($Type eq 'M') { # Modified
760 $ModifiedFiles{$Filename} = 1;
761 $UsersCommitted{$UID} = 1;
762 } elsif ($Type eq 'A') { # Added
763 $AddedFiles{$Filename} = 1;
764 $UsersCommitted{$UID} = 1;
765 } elsif ($Type eq 'R') { # Removed
766 $RemovedFiles{$Filename} = 1;
767 $UsersCommitted{$UID} = 1;
769 $UsersUpdated{$UID} = 1;
778 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
779 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
780 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
781 my $UserCommitList = join "\n", sort keys %UsersCommitted;
782 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
784 ##############################################################
786 # Build the entire tree, saving build messages to the build log
788 ##############################################################
789 if (!$NOCHECKOUT && !$NOBUILD) {
790 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
791 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
792 $BuildLog, "CONFIGURE");
793 # Build the entire tree, capturing the output into $BuildLog
794 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
795 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
798 ##############################################################
800 # Get some statistics about the build...
802 ##############################################################
803 #this can de done on server
804 #my @Linked = split '\n', `grep Linking $BuildLog`;
805 #my $NumExecutables = scalar(grep(/executable/, @Linked));
806 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
807 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
809 # Get the number of lines of source code. Must be here after the build is done
810 # because countloc.sh uses the llvm-config script which must be built.
811 my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
813 # Get the time taken by the configure script
814 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
815 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
816 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
817 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
819 $ConfigTime=-1 unless $ConfigTime;
820 $ConfigWallTime=-1 unless $ConfigWallTime;
822 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
823 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
824 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
825 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
827 $BuildTime=-1 unless $BuildTime;
828 $BuildWallTime=-1 unless $BuildWallTime;
830 my $BuildError = 0, $BuildStatus = "OK";
832 $BuildStatus = "Skipped by user";
834 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
835 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
836 $BuildStatus = "Error: compilation aborted";
838 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
840 if ($BuildError) { $NODEJAGNU=1; }
845 print "Organizing size of .o and .a files\n"
847 ChangeDir( "$LLVMObjDir", "Build Directory" );
849 my @dirs = ('utils', 'lib', 'tools');
850 if($BUILDTYPE eq "release"){
851 push @dirs, 'Release';
852 } elsif($BUILDTYPE eq "release-asserts") {
853 push @dirs, 'Release-Asserts';
859 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
860 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
863 $a_file_sizes="No data due to a bad build.";
864 $o_file_sizes="No data due to a bad build.";
867 ##############################################################
869 # Running dejagnu tests
871 ##############################################################
872 my $DejangnuTestResults=""; # String containing the results of the dejagnu
873 my $dejagnu_output = "$DejagnuTestsLog";
875 #Run the feature and regression tests, results are put into testrun.sum
876 #Full log in testrun.log
877 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
879 #Copy the testrun.log and testrun.sum to our webdir
880 CopyFile("test/testrun.log", $DejagnuLog);
881 CopyFile("test/testrun.sum", $DejagnuSum);
882 #can be done on server
883 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
884 $unexpfail_tests = $DejagnuTestResults;
887 #Extract time of dejagnu tests
888 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
889 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
890 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
891 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
892 $DejagnuTestResults =
893 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
894 $DejagnuTime = "0.0" unless $DejagnuTime;
895 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
897 ##############################################################
899 # Get warnings from the build
901 ##############################################################
903 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
904 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
908 foreach $Warning (@Warn) {
909 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
910 $CurDir = $1; # Keep track of directory warning is in...
911 # Remove buildir prefix if included
912 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
914 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
917 my $WarningsFile = join "\n", @Warnings;
918 $WarningsFile =~ s/:[0-9]+:/::/g;
920 # Emit the warnings file, so we can diff...
921 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
922 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
924 # Output something to stdout if something has changed
925 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
926 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
928 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
929 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
933 ##############################################################
935 # If we built the tree successfully, run the nightly programs tests...
937 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
940 ##############################################################
944 ChangeDir( "$LLVMTestDir/$SubDir",
945 "Programs Test Subdirectory" ) || return ("", "");
947 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
949 # Run the programs tests... creating a report.nightly.csv file
952 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
953 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
955 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
956 "$TESTFLAGS TEST=nightly",
957 $ProgramTestLog, "TEST DIRECTORY $SubDir");
958 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
962 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
964 $ProgramsTable="Error running test $SubDir\n";
965 print "ERROR TESTING\n";
966 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
968 $ProgramsTable="Makefile error running tests $SubDir!\n";
969 print "ERROR TESTING\n";
973 # Create a list of the tests which were run...
975 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
976 "| sort > $Prefix-$SubDir-Tests.txt";
978 $ProgramsTable = ReadFile "report.nightly.csv";
980 ChangeDir( "../../..", "Programs Test Parent Directory" );
981 return ($ProgramsTable, $llcbeta_options);
982 } #end sub TestDirectory
984 ##############################################################
986 # Calling sub TestDirectory
988 ##############################################################
990 ($SingleSourceProgramsTable, $llcbeta_options) =
991 TestDirectory("SingleSource");
992 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
993 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
994 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
995 if ( ! $NOEXTERNALS ) {
996 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
997 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
998 system "cat $Prefix-SingleSource-Tests.txt " .
999 "$Prefix-MultiSource-Tests.txt ".
1000 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
1001 system "cat $Prefix-SingleSource-Performance.txt " .
1002 "$Prefix-MultiSource-Performance.txt ".
1003 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
1005 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
1007 print "External TEST STAGE SKIPPED\n";
1009 system "cat $Prefix-SingleSource-Tests.txt " .
1010 "$Prefix-MultiSource-Tests.txt ".
1011 " | sort > $Prefix-Tests.txt";
1012 system "cat $Prefix-SingleSource-Performance.txt " .
1013 "$Prefix-MultiSource-Performance.txt ".
1014 " | sort > $Prefix-Performance.txt";
1017 ##############################################################
1020 # gathering tests added removed broken information here
1023 ##############################################################
1024 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
1025 my @DEJAGNU = split "\n", $dejagnu_test_list;
1026 my ($passes, $fails, $xfails) = "";
1029 for ($x=0; $x<@DEJAGNU; $x++) {
1030 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1031 $passes.="$DEJAGNU[$x]\n";
1033 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1034 $fails.="$DEJAGNU[$x]\n";
1036 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1037 $xfails.="$DEJAGNU[$x]\n";
1042 } #end if !$BuildError
1044 ##############################################################
1046 # Getting end timestamp
1048 ##############################################################
1049 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1052 ##############################################################
1054 # Place all the logs neatly into one humungous file
1056 ##############################################################
1057 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1059 $machine_data = "uname: ".`uname -a`.
1060 "hardware: ".`uname -m`.
1062 "name: ".`uname -n`.
1063 "date: ".`date \"+20%y-%m-%d\"`.
1064 "time: ".`date +\"%H:%M:%S\"`;
1068 @CVS_DATA = ReadFile "$COLog";
1069 $cvs_data = join("\n", @CVS_DATA);
1073 @BUILD_DATA = ReadFile "$BuildLog";
1074 $build_data = join("\n", @BUILD_DATA);
1076 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1077 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1078 my ($gcc_version, $gcc_version_long) = "";
1080 $gcc_version_long="";
1081 if ($GCCPATH ne "") {
1082 $gcc_version_long = `$GCCPATH/gcc --version`;
1083 } elsif ($ENV{"CC"}) {
1084 $gcc_version_long = `$ENV{"CC"} --version`;
1086 $gcc_version_long = `gcc --version`;
1088 @GCC_VERSION = split '\n', $gcc_version_long;
1089 $gcc_version = $GCC_VERSION[0];
1091 $llvmgcc_version_long="";
1092 if ($LLVMGCCPATH ne "") {
1093 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1095 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1097 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1098 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1099 $llvmgcc_versionTarget =~ /Target: (.+)/;
1103 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1104 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1105 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1106 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1108 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1109 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1112 ##############################################################
1114 # Send data via a post request
1116 ##############################################################
1118 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1120 my %hash_of_data = (
1121 'machine_data' => $machine_data,
1122 'build_data' => $build_data,
1123 'gcc_version' => $gcc_version,
1124 'nickname' => $nickname,
1125 'dejagnutime_wall' => $DejagnuWallTime,
1126 'dejagnutime_cpu' => $DejagnuTime,
1127 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1128 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1129 'configtime_wall' => $ConfigWallTime,
1130 'configtime_cpu'=> $ConfigTime,
1131 'buildtime_wall' => $BuildWallTime,
1132 'buildtime_cpu' => $BuildTime,
1133 'warnings' => $WarningsFile,
1134 'cvsusercommitlist' => $UserCommitList,
1135 'cvsuserupdatelist' => $UserUpdateList,
1136 'cvsaddedfiles' => $CVSAddedFiles,
1137 'cvsmodifiedfiles' => $CVSModifiedFiles,
1138 'cvsremovedfiles' => $CVSRemovedFiles,
1139 'lines_of_code' => $LOC,
1140 'cvs_file_count' => $NumFilesInCVS,
1141 'cvs_dir_count' => $NumDirsInCVS,
1142 'buildstatus' => $BuildStatus,
1143 'singlesource_programstable' => $SingleSourceProgramsTable,
1144 'multisource_programstable' => $MultiSourceProgramsTable,
1145 'externalsource_programstable' => $ExternalProgramsTable,
1146 'llcbeta_options' => $multisource_llcbeta_options,
1147 'warnings_removed' => $WarningsRemoved,
1148 'warnings_added' => $WarningsAdded,
1149 'passing_tests' => $passes,
1150 'expfail_tests' => $xfails,
1151 'unexpfail_tests' => $fails,
1152 'all_tests' => $dejagnu_test_list,
1154 'removed_tests' => "",
1155 'dejagnutests_results' => $DejagnuTestResults,
1156 'dejagnutests_log' => $dejagnulog_full,
1157 'starttime' => $starttime,
1158 'endtime' => $endtime,
1159 'o_file_sizes' => $o_file_sizes,
1160 'a_file_sizes' => $a_file_sizes,
1161 'target_triple' => $targetTriple
1164 if ($SUBMIT || !($SUBMITAUX eq "")) {
1165 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1166 if( $VERBOSE) { print "============================\n$response"; }
1168 print "============================\n";
1169 foreach $x(keys %hash_of_data){
1170 print "$x => $hash_of_data{$x}\n";
1174 ##############################################################
1176 # Remove the cvs tree...
1178 ##############################################################
1179 system ( "$NICE rm -rf $BuildDir")
1180 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
1181 system ( "$NICE rm -rf $WebDir")
1182 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);