2 use POSIX
qw(strftime);
7 # Program: NewNightlyTest.pl
9 # Synopsis: Perform a series of tests which are designed to be run nightly.
10 # This is used to keep track of the status of the LLVM tree, tracking
11 # regressions and performance changes. Submits this information
12 # to llvm.org where it is placed into the nightlytestresults database.
14 # Modified heavily by Patrick Jenkins, July 2006
16 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
18 # OPTIONS may include one or more of the following:
19 # -nocheckout Do not create, checkout, update, or configure
21 # -noremove Do not remove the BUILDDIR after it has been built.
22 # -noremoveresults Do not remove the WEBDIR after it has been built.
23 # -nobuild Do not build llvm. If tests are enabled perform them
24 # on the llvm build specified in the build directory
25 # -notest Do not even attempt to run the test programs. Implies
27 # -norunningtests Do not run the Olden benchmark suite with
28 # LARGE_PROBLEM_SIZE enabled.
29 # -nodejagnu Do not run feature or regression tests
30 # -parallel Run two parallel jobs with GNU Make.
31 # -release Build an LLVM Release version
32 # -release-asserts Build an LLVM ReleaseAsserts version
33 # -enable-llcbeta Enable testing of beta features in llc.
34 # -enable-lli Enable testing of lli (interpreter) features, default is off
35 # -disable-llc Disable LLC tests in the nightly tester.
36 # -disable-jit Disable JIT tests in the nightly tester.
37 # -disable-cbe Disable C backend tests in the nightly tester.
38 # -disable-lto Disable link time optimization.
39 # -disable-bindings Disable building LLVM bindings.
40 # -verbose Turn on some debug output
41 # -debug Print information useful only to maintainers of this script.
42 # -nice Checkout/Configure/Build with "nice" to reduce impact
44 # -f2c Next argument specifies path to F2C utility
45 # -nickname The next argument specifieds the nickname this script
46 # will submit to the nightlytest results repository.
47 # -gccpath Path to gcc/g++ used to build LLVM
48 # -cvstag Check out a specific CVS tag to build LLVM (useful for
49 # testing release branches)
50 # -usecvs Check code out from the (old) CVS Repository instead of from
51 # the standard Subversion repository.
52 # -target Specify the target triplet
53 # -cflags Next argument specifies that C compilation options that
54 # override the default.
55 # -cxxflags Next argument specifies that C++ compilation options that
56 # override the default.
57 # -ldflags Next argument specifies that linker options that override
59 # -compileflags Next argument specifies extra options passed to make when
61 # -use-gmake Use gmake instead of the default make command to build
64 # ---------------- Options to configure llvm-test ----------------------------
65 # -extraflags Next argument specifies extra options that are passed to
67 # -noexternals Do not run the external tests (for cases where povray
68 # or SPEC are not installed)
69 # -with-externals Specify a directory where the external tests are located.
70 # -submit-server Specifies a server to submit the test results too. If this
71 # option is not specified it defaults to
72 # llvm.org. This is basically just the address of the
74 # -submit-script Specifies which script to call on the submit server. If
75 # this option is not specified it defaults to
76 # /nightlytest/NightlyTestAccept.php. This is basically
77 # everything after the www.yourserver.org.
78 # -nosubmit Do not report the test results back to a submit server.
80 # CVSROOT is the CVS repository from which the tree will be checked out,
81 # specified either in the full :method:user@host:/dir syntax, or
82 # just /dir if using a local repo.
83 # BUILDDIR is the directory where sources for this test run will be checked out
84 # AND objects for this test run will be built. This directory MUST NOT
85 # exist before the script is run; it will be created by the cvs checkout
86 # process and erased (unless -noremove is specified; see above.)
87 # WEBDIR is the directory into which the test results web page will be written,
88 # AND in which the "index.html" is assumed to be a symlink to the most recent
89 # copy of the results. This directory will be created if it does not exist.
90 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
91 # to. This is the same as you would have for a normal LLVM build.
93 ##############################################################
95 # Getting environment variables
97 ##############################################################
98 my $HOME = $ENV{'HOME'};
99 my $SVNURL = $ENV{"SVNURL"};
100 $SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
101 my $CVSRootDir = $ENV{'CVSROOT'};
102 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
103 my $BuildDir = $ENV{'BUILDDIR'};
104 $BuildDir = "$HOME/buildtest" unless $BuildDir;
105 my $WebDir = $ENV{'WEBDIR'};
106 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
108 ##############################################################
110 # Calculate the date prefix...
112 ##############################################################
114 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
115 my $DateString = strftime
"%B %d, %Y", localtime;
116 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
118 ##############################################################
122 ##############################################################
129 $SUBMITSERVER = "llvm.org";
130 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
133 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
135 last if /^--$/; # Stop processing arguments on --
137 # List command line options here...
138 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
139 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
140 if (/^-noremove$/) { $NOREMOVE = 1; next; }
141 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
142 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
143 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
144 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
145 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
146 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
147 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
148 "DISABLE_ASSERTIONS=1 ".
149 "OPTIMIZE_OPTION=-O2";
150 $BUILDTYPE="release-asserts"; next;}
151 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
152 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
153 $CONFIGUREARGS .= " --enable-lli"; next; }
154 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
155 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
156 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
157 $CONFIGUREARGS .= " --disable-jit"; next; }
158 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
159 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
160 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
161 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
162 if (/^-verbose$/) { $VERBOSE = 1; next; }
163 if (/^-debug$/) { $DEBUG = 1; next; }
164 if (/^-nice$/) { $NICE = "nice "; next; }
165 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
167 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
169 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
170 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
171 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
172 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
173 if (/^-gccpath/) { $CONFIGUREARGS .=
174 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
175 $GCCPATH=$ARGV[0]; shift; next; }
176 else { $GCCPATH=""; }
177 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
178 else { $CVSCOOPT="";}
179 if (/^-usecvs/) { $USESVN = 0; }
180 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
182 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
184 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
186 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
188 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
189 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
190 if (/^-extraflags/) { $CONFIGUREARGS .=
191 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
192 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
193 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
194 if (/^-nobuild$/) { $NOBUILD = 1; next; }
195 print "Unknown option: $_ : ignoring!\n";
198 if ($ENV{'LLVMGCCDIR'}) {
199 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
200 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
206 if ($CONFIGUREARGS !~ /--disable-jit/) {
207 $CONFIGUREARGS .= " --enable-jit";
210 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
214 print "Must specify 0 or 3 options!";
218 $CVSRootDir = $ARGV[0];
219 $BuildDir = $ARGV[1];
223 if ($CVSRootDir eq "" or
226 die("please specify a cvs root directory, a build directory, and a ".
230 if ($nickname eq "") {
231 die ("Please invoke NewNightlyTest.pl with command line option " .
232 "\"-nickname <nickname>\"");
235 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
236 $BUILDTYPE = "debug";
239 ##############################################################
241 #define the file names we'll use
243 ##############################################################
244 my $Prefix = "$WebDir/$DATE";
245 my $BuildLog = "$Prefix-Build-Log.txt";
246 my $COLog = "$Prefix-CVS-Log.txt";
247 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
248 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
249 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
250 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
251 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
252 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
253 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
257 warn "$WebDir did not exist; creating it.\n";
262 print "INITIALIZED\n";
264 print "SVN URL = $SVNURL\n";
266 print "CVS Root = $CVSRootDir\n";
268 print "COLog = $COLog\n";
269 print "BuildDir = $BuildDir\n";
270 print "WebDir = $WebDir\n";
271 print "Prefix = $Prefix\n";
272 print "BuildLog = $BuildLog\n";
275 ##############################################################
279 ##############################################################
283 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH
;
288 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290 # DiffFiles - Diff the current version of the file against the last version of
291 # the file, reporting things added and removed. This is used to report, for
292 # example, added and removed warnings. This returns a pair (added, removed)
294 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297 my @Others = GetDir
$Suffix;
298 if (@Others == 0) { # No other files? We added all entries...
299 return (`cat $WebDir/$DATE$Suffix`, "");
301 # Diff the files now...
302 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
303 my $Added = join "\n", grep /^</, @Diffs;
304 my $Removed = join "\n", grep /^>/, @Diffs;
306 $Removed =~ s/^> //gm;
307 return ($Added, $Removed);
310 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 sub GetRegex
{ # (Regex with ()'s, value)
319 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322 my ($Regex, $Num, $Regex2, $File) = @_;
323 my @Items = split "\n", `grep '$Regex' $File`;
324 return GetRegex
$Regex2, $Items[$Num];
327 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329 sub ChangeDir
{ # directory, logical name
330 my ($dir,$name) = @_;
332 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
333 $result = chdir($dir);
335 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
341 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344 if (open (FILE
, $_[0])) {
351 print "Could not open file '$_[0]' for reading!\n";
356 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 sub WriteFile
{ # (filename, contents)
359 open (FILE
, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
364 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366 sub CopyFile
{ #filename, newfile
367 my ($file, $newfile) = @_;
369 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
370 copy
($file, $newfile);
373 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376 my ($Val, $Filename,$WebDir) = @_;
378 if (open FILE
, "$WebDir/$Filename") {
379 @Records = grep !/$DATE/, split "\n", <FILE
>;
382 push @Records, "$DATE: $Val";
383 WriteFile
"$WebDir/$Filename", (join "\n", @Records) . "\n";
386 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
388 # FormatTime - Convert a time from 1m23.45 into 83.45
390 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
394 $Time = sprintf("%7.4f", $1*60.0+$2);
399 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
401 # This function is meant to read in the dejagnu sum file and
402 # return a string with only the results (i.e. PASS/FAIL/XPASS/
405 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406 sub GetDejagnuTestResults
{ # (filename, log)
407 my ($filename, $DejagnuLog) = @_;
409 $/ = "\n"; #Make sure we're going line at a time.
411 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
413 if (open SRCHFILE
, $filename) {
414 # Process test results
415 while ( <SRCHFILE
> ) {
416 if ( length($_) > 1 ) {
418 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\
/test\/(.*)$/ ) {
419 push(@lines, "$1: test/$2");
426 my $content = join("\n", @lines);
432 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
434 # This function acts as a mini web browswer submitting data
435 # to our central server via the post method
437 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
444 $socketaddr= sockaddr_in
$port, inet_aton
$host or die "Bad hostname\n";
445 socket SOCK
, PF_INET
, SOCK_STREAM
, getprotobyname('tcp') or
447 connect SOCK
, $socketaddr or die "Bad connection\n";
448 select((select(SOCK
), $| = 1)[0]);
450 #creating content here
452 foreach $key (keys (%$variables)){
453 $value = $variables->{$key};
454 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
455 $content .= "$key=$value&";
458 $length = length($content);
460 my $send= "POST $file HTTP/1.0\n";
461 $send.= "Host: $host\n";
462 $send.= "Content-Type: application/x-www-form-urlencoded\n";
463 $send.= "Content-length: $length\n\n";
474 foreach $x (keys (%$variables)){
475 $value = $variables->{$x};
476 $sentdata.= "$x => $value\n";
478 WriteFile
"$Prefix-sentdata.txt", $sentdata;
484 ##############################################################
486 # Getting Start timestamp
488 ##############################################################
489 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
491 ##############################################################
493 # Create the CVS repository directory
495 ##############################################################
500 print "Build directory exists! Removing it\n";
502 system "rm -rf $BuildDir";
503 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
506 print "Build directory exists!\n";
510 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
513 ChangeDir
( $BuildDir, "checkout directory" );
516 ##############################################################
518 # Check out the llvm tree, using either SVN or CVS
520 ##############################################################
522 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
524 my $SVNCMD = "$NICE svn co $SVNURL";
526 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
527 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
529 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
530 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
533 $CVSOPT = "-z3" # Use compression if going over ssh.
534 if $CVSRootDir =~ /^:ext:/;
535 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
537 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
538 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
540 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
541 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
544 ChangeDir
( $BuildDir , "Checkout directory") ;
545 ChangeDir
( "llvm" , "llvm source directory") ;
547 ##############################################################
549 # Get some static statistics about the current state of CVS
551 # This can probably be put on the server side
553 ##############################################################
554 my $CheckoutTime_Wall = GetRegex
"([0-9.]+)", `grep '^real' $COLog`;
555 my $CheckoutTime_User = GetRegex
"([0-9.]+)", `grep '^user' $COLog`;
556 my $CheckoutTime_Sys = GetRegex
"([0-9.]+)", `grep '^sys' $COLog`;
557 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
559 my $NumFilesInCVS = 0;
560 my $NumDirsInCVS = 0;
562 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
563 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
565 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
566 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
569 ##############################################################
571 # Extract some information from the CVS history... use a hash so no duplicate
572 # stuff is stored. This gets the history from the previous days worth
573 # of cvs activity and parses it.
575 ##############################################################
577 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
578 # have to be perfect as its only used for comparing date ranges within a couple
580 sub ConvertToSeconds
{
581 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
582 my $Result = ($yr - 2000) * 12;
595 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
598 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
601 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
602 # Skip very first entry because it is the XML header cruft
605 foreach $Record (@SVNHistory) {
606 my @Lines = split "\n", $Record;
607 my ($Author, $Date, $Revision);
608 # Get the date and see if its one we want to process.
609 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
610 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
611 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
613 my $Then = ConvertToSeconds
($Sec, $Min, $Hour, $Day, $Month, $Year);
614 # Get the current date and compute when "yesterday" is.
615 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
616 my $Now = ConvertToSeconds
( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
617 if (($Now - 24*60*60) > $Then) {
620 if ($Lines[1] =~ / revision="([0-9]*)">/) {
623 if ($Lines[2] =~ /<author>([^<]*)<\/author
>/) {
626 $UsersCommitted{$Author} = 1;
627 $Date = $Year . "-" . $Month . "-" . $Day;
628 $Time = $Hour . ":" . $Min . ":" . $Sec;
629 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
630 for ($i = 6; $i < $#Lines; $i += 2 ) {
631 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
634 } elsif ($1 == 'D') {
635 $RemovedFiles{$2} = 1;
636 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
637 $ModifiedFiles{$2} = 1;
639 print "UNMATCHABLE: $Lines[$i]\n";
645 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
646 #print join "\n", @CVSHistory; print "\n";
648 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
650 # Loop over every record from the CVS history, filling in the hashes.
651 foreach $File (@CVSHistory) {
652 my ($Type, $Date, $UID, $Rev, $Filename);
653 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
654 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
655 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
656 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
657 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
658 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
660 print "UNMATCHABLE: $File\n";
663 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
665 if ($Filename =~ /^llvm/) {
666 if ($Type eq 'M') { # Modified
667 $ModifiedFiles{$Filename} = 1;
668 $UsersCommitted{$UID} = 1;
669 } elsif ($Type eq 'A') { # Added
670 $AddedFiles{$Filename} = 1;
671 $UsersCommitted{$UID} = 1;
672 } elsif ($Type eq 'R') { # Removed
673 $RemovedFiles{$Filename} = 1;
674 $UsersCommitted{$UID} = 1;
676 $UsersUpdated{$UID} = 1;
685 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
686 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
687 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
688 my $UserCommitList = join "\n", sort keys %UsersCommitted;
689 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
691 ##############################################################
693 # Build the entire tree, saving build messages to the build log
695 ##############################################################
696 if (!$NOCHECKOUT && !$NOBUILD) {
697 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
699 print "CONFIGURE STAGE:\n";
700 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
701 "> $BuildLog 2>&1\n";
703 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
706 print "BUILD STAGE:\n";
707 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
709 # Build the entire tree, capturing the output into $BuildLog
710 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
713 ##############################################################
715 # Get some statistics about the build...
717 ##############################################################
718 #this can de done on server
719 #my @Linked = split '\n', `grep Linking $BuildLog`;
720 #my $NumExecutables = scalar(grep(/executable/, @Linked));
721 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
722 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
724 # Get the number of lines of source code. Must be here after the build is done
725 # because countloc.sh uses the llvm-config script which must be built.
726 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
728 # Get the time taken by the configure script
729 my $ConfigTimeU = GetRegexNum
"^user", 0, "([0-9.]+)", "$BuildLog";
730 my $ConfigTimeS = GetRegexNum
"^sys", 0, "([0-9.]+)", "$BuildLog";
731 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
732 my $ConfigWallTime = GetRegexNum
"^real", 0,"([0-9.]+)","$BuildLog";
734 $ConfigTime=-1 unless $ConfigTime;
735 $ConfigWallTime=-1 unless $ConfigWallTime;
737 my $BuildTimeU = GetRegexNum
"^user", 1, "([0-9.]+)", "$BuildLog";
738 my $BuildTimeS = GetRegexNum
"^sys", 1, "([0-9.]+)", "$BuildLog";
739 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
740 my $BuildWallTime = GetRegexNum
"^real", 1, "([0-9.]+)","$BuildLog";
742 $BuildTime=-1 unless $BuildTime;
743 $BuildWallTime=-1 unless $BuildWallTime;
745 my $BuildError = 0, $BuildStatus = "OK";
747 $BuildStatus = "Skipped by user";
749 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
750 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
751 $BuildStatus = "Error: compilation aborted";
753 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
755 if ($BuildError) { $NODEJAGNU=1; }
760 print "Organizing size of .o and .a files\n"
762 ChangeDir
( "$BuildDir/llvm", "Build Directory" );
763 $afiles.= `find utils/ -iname '*.a' -ls`;
764 $afiles.= `find lib/ -iname '*.a' -ls`;
765 $afiles.= `find tools/ -iname '*.a' -ls`;
766 if($BUILDTYPE eq "release"){
767 $afiles.= `find Release/ -iname '*.a' -ls`;
768 } elsif($BUILDTYPE eq "release-asserts") {
769 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
771 $afiles.= `find Debug/ -iname '*.a' -ls`;
774 $ofiles.= `find utils/ -iname '*.o' -ls`;
775 $ofiles.= `find lib/ -iname '*.o' -ls`;
776 $ofiles.= `find tools/ -iname '*.o' -ls`;
777 if($BUILDTYPE eq "release"){
778 $ofiles.= `find Release/ -iname '*.o' -ls`;
779 } elsif($BUILDTYPE eq "release-asserts") {
780 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
782 $ofiles.= `find Debug/ -iname '*.o' -ls`;
785 @AFILES = split "\n", $afiles;
787 foreach $x (@AFILES){
788 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
789 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
791 @OFILES = split "\n", $ofiles;
793 foreach $x (@OFILES){
794 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
795 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
798 $a_file_sizes="No data due to a bad build.";
799 $o_file_sizes="No data due to a bad build.";
802 ##############################################################
804 # Running dejagnu tests
806 ##############################################################
807 my $DejangnuTestResults=""; # String containing the results of the dejagnu
808 my $dejagnu_output = "$DejagnuTestsLog";
811 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
812 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
815 #Run the feature and regression tests, results are put into testrun.sum
816 #Full log in testrun.log
817 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
819 #Copy the testrun.log and testrun.sum to our webdir
820 CopyFile
("test/testrun.log", $DejagnuLog);
821 CopyFile
("test/testrun.sum", $DejagnuSum);
822 #can be done on server
823 $DejagnuTestResults = GetDejagnuTestResults
($DejagnuSum, $DejagnuLog);
824 $unexpfail_tests = $DejagnuTestResults;
827 #Extract time of dejagnu tests
828 my $DejagnuTimeU = GetRegexNum
"^user", 0, "([0-9.]+)", "$dejagnu_output";
829 my $DejagnuTimeS = GetRegexNum
"^sys", 0, "([0-9.]+)", "$dejagnu_output";
830 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
831 $DejagnuWallTime = GetRegexNum
"^real", 0,"([0-9.]+)","$dejagnu_output";
832 $DejagnuTestResults =
833 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
834 $DejagnuTime = "0.0" unless $DejagnuTime;
835 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
837 ##############################################################
839 # Get warnings from the build
841 ##############################################################
843 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
844 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
848 foreach $Warning (@Warn) {
849 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
850 $CurDir = $1; # Keep track of directory warning is in...
851 # Remove buildir prefix if included
852 if ($CurDir =~ m
#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
854 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
857 my $WarningsFile = join "\n", @Warnings;
858 $WarningsFile =~ s/:[0-9]+:/::/g;
860 # Emit the warnings file, so we can diff...
861 WriteFile
"$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
862 my ($WarningsAdded, $WarningsRemoved) = DiffFiles
"-Warnings.txt";
864 # Output something to stdout if something has changed
865 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
866 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
868 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
869 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
873 ##############################################################
875 # If we built the tree successfully, run the nightly programs tests...
877 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
880 ##############################################################
883 ChangeDir
( "$BuildDir/llvm/projects/llvm-test/$SubDir",
884 "Programs Test Subdirectory" ) || return ("", "");
886 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
888 # Run the programs tests... creating a report.nightly.csv file
891 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
892 "TEST=nightly > $ProgramTestLog 2>&1\n";
894 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
895 "TEST=nightly > $ProgramTestLog 2>&1";
896 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
900 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
902 $ProgramsTable="Error running test $SubDir\n";
903 print "ERROR TESTING\n";
904 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
906 $ProgramsTable="Makefile error running tests $SubDir!\n";
907 print "ERROR TESTING\n";
911 # Create a list of the tests which were run...
913 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
914 "| sort > $Prefix-$SubDir-Tests.txt";
916 $ProgramsTable = ReadFile
"report.nightly.csv";
918 ChangeDir
( "../../..", "Programs Test Parent Directory" );
919 return ($ProgramsTable, $llcbeta_options);
920 } #end sub TestDirectory
922 ##############################################################
924 # Calling sub TestDirectory
926 ##############################################################
929 print "SingleSource TEST STAGE\n";
931 ($SingleSourceProgramsTable, $llcbeta_options) =
932 TestDirectory
("SingleSource");
933 WriteFile
"$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
935 print "MultiSource TEST STAGE\n";
937 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory
("MultiSource");
938 WriteFile
"$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
939 if ( ! $NOEXTERNALS ) {
941 print "External TEST STAGE\n";
943 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory
("External");
944 WriteFile
"$Prefix-External-Performance.txt", $ExternalProgramsTable;
945 system "cat $Prefix-SingleSource-Tests.txt " .
946 "$Prefix-MultiSource-Tests.txt ".
947 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
948 system "cat $Prefix-SingleSource-Performance.txt " .
949 "$Prefix-MultiSource-Performance.txt ".
950 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
952 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
954 print "External TEST STAGE SKIPPED\n";
956 system "cat $Prefix-SingleSource-Tests.txt " .
957 "$Prefix-MultiSource-Tests.txt ".
958 " | sort > $Prefix-Tests.txt";
959 system "cat $Prefix-SingleSource-Performance.txt " .
960 "$Prefix-MultiSource-Performance.txt ".
961 " | sort > $Prefix-Performance.txt";
964 ##############################################################
967 # gathering tests added removed broken information here
970 ##############################################################
971 my $dejagnu_test_list = ReadFile
"$Prefix-Tests.txt";
972 my @DEJAGNU = split "\n", $dejagnu_test_list;
973 my ($passes, $fails, $xfails) = "";
976 for ($x=0; $x<@DEJAGNU; $x++) {
977 if ($DEJAGNU[$x] =~ m/^PASS:/) {
978 $passes.="$DEJAGNU[$x]\n";
980 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
981 $fails.="$DEJAGNU[$x]\n";
983 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
984 $xfails.="$DEJAGNU[$x]\n";
989 } #end if !$BuildError
992 ##############################################################
994 # If we built the tree successfully, runs of the Olden suite with
995 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
997 ##############################################################
999 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
1000 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
1001 $MachCodeSize) = ("","","","","","","");
1002 if (!$NORUNNINGTESTS) {
1003 ChangeDir
( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
1004 "Olden Test Directory");
1006 # Clean out previous results...
1007 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
1009 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1010 # GET_STABLE_NUMBERS enabled!
1012 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1013 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1014 "> /dev/null 2>&1\n";
1016 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1017 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1019 system "cp report.nightly.csv $OldenTestsLog";
1023 ##############################################################
1025 # Getting end timestamp
1027 ##############################################################
1028 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1031 ##############################################################
1033 # Place all the logs neatly into one humungous file
1035 ##############################################################
1036 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1038 $machine_data = "uname: ".`uname -a`.
1039 "hardware: ".`uname -m`.
1041 "name: ".`uname -n`.
1042 "date: ".`date \"+20%y-%m-%d\"`.
1043 "time: ".`date +\"%H:%M:%S\"`;
1047 @CVS_DATA = ReadFile
"$COLog";
1048 $cvs_data = join("\n", @CVS_DATA);
1052 @BUILD_DATA = ReadFile
"$BuildLog";
1053 $build_data = join("\n", @BUILD_DATA);
1055 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1056 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1057 my ($gcc_version, $gcc_version_long) = "";
1059 $gcc_version_long="";
1060 if ($GCCPATH ne "") {
1061 $gcc_version_long = `$GCCPATH/gcc --version`;
1062 } elsif ($ENV{"CC"}) {
1063 $gcc_version_long = `$ENV{"CC"} --version`;
1065 $gcc_version_long = `gcc --version`;
1067 @GCC_VERSION = split '\n', $gcc_version_long;
1068 $gcc_version = $GCC_VERSION[0];
1070 $llvmgcc_version_long="";
1071 if ($LLVMGCCPATH ne "") {
1072 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1074 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1076 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1077 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1078 $llvmgcc_versionTarget =~ /Target: (.+)/;
1082 @DEJAGNU_LOG = ReadFile
"$DejagnuLog";
1083 @DEJAGNU_SUM = ReadFile
"$DejagnuSum";
1084 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1085 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1087 @DEJAGNULOG_FULL = ReadFile
"$DejagnuTestsLog";
1088 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1091 ##############################################################
1093 # Send data via a post request
1095 ##############################################################
1097 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1099 my %hash_of_data = (
1100 'machine_data' => $machine_data,
1101 'build_data' => $build_data,
1102 'gcc_version' => $gcc_version,
1103 'nickname' => $nickname,
1104 'dejagnutime_wall' => $DejagnuWallTime,
1105 'dejagnutime_cpu' => $DejagnuTime,
1106 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1107 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1108 'configtime_wall' => $ConfigWallTime,
1109 'configtime_cpu'=> $ConfigTime,
1110 'buildtime_wall' => $BuildWallTime,
1111 'buildtime_cpu' => $BuildTime,
1112 'warnings' => $WarningsFile,
1113 'cvsusercommitlist' => $UserCommitList,
1114 'cvsuserupdatelist' => $UserUpdateList,
1115 'cvsaddedfiles' => $CVSAddedFiles,
1116 'cvsmodifiedfiles' => $CVSModifiedFiles,
1117 'cvsremovedfiles' => $CVSRemovedFiles,
1118 'lines_of_code' => $LOC,
1119 'cvs_file_count' => $NumFilesInCVS,
1120 'cvs_dir_count' => $NumDirsInCVS,
1121 'buildstatus' => $BuildStatus,
1122 'singlesource_programstable' => $SingleSourceProgramsTable,
1123 'multisource_programstable' => $MultiSourceProgramsTable,
1124 'externalsource_programstable' => $ExternalProgramsTable,
1125 'llcbeta_options' => $multisource_llcbeta_options,
1126 'warnings_removed' => $WarningsRemoved,
1127 'warnings_added' => $WarningsAdded,
1128 'passing_tests' => $passes,
1129 'expfail_tests' => $xfails,
1130 'unexpfail_tests' => $fails,
1131 'all_tests' => $dejagnu_test_list,
1133 'removed_tests' => "",
1134 'dejagnutests_results' => $DejagnuTestResults,
1135 'dejagnutests_log' => $dejagnulog_full,
1136 'starttime' => $starttime,
1137 'endtime' => $endtime,
1138 'o_file_sizes' => $o_file_sizes,
1139 'a_file_sizes' => $a_file_sizes,
1140 'target_triple' => $targetTriple
1144 my $response = SendData
$SUBMITSERVER,$SUBMITSCRIPT,\
%hash_of_data;
1145 if( $VERBOSE) { print "============================\n$response"; }
1147 print "============================\n";
1148 foreach $x(keys %hash_of_data){
1149 print "$x => $hash_of_data{$x}\n";
1153 ##############################################################
1155 # Remove the cvs tree...
1157 ##############################################################
1158 system ( "$NICE rm -rf $BuildDir")
1159 if (!$NOCHECKOUT and !$NOREMOVE);
1160 system ( "$NICE rm -rf $WebDir")
1161 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);