2 use POSIX qw(strftime);
8 # Program: NewNightlyTest.pl
10 # Synopsis: Perform a series of tests which are designed to be run nightly.
11 # This is used to keep track of the status of the LLVM tree, tracking
12 # regressions and performance changes. Submits this information
13 # to llvm.org where it is placed into the nightlytestresults database.
15 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
17 # OPTIONS may include one or more of the following:
18 # -nocheckout Do not create, checkout, update, or configure
20 # -noremove Do not remove the BUILDDIR after it has been built.
21 # -noremoveresults Do not remove the WEBDIR after it has been built.
22 # -nobuild Do not build llvm. If tests are enabled perform them
23 # on the llvm build specified in the build directory
24 # -notest Do not even attempt to run the test programs.
25 # -nodejagnu Do not run feature or regression tests
26 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
27 # -parallel-jobs The number of parallel Make jobs to use (default is two).
28 # -with-clang Checkout Clang source into tools/clang.
29 # -release Build an LLVM Release version
30 # -release-asserts Build an LLVM ReleaseAsserts version
31 # -enable-llcbeta Enable testing of beta features in llc.
32 # -enable-lli Enable testing of lli (interpreter) features, default is off
33 # -disable-pic Disable building with Position Independent Code.
34 # -disable-llc Disable LLC tests in the nightly tester.
35 # -disable-jit Disable JIT tests in the nightly tester.
36 # -disable-cbe Disable C backend tests in the nightly tester.
37 # -disable-lto Disable link time optimization.
38 # -disable-bindings Disable building LLVM bindings.
39 # -verbose Turn on some debug output
40 # -debug Print information useful only to maintainers of this script.
41 # -nice Checkout/Configure/Build with "nice" to reduce impact
43 # -f2c Next argument specifies path to F2C utility
44 # -nickname The next argument specifieds the nickname this script
45 # will submit to the nightlytest results repository.
46 # -gccpath Path to gcc/g++ used to build LLVM
47 # -cvstag Check out a specific CVS tag to build LLVM (useful for
48 # testing release branches)
49 # -usecvs Check code out from the (old) CVS Repository instead of from
50 # the standard Subversion repository.
51 # -target Specify the target triplet
52 # -cflags Next argument specifies that C compilation options that
53 # override the default.
54 # -cxxflags Next argument specifies that C++ compilation options that
55 # override the default.
56 # -ldflags Next argument specifies that linker options that override
58 # -compileflags Next argument specifies extra options passed to make when
60 # -use-gmake Use gmake instead of the default make command to build
63 # ---------------- Options to configure llvm-test ----------------------------
64 # -extraflags Next argument specifies extra options that are passed to
66 # -noexternals Do not run the external tests (for cases where povray
67 # or SPEC are not installed)
68 # -with-externals Specify a directory where the external tests are located.
69 # -submit-server Specifies a server to submit the test results too. If this
70 # option is not specified it defaults to
71 # llvm.org. This is basically just the address of the
73 # -submit-script Specifies which script to call on the submit server. If
74 # this option is not specified it defaults to
75 # /nightlytest/NightlyTestAccept.php. This is basically
76 # everything after the www.yourserver.org.
77 # -submit-aux If specified, an auxiliary script to run in addition to the
78 # normal submit script. The script will be passed the path to
79 # the "sentdata.txt" file as its sole argument.
80 # -nosubmit Do not report the test results back to a submit server.
82 # CVSROOT is the CVS repository from which the tree will be checked out,
83 # specified either in the full :method:user@host:/dir syntax, or
84 # just /dir if using a local repo.
85 # BUILDDIR is the directory where sources for this test run will be checked out
86 # AND objects for this test run will be built. This directory MUST NOT
87 # exist before the script is run; it will be created by the cvs checkout
88 # process and erased (unless -noremove is specified; see above.)
89 # WEBDIR is the directory into which the test results web page will be written,
90 # AND in which the "index.html" is assumed to be a symlink to the most recent
91 # copy of the results. This directory will be created if it does not exist.
92 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
93 # to. This is the same as you would have for a normal LLVM build.
95 ##############################################################
97 # Getting environment variables
99 ##############################################################
100 my $HOME = $ENV{'HOME'};
101 my $SVNURL = $ENV{"SVNURL"};
102 $SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
103 my $TestSVNURL = $ENV{"TestSVNURL"};
104 $TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
105 my $CVSRootDir = $ENV{'CVSROOT'};
106 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
107 my $BuildDir = $ENV{'BUILDDIR'};
108 $BuildDir = "$HOME/buildtest" unless $BuildDir;
109 my $WebDir = $ENV{'WEBDIR'};
110 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
112 my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
113 $LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
114 my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
115 $LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
116 my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
117 $LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
119 ##############################################################
121 # Calculate the date prefix...
123 ##############################################################
125 my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
127 ##############################################################
131 ##############################################################
137 $SUBMITSERVER = "llvm.org";
138 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
143 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
145 last if /^--$/; # Stop processing arguments on --
147 # List command line options here...
148 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
149 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
150 if (/^-noremove$/) { $NOREMOVE = 1; next; }
151 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
152 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
153 if (/^-notest$/) { $NOTEST = 1; next; }
154 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
155 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
156 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
157 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
158 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
159 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
160 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
161 "DISABLE_ASSERTIONS=1 ".
162 "OPTIMIZE_OPTION=-O2";
163 $BUILDTYPE="release-asserts"; next;}
164 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
165 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
166 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
167 $CONFIGUREARGS .= " --enable-lli"; next; }
168 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
169 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
170 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
171 $CONFIGUREARGS .= " --disable-jit"; next; }
172 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
173 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
174 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
175 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
176 if (/^-verbose$/) { $VERBOSE = 1; next; }
177 if (/^-teelogs$/) { $TEELOGS = 1; next; }
178 if (/^-debug$/) { $DEBUG = 1; next; }
179 if (/^-nice$/) { $NICE = "nice "; next; }
180 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
182 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
184 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
186 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
187 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
188 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
189 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
190 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
191 if (/^-gccpath/) { $CONFIGUREARGS .=
192 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
193 $GCCPATH=$ARGV[0]; shift; next; }
194 else { $GCCPATH=""; }
195 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
196 else { $CVSCOOPT="";}
197 if (/^-usecvs/) { $USESVN = 0; }
198 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
200 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
202 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
204 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
206 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
207 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
208 if (/^-extraflags/) { $CONFIGUREARGS .=
209 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
210 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
211 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
212 if (/^-nobuild$/) { $NOBUILD = 1; next; }
213 print "Unknown option: $_ : ignoring!\n";
216 if ($ENV{'LLVMGCCDIR'}) {
217 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
218 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
224 if ($CONFIGUREARGS !~ /--disable-jit/) {
225 $CONFIGUREARGS .= " --enable-jit";
228 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
232 print "Must specify 0 or 3 options!";
236 $CVSRootDir = $ARGV[0];
237 $BuildDir = $ARGV[1];
241 if ($CVSRootDir eq "" or
244 die("please specify a cvs root directory, a build directory, and a ".
248 if ($nickname eq "") {
249 die ("Please invoke NewNightlyTest.pl with command line option " .
250 "\"-nickname <nickname>\"");
253 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
254 $BUILDTYPE = "debug";
257 ##############################################################
259 #define the file names we'll use
261 ##############################################################
262 my $Prefix = "$WebDir/$DATE";
263 my $BuildLog = "$Prefix-Build-Log.txt";
264 my $COLog = "$Prefix-CVS-Log.txt";
265 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
266 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
267 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
268 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
269 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
270 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
274 warn "$WebDir did not exist; creating it.\n";
279 print "INITIALIZED\n";
281 print "SVN URL = $SVNURL\n";
283 print "CVS Root = $CVSRootDir\n";
285 print "COLog = $COLog\n";
286 print "BuildDir = $BuildDir\n";
287 print "WebDir = $WebDir\n";
288 print "Prefix = $Prefix\n";
289 print "BuildLog = $BuildLog\n";
292 ##############################################################
296 ##############################################################
300 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
305 sub RunLoggedCommand {
312 print "$Command 2>&1 | tee $Log\n";
314 system "$Command 2>&1 | tee $Log";
318 print "$Command 2>&1 > $Log\n";
320 system "$Command 2>&1 > $Log";
324 sub RunAppendingLoggedCommand {
331 print "$Command 2>&1 | tee -a $Log\n";
333 system "$Command 2>&1 | tee -a $Log";
337 print "$Command 2>&1 > $Log\n";
339 system "$Command 2>&1 >> $Log";
343 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345 # DiffFiles - Diff the current version of the file against the last version of
346 # the file, reporting things added and removed. This is used to report, for
347 # example, added and removed warnings. This returns a pair (added, removed)
349 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352 my @Others = GetDir $Suffix;
353 if (@Others == 0) { # No other files? We added all entries...
354 return (`cat $WebDir/$DATE$Suffix`, "");
356 # Diff the files now...
357 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
358 my $Added = join "\n", grep /^</, @Diffs;
359 my $Removed = join "\n", grep /^>/, @Diffs;
361 $Removed =~ s/^> //gm;
362 return ($Added, $Removed);
365 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367 sub GetRegex { # (Regex with ()'s, value)
374 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377 my ($Regex, $Num, $Regex2, $File) = @_;
378 my @Items = split "\n", `grep '$Regex' $File`;
379 return GetRegex $Regex2, $Items[$Num];
382 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384 sub ChangeDir { # directory, logical name
385 my ($dir,$name) = @_;
387 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
388 $result = chdir($dir);
390 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
396 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399 if (open (FILE, $_[0])) {
406 print "Could not open file '$_[0]' for reading!\n";
411 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413 sub WriteFile { # (filename, contents)
414 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
419 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
421 sub CopyFile { #filename, newfile
422 my ($file, $newfile) = @_;
424 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
425 copy($file, $newfile);
428 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
431 my ($Val, $Filename,$WebDir) = @_;
433 if (open FILE, "$WebDir/$Filename") {
434 @Records = grep !/$DATE/, split "\n", <FILE>;
437 push @Records, "$DATE: $Val";
438 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
441 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
443 # FormatTime - Convert a time from 1m23.45 into 83.45
445 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
448 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
449 $Time = sprintf("%7.4f", $1*60.0+$2);
454 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
456 # This function is meant to read in the dejagnu sum file and
457 # return a string with only the results (i.e. PASS/FAIL/XPASS/
460 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
461 sub GetDejagnuTestResults { # (filename, log)
462 my ($filename, $DejagnuLog) = @_;
464 $/ = "\n"; #Make sure we're going line at a time.
466 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
468 if (open SRCHFILE, $filename) {
469 # Process test results
470 while ( <SRCHFILE> ) {
471 if ( length($_) > 1 ) {
473 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
474 push(@lines, "$1: test/$2");
481 my $content = join("\n", @lines);
487 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
489 # This function acts as a mini web browswer submitting data
490 # to our central server via the post method
492 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
498 # Write out the "...-sentdata.txt" file.
501 foreach $x (keys (%$variables)){
502 $value = $variables->{$x};
503 $sentdata.= "$x => $value\n";
505 WriteFile "$Prefix-sentdata.txt", $sentdata;
507 if (!($SUBMITAUX eq "")) {
508 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
512 return "Skipped standard submit.\n";
515 # Create the content to send to the server.
518 foreach $key (keys (%$variables)){
519 $value = $variables->{$key};
520 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
521 $content .= "$key=$value&";
524 # Send the data to the server.
526 # FIXME: This code should be more robust?
529 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
530 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
532 connect SOCK, $socketaddr or die "Bad connection\n";
533 select((select(SOCK), $| = 1)[0]);
535 $length = length($content);
537 my $send= "POST $file HTTP/1.0\n";
538 $send.= "Host: $host\n";
539 $send.= "Content-Type: application/x-www-form-urlencoded\n";
540 $send.= "Content-length: $length\n\n";
553 ##############################################################
555 # Getting Start timestamp
557 ##############################################################
558 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
560 ##############################################################
562 # Create the CVS repository directory
564 ##############################################################
569 print "Build directory exists! Removing it\n";
571 system "rm -rf $BuildDir";
572 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
575 print "Build directory exists!\n";
579 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
584 ##############################################################
586 # Check out the llvm tree, using either SVN or CVS
588 ##############################################################
590 ChangeDir( $BuildDir, "checkout directory" );
592 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
593 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
594 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
595 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
598 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
599 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
604 $CVSOPT = "-z3" # Use compression if going over ssh.
605 if $CVSRootDir =~ /^:ext:/;
606 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
607 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
608 "$CVSCMD llvm-test )", $COLog,
609 "CHECKOUT LLVM-TEST");
612 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
614 ##############################################################
616 # Get some static statistics about the current state of CVS
618 # This can probably be put on the server side
620 ##############################################################
621 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
622 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
623 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
624 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
626 my $NumFilesInCVS = 0;
627 my $NumDirsInCVS = 0;
629 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
630 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
632 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
633 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
636 ##############################################################
638 # Extract some information from the CVS history... use a hash so no duplicate
639 # stuff is stored. This gets the history from the previous days worth
640 # of cvs activity and parses it.
642 ##############################################################
644 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
645 # have to be perfect as its only used for comparing date ranges within a couple
647 sub ConvertToSeconds {
648 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
649 my $Result = ($yr - 2000) * 12;
662 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
665 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
668 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
669 # Skip very first entry because it is the XML header cruft
672 foreach $Record (@SVNHistory) {
673 my @Lines = split "\n", $Record;
674 my ($Author, $Date, $Revision);
675 # Get the date and see if its one we want to process.
676 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
677 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
678 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
680 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
681 # Get the current date and compute when "yesterday" is.
682 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
683 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
684 if (($Now - 24*60*60) > $Then) {
687 if ($Lines[1] =~ / revision="([0-9]*)">/) {
690 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
693 $UsersCommitted{$Author} = 1;
694 $Date = $Year . "-" . $Month . "-" . $Day;
695 $Time = $Hour . ":" . $Min . ":" . $Sec;
696 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
697 for ($i = 6; $i < $#Lines; $i += 2 ) {
698 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
701 } elsif ($1 == 'D') {
702 $RemovedFiles{$2} = 1;
703 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
704 $ModifiedFiles{$2} = 1;
706 print "UNMATCHABLE: $Lines[$i]\n";
712 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
713 #print join "\n", @CVSHistory; print "\n";
715 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
717 # Loop over every record from the CVS history, filling in the hashes.
718 foreach $File (@CVSHistory) {
719 my ($Type, $Date, $UID, $Rev, $Filename);
720 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
721 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
722 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
723 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
724 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
725 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
727 print "UNMATCHABLE: $File\n";
730 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
732 if ($Filename =~ /^llvm/) {
733 if ($Type eq 'M') { # Modified
734 $ModifiedFiles{$Filename} = 1;
735 $UsersCommitted{$UID} = 1;
736 } elsif ($Type eq 'A') { # Added
737 $AddedFiles{$Filename} = 1;
738 $UsersCommitted{$UID} = 1;
739 } elsif ($Type eq 'R') { # Removed
740 $RemovedFiles{$Filename} = 1;
741 $UsersCommitted{$UID} = 1;
743 $UsersUpdated{$UID} = 1;
752 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
753 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
754 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
755 my $UserCommitList = join "\n", sort keys %UsersCommitted;
756 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
758 ##############################################################
760 # Build the entire tree, saving build messages to the build log
762 ##############################################################
763 if (!$NOCHECKOUT && !$NOBUILD) {
764 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
765 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
766 $BuildLog, "CONFIGURE");
767 # Build the entire tree, capturing the output into $BuildLog
768 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
769 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
772 ##############################################################
774 # Get some statistics about the build...
776 ##############################################################
777 #this can de done on server
778 #my @Linked = split '\n', `grep Linking $BuildLog`;
779 #my $NumExecutables = scalar(grep(/executable/, @Linked));
780 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
781 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
783 # Get the number of lines of source code. Must be here after the build is done
784 # because countloc.sh uses the llvm-config script which must be built.
785 my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
787 # Get the time taken by the configure script
788 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
789 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
790 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
791 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
793 $ConfigTime=-1 unless $ConfigTime;
794 $ConfigWallTime=-1 unless $ConfigWallTime;
796 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
797 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
798 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
799 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
801 $BuildTime=-1 unless $BuildTime;
802 $BuildWallTime=-1 unless $BuildWallTime;
804 my $BuildError = 0, $BuildStatus = "OK";
806 $BuildStatus = "Skipped by user";
808 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
809 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
810 $BuildStatus = "Error: compilation aborted";
812 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
814 if ($BuildError) { $NODEJAGNU=1; }
819 print "Organizing size of .o and .a files\n"
821 ChangeDir( "$LLVMObjDir", "Build Directory" );
823 my @dirs = ('utils', 'lib', 'tools');
824 if($BUILDTYPE eq "release"){
825 push @dirs, 'Release';
826 } elsif($BUILDTYPE eq "release-asserts") {
827 push @dirs, 'Release-Asserts';
833 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
834 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
837 $a_file_sizes="No data due to a bad build.";
838 $o_file_sizes="No data due to a bad build.";
841 ##############################################################
843 # Running dejagnu tests
845 ##############################################################
846 my $DejangnuTestResults=""; # String containing the results of the dejagnu
847 my $dejagnu_output = "$DejagnuTestsLog";
849 #Run the feature and regression tests, results are put into testrun.sum
850 #Full log in testrun.log
851 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
853 #Copy the testrun.log and testrun.sum to our webdir
854 CopyFile("test/testrun.log", $DejagnuLog);
855 CopyFile("test/testrun.sum", $DejagnuSum);
856 #can be done on server
857 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
858 $unexpfail_tests = $DejagnuTestResults;
861 #Extract time of dejagnu tests
862 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
863 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
864 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
865 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
866 $DejagnuTestResults =
867 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
868 $DejagnuTime = "0.0" unless $DejagnuTime;
869 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
871 ##############################################################
873 # Get warnings from the build
875 ##############################################################
877 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
878 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
882 foreach $Warning (@Warn) {
883 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
884 $CurDir = $1; # Keep track of directory warning is in...
885 # Remove buildir prefix if included
886 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
888 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
891 my $WarningsFile = join "\n", @Warnings;
892 $WarningsFile =~ s/:[0-9]+:/::/g;
894 # Emit the warnings file, so we can diff...
895 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
896 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
898 # Output something to stdout if something has changed
899 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
900 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
902 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
903 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
907 ##############################################################
909 # If we built the tree successfully, run the nightly programs tests...
911 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
914 ##############################################################
918 ChangeDir( "$LLVMTestDir/$SubDir",
919 "Programs Test Subdirectory" ) || return ("", "");
921 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
923 # Run the programs tests... creating a report.nightly.csv file
926 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
927 "TEST=nightly > $ProgramTestLog 2>&1\n";
929 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
930 "TEST=nightly", $ProgramTestLog, "TEST DIRECTORY $SubDir");
931 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
935 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
937 $ProgramsTable="Error running test $SubDir\n";
938 print "ERROR TESTING\n";
939 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
941 $ProgramsTable="Makefile error running tests $SubDir!\n";
942 print "ERROR TESTING\n";
946 # Create a list of the tests which were run...
948 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
949 "| sort > $Prefix-$SubDir-Tests.txt";
951 $ProgramsTable = ReadFile "report.nightly.csv";
953 ChangeDir( "../../..", "Programs Test Parent Directory" );
954 return ($ProgramsTable, $llcbeta_options);
955 } #end sub TestDirectory
957 ##############################################################
959 # Calling sub TestDirectory
961 ##############################################################
963 ($SingleSourceProgramsTable, $llcbeta_options) =
964 TestDirectory("SingleSource");
965 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
966 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
967 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
968 if ( ! $NOEXTERNALS ) {
969 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
970 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
971 system "cat $Prefix-SingleSource-Tests.txt " .
972 "$Prefix-MultiSource-Tests.txt ".
973 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
974 system "cat $Prefix-SingleSource-Performance.txt " .
975 "$Prefix-MultiSource-Performance.txt ".
976 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
978 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
980 print "External TEST STAGE SKIPPED\n";
982 system "cat $Prefix-SingleSource-Tests.txt " .
983 "$Prefix-MultiSource-Tests.txt ".
984 " | sort > $Prefix-Tests.txt";
985 system "cat $Prefix-SingleSource-Performance.txt " .
986 "$Prefix-MultiSource-Performance.txt ".
987 " | sort > $Prefix-Performance.txt";
990 ##############################################################
993 # gathering tests added removed broken information here
996 ##############################################################
997 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
998 my @DEJAGNU = split "\n", $dejagnu_test_list;
999 my ($passes, $fails, $xfails) = "";
1002 for ($x=0; $x<@DEJAGNU; $x++) {
1003 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1004 $passes.="$DEJAGNU[$x]\n";
1006 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1007 $fails.="$DEJAGNU[$x]\n";
1009 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1010 $xfails.="$DEJAGNU[$x]\n";
1015 } #end if !$BuildError
1017 ##############################################################
1019 # Getting end timestamp
1021 ##############################################################
1022 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1025 ##############################################################
1027 # Place all the logs neatly into one humungous file
1029 ##############################################################
1030 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1032 $machine_data = "uname: ".`uname -a`.
1033 "hardware: ".`uname -m`.
1035 "name: ".`uname -n`.
1036 "date: ".`date \"+20%y-%m-%d\"`.
1037 "time: ".`date +\"%H:%M:%S\"`;
1041 @CVS_DATA = ReadFile "$COLog";
1042 $cvs_data = join("\n", @CVS_DATA);
1046 @BUILD_DATA = ReadFile "$BuildLog";
1047 $build_data = join("\n", @BUILD_DATA);
1049 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1050 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1051 my ($gcc_version, $gcc_version_long) = "";
1053 $gcc_version_long="";
1054 if ($GCCPATH ne "") {
1055 $gcc_version_long = `$GCCPATH/gcc --version`;
1056 } elsif ($ENV{"CC"}) {
1057 $gcc_version_long = `$ENV{"CC"} --version`;
1059 $gcc_version_long = `gcc --version`;
1061 @GCC_VERSION = split '\n', $gcc_version_long;
1062 $gcc_version = $GCC_VERSION[0];
1064 $llvmgcc_version_long="";
1065 if ($LLVMGCCPATH ne "") {
1066 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1068 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1070 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1071 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1072 $llvmgcc_versionTarget =~ /Target: (.+)/;
1076 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1077 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1078 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1079 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1081 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1082 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1085 ##############################################################
1087 # Send data via a post request
1089 ##############################################################
1091 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1093 my %hash_of_data = (
1094 'machine_data' => $machine_data,
1095 'build_data' => $build_data,
1096 'gcc_version' => $gcc_version,
1097 'nickname' => $nickname,
1098 'dejagnutime_wall' => $DejagnuWallTime,
1099 'dejagnutime_cpu' => $DejagnuTime,
1100 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1101 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1102 'configtime_wall' => $ConfigWallTime,
1103 'configtime_cpu'=> $ConfigTime,
1104 'buildtime_wall' => $BuildWallTime,
1105 'buildtime_cpu' => $BuildTime,
1106 'warnings' => $WarningsFile,
1107 'cvsusercommitlist' => $UserCommitList,
1108 'cvsuserupdatelist' => $UserUpdateList,
1109 'cvsaddedfiles' => $CVSAddedFiles,
1110 'cvsmodifiedfiles' => $CVSModifiedFiles,
1111 'cvsremovedfiles' => $CVSRemovedFiles,
1112 'lines_of_code' => $LOC,
1113 'cvs_file_count' => $NumFilesInCVS,
1114 'cvs_dir_count' => $NumDirsInCVS,
1115 'buildstatus' => $BuildStatus,
1116 'singlesource_programstable' => $SingleSourceProgramsTable,
1117 'multisource_programstable' => $MultiSourceProgramsTable,
1118 'externalsource_programstable' => $ExternalProgramsTable,
1119 'llcbeta_options' => $multisource_llcbeta_options,
1120 'warnings_removed' => $WarningsRemoved,
1121 'warnings_added' => $WarningsAdded,
1122 'passing_tests' => $passes,
1123 'expfail_tests' => $xfails,
1124 'unexpfail_tests' => $fails,
1125 'all_tests' => $dejagnu_test_list,
1127 'removed_tests' => "",
1128 'dejagnutests_results' => $DejagnuTestResults,
1129 'dejagnutests_log' => $dejagnulog_full,
1130 'starttime' => $starttime,
1131 'endtime' => $endtime,
1132 'o_file_sizes' => $o_file_sizes,
1133 'a_file_sizes' => $a_file_sizes,
1134 'target_triple' => $targetTriple
1137 if ($SUBMIT || !($SUBMITAUX eq "")) {
1138 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1139 if( $VERBOSE) { print "============================\n$response"; }
1141 print "============================\n";
1142 foreach $x(keys %hash_of_data){
1143 print "$x => $hash_of_data{$x}\n";
1147 ##############################################################
1149 # Remove the cvs tree...
1151 ##############################################################
1152 system ( "$NICE rm -rf $BuildDir")
1153 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
1154 system ( "$NICE rm -rf $WebDir")
1155 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);