3 use POSIX qw(strftime);
8 # Program: NewNightlyTest.pl
10 # Synopsis: Perform a series of tests which are designed to be run nightly.
11 # This is used to keep track of the status of the LLVM tree, tracking
12 # regressions and performance changes. Submits this information
13 # to llvm.org where it is placed into the nightlytestresults database.
15 # Modified heavily by Patrick Jenkins, July 2006
17 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
19 # OPTIONS may include one or more of the following:
20 # -nocheckout Do not create, checkout, update, or configure
22 # -noremove Do not remove the BUILDDIR 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 # -noexternals Do not run the external tests (for cases where povray
30 # or SPEC are not installed)
31 # -with-externals Specify a directory where the external tests are located.
32 # -nodejagnu Do not run feature or regression tests
33 # -parallel Run two parallel jobs with GNU Make.
34 # -release Build an LLVM Release version
35 # -enable-llcbeta Enable testing of beta features in llc.
36 # -disable-llc Disable LLC tests in the nightly tester.
37 # -disable-jit Disable JIT tests in the nightly tester.
38 # -disable-cbe Disable C backend tests in the nightly tester.
39 # -verbose Turn on some debug output
40 # -debug Print information useful only to maintainers of this script.
41 # -nice Checkout/Configure/Build with "nice" to reduce impact
43 # -f2c Next argument specifies path to F2C utility
44 # -nickname The next argument specifieds the nickname this script
45 # will submit to the nightlytest results repository.
46 # -gccpath Path to gcc/g++ used to build LLVM
47 # -cvstag Check out a specific CVS tag to build LLVM (useful for
48 # testing release branches)
49 # -target Specify the target triplet
50 # -cflags Next argument specifies that C compilation options that
51 # override the default.
52 # -cxxflags Next argument specifies that C++ compilation options that
53 # override the default.
54 # -ldflags Next argument specifies that linker options that override
56 # -extraflags Next argument specifies extra options that are passed to
59 # ---------------- Options to configure llvm-test ----------------------------
60 # -spec2000path Path to the benchspec directory in the SPEC 2000 distro
61 # -spec95path Path to the benchspec directory in the SPEC 95 distro.
62 # -povraypath Path to the povray sources
63 # -namdpath Path to the namd sources
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 ##############################################################
114 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
116 last if /^--$/; # Stop processing arguments on --
118 # List command line options here...
119 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
120 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
121 if (/^-noremove$/) { $NOREMOVE = 1; next; }
122 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
123 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
124 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
125 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 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 .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;}
142 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } else{ $CVSCOOPT="";}
144 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
147 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
150 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
153 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
155 if (/^-compileflags/) {
156 $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
158 if (/^-extraflags/) {
159 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
161 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
162 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
163 if (/^-nobuild$/) { $NOBUILD = 1; next; }
164 if (/^-spec2000path$/) {
165 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
166 } else{ $LLVMTESTCONFIGARGS=""; }
167 if (/^-spec95path$/) {
168 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
170 if (/^-povraypath$/) {
171 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
174 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
176 print "Unknown option: $_ : ignoring!\n";
179 if ($ENV{'LLVMGCCDIR'}) {
180 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
182 if ($CONFIGUREARGS !~ /--disable-jit/) {
183 $CONFIGUREARGS .= " --enable-jit";
186 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
189 $CVSRootDir = $ARGV[0];
190 $BuildDir = $ARGV[1];
194 ##############################################################
196 #define the file names we'll use
198 ##############################################################
199 my $Prefix = "$WebDir/$DATE";
200 my $BuildLog = "$Prefix-Build-Log.txt";
201 my $CVSLog = "$Prefix-CVS-Log.txt";
202 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
203 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
204 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
205 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
206 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
207 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
208 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
211 warn "$WebDir did not exist; creating it.\n";
215 print "INITIALIZED\n";
216 print "CVS Root = $CVSRootDir\n";
217 print "BuildDir = $BuildDir\n";
218 print "WebDir = $WebDir\n";
219 print "Prefix = $Prefix\n";
220 print "CVSLog = $CVSLog\n";
221 print "BuildLog = $BuildLog\n";
224 ##############################################################
228 ##############################################################
232 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
237 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239 # DiffFiles - Diff the current version of the file against the last version of
240 # the file, reporting things added and removed. This is used to report, for
241 # example, added and removed warnings. This returns a pair (added, removed)
243 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246 my @Others = GetDir $Suffix;
247 if (@Others == 0) { # No other files? We added all entries...
248 return (`cat $WebDir/$DATE$Suffix`, "");
250 # Diff the files now...
251 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
252 my $Added = join "\n", grep /^</, @Diffs;
253 my $Removed = join "\n", grep /^>/, @Diffs;
255 $Removed =~ s/^> //gm;
256 return ($Added, $Removed);
259 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261 sub GetRegex { # (Regex with ()'s, value)
269 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272 my ($Regex, $Num, $Regex2, $File) = @_;
273 my @Items = split "\n", `grep '$Regex' $File`;
274 return GetRegex $Regex2, $Items[$Num];
277 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279 sub ChangeDir { # directory, logical name
280 my ($dir,$name) = @_;
282 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
283 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
286 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289 if (open (FILE, $_[0])) {
296 print "Could not open file '$_[0]' for reading!";
301 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 sub WriteFile { # (filename, contents)
304 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
309 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311 sub CopyFile { #filename, newfile
312 my ($file, $newfile) = @_;
314 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
315 copy($file, $newfile);
318 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321 my ($Val, $Filename,$WebDir) = @_;
323 if (open FILE, "$WebDir/$Filename") {
324 @Records = grep !/$DATE/, split "\n", <FILE>;
327 push @Records, "$DATE: $Val";
328 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
331 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333 # FormatTime - Convert a time from 1m23.45 into 83.45
335 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
339 $Time = sprintf("%7.4f", $1*60.0+$2);
344 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346 sub GetDejagnuTestResults { # (filename, log)
347 my ($filename, $DejagnuLog) = @_;
350 $/ = "\n"; #Make sure we're going line at a time.
352 print "DEJAGNU TEST RESULTS:\n";
354 if (open SRCHFILE, $filename) {
355 # Process test results
357 my $should_break = 1;
360 while ( <SRCHFILE> ) {
361 if ( length($_) > 1 ) {
363 if ( m/^XPASS:/ || m/^FAIL:/ ) {
366 push(@lines, "UNEXPECTED TEST RESULTS\n");
369 push(@lines, "$_\n");
372 push(@lines, "$_\n");
375 } #elsif ( m/Summary/ ) {
376 # if ( $first_list ) {
377 # push(@lines, "PERFECT!");
378 # print " PERFECT!\n";
380 # push(@lines, "</li></ol>\n");
382 # push(@lines, "STATISTICS\n");
383 # print "\nDEJAGNU STATISTICS:\n";
388 elsif ( $readingsum ) {
398 my $content = join("", @lines);
403 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405 # This function acts as a mini web browswer submitting data
406 # to our central server via the post method
408 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
416 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die "Bad socket\n";
417 connect SOCK, $socketaddr or die "Bad connection\n";
418 select((select(SOCK), $| = 1)[0]);
420 #creating content here
422 foreach $key (keys (%$variables)){
423 $value = $variables->{$key};
424 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
425 $content .= "$key=$value&";
428 $length = length($content);
430 my $send= "POST $file HTTP/1.0\n";
431 $send.= "Content-Type: application/x-www-form-urlencoded\n";
432 $send.= "Content-length: $length\n\n";
443 foreach $x(keys(%hash_of_data)){
444 $senddata.= "$x => $hash_of_data{$x}\n";
446 WriteFile "$Prefix-sentdata.txt", $sentdata;
453 ##############################################################
455 # Create the CVS repository directory
457 ##############################################################
461 system "rm -rf $BuildDir";
463 die "CVS checkout directory $BuildDir already exists!";
466 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
468 ChangeDir( $BuildDir, "CVS checkout directory" );
471 ##############################################################
473 # Check out the llvm tree, saving CVS messages to the cvs log...
475 ##############################################################
477 # Use compression if going over ssh.
478 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
479 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
483 print "CHECKOUT STAGE:\n";
484 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) > $CVSLog 2>&1\n";
486 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
487 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
488 ChangeDir( $BuildDir , "CVS Checkout directory") ;
490 ChangeDir( "llvm" , "llvm source directory") ;
492 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
493 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
496 ##############################################################
498 # Get some static statistics about the current state of CVS
500 # This can probably be put on the server side
502 ##############################################################
503 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
504 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
505 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
506 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
508 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
509 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
510 my $LOC = `utils/countloc.sh`;
512 ##############################################################
514 # Extract some information from the CVS history... use a hash so no duplicate
515 # stuff is stored. This gets the history from the previous days worth
516 # of cvs activit and parses it.
518 ##############################################################
520 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
524 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
525 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
526 #print join "\n", @CVSHistory; print "\n";
528 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
530 # Loop over every record from the CVS history, filling in the hashes.
531 foreach $File (@CVSHistory) {
532 my ($Type, $Date, $UID, $Rev, $Filename);
533 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
534 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
535 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
536 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
537 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
538 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
540 print "UNMATCHABLE: $File\n";
543 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
545 if ($Filename =~ /^llvm/) {
546 if ($Type eq 'M') { # Modified
547 $ModifiedFiles{$Filename} = 1;
548 $UsersCommitted{$UID} = 1;
549 } elsif ($Type eq 'A') { # Added
550 $Addediles{$Filename} = 1;
551 $UsersCommitted{$UID} = 1;
552 } elsif ($Type eq 'R') { # Removed
553 $RemovedFiles{$Filename} = 1;
554 $UsersCommitted{$UID} = 1;
556 $UsersUpdated{$UID} = 1;
565 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
566 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
567 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
568 my $UserCommitList = join "\n", sort keys %UsersCommitted;
569 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
571 ##############################################################
573 # Build the entire tree, saving build messages to the build log
575 ##############################################################
576 if (!$NOCHECKOUT && !$NOBUILD) {
577 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
580 print "CONFIGURE STAGE:\n";
581 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1\n";
583 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
586 print "BUILD STAGE:\n";
587 print "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1\n";
589 # Build the entire tree, capturing the output into $BuildLog
590 system "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1";
594 ##############################################################
596 # Get some statistics about the build...
598 ##############################################################
599 #this can de done on server
600 #my @Linked = split '\n', `grep Linking $BuildLog`;
601 #my $NumExecutables = scalar(grep(/executable/, @Linked));
602 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
603 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
606 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
607 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
608 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
609 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
611 $ConfigTime=-1 unless $ConfigTime;
612 $ConfigWallTime=-1 unless $ConfigWallTime;
614 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
615 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
616 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
617 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
619 $BuildTime=-1 unless $BuildTime;
620 $BuildWallTime=-1 unless $BuildWallTime;
622 my $BuildError = 0, $BuildStatus = "OK";
624 $BuildStatus = "Skipped by user";
627 elsif (`grep '^make[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
628 `grep '^make: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
629 $BuildStatus = "Error: compilation aborted";
631 print "\n***ERROR BUILDING TREE\n\n";
633 if ($BuildError) { $NODEJAGNU=1; }
635 ##############################################################
637 # Running dejagnu tests
639 ##############################################################
640 my $DejangnuTestResults; # String containing the results of the dejagnu
641 my $dejagnu_output = "$DejagnuTestsLog";
645 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
646 print "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1\n";
649 #Run the feature and regression tests, results are put into testrun.sum
650 #Full log in testrun.log
651 system "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1";
653 #Copy the testrun.log and testrun.sum to our webdir
654 CopyFile("test/testrun.log", $DejagnuLog);
655 CopyFile("test/testrun.sum", $DejagnuSum);
656 #can be done on server
657 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
658 $unexpfail_tests = $DejagnuTestResults;
660 #Extract time of dejagnu tests
661 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
662 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
663 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
664 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
665 $DejagnuTestResults = "Dejagnu skipped by user choice." unless $DejagnuTestResults;
666 $DejagnuTime = "0.0" unless $DejagnuTime;
667 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
670 print $DejagnuTestResults;
673 ##############################################################
675 # Get warnings from the build
677 ##############################################################
680 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
681 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
685 foreach $Warning (@Warn) {
686 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
687 $CurDir = $1; # Keep track of directory warning is in...
688 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
692 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
695 my $WarningsFile = join "\n", @Warnings;
696 $WarningsFile =~ s/:[0-9]+:/::/g;
698 # Emit the warnings file, so we can diff...
699 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
700 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "$Prefix-Warnings.txt";
702 # Output something to stdout if something has changed
703 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
704 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
706 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
707 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
711 ##############################################################
713 # If we built the tree successfully, run the nightly programs tests...
715 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" "External")
717 ##############################################################
721 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
723 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
724 #my $ProgramTestLog = "$Prefix-MultiSource-ProgramTest.txt"; #CHANGE ME!
726 # Run the programs tests... creating a report.nightly.csv file
728 print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
729 . "TEST=nightly > $ProgramTestLog 2>&1\n";
730 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
731 . "TEST=nightly > $ProgramTestLog 2>&1";
732 $llcbeta_options=`make print-llcbeta-option`;
736 if (`grep '^make[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
738 $ProgramsTable="Error running test $SubDir\n";
739 print "ERROR TESTING\n";
740 } elsif (`grep '^make[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
742 $ProgramsTable="Makefile error running tests $SubDir!\n";
743 print "ERROR TESTING\n";
748 # Create a list of the tests which were run...
750 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
751 . "| sort > $Prefix-multisourceprogramstable.txt";
753 $ProgramsTable = ReadFile "report.nightly.csv";
755 ChangeDir( "../../..", "Programs Test Parent Directory" );
756 return ($ProgramsTable, $llcbeta_options);
760 if(!$patrickjenkins){
762 print "Modified Multisource Olden test stage\n";
764 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource/");
765 ChangeDir( "../../..", "Programs Test Parent Directory" );
768 WriteFile "$WebDir/multisourceprogramstable.txt", $MultiSourceProgramsTable;
770 if (!$BuildError && $patrickjenkins) {
772 print "SingleSource TEST STAGE\n";
774 ($SingleSourceProgramsTable, $singlesource_llcbeta_options) = TestDirectory("SingleSource");
775 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
777 print "MultiSource TEST STAGE\n";
779 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource");
780 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
781 if ( ! $NOEXTERNALS ) {
783 print "External TEST STAGE\n";
785 ($ExternalProgramsTable, $externalsource_llcbeta_options) = TestDirectory("External");
786 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
787 " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
789 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
791 print "External TEST STAGE SKIPPED\n";
793 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
794 " | sort > $Prefix-Tests.txt";
796 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
800 ##############################################################
803 # gathering tests added removed broken information here
806 ##############################################################
807 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
810 $TestsAdded = "<b>error testing</b><br>";
811 $TestsRemoved = "<b>error testing</b><br>";
812 $TestsFixed = "<b>error testing</b><br>";
813 $TestsBroken = "<b>error testing</b><br>";
815 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "$Prefix-Tests.txt";
817 my @RawTestsAddedArray = split '\n', $RTestsAdded;
818 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
820 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
821 @RawTestsRemovedArray;
822 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
825 foreach $Test (keys %NewTests) {
826 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
827 $TestsAdded = "$TestsAdded$Test\n";
829 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
830 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
832 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
836 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
837 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
840 #print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
841 #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
842 #print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
843 #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
845 #$TestsAdded = AddPreTag $TestsAdded;
846 #$TestsRemoved = AddPreTag $TestsRemoved;
847 #$TestsFixed = AddPreTag $TestsFixed;
848 #$TestsBroken = AddPreTag $TestsBroken;
851 ##############################################################
853 # If we built the tree successfully, runs of the Olden suite with
854 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
856 ##############################################################
858 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
859 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
860 $MachCodeSize) = ("","","","","","","");
861 if (!$NORUNNINGTESTS) {
862 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
863 "Olden Test Directory");
865 # Clean out previous results...
866 system "$NICE make $MAKEOPTS clean > /dev/null 2>&1";
868 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
869 # GET_STABLE_NUMBERS enabled!
870 if( $VERBOSE ) { print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
871 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1\n"; }
872 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
873 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
874 system "cp report.nightly.csv $OldenTestsLog";
876 #system "gunzip ${OldenTestsLog}.gz";
879 # Now we know we have $OldenTestsLog as the raw output file. Split
880 # it up into records and read the useful information.
881 #my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
882 #shift @Records; # Delete the first (garbage) record
884 # Loop over all of the records, summarizing them into rows for the running
886 #my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
887 #foreach $Rec (@Records) {
888 #my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
889 #my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
890 #my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
891 #my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
892 #my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
893 #my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
895 #$NATTime .= " " . FormatTime($rNATTime);
896 #$CBETime .= " " . FormatTime($rCBETime);
897 #$LLCTime .= " " . FormatTime($rLLCTime);
898 #$JITTime .= " " . FormatTime($rJITTime);
899 #$OptTime .= " $rOptTime";
900 #$BytecodeSize .= " $rBytecodeSize";
903 # Now that we have all of the numbers we want, add them to the running totals
905 #AddRecord($NATTime, "running_Olden_nat_time.txt", $WebDir);
906 #AddRecord($CBETime, "running_Olden_cbe_time.txt", $WebDir);
907 #AddRecord($LLCTime, "running_Olden_llc_time.txt", $WebDir);
908 #AddRecord($JITTime, "running_Olden_jit_time.txt", $WebDir);
909 #AddRecord($OptTime, "running_Olden_opt_time.txt", $WebDir);
910 #AddRecord($BytecodeSize, "running_Olden_bytecode.txt", $WebDir);
914 ##############################################################
916 # Place all the logs neatly into one humungous file
918 ##############################################################
920 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
922 $machine_data = "uname: ".`uname -a`.
923 "hardware: ".`uname -m`.
926 "date: ".`date \"+20%y-%m-%d\"`.
927 "time: ".`date +\"%H:%M:%S\"`;
931 @CVS_DATA = ReadFile "$CVSLog";
932 $cvs_data = join("\n", @CVS_DATA);
936 @BUILD_DATA = ReadFile "$BuildLog";
937 $build_data = join("\n", @BUILD_DATA);
941 my $dejagnutests_log;
942 my $dejagnutests_sum;
943 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
944 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
945 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
946 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
950 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
951 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
953 my $gcc_version_long = `gcc --version`;
954 @GCC_VERSION = split "\n", $gcc_version_long;
955 my $gcc_version = $GCC_VERSION[0];
957 ##############################################################
959 # Send data via a post request
961 ##############################################################
963 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
966 my $host = "llvm.org";
967 my $file = "/nightlytest/NightlyTestAccept.cgi";
968 my %hash_of_data = ('machine_data' => $machine_data,
969 'build_data' => $build_data,
970 'gcc_version' => $gcc_version,
971 'nickname' => $nickname,
972 'dejagnutime_wall' => $DejagnuWallTime,
973 'dejagnutime_cpu' => $DejagnuTime,
974 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
975 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
976 'configtime_wall' => $ConfigWallTime,
977 'configtime_cpu'=> $ConfigTime,
978 'buildtime_wall' => $BuildWallTime,
979 'buildtime_cpu' => $BuildTime,
980 'warnings' => $WarningsFile,
981 'cvsusercommitlist' => $UserCommitList,
982 'cvsuserupdatelist' => $UserUpdateList,
983 'cvsaddedfiles' => $CVSAddedFiles,
984 'cvsmodifiedfiles' => $CVSModifiedFiles,
985 'cvsremovedfiles' => $CVSRemovedFiles,
986 'lines_of_code' => $LOC,
987 'cvs_file_count' => $NumFilesInCVS,
988 'cvs_dir_count' => $NumDirsInCVS,
989 'buildstatus' => $BuildStatus,
990 'singlesource_programstable' => $SingleSourceProgramsTable,
991 'multisource_programstable' => $MultiSourceProgramsTable,
992 'externalsource_programstable' => $ExternalSourceProgramsTable,
993 'llcbeta_options' => $multisource_llcbeta_options,
994 'warnings_removed' => $WarningsRemoved,
995 'warnings_added' => $WarningsAdded,
996 'newly_passing_tests' => $TestsFixed,
997 'newly_failing_tests' => $TestsBroken,
998 'new_tests' => $TestsAdded,
999 'removed_tests' => $TestsRemoved,
1000 'unexpfail_tests' => $unexpfail_tests,
1001 'dejagnutests_log' => $dejagnutests_log,
1002 'dejagnutests_sum' => $dejagnutests_sum);
1007 print "============================\n";
1008 foreach $x(keys %hash_of_data){
1009 print "$x => $hash_of_data{$x}\n";
1013 my $response = SendData $host,$file,\%hash_of_data;
1014 print "============================\n$response";
1017 ##############################################################
1019 # Remove the cvs tree...
1021 ##############################################################
1022 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);