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"; next; }
126 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
127 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
128 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
129 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
130 $CONFIGUREARGS .= " --disable-jit"; next; }
131 if (/^-verbose$/) { $VERBOSE = 1; next; }
132 if (/^-debug$/) { $DEBUG = 1; next; }
133 if (/^-nice$/) { $NICE = "nice "; next; }
135 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
137 if (/^-with-externals/) {
138 $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next;
140 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
141 if (/^-gccpath/) { $CONFIGUREARGS .=
142 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
147 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
150 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
153 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
156 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
159 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
161 if (/^-compileflags/) {
162 $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
164 if (/^-extraflags/) {
165 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
167 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
168 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
169 if (/^-nobuild$/) { $NOBUILD = 1; next; }
170 print "Unknown option: $_ : ignoring!\n";
173 if ($ENV{'LLVMGCCDIR'}) {
174 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
176 if ($CONFIGUREARGS !~ /--disable-jit/) {
177 $CONFIGUREARGS .= " --enable-jit";
180 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
183 $CVSRootDir = $ARGV[0];
184 $BuildDir = $ARGV[1];
189 die ("Please invoke NewNightlyTest.pl with command line option \"-nickname <nickname>\"");
192 ##############################################################
194 #define the file names we'll use
196 ##############################################################
197 my $Prefix = "$WebDir/$DATE";
198 my $BuildLog = "$Prefix-Build-Log.txt";
199 my $CVSLog = "$Prefix-CVS-Log.txt";
200 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
201 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
202 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
203 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
204 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
205 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
206 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
209 warn "$WebDir did not exist; creating it.\n";
213 print "INITIALIZED\n";
214 print "CVS Root = $CVSRootDir\n";
215 print "BuildDir = $BuildDir\n";
216 print "WebDir = $WebDir\n";
217 print "Prefix = $Prefix\n";
218 print "CVSLog = $CVSLog\n";
219 print "BuildLog = $BuildLog\n";
222 ##############################################################
226 ##############################################################
230 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
235 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237 # DiffFiles - Diff the current version of the file against the last version of
238 # the file, reporting things added and removed. This is used to report, for
239 # example, added and removed warnings. This returns a pair (added, removed)
241 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244 my @Others = GetDir $Suffix;
245 if (@Others == 0) { # No other files? We added all entries...
246 return (`cat $WebDir/$DATE$Suffix`, "");
248 # Diff the files now...
249 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
250 my $Added = join "\n", grep /^</, @Diffs;
251 my $Removed = join "\n", grep /^>/, @Diffs;
253 $Removed =~ s/^> //gm;
254 return ($Added, $Removed);
257 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
258 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259 sub GetRegex { # (Regex with ()'s, value)
267 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270 my ($Regex, $Num, $Regex2, $File) = @_;
271 my @Items = split "\n", `grep '$Regex' $File`;
272 return GetRegex $Regex2, $Items[$Num];
275 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277 sub ChangeDir { # directory, logical name
278 my ($dir,$name) = @_;
280 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
281 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
284 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287 if (open (FILE, $_[0])) {
294 print "Could not open file '$_[0]' for reading!\n";
299 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301 sub WriteFile { # (filename, contents)
302 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
307 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
308 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309 sub CopyFile { #filename, newfile
310 my ($file, $newfile) = @_;
312 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
313 copy($file, $newfile);
316 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319 my ($Val, $Filename,$WebDir) = @_;
321 if (open FILE, "$WebDir/$Filename") {
322 @Records = grep !/$DATE/, split "\n", <FILE>;
325 push @Records, "$DATE: $Val";
326 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
329 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
331 # FormatTime - Convert a time from 1m23.45 into 83.45
333 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
337 $Time = sprintf("%7.4f", $1*60.0+$2);
342 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344 sub GetDejagnuTestResults { # (filename, log)
345 my ($filename, $DejagnuLog) = @_;
348 $/ = "\n"; #Make sure we're going line at a time.
350 print "DEJAGNU TEST RESULTS:\n";
352 if (open SRCHFILE, $filename) {
353 # Process test results
355 my $should_break = 1;
358 while ( <SRCHFILE> ) {
359 if ( length($_) > 1 ) {
361 if ( m/^XPASS:/ || m/^FAIL:/ ) {
364 push(@lines, "UNEXPECTED TEST RESULTS\n");
367 push(@lines, "$_\n");
370 push(@lines, "$_\n");
373 } #elsif ( m/Summary/ ) {
374 # if ( $first_list ) {
375 # push(@lines, "PERFECT!");
376 # print " PERFECT!\n";
378 # push(@lines, "</li></ol>\n");
380 # push(@lines, "STATISTICS\n");
381 # print "\nDEJAGNU STATISTICS:\n";
386 elsif ( $readingsum ) {
396 my $content = join("", @lines);
401 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
403 # This function acts as a mini web browswer submitting data
404 # to our central server via the post method
406 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
414 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
416 connect SOCK, $socketaddr or die "Bad connection\n";
417 select((select(SOCK), $| = 1)[0]);
419 #creating content here
421 foreach $key (keys (%$variables)){
422 $value = $variables->{$key};
423 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
424 $content .= "$key=$value&";
427 $length = length($content);
429 my $send= "POST $file HTTP/1.0\n";
430 $send.= "Content-Type: application/x-www-form-urlencoded\n";
431 $send.= "Content-length: $length\n\n";
442 foreach $x (keys (%$variables)){
443 $value = $variables->{$x};
444 $sentdata.= "$x => $value\n";
446 WriteFile "$Prefix-sentdata.txt", $sentdata;
452 ##############################################################
454 # Getting Start timestamp
456 ##############################################################
457 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
459 ##############################################################
461 # Create the CVS repository directory
463 ##############################################################
468 print "Build directory exists! Removing it\n";
470 system "rm -rf $BuildDir";
472 die "CVS checkout directory $BuildDir already exists!";
475 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
477 ChangeDir( $BuildDir, "CVS checkout directory" );
480 ##############################################################
482 # Check out the llvm tree, saving CVS messages to the cvs log...
484 ##############################################################
486 # Use compression if going over ssh.
487 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
488 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
492 print "CHECKOUT STAGE:\n";
493 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) > $CVSLog 2>&1\n";
495 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
496 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
497 ChangeDir( $BuildDir , "CVS Checkout directory") ;
499 ChangeDir( "llvm" , "llvm source directory") ;
501 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
502 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
505 ##############################################################
507 # Get some static statistics about the current state of CVS
509 # This can probably be put on the server side
511 ##############################################################
512 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
513 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
514 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
515 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
517 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
518 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
519 my $LOC = `utils/countloc.sh`;
521 ##############################################################
523 # Extract some information from the CVS history... use a hash so no duplicate
524 # stuff is stored. This gets the history from the previous days worth
525 # of cvs activit and parses it.
527 ##############################################################
529 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
533 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
534 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
535 #print join "\n", @CVSHistory; print "\n";
537 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
539 # Loop over every record from the CVS history, filling in the hashes.
540 foreach $File (@CVSHistory) {
541 my ($Type, $Date, $UID, $Rev, $Filename);
542 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
543 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
544 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
545 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
546 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
547 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
549 print "UNMATCHABLE: $File\n";
552 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
554 if ($Filename =~ /^llvm/) {
555 if ($Type eq 'M') { # Modified
556 $ModifiedFiles{$Filename} = 1;
557 $UsersCommitted{$UID} = 1;
558 } elsif ($Type eq 'A') { # Added
559 $AddedFiles{$Filename} = 1;
560 $UsersCommitted{$UID} = 1;
561 } elsif ($Type eq 'R') { # Removed
562 $RemovedFiles{$Filename} = 1;
563 $UsersCommitted{$UID} = 1;
565 $UsersUpdated{$UID} = 1;
574 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
575 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
576 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
577 my $UserCommitList = join "\n", sort keys %UsersCommitted;
578 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
580 ##############################################################
582 # Build the entire tree, saving build messages to the build log
584 ##############################################################
585 if (!$NOCHECKOUT && !$NOBUILD) {
586 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
589 print "CONFIGURE STAGE:\n";
590 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1\n";
592 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
595 print "BUILD STAGE:\n";
596 print "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1\n";
598 # Build the entire tree, capturing the output into $BuildLog
599 system "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1";
603 ##############################################################
605 # Get some statistics about the build...
607 ##############################################################
608 #this can de done on server
609 #my @Linked = split '\n', `grep Linking $BuildLog`;
610 #my $NumExecutables = scalar(grep(/executable/, @Linked));
611 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
612 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
617 ChangeDir( "$BuildDir", "Build Directory" );
618 $afiles = `find . -iname '*.a' -ls`;
619 $ofiles = `find . -iname '*.o' -ls`;
620 @AFILES = split "\n", $afiles;
622 foreach $x (@AFILES){
623 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
624 $a_file_sizes.="$1 $2\n";
626 @OFILES = split "\n", $ofiles;
628 foreach $x (@OFILES){
629 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
630 $o_file_sizes.="$1 $2\n";
634 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
635 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
636 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
637 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
639 $ConfigTime=-1 unless $ConfigTime;
640 $ConfigWallTime=-1 unless $ConfigWallTime;
642 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
643 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
644 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
645 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
647 $BuildTime=-1 unless $BuildTime;
648 $BuildWallTime=-1 unless $BuildWallTime;
650 my $BuildError = 0, $BuildStatus = "OK";
652 $BuildStatus = "Skipped by user";
655 elsif (`grep '^make[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
656 `grep '^make: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
657 $BuildStatus = "Error: compilation aborted";
659 print "\n***ERROR BUILDING TREE\n\n";
661 if ($BuildError) { $NODEJAGNU=1; }
663 ##############################################################
665 # Running dejagnu tests
667 ##############################################################
668 my $DejangnuTestResults; # String containing the results of the dejagnu
669 my $dejagnu_output = "$DejagnuTestsLog";
673 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
674 print "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1\n";
677 #Run the feature and regression tests, results are put into testrun.sum
678 #Full log in testrun.log
679 system "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1";
681 #Copy the testrun.log and testrun.sum to our webdir
682 CopyFile("test/testrun.log", $DejagnuLog);
683 CopyFile("test/testrun.sum", $DejagnuSum);
684 #can be done on server
685 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
686 $unexpfail_tests = $DejagnuTestResults;
688 #Extract time of dejagnu tests
689 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
690 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
691 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
692 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
693 $DejagnuTestResults = "Dejagnu skipped by user choice." unless $DejagnuTestResults;
694 $DejagnuTime = "0.0" unless $DejagnuTime;
695 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
698 print $DejagnuTestResults;
701 ##############################################################
703 # Get warnings from the build
705 ##############################################################
708 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
709 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
713 foreach $Warning (@Warn) {
714 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
715 $CurDir = $1; # Keep track of directory warning is in...
716 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
720 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
723 my $WarningsFile = join "\n", @Warnings;
724 $WarningsFile =~ s/:[0-9]+:/::/g;
726 # Emit the warnings file, so we can diff...
727 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
728 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
730 # Output something to stdout if something has changed
731 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
732 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
734 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
735 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
739 ##############################################################
741 # If we built the tree successfully, run the nightly programs tests...
743 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" "External")
745 ##############################################################
749 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
751 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
752 #my $ProgramTestLog = "$Prefix-MultiSource-ProgramTest.txt"; #CHANGE ME!
754 # Run the programs tests... creating a report.nightly.csv file
756 print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
757 . "TEST=nightly > $ProgramTestLog 2>&1\n";
758 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
759 . "TEST=nightly > $ProgramTestLog 2>&1";
760 $llcbeta_options=`make print-llcbeta-option`;
764 if (`grep '^make[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
766 $ProgramsTable="Error running test $SubDir\n";
767 print "ERROR TESTING\n";
768 } elsif (`grep '^make[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
770 $ProgramsTable="Makefile error running tests $SubDir!\n";
771 print "ERROR TESTING\n";
776 # Create a list of the tests which were run...
778 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
779 . "| sort > $Prefix-multisourceprogramstable.txt";
781 $ProgramsTable = ReadFile "report.nightly.csv";
783 ChangeDir( "../../..", "Programs Test Parent Directory" );
784 return ($ProgramsTable, $llcbeta_options);
788 if(!$patrickjenkins){
790 print "Modified Multisource Olden test stage\n";
792 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource/");
793 ChangeDir( "../../..", "Programs Test Parent Directory" );
796 WriteFile "$WebDir/multisourceprogramstable.txt", $MultiSourceProgramsTable;
798 if (!$BuildError && $patrickjenkins) {
800 print "SingleSource TEST STAGE\n";
802 ($SingleSourceProgramsTable, $llcbeta_options) = TestDirectory("SingleSource");
803 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
805 print "MultiSource TEST STAGE\n";
807 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
808 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
809 if ( ! $NOEXTERNALS ) {
811 print "External TEST STAGE\n";
813 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
814 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
815 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
816 " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
818 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
820 print "External TEST STAGE SKIPPED\n";
822 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
823 " | sort > $Prefix-Tests.txt";
825 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
828 ##############################################################
831 # gathering tests added removed broken information here
834 ##############################################################
835 my $dejagnu = ReadFile $DejagnuSum;
836 my @DEJAGNU = split "\n", $dejagnu;
843 for($x=0; $x<@DEJAGNU; $x++){
844 if($DEJAGNU[$x] =~ m/^PASS:/){
845 $passes.="$DEJAGNU[$x]\n";
847 elsif($DEJAGNU[$x] =~ m/^FAIL:/){
848 $fails.="$DEJAGNU[$x]\n";
850 elsif($DEJAGNU[$x] =~ m/^XFAIL:/){
851 $xfails.="$DEJAGNU[$x]\n";
856 # my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
859 # $TestsAdded = "<b>error testing</b><br>";
860 # $TestsRemoved = "<b>error testing</b><br>";
861 # $TestsFixed = "<b>error testing</b><br>";
862 # $TestsBroken = "<b>error testing</b><br>";
864 # my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
866 # my @RawTestsAddedArray = split '\n', $RTestsAdded;
867 # my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
869 # my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
870 # @RawTestsRemovedArray;
871 # my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
872 # @RawTestsAddedArray;
874 # foreach $Test (keys %NewTests) {
875 # if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
876 # $TestsAdded = "$TestsAdded$Test\n";
878 # if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
879 # $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
881 # $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
885 # foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
886 # $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
889 # #print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
890 # #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
891 # #print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
892 # #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
894 # #$TestsAdded = AddPreTag $TestsAdded;
895 # #$TestsRemoved = AddPreTag $TestsRemoved;
896 # #$TestsFixed = AddPreTag $TestsFixed;
897 # #$TestsBroken = AddPreTag $TestsBroken;
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 make $MAKEOPTS clean > /dev/null 2>&1";
917 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
918 # GET_STABLE_NUMBERS enabled!
919 if( $VERBOSE ) { print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
920 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1\n"; }
921 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
922 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
923 system "cp report.nightly.csv $OldenTestsLog";
925 #system "gunzip ${OldenTestsLog}.gz";
928 # Now we know we have $OldenTestsLog as the raw output file. Split
929 # it up into records and read the useful information.
930 #my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
931 #shift @Records; # Delete the first (garbage) record
933 # Loop over all of the records, summarizing them into rows for the running
935 #my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
936 #foreach $Rec (@Records) {
937 #my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
938 #my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
939 #my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
940 #my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
941 #my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
942 #my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
944 #$NATTime .= " " . FormatTime($rNATTime);
945 #$CBETime .= " " . FormatTime($rCBETime);
946 #$LLCTime .= " " . FormatTime($rLLCTime);
947 #$JITTime .= " " . FormatTime($rJITTime);
948 #$OptTime .= " $rOptTime";
949 #$BytecodeSize .= " $rBytecodeSize";
952 # Now that we have all of the numbers we want, add them to the running totals
954 #AddRecord($NATTime, "running_Olden_nat_time.txt", $WebDir);
955 #AddRecord($CBETime, "running_Olden_cbe_time.txt", $WebDir);
956 #AddRecord($LLCTime, "running_Olden_llc_time.txt", $WebDir);
957 #AddRecord($JITTime, "running_Olden_jit_time.txt", $WebDir);
958 #AddRecord($OptTime, "running_Olden_opt_time.txt", $WebDir);
959 #AddRecord($BytecodeSize, "running_Olden_bytecode.txt", $WebDir);
962 ##############################################################
964 # Getting end timestamp
966 ##############################################################
967 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
970 ##############################################################
972 # Place all the logs neatly into one humungous file
974 ##############################################################
976 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
978 $machine_data = "uname: ".`uname -a`.
979 "hardware: ".`uname -m`.
982 "date: ".`date \"+20%y-%m-%d\"`.
983 "time: ".`date +\"%H:%M:%S\"`;
987 @CVS_DATA = ReadFile "$CVSLog";
988 $cvs_data = join("\n", @CVS_DATA);
992 @BUILD_DATA = ReadFile "$BuildLog";
993 $build_data = join("\n", @BUILD_DATA);
997 my $dejagnutests_log;
998 my $dejagnutests_sum;
999 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1000 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1001 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1002 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1004 my @DEJAGNULOG_FULL;
1005 my $dejagnulog_full;
1006 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1007 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1009 my $gcc_version_long="";
1011 $gcc_version_long = `$GCCPATH/gcc --version`;
1012 print "$GCCPATH/gcc --version\n";
1015 $gcc_version_long = `gcc --version`;
1016 print "gcc --version\n";
1018 @GCC_VERSION = split '\n', $gcc_version_long;
1019 my $gcc_version = $GCC_VERSION[0];
1021 $all_tests = ReadFile, "$Prefix-Tests.txt";
1023 ##############################################################
1025 # Send data via a post request
1027 ##############################################################
1029 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1032 my $host = "llvm.org";
1033 my $file = "/nightlytest/NightlyTestAccept.cgi";
1034 my %hash_of_data = ('machine_data' => $machine_data,
1035 'build_data' => $build_data,
1036 'gcc_version' => $gcc_version,
1037 'nickname' => $nickname,
1038 'dejagnutime_wall' => $DejagnuWallTime,
1039 'dejagnutime_cpu' => $DejagnuTime,
1040 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
1041 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
1042 'configtime_wall' => $ConfigWallTime,
1043 'configtime_cpu'=> $ConfigTime,
1044 'buildtime_wall' => $BuildWallTime,
1045 'buildtime_cpu' => $BuildTime,
1046 'warnings' => $WarningsFile,
1047 'cvsusercommitlist' => $UserCommitList,
1048 'cvsuserupdatelist' => $UserUpdateList,
1049 'cvsaddedfiles' => $CVSAddedFiles,
1050 'cvsmodifiedfiles' => $CVSModifiedFiles,
1051 'cvsremovedfiles' => $CVSRemovedFiles,
1052 'lines_of_code' => $LOC,
1053 'cvs_file_count' => $NumFilesInCVS,
1054 'cvs_dir_count' => $NumDirsInCVS,
1055 'buildstatus' => $BuildStatus,
1056 'singlesource_programstable' => $SingleSourceProgramsTable,
1057 'multisource_programstable' => $MultiSourceProgramsTable,
1058 'externalsource_programstable' => $ExternalProgramsTable,
1059 'llcbeta_options' => $multisource_llcbeta_options,
1060 'warnings_removed' => $WarningsRemoved,
1061 'warnings_added' => $WarningsAdded,
1062 'passing_tests' => $passes,
1063 'expfail_tests' => $xfails,
1064 'unexpfail_tests' => $fails,
1065 'all_tests' => $all_tests,
1067 'removed_tests' => "",
1068 'dejagnutests_log' => $dejagnutests_log,
1069 'dejagnutests_sum' => $dejagnutests_sum,
1070 'starttime' => $starttime,
1071 'endtime' => $endtime,
1072 'o_file_sizes' => $o_file_sizes,
1073 'a_file_sizes' => $a_file_sizes);
1078 print "============================\n";
1079 foreach $x(keys %hash_of_data){
1080 print "$x => $hash_of_data{$x}\n";
1084 my $response = SendData $host,$file,\%hash_of_data;
1085 print "============================\n$response";
1088 ##############################################################
1090 # Remove the cvs tree...
1092 ##############################################################
1093 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
1094 system ( "$NICE rm -rf $WebDir") if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);