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 # -enable-llcbeta Enable testing of beta features in llc.
33 # -disable-llc Disable LLC tests in the nightly tester.
34 # -disable-jit Disable JIT tests in the nightly tester.
35 # -disable-cbe Disable C backend tests in the nightly tester.
36 # -verbose Turn on some debug output
37 # -debug Print information useful only to maintainers of this script.
38 # -nice Checkout/Configure/Build with "nice" to reduce impact
40 # -f2c Next argument specifies path to F2C utility
41 # -nickname The next argument specifieds the nickname this script
42 # will submit to the nightlytest results repository.
43 # -gccpath Path to gcc/g++ used to build LLVM
44 # -cvstag Check out a specific CVS tag to build LLVM (useful for
45 # testing release branches)
46 # -target Specify the target triplet
47 # -cflags Next argument specifies that C compilation options that
48 # override the default.
49 # -cxxflags Next argument specifies that C++ compilation options that
50 # override the default.
51 # -ldflags Next argument specifies that linker options that override
53 # -compileflags Next argument specifies extra options passed to make when
55 # -use-gmake Use gmake instead of the default make command to build
58 # ---------------- Options to configure llvm-test ----------------------------
59 # -extraflags Next argument specifies extra options that are passed to
61 # -noexternals Do not run the external tests (for cases where povray
62 # or SPEC are not installed)
63 # -with-externals Specify a directory where the external tests are located.
64 # -submit-server Specifies a server to submit the test results too. If this
65 # option is not specified it defaults to
66 # llvm.org. This is basically just the address of the
68 # -submit-script Specifies which script to call on the submit server. If
69 # this option is not specified it defaults to
70 # /nightlytest/NightlyTestAccept.cgi. This is basically
71 # everything after the www.yourserver.org.
73 # CVSROOT is the CVS repository from which the tree will be checked out,
74 # specified either in the full :method:user@host:/dir syntax, or
75 # just /dir if using a local repo.
76 # BUILDDIR is the directory where sources for this test run will be checked out
77 # AND objects for this test run will be built. This directory MUST NOT
78 # exist before the script is run; it will be created by the cvs checkout
79 # process and erased (unless -noremove is specified; see above.)
80 # WEBDIR is the directory into which the test results web page will be written,
81 # AND in which the "index.html" is assumed to be a symlink to the most recent
82 # copy of the results. This directory will be created if it does not exist.
83 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
84 # to. This is the same as you would have for a normal LLVM build.
86 ##############################################################
88 # Getting environment variables
90 ##############################################################
91 my $HOME = $ENV{'HOME'};
92 my $CVSRootDir = $ENV{'CVSROOT'};
93 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
94 my $BuildDir = $ENV{'BUILDDIR'};
95 $BuildDir = "$HOME/buildtest" unless $BuildDir;
96 my $WebDir = $ENV{'WEBDIR'};
97 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
99 ##############################################################
101 # Calculate the date prefix...
103 ##############################################################
105 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
106 my $DateString = strftime "%B %d, %Y", localtime;
107 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
109 ##############################################################
113 ##############################################################
119 $SUBMITSERVER = "llvm.org";
120 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.cgi";
122 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
124 last if /^--$/; # Stop processing arguments on --
126 # List command line options here...
127 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
128 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
129 if (/^-noremove$/) { $NOREMOVE = 1; next; }
130 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
131 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
132 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
133 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
134 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
135 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
136 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
137 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
138 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
139 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
140 $CONFIGUREARGS .= " --disable-jit"; next; }
141 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
142 if (/^-verbose$/) { $VERBOSE = 1; next; }
143 if (/^-debug$/) { $DEBUG = 1; next; }
144 if (/^-nice$/) { $NICE = "nice "; next; }
145 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
147 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
149 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
150 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
151 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
152 if (/^-gccpath/) { $CONFIGUREARGS .=
153 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
154 $GCCPATH=$ARGV[0]; shift; next; }
155 else { $GCCPATH=""; }
156 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
157 else { $CVSCOOPT="";}
158 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
160 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
162 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
164 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
166 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
167 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
168 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
169 if (/^-extraflags/) { $CONFIGUREARGS .=
170 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
171 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
172 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
173 if (/^-nobuild$/) { $NOBUILD = 1; next; }
174 print "Unknown option: $_ : ignoring!\n";
177 if ($ENV{'LLVMGCCDIR'}) {
178 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
180 if ($CONFIGUREARGS !~ /--disable-jit/) {
181 $CONFIGUREARGS .= " --enable-jit";
184 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
188 print "Must specify 0 or 3 options!";
192 $CVSRootDir = $ARGV[0];
193 $BuildDir = $ARGV[1];
197 if ($CVSRootDir eq "" or
200 die("please specify a cvs root directory, a build directory, and a ".
204 if ($nickname eq "") {
205 die ("Please invoke NewNightlyTest.pl with command line option " .
206 "\"-nickname <nickname>\"");
209 if ($BUILDTYPE ne "release") {
210 $BUILDTYPE = "debug";
213 ##############################################################
215 #define the file names we'll use
217 ##############################################################
218 my $Prefix = "$WebDir/$DATE";
219 my $BuildLog = "$Prefix-Build-Log.txt";
220 my $CVSLog = "$Prefix-CVS-Log.txt";
221 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
222 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
223 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
224 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
225 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
226 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
227 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
230 warn "$WebDir did not exist; creating it.\n";
234 print "INITIALIZED\n";
235 print "CVS Root = $CVSRootDir\n";
236 print "BuildDir = $BuildDir\n";
237 print "WebDir = $WebDir\n";
238 print "Prefix = $Prefix\n";
239 print "CVSLog = $CVSLog\n";
240 print "BuildLog = $BuildLog\n";
243 ##############################################################
247 ##############################################################
251 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
256 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
258 # DiffFiles - Diff the current version of the file against the last version of
259 # the file, reporting things added and removed. This is used to report, for
260 # example, added and removed warnings. This returns a pair (added, removed)
262 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
265 my @Others = GetDir $Suffix;
266 if (@Others == 0) { # No other files? We added all entries...
267 return (`cat $WebDir/$DATE$Suffix`, "");
269 # Diff the files now...
270 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
271 my $Added = join "\n", grep /^</, @Diffs;
272 my $Removed = join "\n", grep /^>/, @Diffs;
274 $Removed =~ s/^> //gm;
275 return ($Added, $Removed);
278 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280 sub GetRegex { # (Regex with ()'s, value)
287 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290 my ($Regex, $Num, $Regex2, $File) = @_;
291 my @Items = split "\n", `grep '$Regex' $File`;
292 return GetRegex $Regex2, $Items[$Num];
295 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297 sub ChangeDir { # directory, logical name
298 my ($dir,$name) = @_;
300 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
301 $result = chdir($dir);
303 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
309 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 if (open (FILE, $_[0])) {
319 print "Could not open file '$_[0]' for reading!\n";
324 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326 sub WriteFile { # (filename, contents)
327 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
332 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334 sub CopyFile { #filename, newfile
335 my ($file, $newfile) = @_;
337 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
338 copy($file, $newfile);
341 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344 my ($Val, $Filename,$WebDir) = @_;
346 if (open FILE, "$WebDir/$Filename") {
347 @Records = grep !/$DATE/, split "\n", <FILE>;
350 push @Records, "$DATE: $Val";
351 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
354 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356 # FormatTime - Convert a time from 1m23.45 into 83.45
358 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
362 $Time = sprintf("%7.4f", $1*60.0+$2);
367 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369 sub GetDejagnuTestResults { # (filename, log)
370 my ($filename, $DejagnuLog) = @_;
373 $/ = "\n"; #Make sure we're going line at a time.
375 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
377 if (open SRCHFILE, $filename) {
378 # Process test results
380 my $should_break = 1;
383 while ( <SRCHFILE> ) {
384 if ( length($_) > 1 ) {
386 if ( m/^XPASS:/ || m/^FAIL:/ ) {
389 push(@lines, "UNEXPECTED TEST RESULTS\n");
392 push(@lines, "$_\n");
393 if( $VERBOSE) { print " $_\n"; }
395 push(@lines, "$_\n");
396 if( $VERBOSE) { print " $_\n"; }
398 } #elsif ( m/Summary/ ) {
399 # if ( $first_list ) {
400 # push(@lines, "PERFECT!");
401 # print " PERFECT!\n";
403 # push(@lines, "</li></ol>\n");
405 # push(@lines, "STATISTICS\n");
406 # print "\nDEJAGNU STATISTICS:\n";
411 elsif ( $readingsum ) {
413 if( $VERBOSE) { print " $_\n"; }
421 my $content = join("", @lines);
426 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428 # This function acts as a mini web browswer submitting data
429 # to our central server via the post method
431 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
439 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
441 connect SOCK, $socketaddr or die "Bad connection\n";
442 select((select(SOCK), $| = 1)[0]);
444 #creating content here
446 foreach $key (keys (%$variables)){
447 $value = $variables->{$key};
448 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
449 $content .= "$key=$value&";
452 $length = length($content);
454 my $send= "POST $file HTTP/1.0\n";
455 $send.= "Content-Type: application/x-www-form-urlencoded\n";
456 $send.= "Content-length: $length\n\n";
467 foreach $x (keys (%$variables)){
468 $value = $variables->{$x};
469 $sentdata.= "$x => $value\n";
471 WriteFile "$Prefix-sentdata.txt", $sentdata;
477 ##############################################################
479 # Getting Start timestamp
481 ##############################################################
482 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
484 ##############################################################
486 # Create the CVS repository directory
488 ##############################################################
493 print "Build directory exists! Removing it\n";
495 system "rm -rf $BuildDir";
497 die "CVS checkout directory $BuildDir already exists!";
500 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
502 ChangeDir( $BuildDir, "CVS checkout directory" );
505 ##############################################################
507 # Check out the llvm tree, saving CVS messages to the cvs log...
509 ##############################################################
511 # Use compression if going over ssh.
513 if $CVSRootDir =~ /^:ext:/;
514 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
517 print "CHECKOUT STAGE:\n";
518 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
521 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
522 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
523 ChangeDir( $BuildDir , "CVS Checkout directory") ;
525 ChangeDir( "llvm" , "llvm source directory") ;
527 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
528 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
531 ##############################################################
533 # Get some static statistics about the current state of CVS
535 # This can probably be put on the server side
537 ##############################################################
538 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
539 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
540 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
541 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
543 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
545 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
547 ##############################################################
549 # Extract some information from the CVS history... use a hash so no duplicate
550 # stuff is stored. This gets the history from the previous days worth
551 # of cvs activity and parses it.
553 ##############################################################
555 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
559 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
560 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
561 #print join "\n", @CVSHistory; print "\n";
563 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
565 # Loop over every record from the CVS history, filling in the hashes.
566 foreach $File (@CVSHistory) {
567 my ($Type, $Date, $UID, $Rev, $Filename);
568 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
569 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
570 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
571 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
572 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
573 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
575 print "UNMATCHABLE: $File\n";
578 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
580 if ($Filename =~ /^llvm/) {
581 if ($Type eq 'M') { # Modified
582 $ModifiedFiles{$Filename} = 1;
583 $UsersCommitted{$UID} = 1;
584 } elsif ($Type eq 'A') { # Added
585 $AddedFiles{$Filename} = 1;
586 $UsersCommitted{$UID} = 1;
587 } elsif ($Type eq 'R') { # Removed
588 $RemovedFiles{$Filename} = 1;
589 $UsersCommitted{$UID} = 1;
591 $UsersUpdated{$UID} = 1;
600 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
601 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
602 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
603 my $UserCommitList = join "\n", sort keys %UsersCommitted;
604 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
606 ##############################################################
608 # Build the entire tree, saving build messages to the build log
610 ##############################################################
611 if (!$NOCHECKOUT && !$NOBUILD) {
612 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
614 print "CONFIGURE STAGE:\n";
615 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
616 "> $BuildLog 2>&1\n";
618 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
621 print "BUILD STAGE:\n";
622 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
624 # Build the entire tree, capturing the output into $BuildLog
625 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
628 ##############################################################
630 # Get some statistics about the build...
632 ##############################################################
633 #this can de done on server
634 #my @Linked = split '\n', `grep Linking $BuildLog`;
635 #my $NumExecutables = scalar(grep(/executable/, @Linked));
636 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
637 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
639 # Get the number of lines of source code. Must be here after the build is done
640 # because countloc.sh uses the llvm-config script which must be built.
641 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
643 # Get the time taken by the configure script
644 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
645 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
646 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
647 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
649 $ConfigTime=-1 unless $ConfigTime;
650 $ConfigWallTime=-1 unless $ConfigWallTime;
652 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
653 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
654 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
655 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
657 $BuildTime=-1 unless $BuildTime;
658 $BuildWallTime=-1 unless $BuildWallTime;
660 my $BuildError = 0, $BuildStatus = "OK";
662 $BuildStatus = "Skipped by user";
665 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
666 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
667 $BuildStatus = "Error: compilation aborted";
669 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
671 if ($BuildError) { $NODEJAGNU=1; }
676 print "Organizing size of .o and .a files\n"
678 ChangeDir( "$BuildDir/llvm", "Build Directory" );
679 $afiles.= `find utils/ -iname '*.a' -ls`;
680 $afiles.= `find lib/ -iname '*.a' -ls`;
681 $afiles.= `find tools/ -iname '*.a' -ls`;
682 if($BUILDTYPE eq "release"){
683 $afiles.= `find Release/ -iname '*.a' -ls`;
685 $afiles.= `find Debug/ -iname '*.a' -ls`;
688 $ofiles.= `find utils/ -iname '*.o' -ls`;
689 $ofiles.= `find lib/ -iname '*.o' -ls`;
690 $ofiles.= `find tools/ -iname '*.o' -ls`;
691 if($BUILDTYPE eq "release"){
692 $ofiles.= `find Release/ -iname '*.o' -ls`;
694 $ofiles.= `find Debug/ -iname '*.o' -ls`;
697 @AFILES = split "\n", $afiles;
699 foreach $x (@AFILES){
700 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
701 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
703 @OFILES = split "\n", $ofiles;
705 foreach $x (@OFILES){
706 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
707 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
710 $a_file_sizes="No data due to a bad build.";
711 $o_file_sizes="No data due to a bad build.";
714 ##############################################################
716 # Running dejagnu tests
718 ##############################################################
719 my $DejangnuTestResults; # String containing the results of the dejagnu
720 my $dejagnu_output = "$DejagnuTestsLog";
723 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
724 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
727 #Run the feature and regression tests, results are put into testrun.sum
728 #Full log in testrun.log
729 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
731 #Copy the testrun.log and testrun.sum to our webdir
732 CopyFile("test/testrun.log", $DejagnuLog);
733 CopyFile("test/testrun.sum", $DejagnuSum);
734 #can be done on server
735 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
736 $unexpfail_tests = $DejagnuTestResults;
739 #Extract time of dejagnu tests
740 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
741 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
742 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
743 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
744 $DejagnuTestResults =
745 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
746 $DejagnuTime = "0.0" unless $DejagnuTime;
747 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
749 ##############################################################
751 # Get warnings from the build
753 ##############################################################
755 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
756 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
760 foreach $Warning (@Warn) {
761 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
762 $CurDir = $1; # Keep track of directory warning is in...
763 # Remove buildir prefix if included
764 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
766 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
769 my $WarningsFile = join "\n", @Warnings;
770 $WarningsFile =~ s/:[0-9]+:/::/g;
772 # Emit the warnings file, so we can diff...
773 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
774 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
776 # Output something to stdout if something has changed
777 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
778 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
780 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
781 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
785 ##############################################################
787 # If we built the tree successfully, run the nightly programs tests...
789 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
792 ##############################################################
796 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
797 "Programs Test Subdirectory" ) || return ("", "");
799 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
801 # Run the programs tests... creating a report.nightly.csv file
804 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
805 "TEST=nightly > $ProgramTestLog 2>&1\n";
807 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
808 "TEST=nightly > $ProgramTestLog 2>&1";
809 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
813 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
815 $ProgramsTable="Error running test $SubDir\n";
816 print "ERROR TESTING\n";
817 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
819 $ProgramsTable="Makefile error running tests $SubDir!\n";
820 print "ERROR TESTING\n";
824 # Create a list of the tests which were run...
826 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
827 "| sort > $Prefix-multisourceprogramstable.txt";
829 $ProgramsTable = ReadFile "report.nightly.csv";
831 ChangeDir( "../../..", "Programs Test Parent Directory" );
832 return ($ProgramsTable, $llcbeta_options);
833 } #end sub TestDirectory
837 print "SingleSource TEST STAGE\n";
839 ($SingleSourceProgramsTable, $llcbeta_options) =
840 TestDirectory("SingleSource");
841 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
843 print "MultiSource TEST STAGE\n";
845 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
846 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
847 if ( ! $NOEXTERNALS ) {
849 print "External TEST STAGE\n";
851 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
852 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
853 system "cat $Prefix-singlesourceprogramstable.txt " .
854 "$Prefix-multisourceprogramstable.txt ".
855 "$Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
857 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
859 print "External TEST STAGE SKIPPED\n";
861 system "cat $Prefix-singlesourceprogramstable.txt " .
862 "$Prefix-multisourceprogramstable.txt ".
863 " | sort > $Prefix-Tests.txt";
865 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
868 ##############################################################
871 # gathering tests added removed broken information here
874 ##############################################################
875 my $dejagnu = ReadFile $DejagnuSum;
876 my @DEJAGNU = split "\n", $dejagnu;
877 my $dejagnu_test_list="";
884 for ($x=0; $x<@DEJAGNU; $x++) {
885 if ($DEJAGNU[$x] =~ m/^PASS:/) {
886 $passes.="$DEJAGNU[$x]\n";
887 $dejagnu_test_list.="$DEJAGNU[$x]\n";
889 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
890 $fails.="$DEJAGNU[$x]\n";
891 $dejagnu_test_list.="$DEJAGNU[$x]\n";
893 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
894 $xfails.="$DEJAGNU[$x]\n";
895 $dejagnu_test_list.="$DEJAGNU[$x]\n";
900 ##############################################################
902 # If we built the tree successfully, runs of the Olden suite with
903 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
905 ##############################################################
907 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
908 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
909 $MachCodeSize) = ("","","","","","","");
910 if (!$NORUNNINGTESTS) {
911 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
912 "Olden Test Directory");
914 # Clean out previous results...
915 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
917 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
918 # GET_STABLE_NUMBERS enabled!
920 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
921 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
922 "> /dev/null 2>&1\n";
924 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
925 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
927 system "cp report.nightly.csv $OldenTestsLog";
931 ##############################################################
933 # Getting end timestamp
935 ##############################################################
936 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
939 ##############################################################
941 # Place all the logs neatly into one humungous file
943 ##############################################################
944 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
946 $machine_data = "uname: ".`uname -a`.
947 "hardware: ".`uname -m`.
950 "date: ".`date \"+20%y-%m-%d\"`.
951 "time: ".`date +\"%H:%M:%S\"`;
955 @CVS_DATA = ReadFile "$CVSLog";
956 $cvs_data = join("\n", @CVS_DATA);
960 @BUILD_DATA = ReadFile "$BuildLog";
961 $build_data = join("\n", @BUILD_DATA);
965 my $dejagnutests_log;
966 my $dejagnutests_sum;
967 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
968 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
969 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
970 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
974 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
975 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
977 my $gcc_version_long="";
978 if ($GCCPATH ne "") {
979 $gcc_version_long = `$GCCPATH/gcc --version`;
981 $gcc_version_long = `gcc --version`;
983 @GCC_VERSION = split '\n', $gcc_version_long;
984 my $gcc_version = $GCC_VERSION[0];
986 my $all_tests = ReadFile "$Prefix-Tests.txt";
988 ##############################################################
990 # Send data via a post request
992 ##############################################################
994 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
997 'machine_data' => $machine_data,
998 'build_data' => $build_data,
999 'gcc_version' => $gcc_version,
1000 'nickname' => $nickname,
1001 'dejagnutime_wall' => $DejagnuWallTime,
1002 'dejagnutime_cpu' => $DejagnuTime,
1003 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
1004 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
1005 'configtime_wall' => $ConfigWallTime,
1006 'configtime_cpu'=> $ConfigTime,
1007 'buildtime_wall' => $BuildWallTime,
1008 'buildtime_cpu' => $BuildTime,
1009 'warnings' => $WarningsFile,
1010 'cvsusercommitlist' => $UserCommitList,
1011 'cvsuserupdatelist' => $UserUpdateList,
1012 'cvsaddedfiles' => $CVSAddedFiles,
1013 'cvsmodifiedfiles' => $CVSModifiedFiles,
1014 'cvsremovedfiles' => $CVSRemovedFiles,
1015 'lines_of_code' => $LOC,
1016 'cvs_file_count' => $NumFilesInCVS,
1017 'cvs_dir_count' => $NumDirsInCVS,
1018 'buildstatus' => $BuildStatus,
1019 'singlesource_programstable' => $SingleSourceProgramsTable,
1020 'multisource_programstable' => $MultiSourceProgramsTable,
1021 'externalsource_programstable' => $ExternalProgramsTable,
1022 'llcbeta_options' => $multisource_llcbeta_options,
1023 'warnings_removed' => $WarningsRemoved,
1024 'warnings_added' => $WarningsAdded,
1025 'passing_tests' => $passes,
1026 'expfail_tests' => $xfails,
1027 'unexpfail_tests' => $fails,
1028 'all_tests' => $dejagnu_test_list,
1030 'removed_tests' => "",
1031 'dejagnutests_log' => $dejagnutests_log,
1032 'dejagnutests_sum' => $dejagnutests_sum,
1033 'starttime' => $starttime,
1034 'endtime' => $endtime,
1035 'o_file_sizes' => $o_file_sizes,
1036 'a_file_sizes' => $a_file_sizes
1042 print "============================\n";
1043 foreach $x(keys %hash_of_data){
1044 print "$x => $hash_of_data{$x}\n";
1047 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1048 if( $VERBOSE) { print "============================\n$response"; }
1051 ##############################################################
1053 # Remove the cvs tree...
1055 ##############################################################
1056 system ( "$NICE rm -rf $BuildDir")
1057 if (!$NOCHECKOUT and !$NOREMOVE);
1058 system ( "$NICE rm -rf $WebDir")
1059 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);