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 # -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 # -nosubmit Do not report the test results back to a submit server.
79 # CVSROOT is the CVS repository from which the tree will be checked out,
80 # specified either in the full :method:user@host:/dir syntax, or
81 # just /dir if using a local repo.
82 # BUILDDIR is the directory where sources for this test run will be checked out
83 # AND objects for this test run will be built. This directory MUST NOT
84 # exist before the script is run; it will be created by the cvs checkout
85 # process and erased (unless -noremove is specified; see above.)
86 # WEBDIR is the directory into which the test results web page will be written,
87 # AND in which the "index.html" is assumed to be a symlink to the most recent
88 # copy of the results. This directory will be created if it does not exist.
89 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
90 # to. This is the same as you would have for a normal LLVM build.
92 ##############################################################
94 # Getting environment variables
96 ##############################################################
97 my $HOME = $ENV{'HOME'};
98 my $SVNURL = $ENV{"SVNURL"};
99 $SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
100 my $CVSRootDir = $ENV{'CVSROOT'};
101 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
102 my $BuildDir = $ENV{'BUILDDIR'};
103 $BuildDir = "$HOME/buildtest" unless $BuildDir;
104 my $WebDir = $ENV{'WEBDIR'};
105 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
107 ##############################################################
109 # Calculate the date prefix...
111 ##############################################################
113 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
114 my $DateString = strftime "%B %d, %Y", localtime;
115 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
117 ##############################################################
121 ##############################################################
128 $SUBMITSERVER = "llvm.org";
129 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
132 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
134 last if /^--$/; # Stop processing arguments on --
136 # List command line options here...
137 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
138 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
139 if (/^-noremove$/) { $NOREMOVE = 1; next; }
140 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
141 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
142 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
143 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
144 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
145 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
146 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
147 "DISABLE_ASSERTIONS=1 ".
148 "OPTIMIZE_OPTION=-O2";
149 $BUILDTYPE="release-asserts"; next;}
150 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
151 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
152 $CONFIGUREARGS .= " --enable-lli"; next; }
153 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
154 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
155 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
156 $CONFIGUREARGS .= " --disable-jit"; next; }
157 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
158 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
159 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
160 if (/^-verbose$/) { $VERBOSE = 1; next; }
161 if (/^-debug$/) { $DEBUG = 1; next; }
162 if (/^-nice$/) { $NICE = "nice "; next; }
163 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
165 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
167 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
168 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
169 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
170 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
171 if (/^-gccpath/) { $CONFIGUREARGS .=
172 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
173 $GCCPATH=$ARGV[0]; shift; next; }
174 else { $GCCPATH=""; }
175 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
176 else { $CVSCOOPT="";}
177 if (/^-usecvs/) { $USESVN = 0; }
178 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
180 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
182 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
184 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
186 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
187 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
188 if (/^-extraflags/) { $CONFIGUREARGS .=
189 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
190 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
191 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
192 if (/^-nobuild$/) { $NOBUILD = 1; next; }
193 print "Unknown option: $_ : ignoring!\n";
196 if ($ENV{'LLVMGCCDIR'}) {
197 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
198 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'};
204 if ($CONFIGUREARGS !~ /--disable-jit/) {
205 $CONFIGUREARGS .= " --enable-jit";
208 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
212 print "Must specify 0 or 3 options!";
216 $CVSRootDir = $ARGV[0];
217 $BuildDir = $ARGV[1];
221 if ($CVSRootDir eq "" or
224 die("please specify a cvs root directory, a build directory, and a ".
228 if ($nickname eq "") {
229 die ("Please invoke NewNightlyTest.pl with command line option " .
230 "\"-nickname <nickname>\"");
233 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
234 $BUILDTYPE = "debug";
237 ##############################################################
239 #define the file names we'll use
241 ##############################################################
242 my $Prefix = "$WebDir/$DATE";
243 my $BuildLog = "$Prefix-Build-Log.txt";
244 my $COLog = "$Prefix-CVS-Log.txt";
245 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
246 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
247 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
248 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
249 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
250 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
251 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
255 warn "$WebDir did not exist; creating it.\n";
260 print "INITIALIZED\n";
262 print "SVN URL = $SVNURL\n";
264 print "CVS Root = $CVSRootDir\n";
266 print "COLog = $COLog\n";
267 print "BuildDir = $BuildDir\n";
268 print "WebDir = $WebDir\n";
269 print "Prefix = $Prefix\n";
270 print "BuildLog = $BuildLog\n";
273 ##############################################################
277 ##############################################################
281 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
286 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288 # DiffFiles - Diff the current version of the file against the last version of
289 # the file, reporting things added and removed. This is used to report, for
290 # example, added and removed warnings. This returns a pair (added, removed)
292 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295 my @Others = GetDir $Suffix;
296 if (@Others == 0) { # No other files? We added all entries...
297 return (`cat $WebDir/$DATE$Suffix`, "");
299 # Diff the files now...
300 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
301 my $Added = join "\n", grep /^</, @Diffs;
302 my $Removed = join "\n", grep /^>/, @Diffs;
304 $Removed =~ s/^> //gm;
305 return ($Added, $Removed);
308 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310 sub GetRegex { # (Regex with ()'s, value)
317 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320 my ($Regex, $Num, $Regex2, $File) = @_;
321 my @Items = split "\n", `grep '$Regex' $File`;
322 return GetRegex $Regex2, $Items[$Num];
325 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327 sub ChangeDir { # directory, logical name
328 my ($dir,$name) = @_;
330 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
331 $result = chdir($dir);
333 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
339 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342 if (open (FILE, $_[0])) {
349 print "Could not open file '$_[0]' for reading!\n";
354 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
355 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356 sub WriteFile { # (filename, contents)
357 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
362 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
364 sub CopyFile { #filename, newfile
365 my ($file, $newfile) = @_;
367 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
368 copy($file, $newfile);
371 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374 my ($Val, $Filename,$WebDir) = @_;
376 if (open FILE, "$WebDir/$Filename") {
377 @Records = grep !/$DATE/, split "\n", <FILE>;
380 push @Records, "$DATE: $Val";
381 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
384 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
386 # FormatTime - Convert a time from 1m23.45 into 83.45
388 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
391 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
392 $Time = sprintf("%7.4f", $1*60.0+$2);
397 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399 # This function is meant to read in the dejagnu sum file and
400 # return a string with only the results (i.e. PASS/FAIL/XPASS/
403 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404 sub GetDejagnuTestResults { # (filename, log)
405 my ($filename, $DejagnuLog) = @_;
407 $/ = "\n"; #Make sure we're going line at a time.
409 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
411 if (open SRCHFILE, $filename) {
412 # Process test results
413 while ( <SRCHFILE> ) {
414 if ( length($_) > 1 ) {
416 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
417 push(@lines, "$1: test/$2");
424 my $content = join("\n", @lines);
430 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432 # This function acts as a mini web browswer submitting data
433 # to our central server via the post method
435 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
442 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
443 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
445 connect SOCK, $socketaddr or die "Bad connection\n";
446 select((select(SOCK), $| = 1)[0]);
448 #creating content here
450 foreach $key (keys (%$variables)){
451 $value = $variables->{$key};
452 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
453 $content .= "$key=$value&";
456 $length = length($content);
458 my $send= "POST $file HTTP/1.0\n";
459 $send.= "Host: $host\n";
460 $send.= "Content-Type: application/x-www-form-urlencoded\n";
461 $send.= "Content-length: $length\n\n";
472 foreach $x (keys (%$variables)){
473 $value = $variables->{$x};
474 $sentdata.= "$x => $value\n";
476 WriteFile "$Prefix-sentdata.txt", $sentdata;
482 ##############################################################
484 # Getting Start timestamp
486 ##############################################################
487 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
489 ##############################################################
491 # Create the CVS repository directory
493 ##############################################################
498 print "Build directory exists! Removing it\n";
500 system "rm -rf $BuildDir";
501 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
504 print "Build directory exists!\n";
508 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
511 ChangeDir( $BuildDir, "checkout directory" );
514 ##############################################################
516 # Check out the llvm tree, using either SVN or CVS
518 ##############################################################
520 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
522 my $SVNCMD = "$NICE svn co $SVNURL";
524 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
525 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
527 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
528 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
531 $CVSOPT = "-z3" # Use compression if going over ssh.
532 if $CVSRootDir =~ /^:ext:/;
533 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
535 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
536 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
538 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
539 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
542 ChangeDir( $BuildDir , "Checkout directory") ;
543 ChangeDir( "llvm" , "llvm source directory") ;
545 ##############################################################
547 # Get some static statistics about the current state of CVS
549 # This can probably be put on the server side
551 ##############################################################
552 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
553 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
554 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
555 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
557 my $NumFilesInCVS = 0;
558 my $NumDirsInCVS = 0;
560 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
561 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
563 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
564 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
567 ##############################################################
569 # Extract some information from the CVS history... use a hash so no duplicate
570 # stuff is stored. This gets the history from the previous days worth
571 # of cvs activity and parses it.
573 ##############################################################
575 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
576 # have to be perfect as its only used for comparing date ranges within a couple
578 sub ConvertToSeconds {
579 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
580 my $Result = ($yr - 2000) * 12;
593 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
596 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
599 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
600 # Skip very first entry because it is the XML header cruft
603 foreach $Record (@SVNHistory) {
604 my @Lines = split "\n", $Record;
605 my ($Author, $Date, $Revision);
606 # Get the date and see if its one we want to process.
607 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
608 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
609 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
611 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
612 # Get the current date and compute when "yesterday" is.
613 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
614 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
615 if (($Now - 24*60*60) > $Then) {
618 if ($Lines[1] =~ / revision="([0-9]*)">/) {
621 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
624 $UsersCommitted{$Author} = 1;
625 $Date = $Year . "-" . $Month . "-" . $Day;
626 $Time = $Hour . ":" . $Min . ":" . $Sec;
627 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
628 for ($i = 6; $i < $#Lines; $i += 2 ) {
629 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
632 } elsif ($1 == 'D') {
633 $RemovedFiles{$2} = 1;
634 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
635 $ModifiedFiles{$2} = 1;
637 print "UNMATCHABLE: $Lines[$i]\n";
643 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
644 #print join "\n", @CVSHistory; print "\n";
646 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
648 # Loop over every record from the CVS history, filling in the hashes.
649 foreach $File (@CVSHistory) {
650 my ($Type, $Date, $UID, $Rev, $Filename);
651 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
652 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
653 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
654 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
655 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
656 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
658 print "UNMATCHABLE: $File\n";
661 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
663 if ($Filename =~ /^llvm/) {
664 if ($Type eq 'M') { # Modified
665 $ModifiedFiles{$Filename} = 1;
666 $UsersCommitted{$UID} = 1;
667 } elsif ($Type eq 'A') { # Added
668 $AddedFiles{$Filename} = 1;
669 $UsersCommitted{$UID} = 1;
670 } elsif ($Type eq 'R') { # Removed
671 $RemovedFiles{$Filename} = 1;
672 $UsersCommitted{$UID} = 1;
674 $UsersUpdated{$UID} = 1;
683 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
684 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
685 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
686 my $UserCommitList = join "\n", sort keys %UsersCommitted;
687 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
689 ##############################################################
691 # Build the entire tree, saving build messages to the build log
693 ##############################################################
694 if (!$NOCHECKOUT && !$NOBUILD) {
695 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
697 print "CONFIGURE STAGE:\n";
698 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
699 "> $BuildLog 2>&1\n";
701 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
704 print "BUILD STAGE:\n";
705 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
707 # Build the entire tree, capturing the output into $BuildLog
708 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
711 ##############################################################
713 # Get some statistics about the build...
715 ##############################################################
716 #this can de done on server
717 #my @Linked = split '\n', `grep Linking $BuildLog`;
718 #my $NumExecutables = scalar(grep(/executable/, @Linked));
719 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
720 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
722 # Get the number of lines of source code. Must be here after the build is done
723 # because countloc.sh uses the llvm-config script which must be built.
724 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
726 # Get the time taken by the configure script
727 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
728 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
729 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
730 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
732 $ConfigTime=-1 unless $ConfigTime;
733 $ConfigWallTime=-1 unless $ConfigWallTime;
735 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
736 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
737 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
738 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
740 $BuildTime=-1 unless $BuildTime;
741 $BuildWallTime=-1 unless $BuildWallTime;
743 my $BuildError = 0, $BuildStatus = "OK";
745 $BuildStatus = "Skipped by user";
747 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
748 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
749 $BuildStatus = "Error: compilation aborted";
751 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
753 if ($BuildError) { $NODEJAGNU=1; }
758 print "Organizing size of .o and .a files\n"
760 ChangeDir( "$BuildDir/llvm", "Build Directory" );
761 $afiles.= `find utils/ -iname '*.a' -ls`;
762 $afiles.= `find lib/ -iname '*.a' -ls`;
763 $afiles.= `find tools/ -iname '*.a' -ls`;
764 if($BUILDTYPE eq "release"){
765 $afiles.= `find Release/ -iname '*.a' -ls`;
766 } elsif($BUILDTYPE eq "release-asserts") {
767 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
769 $afiles.= `find Debug/ -iname '*.a' -ls`;
772 $ofiles.= `find utils/ -iname '*.o' -ls`;
773 $ofiles.= `find lib/ -iname '*.o' -ls`;
774 $ofiles.= `find tools/ -iname '*.o' -ls`;
775 if($BUILDTYPE eq "release"){
776 $ofiles.= `find Release/ -iname '*.o' -ls`;
777 } elsif($BUILDTYPE eq "release-asserts") {
778 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
780 $ofiles.= `find Debug/ -iname '*.o' -ls`;
783 @AFILES = split "\n", $afiles;
785 foreach $x (@AFILES){
786 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
787 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
789 @OFILES = split "\n", $ofiles;
791 foreach $x (@OFILES){
792 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
793 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
796 $a_file_sizes="No data due to a bad build.";
797 $o_file_sizes="No data due to a bad build.";
800 ##############################################################
802 # Running dejagnu tests
804 ##############################################################
805 my $DejangnuTestResults=""; # String containing the results of the dejagnu
806 my $dejagnu_output = "$DejagnuTestsLog";
809 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
810 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
813 #Run the feature and regression tests, results are put into testrun.sum
814 #Full log in testrun.log
815 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
817 #Copy the testrun.log and testrun.sum to our webdir
818 CopyFile("test/testrun.log", $DejagnuLog);
819 CopyFile("test/testrun.sum", $DejagnuSum);
820 #can be done on server
821 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
822 $unexpfail_tests = $DejagnuTestResults;
825 #Extract time of dejagnu tests
826 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
827 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
828 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
829 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
830 $DejagnuTestResults =
831 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
832 $DejagnuTime = "0.0" unless $DejagnuTime;
833 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
835 ##############################################################
837 # Get warnings from the build
839 ##############################################################
841 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
842 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
846 foreach $Warning (@Warn) {
847 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
848 $CurDir = $1; # Keep track of directory warning is in...
849 # Remove buildir prefix if included
850 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
852 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
855 my $WarningsFile = join "\n", @Warnings;
856 $WarningsFile =~ s/:[0-9]+:/::/g;
858 # Emit the warnings file, so we can diff...
859 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
860 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
862 # Output something to stdout if something has changed
863 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
864 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
866 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
867 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
871 ##############################################################
873 # If we built the tree successfully, run the nightly programs tests...
875 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
878 ##############################################################
881 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
882 "Programs Test Subdirectory" ) || return ("", "");
884 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
886 # Run the programs tests... creating a report.nightly.csv file
889 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
890 "TEST=nightly > $ProgramTestLog 2>&1\n";
892 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
893 "TEST=nightly > $ProgramTestLog 2>&1";
894 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
898 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
900 $ProgramsTable="Error running test $SubDir\n";
901 print "ERROR TESTING\n";
902 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
904 $ProgramsTable="Makefile error running tests $SubDir!\n";
905 print "ERROR TESTING\n";
909 # Create a list of the tests which were run...
911 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
912 "| sort > $Prefix-$SubDir-Tests.txt";
914 $ProgramsTable = ReadFile "report.nightly.csv";
916 ChangeDir( "../../..", "Programs Test Parent Directory" );
917 return ($ProgramsTable, $llcbeta_options);
918 } #end sub TestDirectory
920 ##############################################################
922 # Calling sub TestDirectory
924 ##############################################################
927 print "SingleSource TEST STAGE\n";
929 ($SingleSourceProgramsTable, $llcbeta_options) =
930 TestDirectory("SingleSource");
931 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
933 print "MultiSource TEST STAGE\n";
935 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
936 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
937 if ( ! $NOEXTERNALS ) {
939 print "External TEST STAGE\n";
941 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
942 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
943 system "cat $Prefix-SingleSource-Tests.txt " .
944 "$Prefix-MultiSource-Tests.txt ".
945 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
946 system "cat $Prefix-SingleSource-Performance.txt " .
947 "$Prefix-MultiSource-Performance.txt ".
948 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
950 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
952 print "External TEST STAGE SKIPPED\n";
954 system "cat $Prefix-SingleSource-Tests.txt " .
955 "$Prefix-MultiSource-Tests.txt ".
956 " | sort > $Prefix-Tests.txt";
957 system "cat $Prefix-SingleSource-Performance.txt " .
958 "$Prefix-MultiSource-Performance.txt ".
959 " | sort > $Prefix-Performance.txt";
962 ##############################################################
965 # gathering tests added removed broken information here
968 ##############################################################
969 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
970 my @DEJAGNU = split "\n", $dejagnu_test_list;
971 my ($passes, $fails, $xfails) = "";
974 for ($x=0; $x<@DEJAGNU; $x++) {
975 if ($DEJAGNU[$x] =~ m/^PASS:/) {
976 $passes.="$DEJAGNU[$x]\n";
978 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
979 $fails.="$DEJAGNU[$x]\n";
981 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
982 $xfails.="$DEJAGNU[$x]\n";
987 } #end if !$BuildError
990 ##############################################################
992 # If we built the tree successfully, runs of the Olden suite with
993 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
995 ##############################################################
997 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
998 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
999 $MachCodeSize) = ("","","","","","","");
1000 if (!$NORUNNINGTESTS) {
1001 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
1002 "Olden Test Directory");
1004 # Clean out previous results...
1005 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
1007 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1008 # GET_STABLE_NUMBERS enabled!
1010 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1011 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1012 "> /dev/null 2>&1\n";
1014 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1015 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1017 system "cp report.nightly.csv $OldenTestsLog";
1021 ##############################################################
1023 # Getting end timestamp
1025 ##############################################################
1026 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1029 ##############################################################
1031 # Place all the logs neatly into one humungous file
1033 ##############################################################
1034 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1036 $machine_data = "uname: ".`uname -a`.
1037 "hardware: ".`uname -m`.
1039 "name: ".`uname -n`.
1040 "date: ".`date \"+20%y-%m-%d\"`.
1041 "time: ".`date +\"%H:%M:%S\"`;
1045 @CVS_DATA = ReadFile "$COLog";
1046 $cvs_data = join("\n", @CVS_DATA);
1050 @BUILD_DATA = ReadFile "$BuildLog";
1051 $build_data = join("\n", @BUILD_DATA);
1053 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1054 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1055 my ($gcc_version, $gcc_version_long) = "";
1057 $gcc_version_long="";
1058 if ($GCCPATH ne "") {
1059 $gcc_version_long = `$GCCPATH/gcc --version`;
1060 } elsif ($ENV{"CC"}) {
1061 $gcc_version_long = `$ENV{"CC"} --version`;
1063 $gcc_version_long = `gcc --version`;
1065 @GCC_VERSION = split '\n', $gcc_version_long;
1066 $gcc_version = $GCC_VERSION[0];
1068 $llvmgcc_version_long="";
1069 if ($LLVMGCCPATH ne "") {
1070 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1072 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1074 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1075 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1076 $llvmgcc_versionTarget =~ /Target: (.+)/;
1080 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1081 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1082 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1083 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1085 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1086 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1089 ##############################################################
1091 # Send data via a post request
1093 ##############################################################
1095 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1097 my %hash_of_data = (
1098 'machine_data' => $machine_data,
1099 'build_data' => $build_data,
1100 'gcc_version' => $gcc_version,
1101 'nickname' => $nickname,
1102 'dejagnutime_wall' => $DejagnuWallTime,
1103 'dejagnutime_cpu' => $DejagnuTime,
1104 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1105 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1106 'configtime_wall' => $ConfigWallTime,
1107 'configtime_cpu'=> $ConfigTime,
1108 'buildtime_wall' => $BuildWallTime,
1109 'buildtime_cpu' => $BuildTime,
1110 'warnings' => $WarningsFile,
1111 'cvsusercommitlist' => $UserCommitList,
1112 'cvsuserupdatelist' => $UserUpdateList,
1113 'cvsaddedfiles' => $CVSAddedFiles,
1114 'cvsmodifiedfiles' => $CVSModifiedFiles,
1115 'cvsremovedfiles' => $CVSRemovedFiles,
1116 'lines_of_code' => $LOC,
1117 'cvs_file_count' => $NumFilesInCVS,
1118 'cvs_dir_count' => $NumDirsInCVS,
1119 'buildstatus' => $BuildStatus,
1120 'singlesource_programstable' => $SingleSourceProgramsTable,
1121 'multisource_programstable' => $MultiSourceProgramsTable,
1122 'externalsource_programstable' => $ExternalProgramsTable,
1123 'llcbeta_options' => $multisource_llcbeta_options,
1124 'warnings_removed' => $WarningsRemoved,
1125 'warnings_added' => $WarningsAdded,
1126 'passing_tests' => $passes,
1127 'expfail_tests' => $xfails,
1128 'unexpfail_tests' => $fails,
1129 'all_tests' => $dejagnu_test_list,
1131 'removed_tests' => "",
1132 'dejagnutests_results' => $DejagnuTestResults,
1133 'dejagnutests_log' => $dejagnulog_full,
1134 'starttime' => $starttime,
1135 'endtime' => $endtime,
1136 'o_file_sizes' => $o_file_sizes,
1137 'a_file_sizes' => $a_file_sizes,
1138 'target_triple' => $targetTriple
1142 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1143 if( $VERBOSE) { print "============================\n$response"; }
1145 print "============================\n";
1146 foreach $x(keys %hash_of_data){
1147 print "$x => $hash_of_data{$x}\n";
1151 ##############################################################
1153 # Remove the cvs tree...
1155 ##############################################################
1156 system ( "$NICE rm -rf $BuildDir")
1157 if (!$NOCHECKOUT and !$NOREMOVE);
1158 system ( "$NICE rm -rf $WebDir")
1159 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);