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.
65 # CVSROOT is the CVS repository from which the tree will be checked out,
66 # specified either in the full :method:user@host:/dir syntax, or
67 # just /dir if using a local repo.
68 # BUILDDIR is the directory where sources for this test run will be checked out
69 # AND objects for this test run will be built. This directory MUST NOT
70 # exist before the script is run; it will be created by the cvs checkout
71 # process and erased (unless -noremove is specified; see above.)
72 # WEBDIR is the directory into which the test results web page will be written,
73 # AND in which the "index.html" is assumed to be a symlink to the most recent
74 # copy of the results. This directory will be created if it does not exist.
75 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
76 # to. This is the same as you would have for a normal LLVM build.
78 ##############################################################
80 # Getting environment variables
82 ##############################################################
83 my $HOME = $ENV{'HOME'};
84 my $CVSRootDir = $ENV{'CVSROOT'};
85 $CVSRootDir = "/home/vadve/shared/PublicCVS"
87 my $BuildDir = $ENV{'BUILDDIR'};
88 $BuildDir = "$HOME/buildtest"
90 my $WebDir = $ENV{'WEBDIR'};
91 $WebDir = "$HOME/cvs/testresults-X86"
94 ##############################################################
96 # Calculate the date prefix...
98 ##############################################################
100 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
101 my $DateString = strftime "%B %d, %Y", localtime;
102 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
104 ##############################################################
108 ##############################################################
115 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
117 last if /^--$/; # Stop processing arguments on --
119 # List command line options here...
120 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
121 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
122 if (/^-noremove$/) { $NOREMOVE = 1; next; }
123 if (/^-noremoveresults$/) { $NOREMOVERESULTS = 1; next; }
124 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
125 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
126 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
127 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
128 "OPTIMIZE_OPTION=-O2";
129 $BUILDTYPE="release"; next; }
130 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
131 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
132 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
133 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
134 $CONFIGUREARGS .= " --disable-jit"; next; }
135 if (/^-verbose$/) { $VERBOSE = 1; next; }
136 if (/^-debug$/) { $DEBUG = 1; next; }
137 if (/^-nice$/) { $NICE = "nice "; next; }
139 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
141 if (/^-with-externals$/) {
142 $CONFIGUREARGS .= " --with-externals=$ARGV[0]"; shift; next;
144 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
145 if (/^-gccpath/) { $CONFIGUREARGS .=
146 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
151 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
154 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
157 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
160 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
163 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
165 if (/^-compileflags/) {
166 $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
169 $MAKECMD = "gmake"; shift; next;
171 if (/^-extraflags/) {
172 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
174 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
175 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
176 if (/^-nobuild$/) { $NOBUILD = 1; next; }
177 print "Unknown option: $_ : ignoring!\n";
180 if ($ENV{'LLVMGCCDIR'}) {
181 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
183 if ($CONFIGUREARGS !~ /--disable-jit/) {
184 $CONFIGUREARGS .= " --enable-jit";
188 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE){
192 print "Must specify 0 or 3 options!";
196 $CVSRootDir = $ARGV[0];
197 $BuildDir = $ARGV[1];
201 if($CVSRootDir eq "" or
204 die("please specify a cvs root directory, a build directory, and a ".
209 die ("Please invoke NewNightlyTest.pl with command line option \"-nickname <nickname>\"");
212 if($BUILDTYPE ne "release"){
213 $BUILDTYPE = "debug";
216 ##############################################################
218 #define the file names we'll use
220 ##############################################################
221 my $Prefix = "$WebDir/$DATE";
222 my $BuildLog = "$Prefix-Build-Log.txt";
223 my $CVSLog = "$Prefix-CVS-Log.txt";
224 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
225 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
226 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
227 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
228 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
229 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
230 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
233 warn "$WebDir did not exist; creating it.\n";
237 print "INITIALIZED\n";
238 print "CVS Root = $CVSRootDir\n";
239 print "BuildDir = $BuildDir\n";
240 print "WebDir = $WebDir\n";
241 print "Prefix = $Prefix\n";
242 print "CVSLog = $CVSLog\n";
243 print "BuildLog = $BuildLog\n";
246 ##############################################################
250 ##############################################################
254 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
259 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261 # DiffFiles - Diff the current version of the file against the last version of
262 # the file, reporting things added and removed. This is used to report, for
263 # example, added and removed warnings. This returns a pair (added, removed)
265 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268 my @Others = GetDir $Suffix;
269 if (@Others == 0) { # No other files? We added all entries...
270 return (`cat $WebDir/$DATE$Suffix`, "");
272 # Diff the files now...
273 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
274 my $Added = join "\n", grep /^</, @Diffs;
275 my $Removed = join "\n", grep /^>/, @Diffs;
277 $Removed =~ s/^> //gm;
278 return ($Added, $Removed);
281 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
282 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283 sub GetRegex { # (Regex with ()'s, value)
291 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294 my ($Regex, $Num, $Regex2, $File) = @_;
295 my @Items = split "\n", `grep '$Regex' $File`;
296 return GetRegex $Regex2, $Items[$Num];
299 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301 sub ChangeDir { # directory, logical name
302 my ($dir,$name) = @_;
304 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
305 $result = chdir($dir);
307 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
313 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316 if (open (FILE, $_[0])) {
323 print "Could not open file '$_[0]' for reading!\n";
328 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
330 sub WriteFile { # (filename, contents)
331 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
336 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 sub CopyFile { #filename, newfile
339 my ($file, $newfile) = @_;
341 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
342 copy($file, $newfile);
345 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348 my ($Val, $Filename,$WebDir) = @_;
350 if (open FILE, "$WebDir/$Filename") {
351 @Records = grep !/$DATE/, split "\n", <FILE>;
354 push @Records, "$DATE: $Val";
355 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
358 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360 # FormatTime - Convert a time from 1m23.45 into 83.45
362 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
366 $Time = sprintf("%7.4f", $1*60.0+$2);
371 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373 sub GetDejagnuTestResults { # (filename, log)
374 my ($filename, $DejagnuLog) = @_;
377 $/ = "\n"; #Make sure we're going line at a time.
379 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
381 if (open SRCHFILE, $filename) {
382 # Process test results
384 my $should_break = 1;
387 while ( <SRCHFILE> ) {
388 if ( length($_) > 1 ) {
390 if ( m/^XPASS:/ || m/^FAIL:/ ) {
393 push(@lines, "UNEXPECTED TEST RESULTS\n");
396 push(@lines, "$_\n");
397 if( $VERBOSE) { print " $_\n"; }
399 push(@lines, "$_\n");
400 if( $VERBOSE) { print " $_\n"; }
402 } #elsif ( m/Summary/ ) {
403 # if ( $first_list ) {
404 # push(@lines, "PERFECT!");
405 # print " PERFECT!\n";
407 # push(@lines, "</li></ol>\n");
409 # push(@lines, "STATISTICS\n");
410 # print "\nDEJAGNU STATISTICS:\n";
415 elsif ( $readingsum ) {
417 if( $VERBOSE) { print " $_\n"; }
425 my $content = join("", @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.= "Content-Type: application/x-www-form-urlencoded\n";
460 $send.= "Content-length: $length\n\n";
471 foreach $x (keys (%$variables)){
472 $value = $variables->{$x};
473 $sentdata.= "$x => $value\n";
475 WriteFile "$Prefix-sentdata.txt", $sentdata;
481 ##############################################################
483 # Getting Start timestamp
485 ##############################################################
486 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
488 ##############################################################
490 # Create the CVS repository directory
492 ##############################################################
497 print "Build directory exists! Removing it\n";
499 system "rm -rf $BuildDir";
501 die "CVS checkout directory $BuildDir already exists!";
504 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
506 ChangeDir( $BuildDir, "CVS checkout directory" );
509 ##############################################################
511 # Check out the llvm tree, saving CVS messages to the cvs log...
513 ##############################################################
515 # Use compression if going over ssh.
516 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
517 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
521 print "CHECKOUT STAGE:\n";
522 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) > $CVSLog 2>&1\n";
524 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
525 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
526 ChangeDir( $BuildDir , "CVS Checkout directory") ;
528 ChangeDir( "llvm" , "llvm source directory") ;
530 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
531 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
534 ##############################################################
536 # Get some static statistics about the current state of CVS
538 # This can probably be put on the server side
540 ##############################################################
541 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
542 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
543 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
544 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
546 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
547 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
548 my $LOC = `utils/countloc.sh`;
550 ##############################################################
552 # Extract some information from the CVS history... use a hash so no duplicate
553 # stuff is stored. This gets the history from the previous days worth
554 # of cvs activit and parses it.
556 ##############################################################
558 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
562 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
563 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
564 #print join "\n", @CVSHistory; print "\n";
566 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
568 # Loop over every record from the CVS history, filling in the hashes.
569 foreach $File (@CVSHistory) {
570 my ($Type, $Date, $UID, $Rev, $Filename);
571 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
572 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
573 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
574 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
575 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
576 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
578 print "UNMATCHABLE: $File\n";
581 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
583 if ($Filename =~ /^llvm/) {
584 if ($Type eq 'M') { # Modified
585 $ModifiedFiles{$Filename} = 1;
586 $UsersCommitted{$UID} = 1;
587 } elsif ($Type eq 'A') { # Added
588 $AddedFiles{$Filename} = 1;
589 $UsersCommitted{$UID} = 1;
590 } elsif ($Type eq 'R') { # Removed
591 $RemovedFiles{$Filename} = 1;
592 $UsersCommitted{$UID} = 1;
594 $UsersUpdated{$UID} = 1;
603 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
604 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
605 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
606 my $UserCommitList = join "\n", sort keys %UsersCommitted;
607 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
609 ##############################################################
611 # Build the entire tree, saving build messages to the build log
613 ##############################################################
614 if (!$NOCHECKOUT && !$NOBUILD) {
615 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
617 print "CONFIGURE STAGE:\n";
618 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1\n";
620 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
623 print "BUILD STAGE:\n";
624 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
626 # Build the entire tree, capturing the output into $BuildLog
627 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
631 ##############################################################
633 # Get some statistics about the build...
635 ##############################################################
636 #this can de done on server
637 #my @Linked = split '\n', `grep Linking $BuildLog`;
638 #my $NumExecutables = scalar(grep(/executable/, @Linked));
639 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
640 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
643 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
644 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
645 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
646 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
648 $ConfigTime=-1 unless $ConfigTime;
649 $ConfigWallTime=-1 unless $ConfigWallTime;
651 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
652 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
653 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
654 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
656 $BuildTime=-1 unless $BuildTime;
657 $BuildWallTime=-1 unless $BuildWallTime;
659 my $BuildError = 0, $BuildStatus = "OK";
661 $BuildStatus = "Skipped by user";
664 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
665 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
666 $BuildStatus = "Error: compilation aborted";
668 print "\n***ERROR BUILDING TREE\n\n";
670 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`;
686 $afiles.= `find Debug/ -iname '*.a' -ls`;
690 $ofiles.= `find utils/ -iname '*.o' -ls`;
691 $ofiles.= `find lib/ -iname '*.o' -ls`;
692 $ofiles.= `find tools/ -iname '*.o' -ls`;
693 if($BUILDTYPE eq "release"){
694 $ofiles.= `find Release/ -iname '*.o' -ls`;
697 $ofiles.= `find Debug/ -iname '*.o' -ls`;
700 @AFILES = split "\n", $afiles;
702 foreach $x (@AFILES){
703 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
704 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
706 @OFILES = split "\n", $ofiles;
708 foreach $x (@OFILES){
709 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
710 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
714 $a_file_sizes="No data due to a bad build.";
715 $o_file_sizes="No data due to a bad build.";
719 ##############################################################
721 # Running dejagnu tests
723 ##############################################################
724 my $DejangnuTestResults; # String containing the results of the dejagnu
725 my $dejagnu_output = "$DejagnuTestsLog";
729 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
730 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
733 #Run the feature and regression tests, results are put into testrun.sum
734 #Full log in testrun.log
735 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
737 #Copy the testrun.log and testrun.sum to our webdir
738 CopyFile("test/testrun.log", $DejagnuLog);
739 CopyFile("test/testrun.sum", $DejagnuSum);
740 #can be done on server
741 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
742 $unexpfail_tests = $DejagnuTestResults;
744 #Extract time of dejagnu tests
745 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
746 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
747 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
748 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
749 $DejagnuTestResults = "Dejagnu skipped by user choice." unless $DejagnuTestResults;
750 $DejagnuTime = "0.0" unless $DejagnuTime;
751 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
754 print $DejagnuTestResults;
757 ##############################################################
759 # Get warnings from the build
761 ##############################################################
764 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
765 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
769 foreach $Warning (@Warn) {
770 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
771 $CurDir = $1; # Keep track of directory warning is in...
772 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
776 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
779 my $WarningsFile = join "\n", @Warnings;
780 $WarningsFile =~ s/:[0-9]+:/::/g;
782 # Emit the warnings file, so we can diff...
783 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
784 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
786 # Output something to stdout if something has changed
787 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
788 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
790 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
791 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
795 ##############################################################
797 # If we built the tree successfully, run the nightly programs tests...
799 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" "External")
801 ##############################################################
805 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir", "Programs Test Subdirectory" ) || return ("", "");
807 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
809 # Run the programs tests... creating a report.nightly.csv file
811 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
812 "TEST=nightly > $ProgramTestLog 2>&1\n";
813 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
814 "TEST=nightly > $ProgramTestLog 2>&1";
815 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
819 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
821 $ProgramsTable="Error running test $SubDir\n";
822 print "ERROR TESTING\n";
823 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
825 $ProgramsTable="Makefile error running tests $SubDir!\n";
826 print "ERROR TESTING\n";
830 # Create a list of the tests which were run...
832 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
833 "| sort > $Prefix-multisourceprogramstable.txt";
835 $ProgramsTable = ReadFile "report.nightly.csv";
837 ChangeDir( "../../..", "Programs Test Parent Directory" );
838 return ($ProgramsTable, $llcbeta_options);
843 print "SingleSource TEST STAGE\n";
845 ($SingleSourceProgramsTable, $llcbeta_options) = TestDirectory("SingleSource");
846 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
847 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
848 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
850 print "MultiSource returned $MultiSourceProgramsTable\n";
852 if ( ! $NOEXTERNALS ) {
854 print "External TEST STAGE\n";
856 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
857 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
858 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
859 " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
861 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
863 print "External TEST STAGE SKIPPED\n";
865 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
866 " | sort > $Prefix-Tests.txt";
868 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
871 ##############################################################
874 # gathering tests added removed broken information here
877 ##############################################################
878 my $dejagnu = ReadFile $DejagnuSum;
879 my @DEJAGNU = split "\n", $dejagnu;
880 my $dejagnu_test_list="";
887 for($x=0; $x<@DEJAGNU; $x++){
888 if($DEJAGNU[$x] =~ m/^PASS:/){
889 $passes.="$DEJAGNU[$x]\n";
890 $dejagnu_test_list="$DEJAGNU[$x]\n";
892 elsif($DEJAGNU[$x] =~ m/^FAIL:/){
893 $fails.="$DEJAGNU[$x]\n";
894 $dejagnu_test_list="$DEJAGNU[$x]\n";
896 elsif($DEJAGNU[$x] =~ m/^XFAIL:/){
897 $xfails.="$DEJAGNU[$x]\n";
898 $dejagnu_test_list="$DEJAGNU[$x]\n";
903 ##############################################################
905 # If we built the tree successfully, runs of the Olden suite with
906 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
908 ##############################################################
910 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
911 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
912 $MachCodeSize) = ("","","","","","","");
913 if (!$NORUNNINGTESTS) {
914 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
915 "Olden Test Directory");
917 # Clean out previous results...
918 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
920 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
921 # GET_STABLE_NUMBERS enabled!
922 if( $VERBOSE ) { print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
923 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1\n"; }
924 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
925 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
926 system "cp report.nightly.csv $OldenTestsLog";
930 ##############################################################
932 # Getting end timestamp
934 ##############################################################
935 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
938 ##############################################################
940 # Place all the logs neatly into one humungous file
942 ##############################################################
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="";
979 $gcc_version_long = `$GCCPATH/gcc --version`;
980 print "$GCCPATH/gcc --version\n";
983 $gcc_version_long = `gcc --version`;
985 @GCC_VERSION = split '\n', $gcc_version_long;
986 my $gcc_version = $GCC_VERSION[0];
988 my $all_tests = ReadFile "$Prefix-Tests.txt";
990 ##############################################################
992 # Send data via a post request
994 ##############################################################
996 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
999 my $host = "llvm.org";
1000 my $file = "/nightlytest/NightlyTestAccept.cgi";
1001 my %hash_of_data = ('machine_data' => $machine_data,
1002 'build_data' => $build_data,
1003 'gcc_version' => $gcc_version,
1004 'nickname' => $nickname,
1005 'dejagnutime_wall' => $DejagnuWallTime,
1006 'dejagnutime_cpu' => $DejagnuTime,
1007 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
1008 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
1009 'configtime_wall' => $ConfigWallTime,
1010 'configtime_cpu'=> $ConfigTime,
1011 'buildtime_wall' => $BuildWallTime,
1012 'buildtime_cpu' => $BuildTime,
1013 'warnings' => $WarningsFile,
1014 'cvsusercommitlist' => $UserCommitList,
1015 'cvsuserupdatelist' => $UserUpdateList,
1016 'cvsaddedfiles' => $CVSAddedFiles,
1017 'cvsmodifiedfiles' => $CVSModifiedFiles,
1018 'cvsremovedfiles' => $CVSRemovedFiles,
1019 'lines_of_code' => $LOC,
1020 'cvs_file_count' => $NumFilesInCVS,
1021 'cvs_dir_count' => $NumDirsInCVS,
1022 'buildstatus' => $BuildStatus,
1023 'singlesource_programstable' => $SingleSourceProgramsTable,
1024 'multisource_programstable' => $MultiSourceProgramsTable,
1025 'externalsource_programstable' => $ExternalProgramsTable,
1026 'llcbeta_options' => $multisource_llcbeta_options,
1027 'warnings_removed' => $WarningsRemoved,
1028 'warnings_added' => $WarningsAdded,
1029 'passing_tests' => $passes,
1030 'expfail_tests' => $xfails,
1031 'unexpfail_tests' => $fails,
1032 'all_tests' => $dejagnu_test_list,
1034 'removed_tests' => "",
1035 'dejagnutests_log' => $dejagnutests_log,
1036 'dejagnutests_sum' => $dejagnutests_sum,
1037 'starttime' => $starttime,
1038 'endtime' => $endtime,
1039 'o_file_sizes' => $o_file_sizes,
1040 'a_file_sizes' => $a_file_sizes);
1045 print "============================\n";
1046 foreach $x(keys %hash_of_data){
1047 print "$x => $hash_of_data{$x}\n";
1051 my $response = SendData $host,$file,\%hash_of_data;
1052 print "============================\n$response";
1055 ##############################################################
1057 # Remove the cvs tree...
1059 ##############################################################
1060 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
1061 system ( "$NICE rm -rf $WebDir") if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);