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
56 # ---------------- Options to configure llvm-test ----------------------------
57 # -extraflags Next argument specifies extra options that are passed to
59 # -noexternals Do not run the external tests (for cases where povray
60 # or SPEC are not installed)
61 # -with-externals Specify a directory where the external tests are located.
63 # CVSROOT is the CVS repository from which the tree will be checked out,
64 # specified either in the full :method:user@host:/dir syntax, or
65 # just /dir if using a local repo.
66 # BUILDDIR is the directory where sources for this test run will be checked out
67 # AND objects for this test run will be built. This directory MUST NOT
68 # exist before the script is run; it will be created by the cvs checkout
69 # process and erased (unless -noremove is specified; see above.)
70 # WEBDIR is the directory into which the test results web page will be written,
71 # AND in which the "index.html" is assumed to be a symlink to the most recent
72 # copy of the results. This directory will be created if it does not exist.
73 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
74 # to. This is the same as you would have for a normal LLVM build.
76 ##############################################################
78 # Getting environment variables
80 ##############################################################
81 my $HOME = $ENV{'HOME'};
82 my $CVSRootDir = $ENV{'CVSROOT'};
83 $CVSRootDir = "/home/vadve/shared/PublicCVS"
85 my $BuildDir = $ENV{'BUILDDIR'};
86 $BuildDir = "$HOME/buildtest"
88 my $WebDir = $ENV{'WEBDIR'};
89 $WebDir = "$HOME/cvs/testresults-X86"
92 ##############################################################
94 # Calculate the date prefix...
96 ##############################################################
98 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
99 my $DateString = strftime "%B %d, %Y", localtime;
100 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
102 ##############################################################
106 ##############################################################
112 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
114 last if /^--$/; # Stop processing arguments on --
116 # List command line options here...
117 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
118 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
119 if (/^-noremove$/) { $NOREMOVE = 1; next; }
120 if (/^-noremoveresults$/) { $NOREMOVERESULTS = 1; next; }
121 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
122 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
123 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
124 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
125 "OPTIMIZE_OPTION=-O2";
126 $BUILDTYPE="release"; next; }
127 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
128 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
129 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
130 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
131 $CONFIGUREARGS .= " --disable-jit"; next; }
132 if (/^-verbose$/) { $VERBOSE = 1; next; }
133 if (/^-debug$/) { $DEBUG = 1; next; }
134 if (/^-nice$/) { $NICE = "nice "; next; }
136 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
138 if (/^-with-externals/) {
139 $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next;
141 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
142 if (/^-gccpath/) { $CONFIGUREARGS .=
143 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
148 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
151 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
154 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
157 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
160 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
162 if (/^-compileflags/) {
163 $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
165 if (/^-extraflags/) {
166 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
168 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
169 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
170 if (/^-nobuild$/) { $NOBUILD = 1; next; }
171 print "Unknown option: $_ : ignoring!\n";
174 if ($ENV{'LLVMGCCDIR'}) {
175 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
177 if ($CONFIGUREARGS !~ /--disable-jit/) {
178 $CONFIGUREARGS .= " --enable-jit";
182 if (@ARGV != 0 and @ARGV != 3){
186 print "Must specify 0 or 3 options!";
190 $CVSRootDir = $ARGV[0];
191 $BuildDir = $ARGV[1];
195 if($CVSRootDir eq "" or
198 die("please specify a cvs root directory, a build directory, and a ".
203 die ("Please invoke NewNightlyTest.pl with command line option \"-nickname <nickname>\"");
205 if($BUILDTYPE ne "releaese"){
206 $BUILDTYPE = "debug";
209 #FIXME: this is a hack for SunOS, there must be a better way
210 if(`uname` eq "SunOS"){
218 ##############################################################
220 #define the file names we'll use
222 ##############################################################
223 my $Prefix = "$WebDir/$DATE";
224 my $BuildLog = "$Prefix-Build-Log.txt";
225 my $CVSLog = "$Prefix-CVS-Log.txt";
226 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
227 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
228 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
229 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
230 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
231 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
232 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
235 warn "$WebDir did not exist; creating it.\n";
239 print "INITIALIZED\n";
240 print "CVS Root = $CVSRootDir\n";
241 print "BuildDir = $BuildDir\n";
242 print "WebDir = $WebDir\n";
243 print "Prefix = $Prefix\n";
244 print "CVSLog = $CVSLog\n";
245 print "BuildLog = $BuildLog\n";
248 ##############################################################
252 ##############################################################
256 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
261 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263 # DiffFiles - Diff the current version of the file against the last version of
264 # the file, reporting things added and removed. This is used to report, for
265 # example, added and removed warnings. This returns a pair (added, removed)
267 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270 my @Others = GetDir $Suffix;
271 if (@Others == 0) { # No other files? We added all entries...
272 return (`cat $WebDir/$DATE$Suffix`, "");
274 # Diff the files now...
275 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
276 my $Added = join "\n", grep /^</, @Diffs;
277 my $Removed = join "\n", grep /^>/, @Diffs;
279 $Removed =~ s/^> //gm;
280 return ($Added, $Removed);
283 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285 sub GetRegex { # (Regex with ()'s, value)
293 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296 my ($Regex, $Num, $Regex2, $File) = @_;
297 my @Items = split "\n", `grep '$Regex' $File`;
298 return GetRegex $Regex2, $Items[$Num];
301 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 sub ChangeDir { # directory, logical name
304 my ($dir,$name) = @_;
306 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
307 chdir($dir) || (print "Cannot change directory to: $name ($dir) " && return -1);
311 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 if (open (FILE, $_[0])) {
321 print "Could not open file '$_[0]' for reading!\n";
326 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328 sub WriteFile { # (filename, contents)
329 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
334 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336 sub CopyFile { #filename, newfile
337 my ($file, $newfile) = @_;
339 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
340 copy($file, $newfile);
343 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346 my ($Val, $Filename,$WebDir) = @_;
348 if (open FILE, "$WebDir/$Filename") {
349 @Records = grep !/$DATE/, split "\n", <FILE>;
352 push @Records, "$DATE: $Val";
353 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
356 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 # FormatTime - Convert a time from 1m23.45 into 83.45
360 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
364 $Time = sprintf("%7.4f", $1*60.0+$2);
369 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 sub GetDejagnuTestResults { # (filename, log)
372 my ($filename, $DejagnuLog) = @_;
375 $/ = "\n"; #Make sure we're going line at a time.
377 print "DEJAGNU TEST RESULTS:\n";
379 if (open SRCHFILE, $filename) {
380 # Process test results
382 my $should_break = 1;
385 while ( <SRCHFILE> ) {
386 if ( length($_) > 1 ) {
388 if ( m/^XPASS:/ || m/^FAIL:/ ) {
391 push(@lines, "UNEXPECTED TEST RESULTS\n");
394 push(@lines, "$_\n");
397 push(@lines, "$_\n");
400 } #elsif ( m/Summary/ ) {
401 # if ( $first_list ) {
402 # push(@lines, "PERFECT!");
403 # print " PERFECT!\n";
405 # push(@lines, "</li></ol>\n");
407 # push(@lines, "STATISTICS\n");
408 # print "\nDEJAGNU STATISTICS:\n";
413 elsif ( $readingsum ) {
423 my $content = join("", @lines);
428 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430 # This function acts as a mini web browswer submitting data
431 # to our central server via the post method
433 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
441 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
443 connect SOCK, $socketaddr or die "Bad connection\n";
444 select((select(SOCK), $| = 1)[0]);
446 #creating content here
448 foreach $key (keys (%$variables)){
449 $value = $variables->{$key};
450 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
451 $content .= "$key=$value&";
454 $length = length($content);
456 my $send= "POST $file HTTP/1.0\n";
457 $send.= "Content-Type: application/x-www-form-urlencoded\n";
458 $send.= "Content-length: $length\n\n";
469 foreach $x (keys (%$variables)){
470 $value = $variables->{$x};
471 $sentdata.= "$x => $value\n";
473 WriteFile "$Prefix-sentdata.txt", $sentdata;
479 ##############################################################
481 # Getting Start timestamp
483 ##############################################################
484 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
486 ##############################################################
488 # Create the CVS repository directory
490 ##############################################################
495 print "Build directory exists! Removing it\n";
497 system "rm -rf $BuildDir";
499 die "CVS checkout directory $BuildDir already exists!";
502 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
504 ChangeDir( $BuildDir, "CVS checkout directory" );
507 ##############################################################
509 # Check out the llvm tree, saving CVS messages to the cvs log...
511 ##############################################################
513 # Use compression if going over ssh.
514 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
515 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
519 print "CHECKOUT STAGE:\n";
520 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) > $CVSLog 2>&1\n";
522 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
523 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
524 ChangeDir( $BuildDir , "CVS Checkout directory") ;
526 ChangeDir( "llvm" , "llvm source directory") ;
528 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
529 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
532 ##############################################################
534 # Get some static statistics about the current state of CVS
536 # This can probably be put on the server side
538 ##############################################################
539 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
540 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
541 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
542 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
544 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
545 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
546 my $LOC = `utils/countloc.sh`;
548 ##############################################################
550 # Extract some information from the CVS history... use a hash so no duplicate
551 # stuff is stored. This gets the history from the previous days worth
552 # of cvs activit and parses it.
554 ##############################################################
556 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
560 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
561 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
562 #print join "\n", @CVSHistory; print "\n";
564 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
566 # Loop over every record from the CVS history, filling in the hashes.
567 foreach $File (@CVSHistory) {
568 my ($Type, $Date, $UID, $Rev, $Filename);
569 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
570 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
571 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
572 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
573 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
574 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
576 print "UNMATCHABLE: $File\n";
579 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
581 if ($Filename =~ /^llvm/) {
582 if ($Type eq 'M') { # Modified
583 $ModifiedFiles{$Filename} = 1;
584 $UsersCommitted{$UID} = 1;
585 } elsif ($Type eq 'A') { # Added
586 $AddedFiles{$Filename} = 1;
587 $UsersCommitted{$UID} = 1;
588 } elsif ($Type eq 'R') { # Removed
589 $RemovedFiles{$Filename} = 1;
590 $UsersCommitted{$UID} = 1;
592 $UsersUpdated{$UID} = 1;
601 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
602 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
603 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
604 my $UserCommitList = join "\n", sort keys %UsersCommitted;
605 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
607 ##############################################################
609 # Build the entire tree, saving build messages to the build log
611 ##############################################################
612 if (!$NOCHECKOUT && !$NOBUILD) {
613 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
615 print "CONFIGURE STAGE:\n";
616 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1\n";
618 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
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";
629 ##############################################################
631 # Get some statistics about the build...
633 ##############################################################
634 #this can de done on server
635 #my @Linked = split '\n', `grep Linking $BuildLog`;
636 #my $NumExecutables = scalar(grep(/executable/, @Linked));
637 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
638 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
641 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
642 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
643 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
644 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
646 $ConfigTime=-1 unless $ConfigTime;
647 $ConfigWallTime=-1 unless $ConfigWallTime;
649 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
650 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
651 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
652 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
654 $BuildTime=-1 unless $BuildTime;
655 $BuildWallTime=-1 unless $BuildWallTime;
657 my $BuildError = 0, $BuildStatus = "OK";
659 $BuildStatus = "Skipped by user";
662 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
663 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
664 $BuildStatus = "Error: compilation aborted";
666 print "\n***ERROR BUILDING TREE\n\n";
668 if ($BuildError) { $NODEJAGNU=1; }
674 print "Organizing size of .o and .a files\n";
676 ChangeDir( "$BuildDir/llvm", "Build Directory" );
677 $afiles = `find . -iname '*.a' -ls`;
678 $ofiles = `find . -iname '*.o' -ls`;
679 @AFILES = split "\n", $afiles;
681 foreach $x (@AFILES){
682 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
683 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
685 @OFILES = split "\n", $ofiles;
687 foreach $x (@OFILES){
688 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
689 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
693 $a_file_sizes="No data due to a bad build.";
694 $o_file_sizes="No data due to a bad build.";
698 ##############################################################
700 # Running dejagnu tests
702 ##############################################################
703 my $DejangnuTestResults; # String containing the results of the dejagnu
704 my $dejagnu_output = "$DejagnuTestsLog";
708 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
709 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
712 #Run the feature and regression tests, results are put into testrun.sum
713 #Full log in testrun.log
714 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
716 #Copy the testrun.log and testrun.sum to our webdir
717 CopyFile("test/testrun.log", $DejagnuLog);
718 CopyFile("test/testrun.sum", $DejagnuSum);
719 #can be done on server
720 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
721 $unexpfail_tests = $DejagnuTestResults;
723 #Extract time of dejagnu tests
724 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
725 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
726 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
727 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
728 $DejagnuTestResults = "Dejagnu skipped by user choice." unless $DejagnuTestResults;
729 $DejagnuTime = "0.0" unless $DejagnuTime;
730 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
733 print $DejagnuTestResults;
736 ##############################################################
738 # Get warnings from the build
740 ##############################################################
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 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
755 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
758 my $WarningsFile = join "\n", @Warnings;
759 $WarningsFile =~ s/:[0-9]+:/::/g;
761 # Emit the warnings file, so we can diff...
762 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
763 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
765 # Output something to stdout if something has changed
766 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
767 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
769 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
770 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
774 ##############################################################
776 # If we built the tree successfully, run the nightly programs tests...
778 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" "External")
780 ##############################################################
784 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" ) || return ("", "");
786 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
787 #my $ProgramTestLog = "$Prefix-MultiSource-ProgramTest.txt"; #CHANGE ME!
789 # 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";
793 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
794 . "TEST=nightly > $ProgramTestLog 2>&1";
795 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
799 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
801 $ProgramsTable="Error running test $SubDir\n";
802 print "ERROR TESTING\n";
803 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
805 $ProgramsTable="Makefile error running tests $SubDir!\n";
806 print "ERROR TESTING\n";
811 # Create a list of the tests which were run...
813 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
814 . "| sort > $Prefix-multisourceprogramstable.txt";
816 $ProgramsTable = ReadFile "report.nightly.csv";
818 ChangeDir( "../../..", "Programs Test Parent Directory" );
819 return ($ProgramsTable, $llcbeta_options);
823 if(!$patrickjenkins){
825 print "Modified Multisource Olden test stage\n";
827 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource/");
828 ChangeDir( "../../..", "Programs Test Parent Directory" );
831 WriteFile "$WebDir/multisourceprogramstable.txt", $MultiSourceProgramsTable;
833 if (!$BuildError && $patrickjenkins) {
835 print "SingleSource TEST STAGE\n";
837 ($SingleSourceProgramsTable, $llcbeta_options) = TestDirectory("SingleSource");
838 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
840 print "MultiSource TEST STAGE\n";
842 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
843 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
844 if ( ! $NOEXTERNALS ) {
846 print "External TEST STAGE\n";
848 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
849 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
850 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
851 " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
853 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
855 print "External TEST STAGE SKIPPED\n";
857 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
858 " | sort > $Prefix-Tests.txt";
860 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
863 ##############################################################
866 # gathering tests added removed broken information here
869 ##############################################################
870 my $dejagnu = ReadFile $DejagnuSum;
871 my @DEJAGNU = split "\n", $dejagnu;
878 for($x=0; $x<@DEJAGNU; $x++){
879 if($DEJAGNU[$x] =~ m/^PASS:/){
880 $passes.="$DEJAGNU[$x]\n";
882 elsif($DEJAGNU[$x] =~ m/^FAIL:/){
883 $fails.="$DEJAGNU[$x]\n";
885 elsif($DEJAGNU[$x] =~ m/^XFAIL:/){
886 $xfails.="$DEJAGNU[$x]\n";
891 # my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
894 # $TestsAdded = "<b>error testing</b><br>";
895 # $TestsRemoved = "<b>error testing</b><br>";
896 # $TestsFixed = "<b>error testing</b><br>";
897 # $TestsBroken = "<b>error testing</b><br>";
899 # my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
901 # my @RawTestsAddedArray = split '\n', $RTestsAdded;
902 # my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
904 # my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
905 # @RawTestsRemovedArray;
906 # my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
907 # @RawTestsAddedArray;
909 # foreach $Test (keys %NewTests) {
910 # if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
911 # $TestsAdded = "$TestsAdded$Test\n";
913 # if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
914 # $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
916 # $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
920 # foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
921 # $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
924 # #print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
925 # #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
926 # #print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
927 # #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
929 # #$TestsAdded = AddPreTag $TestsAdded;
930 # #$TestsRemoved = AddPreTag $TestsRemoved;
931 # #$TestsFixed = AddPreTag $TestsFixed;
932 # #$TestsBroken = AddPreTag $TestsBroken;
935 ##############################################################
937 # If we built the tree successfully, runs of the Olden suite with
938 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
940 ##############################################################
942 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
943 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
944 $MachCodeSize) = ("","","","","","","");
945 if (!$NORUNNINGTESTS) {
946 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
947 "Olden Test Directory");
949 # Clean out previous results...
950 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
952 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
953 # GET_STABLE_NUMBERS enabled!
954 if( $VERBOSE ) { print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
955 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1\n"; }
956 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
957 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
958 system "cp report.nightly.csv $OldenTestsLog";
960 #system "gunzip ${OldenTestsLog}.gz";
963 # Now we know we have $OldenTestsLog as the raw output file. Split
964 # it up into records and read the useful information.
965 #my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
966 #shift @Records; # Delete the first (garbage) record
968 # Loop over all of the records, summarizing them into rows for the running
970 #my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
971 #foreach $Rec (@Records) {
972 #my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
973 #my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
974 #my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
975 #my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
976 #my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
977 #my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
979 #$NATTime .= " " . FormatTime($rNATTime);
980 #$CBETime .= " " . FormatTime($rCBETime);
981 #$LLCTime .= " " . FormatTime($rLLCTime);
982 #$JITTime .= " " . FormatTime($rJITTime);
983 #$OptTime .= " $rOptTime";
984 #$BytecodeSize .= " $rBytecodeSize";
987 # Now that we have all of the numbers we want, add them to the running totals
989 #AddRecord($NATTime, "running_Olden_nat_time.txt", $WebDir);
990 #AddRecord($CBETime, "running_Olden_cbe_time.txt", $WebDir);
991 #AddRecord($LLCTime, "running_Olden_llc_time.txt", $WebDir);
992 #AddRecord($JITTime, "running_Olden_jit_time.txt", $WebDir);
993 #AddRecord($OptTime, "running_Olden_opt_time.txt", $WebDir);
994 #AddRecord($BytecodeSize, "running_Olden_bytecode.txt", $WebDir);
997 ##############################################################
999 # Getting end timestamp
1001 ##############################################################
1002 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1005 ##############################################################
1007 # Place all the logs neatly into one humungous file
1009 ##############################################################
1011 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1013 $machine_data = "uname: ".`uname -a`.
1014 "hardware: ".`uname -m`.
1016 "name: ".`uname -n`.
1017 "date: ".`date \"+20%y-%m-%d\"`.
1018 "time: ".`date +\"%H:%M:%S\"`;
1022 @CVS_DATA = ReadFile "$CVSLog";
1023 $cvs_data = join("\n", @CVS_DATA);
1027 @BUILD_DATA = ReadFile "$BuildLog";
1028 $build_data = join("\n", @BUILD_DATA);
1032 my $dejagnutests_log;
1033 my $dejagnutests_sum;
1034 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1035 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1036 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1037 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1039 my @DEJAGNULOG_FULL;
1040 my $dejagnulog_full;
1041 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1042 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1044 my $gcc_version_long="";
1046 $gcc_version_long = `$GCCPATH/gcc --version`;
1047 print "$GCCPATH/gcc --version\n";
1050 $gcc_version_long = `gcc --version`;
1051 print "gcc --version\n";
1053 @GCC_VERSION = split '\n', $gcc_version_long;
1054 my $gcc_version = $GCC_VERSION[0];
1056 $all_tests = ReadFile, "$Prefix-Tests.txt";
1058 ##############################################################
1060 # Send data via a post request
1062 ##############################################################
1064 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1067 my $host = "llvm.org";
1068 my $file = "/nightlytest/NightlyTestAccept.cgi";
1069 my %hash_of_data = ('machine_data' => $machine_data,
1070 'build_data' => $build_data,
1071 'gcc_version' => $gcc_version,
1072 'nickname' => $nickname,
1073 'dejagnutime_wall' => $DejagnuWallTime,
1074 'dejagnutime_cpu' => $DejagnuTime,
1075 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
1076 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
1077 'configtime_wall' => $ConfigWallTime,
1078 'configtime_cpu'=> $ConfigTime,
1079 'buildtime_wall' => $BuildWallTime,
1080 'buildtime_cpu' => $BuildTime,
1081 'warnings' => $WarningsFile,
1082 'cvsusercommitlist' => $UserCommitList,
1083 'cvsuserupdatelist' => $UserUpdateList,
1084 'cvsaddedfiles' => $CVSAddedFiles,
1085 'cvsmodifiedfiles' => $CVSModifiedFiles,
1086 'cvsremovedfiles' => $CVSRemovedFiles,
1087 'lines_of_code' => $LOC,
1088 'cvs_file_count' => $NumFilesInCVS,
1089 'cvs_dir_count' => $NumDirsInCVS,
1090 'buildstatus' => $BuildStatus,
1091 'singlesource_programstable' => $SingleSourceProgramsTable,
1092 'multisource_programstable' => $MultiSourceProgramsTable,
1093 'externalsource_programstable' => $ExternalProgramsTable,
1094 'llcbeta_options' => $multisource_llcbeta_options,
1095 'warnings_removed' => $WarningsRemoved,
1096 'warnings_added' => $WarningsAdded,
1097 'passing_tests' => $passes,
1098 'expfail_tests' => $xfails,
1099 'unexpfail_tests' => $fails,
1100 'all_tests' => $all_tests,
1102 'removed_tests' => "",
1103 'dejagnutests_log' => $dejagnutests_log,
1104 'dejagnutests_sum' => $dejagnutests_sum,
1105 'starttime' => $starttime,
1106 'endtime' => $endtime,
1107 'o_file_sizes' => $o_file_sizes,
1108 'a_file_sizes' => $a_file_sizes);
1113 print "============================\n";
1114 foreach $x(keys %hash_of_data){
1115 print "$x => $hash_of_data{$x}\n";
1119 my $response = SendData $host,$file,\%hash_of_data;
1120 print "============================\n$response";
1123 ##############################################################
1125 # Remove the cvs tree...
1127 ##############################################################
1128 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
1129 system ( "$NICE rm -rf $WebDir") if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);