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 # -target Specify the target triplet
49 # -cflags Next argument specifies that C compilation options that
50 # override the default.
51 # -cxxflags Next argument specifies that C++ compilation options that
52 # override the default.
53 # -ldflags Next argument specifies that linker options that override
55 # -compileflags Next argument specifies extra options passed to make when
57 # -use-gmake Use gmake instead of the default make command to build
60 # ---------------- Options to configure llvm-test ----------------------------
61 # -extraflags Next argument specifies extra options that are passed to
63 # -noexternals Do not run the external tests (for cases where povray
64 # or SPEC are not installed)
65 # -with-externals Specify a directory where the external tests are located.
66 # -submit-server Specifies a server to submit the test results too. If this
67 # option is not specified it defaults to
68 # llvm.org. This is basically just the address of the
70 # -submit-script Specifies which script to call on the submit server. If
71 # this option is not specified it defaults to
72 # /nightlytest/NightlyTestAccept.php. This is basically
73 # everything after the www.yourserver.org.
75 # CVSROOT is the CVS repository from which the tree will be checked out,
76 # specified either in the full :method:user@host:/dir syntax, or
77 # just /dir if using a local repo.
78 # BUILDDIR is the directory where sources for this test run will be checked out
79 # AND objects for this test run will be built. This directory MUST NOT
80 # exist before the script is run; it will be created by the cvs checkout
81 # process and erased (unless -noremove is specified; see above.)
82 # WEBDIR is the directory into which the test results web page will be written,
83 # AND in which the "index.html" is assumed to be a symlink to the most recent
84 # copy of the results. This directory will be created if it does not exist.
85 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
86 # to. This is the same as you would have for a normal LLVM build.
88 ##############################################################
90 # Getting environment variables
92 ##############################################################
93 my $HOME = $ENV{'HOME'};
94 my $CVSRootDir = $ENV{'CVSROOT'};
95 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
96 my $BuildDir = $ENV{'BUILDDIR'};
97 $BuildDir = "$HOME/buildtest" unless $BuildDir;
98 my $WebDir = $ENV{'WEBDIR'};
99 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
101 ##############################################################
103 # Calculate the date prefix...
105 ##############################################################
107 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
108 my $DateString = strftime "%B %d, %Y", localtime;
109 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
111 ##############################################################
115 ##############################################################
121 $SUBMITSERVER = "llvm.org";
122 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
124 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
126 last if /^--$/; # Stop processing arguments on --
128 # List command line options here...
129 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
130 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
131 if (/^-noremove$/) { $NOREMOVE = 1; next; }
132 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
133 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
134 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
135 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
136 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
137 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
138 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
139 "DISABLE-ASSERTIONS=1 ".
140 "OPTIMIZE_OPTION=-O2";
141 $BUILDTYPE="release-asserts"; next;}
142 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
143 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
144 $CONFIGUREARGS .= " --enable-lli"; next; }
145 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
146 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
147 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
148 $CONFIGUREARGS .= " --disable-jit"; next; }
149 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
150 if (/^-verbose$/) { $VERBOSE = 1; next; }
151 if (/^-debug$/) { $DEBUG = 1; next; }
152 if (/^-nice$/) { $NICE = "nice "; next; }
153 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
155 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
157 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
158 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
159 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
160 if (/^-gccpath/) { $CONFIGUREARGS .=
161 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
162 $GCCPATH=$ARGV[0]; shift; next; }
163 else { $GCCPATH=""; }
164 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
165 else { $CVSCOOPT="";}
166 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
168 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
170 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
172 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
174 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
175 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
176 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
177 if (/^-extraflags/) { $CONFIGUREARGS .=
178 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
179 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
180 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
181 if (/^-nobuild$/) { $NOBUILD = 1; next; }
182 print "Unknown option: $_ : ignoring!\n";
185 if ($ENV{'LLVMGCCDIR'}) {
186 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
188 if ($CONFIGUREARGS !~ /--disable-jit/) {
189 $CONFIGUREARGS .= " --enable-jit";
192 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
196 print "Must specify 0 or 3 options!";
200 $CVSRootDir = $ARGV[0];
201 $BuildDir = $ARGV[1];
205 if ($CVSRootDir eq "" or
208 die("please specify a cvs root directory, a build directory, and a ".
212 if ($nickname eq "") {
213 die ("Please invoke NewNightlyTest.pl with command line option " .
214 "\"-nickname <nickname>\"");
217 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
218 $BUILDTYPE = "debug";
221 ##############################################################
223 #define the file names we'll use
225 ##############################################################
226 my $Prefix = "$WebDir/$DATE";
227 my $BuildLog = "$Prefix-Build-Log.txt";
228 my $CVSLog = "$Prefix-CVS-Log.txt";
229 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
230 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
231 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
232 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
233 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
234 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
235 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
239 warn "$WebDir did not exist; creating it.\n";
244 print "INITIALIZED\n";
245 print "CVS Root = $CVSRootDir\n";
246 print "BuildDir = $BuildDir\n";
247 print "WebDir = $WebDir\n";
248 print "Prefix = $Prefix\n";
249 print "CVSLog = $CVSLog\n";
250 print "BuildLog = $BuildLog\n";
253 ##############################################################
257 ##############################################################
261 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
266 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268 # DiffFiles - Diff the current version of the file against the last version of
269 # the file, reporting things added and removed. This is used to report, for
270 # example, added and removed warnings. This returns a pair (added, removed)
272 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
275 my @Others = GetDir $Suffix;
276 if (@Others == 0) { # No other files? We added all entries...
277 return (`cat $WebDir/$DATE$Suffix`, "");
279 # Diff the files now...
280 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
281 my $Added = join "\n", grep /^</, @Diffs;
282 my $Removed = join "\n", grep /^>/, @Diffs;
284 $Removed =~ s/^> //gm;
285 return ($Added, $Removed);
288 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290 sub GetRegex { # (Regex with ()'s, value)
297 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
298 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300 my ($Regex, $Num, $Regex2, $File) = @_;
301 my @Items = split "\n", `grep '$Regex' $File`;
302 return GetRegex $Regex2, $Items[$Num];
305 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
306 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307 sub ChangeDir { # directory, logical name
308 my ($dir,$name) = @_;
310 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
311 $result = chdir($dir);
313 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
319 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322 if (open (FILE, $_[0])) {
329 print "Could not open file '$_[0]' for reading!\n";
334 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336 sub WriteFile { # (filename, contents)
337 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
342 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344 sub CopyFile { #filename, newfile
345 my ($file, $newfile) = @_;
347 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
348 copy($file, $newfile);
351 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354 my ($Val, $Filename,$WebDir) = @_;
356 if (open FILE, "$WebDir/$Filename") {
357 @Records = grep !/$DATE/, split "\n", <FILE>;
360 push @Records, "$DATE: $Val";
361 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
364 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366 # FormatTime - Convert a time from 1m23.45 into 83.45
368 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
372 $Time = sprintf("%7.4f", $1*60.0+$2);
377 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379 # This function is meant to read in the dejagnu sum file and
380 # return a string with only the results (i.e. PASS/FAIL/XPASS/
383 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384 sub GetDejagnuTestResults { # (filename, log)
385 my ($filename, $DejagnuLog) = @_;
387 $/ = "\n"; #Make sure we're going line at a time.
389 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
391 if (open SRCHFILE, $filename) {
392 # Process test results
393 while ( <SRCHFILE> ) {
394 if ( length($_) > 1 ) {
396 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
397 push(@lines, "$1: test/$2");
404 my $content = join("\n", @lines);
410 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412 # This function acts as a mini web browswer submitting data
413 # to our central server via the post method
415 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
422 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
423 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
425 connect SOCK, $socketaddr or die "Bad connection\n";
426 select((select(SOCK), $| = 1)[0]);
428 #creating content here
430 foreach $key (keys (%$variables)){
431 $value = $variables->{$key};
432 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
433 $content .= "$key=$value&";
436 $length = length($content);
438 my $send= "POST $file HTTP/1.0\n";
439 $send.= "Content-Type: application/x-www-form-urlencoded\n";
440 $send.= "Content-length: $length\n\n";
451 foreach $x (keys (%$variables)){
452 $value = $variables->{$x};
453 $sentdata.= "$x => $value\n";
455 WriteFile "$Prefix-sentdata.txt", $sentdata;
461 ##############################################################
463 # Getting Start timestamp
465 ##############################################################
466 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
468 ##############################################################
470 # Create the CVS repository directory
472 ##############################################################
477 print "Build directory exists! Removing it\n";
479 system "rm -rf $BuildDir";
480 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
483 print "Build directory exists!\n";
487 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
490 ChangeDir( $BuildDir, "CVS checkout directory" );
493 ##############################################################
495 # Check out the llvm tree, saving CVS messages to the cvs log...
497 ##############################################################
499 # Use compression if going over ssh.
501 if $CVSRootDir =~ /^:ext:/;
502 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
505 print "CHECKOUT STAGE:\n";
506 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
509 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
510 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
511 ChangeDir( $BuildDir , "CVS Checkout directory") ;
513 ChangeDir( "llvm" , "llvm source directory") ;
515 ##############################################################
517 # Get some static statistics about the current state of CVS
519 # This can probably be put on the server side
521 ##############################################################
522 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
523 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
524 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
525 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
527 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
529 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
531 ##############################################################
533 # Extract some information from the CVS history... use a hash so no duplicate
534 # stuff is stored. This gets the history from the previous days worth
535 # of cvs activity and parses it.
537 ##############################################################
539 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
543 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
544 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
545 #print join "\n", @CVSHistory; print "\n";
547 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
549 # Loop over every record from the CVS history, filling in the hashes.
550 foreach $File (@CVSHistory) {
551 my ($Type, $Date, $UID, $Rev, $Filename);
552 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
553 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
554 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
555 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
556 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
557 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
559 print "UNMATCHABLE: $File\n";
562 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
564 if ($Filename =~ /^llvm/) {
565 if ($Type eq 'M') { # Modified
566 $ModifiedFiles{$Filename} = 1;
567 $UsersCommitted{$UID} = 1;
568 } elsif ($Type eq 'A') { # Added
569 $AddedFiles{$Filename} = 1;
570 $UsersCommitted{$UID} = 1;
571 } elsif ($Type eq 'R') { # Removed
572 $RemovedFiles{$Filename} = 1;
573 $UsersCommitted{$UID} = 1;
575 $UsersUpdated{$UID} = 1;
584 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
585 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
586 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
587 my $UserCommitList = join "\n", sort keys %UsersCommitted;
588 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
590 ##############################################################
592 # Build the entire tree, saving build messages to the build log
594 ##############################################################
595 if (!$NOCHECKOUT && !$NOBUILD) {
596 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
598 print "CONFIGURE STAGE:\n";
599 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
600 "> $BuildLog 2>&1\n";
602 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
605 print "BUILD STAGE:\n";
606 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
608 # Build the entire tree, capturing the output into $BuildLog
609 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
612 ##############################################################
614 # Get some statistics about the build...
616 ##############################################################
617 #this can de done on server
618 #my @Linked = split '\n', `grep Linking $BuildLog`;
619 #my $NumExecutables = scalar(grep(/executable/, @Linked));
620 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
621 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
623 # Get the number of lines of source code. Must be here after the build is done
624 # because countloc.sh uses the llvm-config script which must be built.
625 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
627 # Get the time taken by the configure script
628 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
629 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
630 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
631 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
633 $ConfigTime=-1 unless $ConfigTime;
634 $ConfigWallTime=-1 unless $ConfigWallTime;
636 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
637 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
638 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
639 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
641 $BuildTime=-1 unless $BuildTime;
642 $BuildWallTime=-1 unless $BuildWallTime;
644 my $BuildError = 0, $BuildStatus = "OK";
646 $BuildStatus = "Skipped by user";
649 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
650 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
651 $BuildStatus = "Error: compilation aborted";
653 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
655 if ($BuildError) { $NODEJAGNU=1; }
660 print "Organizing size of .o and .a files\n"
662 ChangeDir( "$BuildDir/llvm", "Build Directory" );
663 $afiles.= `find utils/ -iname '*.a' -ls`;
664 $afiles.= `find lib/ -iname '*.a' -ls`;
665 $afiles.= `find tools/ -iname '*.a' -ls`;
666 if($BUILDTYPE eq "release"){
667 $afiles.= `find Release/ -iname '*.a' -ls`;
668 } elsif($BUILDTYPE eq "release-asserts") {
669 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
671 $afiles.= `find Debug/ -iname '*.a' -ls`;
674 $ofiles.= `find utils/ -iname '*.o' -ls`;
675 $ofiles.= `find lib/ -iname '*.o' -ls`;
676 $ofiles.= `find tools/ -iname '*.o' -ls`;
677 if($BUILDTYPE eq "release"){
678 $ofiles.= `find Release/ -iname '*.o' -ls`;
679 } elsif($BUILDTYPE eq "release-asserts") {
680 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
682 $ofiles.= `find Debug/ -iname '*.o' -ls`;
685 @AFILES = split "\n", $afiles;
687 foreach $x (@AFILES){
688 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
689 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
691 @OFILES = split "\n", $ofiles;
693 foreach $x (@OFILES){
694 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
695 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
698 $a_file_sizes="No data due to a bad build.";
699 $o_file_sizes="No data due to a bad build.";
702 ##############################################################
704 # Running dejagnu tests
706 ##############################################################
707 my $DejangnuTestResults=""; # String containing the results of the dejagnu
708 my $dejagnu_output = "$DejagnuTestsLog";
711 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
712 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
715 #Run the feature and regression tests, results are put into testrun.sum
716 #Full log in testrun.log
717 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
719 #Copy the testrun.log and testrun.sum to our webdir
720 CopyFile("test/testrun.log", $DejagnuLog);
721 CopyFile("test/testrun.sum", $DejagnuSum);
722 #can be done on server
723 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
724 $unexpfail_tests = $DejagnuTestResults;
727 #Extract time of dejagnu tests
728 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
729 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
730 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
731 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
732 $DejagnuTestResults =
733 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
734 $DejagnuTime = "0.0" unless $DejagnuTime;
735 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
737 ##############################################################
739 # Get warnings from the build
741 ##############################################################
743 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
744 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
748 foreach $Warning (@Warn) {
749 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
750 $CurDir = $1; # Keep track of directory warning is in...
751 # Remove buildir prefix if included
752 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
754 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
757 my $WarningsFile = join "\n", @Warnings;
758 $WarningsFile =~ s/:[0-9]+:/::/g;
760 # Emit the warnings file, so we can diff...
761 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
762 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
764 # Output something to stdout if something has changed
765 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
766 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
768 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
769 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
773 ##############################################################
775 # If we built the tree successfully, run the nightly programs tests...
777 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
780 ##############################################################
783 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
784 "Programs Test Subdirectory" ) || return ("", "");
786 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
788 # Run the programs tests... creating a report.nightly.csv file
791 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
792 "TEST=nightly > $ProgramTestLog 2>&1\n";
794 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
795 "TEST=nightly > $ProgramTestLog 2>&1";
796 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
800 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
802 $ProgramsTable="Error running test $SubDir\n";
803 print "ERROR TESTING\n";
804 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
806 $ProgramsTable="Makefile error running tests $SubDir!\n";
807 print "ERROR TESTING\n";
811 # Create a list of the tests which were run...
813 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
814 "| sort > $Prefix-$SubDir-Tests.txt";
816 $ProgramsTable = ReadFile "report.nightly.csv";
818 ChangeDir( "../../..", "Programs Test Parent Directory" );
819 return ($ProgramsTable, $llcbeta_options);
820 } #end sub TestDirectory
822 ##############################################################
824 # Calling sub TestDirectory
826 ##############################################################
829 print "SingleSource TEST STAGE\n";
831 ($SingleSourceProgramsTable, $llcbeta_options) =
832 TestDirectory("SingleSource");
833 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
835 print "MultiSource TEST STAGE\n";
837 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
838 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
839 if ( ! $NOEXTERNALS ) {
841 print "External TEST STAGE\n";
843 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
844 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
845 system "cat $Prefix-SingleSource-Tests.txt " .
846 "$Prefix-MultiSource-Tests.txt ".
847 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
848 system "cat $Prefix-SingleSource-Performance.txt " .
849 "$Prefix-MultiSource-Performance.txt ".
850 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
852 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
854 print "External TEST STAGE SKIPPED\n";
856 system "cat $Prefix-SingleSource-Tests.txt " .
857 "$Prefix-MultiSource-Tests.txt ".
858 " | sort > $Prefix-Tests.txt";
859 system "cat $Prefix-SingleSource-Performance.txt " .
860 "$Prefix-MultiSource-Performance.txt ".
861 " | sort > $Prefix-Performance.txt";
864 ##############################################################
867 # gathering tests added removed broken information here
870 ##############################################################
871 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
872 my @DEJAGNU = split "\n", $dejagnu_test_list;
873 my ($passes, $fails, $xfails) = "";
876 for ($x=0; $x<@DEJAGNU; $x++) {
877 if ($DEJAGNU[$x] =~ m/^PASS:/) {
878 $passes.="$DEJAGNU[$x]\n";
880 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
881 $fails.="$DEJAGNU[$x]\n";
883 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
884 $xfails.="$DEJAGNU[$x]\n";
889 } #end if !$BuildError
892 ##############################################################
894 # If we built the tree successfully, runs of the Olden suite with
895 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
897 ##############################################################
899 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
900 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
901 $MachCodeSize) = ("","","","","","","");
902 if (!$NORUNNINGTESTS) {
903 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
904 "Olden Test Directory");
906 # Clean out previous results...
907 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
909 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
910 # GET_STABLE_NUMBERS enabled!
912 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
913 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
914 "> /dev/null 2>&1\n";
916 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
917 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
919 system "cp report.nightly.csv $OldenTestsLog";
923 ##############################################################
925 # Getting end timestamp
927 ##############################################################
928 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
931 ##############################################################
933 # Place all the logs neatly into one humungous file
935 ##############################################################
936 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
938 $machine_data = "uname: ".`uname -a`.
939 "hardware: ".`uname -m`.
942 "date: ".`date \"+20%y-%m-%d\"`.
943 "time: ".`date +\"%H:%M:%S\"`;
947 @CVS_DATA = ReadFile "$CVSLog";
948 $cvs_data = join("\n", @CVS_DATA);
952 @BUILD_DATA = ReadFile "$BuildLog";
953 $build_data = join("\n", @BUILD_DATA);
955 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
956 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
957 my ($gcc_version, $gcc_version_long) = "";
959 $gcc_version_long="";
960 if ($GCCPATH ne "") {
961 $gcc_version_long = `$GCCPATH/gcc --version`;
963 $gcc_version_long = `gcc --version`;
965 @GCC_VERSION = split '\n', $gcc_version_long;
966 $gcc_version = $GCC_VERSION[0];
969 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
970 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
971 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
972 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
974 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
975 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
978 ##############################################################
980 # Send data via a post request
982 ##############################################################
984 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
987 'machine_data' => $machine_data,
988 'build_data' => $build_data,
989 'gcc_version' => $gcc_version,
990 'nickname' => $nickname,
991 'dejagnutime_wall' => $DejagnuWallTime,
992 'dejagnutime_cpu' => $DejagnuTime,
993 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
994 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
995 'configtime_wall' => $ConfigWallTime,
996 'configtime_cpu'=> $ConfigTime,
997 'buildtime_wall' => $BuildWallTime,
998 'buildtime_cpu' => $BuildTime,
999 'warnings' => $WarningsFile,
1000 'cvsusercommitlist' => $UserCommitList,
1001 'cvsuserupdatelist' => $UserUpdateList,
1002 'cvsaddedfiles' => $CVSAddedFiles,
1003 'cvsmodifiedfiles' => $CVSModifiedFiles,
1004 'cvsremovedfiles' => $CVSRemovedFiles,
1005 'lines_of_code' => $LOC,
1006 'cvs_file_count' => $NumFilesInCVS,
1007 'cvs_dir_count' => $NumDirsInCVS,
1008 'buildstatus' => $BuildStatus,
1009 'singlesource_programstable' => $SingleSourceProgramsTable,
1010 'multisource_programstable' => $MultiSourceProgramsTable,
1011 'externalsource_programstable' => $ExternalProgramsTable,
1012 'llcbeta_options' => $multisource_llcbeta_options,
1013 'warnings_removed' => $WarningsRemoved,
1014 'warnings_added' => $WarningsAdded,
1015 'passing_tests' => $passes,
1016 'expfail_tests' => $xfails,
1017 'unexpfail_tests' => $fails,
1018 'all_tests' => $dejagnu_test_list,
1020 'removed_tests' => "",
1021 'dejagnutests_results' => $DejagnuTestResults,
1022 'dejagnutests_log' => $dejagnulog_full,
1023 'starttime' => $starttime,
1024 'endtime' => $endtime,
1025 'o_file_sizes' => $o_file_sizes,
1026 'a_file_sizes' => $a_file_sizes
1032 print "============================\n";
1033 foreach $x(keys %hash_of_data){
1034 print "$x => $hash_of_data{$x}\n";
1037 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1038 if( $VERBOSE) { print "============================\n$response"; }
1041 ##############################################################
1043 # Remove the cvs tree...
1045 ##############################################################
1046 system ( "$NICE rm -rf $BuildDir")
1047 if (!$NOCHECKOUT and !$NOREMOVE);
1048 system ( "$NICE rm -rf $WebDir")
1049 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);