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 # -verbose Turn on some debug output
39 # -debug Print information useful only to maintainers of this script.
40 # -nice Checkout/Configure/Build with "nice" to reduce impact
42 # -f2c Next argument specifies path to F2C utility
43 # -nickname The next argument specifieds the nickname this script
44 # will submit to the nightlytest results repository.
45 # -gccpath Path to gcc/g++ used to build LLVM
46 # -cvstag Check out a specific CVS tag to build LLVM (useful for
47 # testing release branches)
48 # -usecvs Check code out from the (old) CVS Repository instead of from
49 # the standard Subversion repository.
50 # -target Specify the target triplet
51 # -cflags Next argument specifies that C compilation options that
52 # override the default.
53 # -cxxflags Next argument specifies that C++ compilation options that
54 # override the default.
55 # -ldflags Next argument specifies that linker options that override
57 # -compileflags Next argument specifies extra options passed to make when
59 # -use-gmake Use gmake instead of the default make command to build
62 # ---------------- Options to configure llvm-test ----------------------------
63 # -extraflags Next argument specifies extra options that are passed to
65 # -noexternals Do not run the external tests (for cases where povray
66 # or SPEC are not installed)
67 # -with-externals Specify a directory where the external tests are located.
68 # -submit-server Specifies a server to submit the test results too. If this
69 # option is not specified it defaults to
70 # llvm.org. This is basically just the address of the
72 # -submit-script Specifies which script to call on the submit server. If
73 # this option is not specified it defaults to
74 # /nightlytest/NightlyTestAccept.php. This is basically
75 # everything after the www.yourserver.org.
77 # CVSROOT is the CVS repository from which the tree will be checked out,
78 # specified either in the full :method:user@host:/dir syntax, or
79 # just /dir if using a local repo.
80 # BUILDDIR is the directory where sources for this test run will be checked out
81 # AND objects for this test run will be built. This directory MUST NOT
82 # exist before the script is run; it will be created by the cvs checkout
83 # process and erased (unless -noremove is specified; see above.)
84 # WEBDIR is the directory into which the test results web page will be written,
85 # AND in which the "index.html" is assumed to be a symlink to the most recent
86 # copy of the results. This directory will be created if it does not exist.
87 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
88 # to. This is the same as you would have for a normal LLVM build.
90 ##############################################################
92 # Getting environment variables
94 ##############################################################
95 my $HOME = $ENV{'HOME'};
96 my $SVNURL = $ENV{"SVNURL"};
97 $SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
98 my $CVSRootDir = $ENV{'CVSROOT'};
99 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
100 my $BuildDir = $ENV{'BUILDDIR'};
101 $BuildDir = "$HOME/buildtest" unless $BuildDir;
102 my $WebDir = $ENV{'WEBDIR'};
103 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
105 ##############################################################
107 # Calculate the date prefix...
109 ##############################################################
111 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
112 my $DateString = strftime "%B %d, %Y", localtime;
113 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
115 ##############################################################
119 ##############################################################
126 $SUBMITSERVER = "llvm.org";
127 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
129 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
131 last if /^--$/; # Stop processing arguments on --
133 # List command line options here...
134 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
135 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
136 if (/^-noremove$/) { $NOREMOVE = 1; next; }
137 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
138 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
139 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
140 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
141 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
142 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
143 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
144 "DISABLE-ASSERTIONS=1 ".
145 "OPTIMIZE_OPTION=-O2";
146 $BUILDTYPE="release-asserts"; next;}
147 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
148 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
149 $CONFIGUREARGS .= " --enable-lli"; next; }
150 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
151 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
152 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
153 $CONFIGUREARGS .= " --disable-jit"; next; }
154 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
155 if (/^-verbose$/) { $VERBOSE = 1; next; }
156 if (/^-debug$/) { $DEBUG = 1; next; }
157 if (/^-nice$/) { $NICE = "nice "; next; }
158 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
160 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
162 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
163 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
164 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
165 if (/^-gccpath/) { $CONFIGUREARGS .=
166 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
167 $GCCPATH=$ARGV[0]; shift; next; }
168 else { $GCCPATH=""; }
169 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
170 else { $CVSCOOPT="";}
171 if (/^-usecvs/) { $USESVN = 0; }
172 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
174 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
176 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
178 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
180 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
181 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
182 if (/^-extraflags/) { $CONFIGUREARGS .=
183 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
184 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
185 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
186 if (/^-nobuild$/) { $NOBUILD = 1; next; }
187 print "Unknown option: $_ : ignoring!\n";
190 if ($ENV{'LLVMGCCDIR'}) {
191 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
192 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'};
198 if ($CONFIGUREARGS !~ /--disable-jit/) {
199 $CONFIGUREARGS .= " --enable-jit";
202 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
206 print "Must specify 0 or 3 options!";
210 $CVSRootDir = $ARGV[0];
211 $BuildDir = $ARGV[1];
215 if ($CVSRootDir eq "" or
218 die("please specify a cvs root directory, a build directory, and a ".
222 if ($nickname eq "") {
223 die ("Please invoke NewNightlyTest.pl with command line option " .
224 "\"-nickname <nickname>\"");
227 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
228 $BUILDTYPE = "debug";
231 ##############################################################
233 #define the file names we'll use
235 ##############################################################
236 my $Prefix = "$WebDir/$DATE";
237 my $BuildLog = "$Prefix-Build-Log.txt";
238 my $COLog = "$Prefix-CVS-Log.txt";
239 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
240 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
241 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
242 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
243 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
244 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
245 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
249 warn "$WebDir did not exist; creating it.\n";
254 print "INITIALIZED\n";
256 print "SVN URL = $SVNURL\n";
258 print "CVS Root = $CVSRootDir\n";
260 print "COLog = $COLog\n";
261 print "BuildDir = $BuildDir\n";
262 print "WebDir = $WebDir\n";
263 print "Prefix = $Prefix\n";
264 print "BuildLog = $BuildLog\n";
267 ##############################################################
271 ##############################################################
275 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
280 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
282 # DiffFiles - Diff the current version of the file against the last version of
283 # the file, reporting things added and removed. This is used to report, for
284 # example, added and removed warnings. This returns a pair (added, removed)
286 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289 my @Others = GetDir $Suffix;
290 if (@Others == 0) { # No other files? We added all entries...
291 return (`cat $WebDir/$DATE$Suffix`, "");
293 # Diff the files now...
294 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
295 my $Added = join "\n", grep /^</, @Diffs;
296 my $Removed = join "\n", grep /^>/, @Diffs;
298 $Removed =~ s/^> //gm;
299 return ($Added, $Removed);
302 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304 sub GetRegex { # (Regex with ()'s, value)
311 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 my ($Regex, $Num, $Regex2, $File) = @_;
315 my @Items = split "\n", `grep '$Regex' $File`;
316 return GetRegex $Regex2, $Items[$Num];
319 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321 sub ChangeDir { # directory, logical name
322 my ($dir,$name) = @_;
324 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
325 $result = chdir($dir);
327 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
333 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336 if (open (FILE, $_[0])) {
343 print "Could not open file '$_[0]' for reading!\n";
348 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350 sub WriteFile { # (filename, contents)
351 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
356 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 sub CopyFile { #filename, newfile
359 my ($file, $newfile) = @_;
361 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
362 copy($file, $newfile);
365 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 my ($Val, $Filename,$WebDir) = @_;
370 if (open FILE, "$WebDir/$Filename") {
371 @Records = grep !/$DATE/, split "\n", <FILE>;
374 push @Records, "$DATE: $Val";
375 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
378 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380 # FormatTime - Convert a time from 1m23.45 into 83.45
382 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
385 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
386 $Time = sprintf("%7.4f", $1*60.0+$2);
391 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393 # This function is meant to read in the dejagnu sum file and
394 # return a string with only the results (i.e. PASS/FAIL/XPASS/
397 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 sub GetDejagnuTestResults { # (filename, log)
399 my ($filename, $DejagnuLog) = @_;
401 $/ = "\n"; #Make sure we're going line at a time.
403 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
405 if (open SRCHFILE, $filename) {
406 # Process test results
407 while ( <SRCHFILE> ) {
408 if ( length($_) > 1 ) {
410 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
411 push(@lines, "$1: test/$2");
418 my $content = join("\n", @lines);
424 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
426 # This function acts as a mini web browswer submitting data
427 # to our central server via the post method
429 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
437 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
439 connect SOCK, $socketaddr or die "Bad connection\n";
440 select((select(SOCK), $| = 1)[0]);
442 #creating content here
444 foreach $key (keys (%$variables)){
445 $value = $variables->{$key};
446 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
447 $content .= "$key=$value&";
450 $length = length($content);
452 my $send= "POST $file HTTP/1.0\n";
453 $send.= "Host: $host\n";
454 $send.= "Content-Type: application/x-www-form-urlencoded\n";
455 $send.= "Content-length: $length\n\n";
466 foreach $x (keys (%$variables)){
467 $value = $variables->{$x};
468 $sentdata.= "$x => $value\n";
470 WriteFile "$Prefix-sentdata.txt", $sentdata;
476 ##############################################################
478 # Getting Start timestamp
480 ##############################################################
481 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
483 ##############################################################
485 # Create the CVS repository directory
487 ##############################################################
492 print "Build directory exists! Removing it\n";
494 system "rm -rf $BuildDir";
495 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
498 print "Build directory exists!\n";
502 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
505 ChangeDir( $BuildDir, "checkout directory" );
508 ##############################################################
510 # Check out the llvm tree, using either SVN or CVS
512 ##############################################################
514 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
516 my $SVNCMD = "$NICE svn co $SVNURL";
518 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
519 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
521 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
522 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
525 $CVSOPT = "-z3" # Use compression if going over ssh.
526 if $CVSRootDir =~ /^:ext:/;
527 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
529 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
530 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
532 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
533 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
536 ChangeDir( $BuildDir , "Checkout directory") ;
537 ChangeDir( "llvm" , "llvm source directory") ;
539 ##############################################################
541 # Get some static statistics about the current state of CVS
543 # This can probably be put on the server side
545 ##############################################################
546 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
547 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
548 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
549 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
551 my $NumFilesInCVS = 0;
552 my $NumDirsInCVS = 0;
554 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
555 $NumDirsInCVS = `sed -e 's#/[^/]*$##' $COLog | sort | uniq | wc -l` + 0;
557 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
558 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
561 ##############################################################
563 # Extract some information from the CVS history... use a hash so no duplicate
564 # stuff is stored. This gets the history from the previous days worth
565 # of cvs activity and parses it.
567 ##############################################################
569 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
570 # have to be perfect as its only used for comparing date ranges within a couple
572 sub ConvertToSeconds {
573 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
574 my $Result = ($yr - 2000) * 12;
587 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
590 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
593 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
594 # Skip very first entry because it is the XML header cruft
597 foreach $Record (@SVNHistory) {
598 my @Lines = split "\n", $Record;
599 my ($Author, $Date, $Revision);
600 # Get the date and see if its one we want to process.
601 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
602 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
603 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
605 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
606 # Get the current date and compute when "yesterday" is.
607 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
608 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
609 if (($Now - 24*60*60) > $Then) {
612 if ($Lines[1] =~ / revision="([0-9]*)">/) {
615 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
618 $UsersCommitted{$Author} = 1;
619 $Date = $Year . "-" . $Month . "-" . $Day;
620 $Time = $Hour . ":" . $Min . ":" . $Sec;
621 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
622 for ($i = 6; $i < $#Lines; $i += 2 ) {
623 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
626 } elsif ($1 == 'D') {
627 $RemovedFiles{$2} = 1;
628 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
629 $ModifiedFiles{$2} = 1;
631 print "UNMATCHABLE: $Lines[$i]\n";
637 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
638 #print join "\n", @CVSHistory; print "\n";
640 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
642 # Loop over every record from the CVS history, filling in the hashes.
643 foreach $File (@CVSHistory) {
644 my ($Type, $Date, $UID, $Rev, $Filename);
645 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
646 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
647 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
648 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
649 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
650 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
652 print "UNMATCHABLE: $File\n";
655 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
657 if ($Filename =~ /^llvm/) {
658 if ($Type eq 'M') { # Modified
659 $ModifiedFiles{$Filename} = 1;
660 $UsersCommitted{$UID} = 1;
661 } elsif ($Type eq 'A') { # Added
662 $AddedFiles{$Filename} = 1;
663 $UsersCommitted{$UID} = 1;
664 } elsif ($Type eq 'R') { # Removed
665 $RemovedFiles{$Filename} = 1;
666 $UsersCommitted{$UID} = 1;
668 $UsersUpdated{$UID} = 1;
677 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
678 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
679 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
680 my $UserCommitList = join "\n", sort keys %UsersCommitted;
681 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
683 ##############################################################
685 # Build the entire tree, saving build messages to the build log
687 ##############################################################
688 if (!$NOCHECKOUT && !$NOBUILD) {
689 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
691 print "CONFIGURE STAGE:\n";
692 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
693 "> $BuildLog 2>&1\n";
695 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
698 print "BUILD STAGE:\n";
699 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
701 # Build the entire tree, capturing the output into $BuildLog
702 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
705 ##############################################################
707 # Get some statistics about the build...
709 ##############################################################
710 #this can de done on server
711 #my @Linked = split '\n', `grep Linking $BuildLog`;
712 #my $NumExecutables = scalar(grep(/executable/, @Linked));
713 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
714 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
716 # Get the number of lines of source code. Must be here after the build is done
717 # because countloc.sh uses the llvm-config script which must be built.
718 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
720 # Get the time taken by the configure script
721 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
722 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
723 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
724 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
726 $ConfigTime=-1 unless $ConfigTime;
727 $ConfigWallTime=-1 unless $ConfigWallTime;
729 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
730 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
731 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
732 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
734 $BuildTime=-1 unless $BuildTime;
735 $BuildWallTime=-1 unless $BuildWallTime;
737 my $BuildError = 0, $BuildStatus = "OK";
739 $BuildStatus = "Skipped by user";
742 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
743 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
744 $BuildStatus = "Error: compilation aborted";
746 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
748 if ($BuildError) { $NODEJAGNU=1; }
753 print "Organizing size of .o and .a files\n"
755 ChangeDir( "$BuildDir/llvm", "Build Directory" );
756 $afiles.= `find utils/ -iname '*.a' -ls`;
757 $afiles.= `find lib/ -iname '*.a' -ls`;
758 $afiles.= `find tools/ -iname '*.a' -ls`;
759 if($BUILDTYPE eq "release"){
760 $afiles.= `find Release/ -iname '*.a' -ls`;
761 } elsif($BUILDTYPE eq "release-asserts") {
762 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
764 $afiles.= `find Debug/ -iname '*.a' -ls`;
767 $ofiles.= `find utils/ -iname '*.o' -ls`;
768 $ofiles.= `find lib/ -iname '*.o' -ls`;
769 $ofiles.= `find tools/ -iname '*.o' -ls`;
770 if($BUILDTYPE eq "release"){
771 $ofiles.= `find Release/ -iname '*.o' -ls`;
772 } elsif($BUILDTYPE eq "release-asserts") {
773 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
775 $ofiles.= `find Debug/ -iname '*.o' -ls`;
778 @AFILES = split "\n", $afiles;
780 foreach $x (@AFILES){
781 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
782 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
784 @OFILES = split "\n", $ofiles;
786 foreach $x (@OFILES){
787 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
788 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
791 $a_file_sizes="No data due to a bad build.";
792 $o_file_sizes="No data due to a bad build.";
795 ##############################################################
797 # Running dejagnu tests
799 ##############################################################
800 my $DejangnuTestResults=""; # String containing the results of the dejagnu
801 my $dejagnu_output = "$DejagnuTestsLog";
804 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
805 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
808 #Run the feature and regression tests, results are put into testrun.sum
809 #Full log in testrun.log
810 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
812 #Copy the testrun.log and testrun.sum to our webdir
813 CopyFile("test/testrun.log", $DejagnuLog);
814 CopyFile("test/testrun.sum", $DejagnuSum);
815 #can be done on server
816 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
817 $unexpfail_tests = $DejagnuTestResults;
820 #Extract time of dejagnu tests
821 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
822 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
823 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
824 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
825 $DejagnuTestResults =
826 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
827 $DejagnuTime = "0.0" unless $DejagnuTime;
828 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
830 ##############################################################
832 # Get warnings from the build
834 ##############################################################
836 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
837 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
841 foreach $Warning (@Warn) {
842 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
843 $CurDir = $1; # Keep track of directory warning is in...
844 # Remove buildir prefix if included
845 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
847 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
850 my $WarningsFile = join "\n", @Warnings;
851 $WarningsFile =~ s/:[0-9]+:/::/g;
853 # Emit the warnings file, so we can diff...
854 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
855 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
857 # Output something to stdout if something has changed
858 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
859 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
861 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
862 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
866 ##############################################################
868 # If we built the tree successfully, run the nightly programs tests...
870 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
873 ##############################################################
876 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
877 "Programs Test Subdirectory" ) || return ("", "");
879 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
881 # Run the programs tests... creating a report.nightly.csv file
884 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
885 "TEST=nightly > $ProgramTestLog 2>&1\n";
887 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
888 "TEST=nightly > $ProgramTestLog 2>&1";
889 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
893 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
895 $ProgramsTable="Error running test $SubDir\n";
896 print "ERROR TESTING\n";
897 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
899 $ProgramsTable="Makefile error running tests $SubDir!\n";
900 print "ERROR TESTING\n";
904 # Create a list of the tests which were run...
906 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
907 "| sort > $Prefix-$SubDir-Tests.txt";
909 $ProgramsTable = ReadFile "report.nightly.csv";
911 ChangeDir( "../../..", "Programs Test Parent Directory" );
912 return ($ProgramsTable, $llcbeta_options);
913 } #end sub TestDirectory
915 ##############################################################
917 # Calling sub TestDirectory
919 ##############################################################
922 print "SingleSource TEST STAGE\n";
924 ($SingleSourceProgramsTable, $llcbeta_options) =
925 TestDirectory("SingleSource");
926 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
928 print "MultiSource TEST STAGE\n";
930 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
931 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
932 if ( ! $NOEXTERNALS ) {
934 print "External TEST STAGE\n";
936 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
937 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
938 system "cat $Prefix-SingleSource-Tests.txt " .
939 "$Prefix-MultiSource-Tests.txt ".
940 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
941 system "cat $Prefix-SingleSource-Performance.txt " .
942 "$Prefix-MultiSource-Performance.txt ".
943 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
945 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
947 print "External TEST STAGE SKIPPED\n";
949 system "cat $Prefix-SingleSource-Tests.txt " .
950 "$Prefix-MultiSource-Tests.txt ".
951 " | sort > $Prefix-Tests.txt";
952 system "cat $Prefix-SingleSource-Performance.txt " .
953 "$Prefix-MultiSource-Performance.txt ".
954 " | sort > $Prefix-Performance.txt";
957 ##############################################################
960 # gathering tests added removed broken information here
963 ##############################################################
964 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
965 my @DEJAGNU = split "\n", $dejagnu_test_list;
966 my ($passes, $fails, $xfails) = "";
969 for ($x=0; $x<@DEJAGNU; $x++) {
970 if ($DEJAGNU[$x] =~ m/^PASS:/) {
971 $passes.="$DEJAGNU[$x]\n";
973 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
974 $fails.="$DEJAGNU[$x]\n";
976 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
977 $xfails.="$DEJAGNU[$x]\n";
982 } #end if !$BuildError
985 ##############################################################
987 # If we built the tree successfully, runs of the Olden suite with
988 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
990 ##############################################################
992 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
993 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
994 $MachCodeSize) = ("","","","","","","");
995 if (!$NORUNNINGTESTS) {
996 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
997 "Olden Test Directory");
999 # Clean out previous results...
1000 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
1002 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1003 # GET_STABLE_NUMBERS enabled!
1005 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1006 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1007 "> /dev/null 2>&1\n";
1009 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1010 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1012 system "cp report.nightly.csv $OldenTestsLog";
1016 ##############################################################
1018 # Getting end timestamp
1020 ##############################################################
1021 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1024 ##############################################################
1026 # Place all the logs neatly into one humungous file
1028 ##############################################################
1029 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1031 $machine_data = "uname: ".`uname -a`.
1032 "hardware: ".`uname -m`.
1034 "name: ".`uname -n`.
1035 "date: ".`date \"+20%y-%m-%d\"`.
1036 "time: ".`date +\"%H:%M:%S\"`;
1040 @CVS_DATA = ReadFile "$COLog";
1041 $cvs_data = join("\n", @CVS_DATA);
1045 @BUILD_DATA = ReadFile "$BuildLog";
1046 $build_data = join("\n", @BUILD_DATA);
1048 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1049 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1050 my ($gcc_version, $gcc_version_long) = "";
1052 $gcc_version_long="";
1053 if ($GCCPATH ne "") {
1054 $gcc_version_long = `$GCCPATH/gcc --version`;
1055 } elsif ($ENV{"CC"}) {
1056 $gcc_version_long = `$ENV{"CC"} --version`;
1058 $gcc_version_long = `gcc --version`;
1060 @GCC_VERSION = split '\n', $gcc_version_long;
1061 $gcc_version = $GCC_VERSION[0];
1063 $llvmgcc_version_long="";
1064 if ($LLVMGCCPATH ne "") {
1065 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1067 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1069 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1070 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1071 $llvmgcc_versionTarget =~ /Target: (.+)/;
1075 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1076 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1077 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1078 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1080 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1081 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1084 ##############################################################
1086 # Send data via a post request
1088 ##############################################################
1090 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1092 my %hash_of_data = (
1093 'machine_data' => $machine_data,
1094 'build_data' => $build_data,
1095 'gcc_version' => $gcc_version,
1096 'nickname' => $nickname,
1097 'dejagnutime_wall' => $DejagnuWallTime,
1098 'dejagnutime_cpu' => $DejagnuTime,
1099 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1100 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1101 'configtime_wall' => $ConfigWallTime,
1102 'configtime_cpu'=> $ConfigTime,
1103 'buildtime_wall' => $BuildWallTime,
1104 'buildtime_cpu' => $BuildTime,
1105 'warnings' => $WarningsFile,
1106 'cvsusercommitlist' => $UserCommitList,
1107 'cvsuserupdatelist' => $UserUpdateList,
1108 'cvsaddedfiles' => $CVSAddedFiles,
1109 'cvsmodifiedfiles' => $CVSModifiedFiles,
1110 'cvsremovedfiles' => $CVSRemovedFiles,
1111 'lines_of_code' => $LOC,
1112 'cvs_file_count' => $NumFilesInCVS,
1113 'cvs_dir_count' => $NumDirsInCVS,
1114 'buildstatus' => $BuildStatus,
1115 'singlesource_programstable' => $SingleSourceProgramsTable,
1116 'multisource_programstable' => $MultiSourceProgramsTable,
1117 'externalsource_programstable' => $ExternalProgramsTable,
1118 'llcbeta_options' => $multisource_llcbeta_options,
1119 'warnings_removed' => $WarningsRemoved,
1120 'warnings_added' => $WarningsAdded,
1121 'passing_tests' => $passes,
1122 'expfail_tests' => $xfails,
1123 'unexpfail_tests' => $fails,
1124 'all_tests' => $dejagnu_test_list,
1126 'removed_tests' => "",
1127 'dejagnutests_results' => $DejagnuTestResults,
1128 'dejagnutests_log' => $dejagnulog_full,
1129 'starttime' => $starttime,
1130 'endtime' => $endtime,
1131 'o_file_sizes' => $o_file_sizes,
1132 'a_file_sizes' => $a_file_sizes,
1133 'target_triple' => $targetTriple
1139 print "============================\n";
1140 foreach $x(keys %hash_of_data){
1141 print "$x => $hash_of_data{$x}\n";
1144 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1145 if( $VERBOSE) { print "============================\n$response"; }
1148 ##############################################################
1150 # Remove the cvs tree...
1152 ##############################################################
1153 system ( "$NICE rm -rf $BuildDir")
1154 if (!$NOCHECKOUT and !$NOREMOVE);
1155 system ( "$NICE rm -rf $WebDir")
1156 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);