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 # -noremoveresults Do not remove the WEBDIR after it has been built.
24 # -nobuild Do not build llvm. If tests are enabled perform them
25 # on the llvm build specified in the build directory
26 # -notest Do not even attempt to run the test programs. Implies
28 # -norunningtests Do not run the Olden benchmark suite with
29 # LARGE_PROBLEM_SIZE enabled.
30 # -noexternals Do not run the external tests (for cases where povray
31 # or SPEC are not installed)
32 # -with-externals Specify a directory where the external tests are located.
33 # -nodejagnu Do not run feature or regression tests
34 # -parallel Run two parallel jobs with GNU Make.
35 # -release Build an LLVM Release version
36 # -enable-llcbeta Enable testing of beta features in llc.
37 # -disable-llc Disable LLC tests in the nightly tester.
38 # -disable-jit Disable JIT tests in the nightly tester.
39 # -disable-cbe Disable C backend tests in the nightly tester.
40 # -verbose Turn on some debug output
41 # -debug Print information useful only to maintainers of this script.
42 # -nice Checkout/Configure/Build with "nice" to reduce impact
44 # -f2c Next argument specifies path to F2C utility
45 # -nickname The next argument specifieds the nickname this script
46 # will submit to the nightlytest results repository.
47 # -gccpath Path to gcc/g++ used to build LLVM
48 # -cvstag Check out a specific CVS tag to build LLVM (useful for
49 # testing release branches)
50 # -target Specify the target triplet
51 # -cflags Next argument specifies that C compilation options that
52 # override the default.
53 # -cxxflags Next argument specifies that C++ compilation options that
54 # override the default.
55 # -ldflags Next argument specifies that linker options that override
57 # -extraflags Next argument specifies extra options that are passed to
60 # ---------------- Options to configure llvm-test ----------------------------
61 # -spec2000path Path to the benchspec directory in the SPEC 2000 distro
62 # -spec95path Path to the benchspec directory in the SPEC 95 distro.
63 # -povraypath Path to the povray sources
64 # -namdpath Path to the namd sources
66 # CVSROOT is the CVS repository from which the tree will be checked out,
67 # specified either in the full :method:user@host:/dir syntax, or
68 # just /dir if using a local repo.
69 # BUILDDIR is the directory where sources for this test run will be checked out
70 # AND objects for this test run will be built. This directory MUST NOT
71 # exist before the script is run; it will be created by the cvs checkout
72 # process and erased (unless -noremove is specified; see above.)
73 # WEBDIR is the directory into which the test results web page will be written,
74 # AND in which the "index.html" is assumed to be a symlink to the most recent
75 # copy of the results. This directory will be created if it does not exist.
76 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
77 # to. This is the same as you would have for a normal LLVM build.
79 ##############################################################
81 # Getting environment variables
83 ##############################################################
84 my $HOME = $ENV{'HOME'};
85 my $CVSRootDir = $ENV{'CVSROOT'};
86 $CVSRootDir = "/home/vadve/shared/PublicCVS"
88 my $BuildDir = $ENV{'BUILDDIR'};
89 $BuildDir = "$HOME/buildtest"
91 my $WebDir = $ENV{'WEBDIR'};
92 $WebDir = "$HOME/cvs/testresults-X86"
95 ##############################################################
97 # Calculate the date prefix...
99 ##############################################################
101 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
102 my $DateString = strftime "%B %d, %Y", localtime;
103 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
105 ##############################################################
109 ##############################################################
115 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
117 last if /^--$/; # Stop processing arguments on --
119 # List command line options here...
120 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
121 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
122 if (/^-noremove$/) { $NOREMOVE = 1; next; }
123 if (/^-noremoveresults$/) { $NOREMOVERESULTS = 1; next; }
124 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
125 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
126 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
127 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O2"; next; }
128 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
129 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
130 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
131 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
132 $CONFIGUREARGS .= " --disable-jit"; next; }
133 if (/^-verbose$/) { $VERBOSE = 1; next; }
134 if (/^-debug$/) { $DEBUG = 1; next; }
135 if (/^-nice$/) { $NICE = "nice "; next; }
137 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
139 if (/^-with-externals/) {
140 $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next;
142 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
143 if (/^-gccpath/) { $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;}
144 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } else{ $CVSCOOPT="";}
146 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
149 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
152 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
155 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
157 if (/^-compileflags/) {
158 $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
160 if (/^-extraflags/) {
161 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
163 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
164 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
165 if (/^-nobuild$/) { $NOBUILD = 1; next; }
166 if (/^-spec2000path$/) {
167 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
168 } else{ $LLVMTESTCONFIGARGS=""; }
169 if (/^-spec95path$/) {
170 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
172 if (/^-povraypath$/) {
173 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
176 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
178 print "Unknown option: $_ : ignoring!\n";
181 if ($ENV{'LLVMGCCDIR'}) {
182 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
184 if ($CONFIGUREARGS !~ /--disable-jit/) {
185 $CONFIGUREARGS .= " --enable-jit";
188 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
191 $CVSRootDir = $ARGV[0];
192 $BuildDir = $ARGV[1];
196 ##############################################################
198 #define the file names we'll use
200 ##############################################################
201 my $Prefix = "$WebDir/$DATE";
202 my $BuildLog = "$Prefix-Build-Log.txt";
203 my $CVSLog = "$Prefix-CVS-Log.txt";
204 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
205 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
206 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
207 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
208 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
209 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
210 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
213 warn "$WebDir did not exist; creating it.\n";
217 print "INITIALIZED\n";
218 print "CVS Root = $CVSRootDir\n";
219 print "BuildDir = $BuildDir\n";
220 print "WebDir = $WebDir\n";
221 print "Prefix = $Prefix\n";
222 print "CVSLog = $CVSLog\n";
223 print "BuildLog = $BuildLog\n";
226 ##############################################################
230 ##############################################################
234 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
239 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241 # DiffFiles - Diff the current version of the file against the last version of
242 # the file, reporting things added and removed. This is used to report, for
243 # example, added and removed warnings. This returns a pair (added, removed)
245 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248 my @Others = GetDir $Suffix;
249 if (@Others == 0) { # No other files? We added all entries...
250 return (`cat $WebDir/$DATE$Suffix`, "");
252 # Diff the files now...
253 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
254 my $Added = join "\n", grep /^</, @Diffs;
255 my $Removed = join "\n", grep /^>/, @Diffs;
257 $Removed =~ s/^> //gm;
258 return ($Added, $Removed);
261 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
262 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263 sub GetRegex { # (Regex with ()'s, value)
271 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274 my ($Regex, $Num, $Regex2, $File) = @_;
275 my @Items = split "\n", `grep '$Regex' $File`;
276 return GetRegex $Regex2, $Items[$Num];
279 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281 sub ChangeDir { # directory, logical name
282 my ($dir,$name) = @_;
284 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
285 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
288 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 if (open (FILE, $_[0])) {
298 print "Could not open file '$_[0]' for reading!";
303 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305 sub WriteFile { # (filename, contents)
306 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
311 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313 sub CopyFile { #filename, newfile
314 my ($file, $newfile) = @_;
316 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
317 copy($file, $newfile);
320 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
323 my ($Val, $Filename,$WebDir) = @_;
325 if (open FILE, "$WebDir/$Filename") {
326 @Records = grep !/$DATE/, split "\n", <FILE>;
329 push @Records, "$DATE: $Val";
330 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
333 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335 # FormatTime - Convert a time from 1m23.45 into 83.45
337 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
341 $Time = sprintf("%7.4f", $1*60.0+$2);
346 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348 sub GetDejagnuTestResults { # (filename, log)
349 my ($filename, $DejagnuLog) = @_;
352 $/ = "\n"; #Make sure we're going line at a time.
354 print "DEJAGNU TEST RESULTS:\n";
356 if (open SRCHFILE, $filename) {
357 # Process test results
359 my $should_break = 1;
362 while ( <SRCHFILE> ) {
363 if ( length($_) > 1 ) {
365 if ( m/^XPASS:/ || m/^FAIL:/ ) {
368 push(@lines, "UNEXPECTED TEST RESULTS\n");
371 push(@lines, "$_\n");
374 push(@lines, "$_\n");
377 } #elsif ( m/Summary/ ) {
378 # if ( $first_list ) {
379 # push(@lines, "PERFECT!");
380 # print " PERFECT!\n";
382 # push(@lines, "</li></ol>\n");
384 # push(@lines, "STATISTICS\n");
385 # print "\nDEJAGNU STATISTICS:\n";
390 elsif ( $readingsum ) {
400 my $content = join("", @lines);
405 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407 # This function acts as a mini web browswer submitting data
408 # to our central server via the post method
410 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
417 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
418 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die "Bad socket\n";
419 connect SOCK, $socketaddr or die "Bad connection\n";
420 select((select(SOCK), $| = 1)[0]);
422 #creating content here
424 foreach $key (keys (%$variables)){
425 $value = $variables->{$key};
426 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
427 $content .= "$key=$value&";
430 $length = length($content);
432 my $send= "POST $file HTTP/1.0\n";
433 $send.= "Content-Type: application/x-www-form-urlencoded\n";
434 $send.= "Content-length: $length\n\n";
445 foreach $x(keys(%hash_of_data)){
446 $sentdata.= "$x => $hash_of_data{$x}\n";
448 WriteFile "$Prefix-sentdata.txt", $sentdata;
455 ##############################################################
457 # Create the CVS repository directory
459 ##############################################################
463 system "rm -rf $BuildDir";
465 die "CVS checkout directory $BuildDir already exists!";
468 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
470 ChangeDir( $BuildDir, "CVS checkout directory" );
473 ##############################################################
475 # Check out the llvm tree, saving CVS messages to the cvs log...
477 ##############################################################
479 # Use compression if going over ssh.
480 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
481 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
485 print "CHECKOUT STAGE:\n";
486 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) > $CVSLog 2>&1\n";
488 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
489 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
490 ChangeDir( $BuildDir , "CVS Checkout directory") ;
492 ChangeDir( "llvm" , "llvm source directory") ;
494 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
495 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
498 ##############################################################
500 # Get some static statistics about the current state of CVS
502 # This can probably be put on the server side
504 ##############################################################
505 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
506 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
507 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
508 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
510 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
511 my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
512 my $LOC = `utils/countloc.sh`;
514 ##############################################################
516 # Extract some information from the CVS history... use a hash so no duplicate
517 # stuff is stored. This gets the history from the previous days worth
518 # of cvs activit and parses it.
520 ##############################################################
522 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
526 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
527 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
528 #print join "\n", @CVSHistory; print "\n";
530 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
532 # Loop over every record from the CVS history, filling in the hashes.
533 foreach $File (@CVSHistory) {
534 my ($Type, $Date, $UID, $Rev, $Filename);
535 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
536 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
537 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
538 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
539 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
540 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
542 print "UNMATCHABLE: $File\n";
545 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
547 if ($Filename =~ /^llvm/) {
548 if ($Type eq 'M') { # Modified
549 $ModifiedFiles{$Filename} = 1;
550 $UsersCommitted{$UID} = 1;
551 } elsif ($Type eq 'A') { # Added
552 $Addediles{$Filename} = 1;
553 $UsersCommitted{$UID} = 1;
554 } elsif ($Type eq 'R') { # Removed
555 $RemovedFiles{$Filename} = 1;
556 $UsersCommitted{$UID} = 1;
558 $UsersUpdated{$UID} = 1;
567 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
568 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
569 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
570 my $UserCommitList = join "\n", sort keys %UsersCommitted;
571 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
573 ##############################################################
575 # Build the entire tree, saving build messages to the build log
577 ##############################################################
578 if (!$NOCHECKOUT && !$NOBUILD) {
579 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
582 print "CONFIGURE STAGE:\n";
583 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1\n";
585 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
588 print "BUILD STAGE:\n";
589 print "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1\n";
591 # Build the entire tree, capturing the output into $BuildLog
592 system "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1";
596 ##############################################################
598 # Get some statistics about the build...
600 ##############################################################
601 #this can de done on server
602 #my @Linked = split '\n', `grep Linking $BuildLog`;
603 #my $NumExecutables = scalar(grep(/executable/, @Linked));
604 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
605 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
608 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
609 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
610 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
611 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
613 $ConfigTime=-1 unless $ConfigTime;
614 $ConfigWallTime=-1 unless $ConfigWallTime;
616 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
617 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
618 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
619 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
621 $BuildTime=-1 unless $BuildTime;
622 $BuildWallTime=-1 unless $BuildWallTime;
624 my $BuildError = 0, $BuildStatus = "OK";
626 $BuildStatus = "Skipped by user";
629 elsif (`grep '^make[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
630 `grep '^make: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
631 $BuildStatus = "Error: compilation aborted";
633 print "\n***ERROR BUILDING TREE\n\n";
635 if ($BuildError) { $NODEJAGNU=1; }
637 ##############################################################
639 # Running dejagnu tests
641 ##############################################################
642 my $DejangnuTestResults; # String containing the results of the dejagnu
643 my $dejagnu_output = "$DejagnuTestsLog";
647 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
648 print "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1\n";
651 #Run the feature and regression tests, results are put into testrun.sum
652 #Full log in testrun.log
653 system "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1";
655 #Copy the testrun.log and testrun.sum to our webdir
656 CopyFile("test/testrun.log", $DejagnuLog);
657 CopyFile("test/testrun.sum", $DejagnuSum);
658 #can be done on server
659 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
660 $unexpfail_tests = $DejagnuTestResults;
662 #Extract time of dejagnu tests
663 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
664 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
665 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
666 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
667 $DejagnuTestResults = "Dejagnu skipped by user choice." unless $DejagnuTestResults;
668 $DejagnuTime = "0.0" unless $DejagnuTime;
669 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
672 print $DejagnuTestResults;
675 ##############################################################
677 # Get warnings from the build
679 ##############################################################
682 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
683 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
687 foreach $Warning (@Warn) {
688 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
689 $CurDir = $1; # Keep track of directory warning is in...
690 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
694 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
697 my $WarningsFile = join "\n", @Warnings;
698 $WarningsFile =~ s/:[0-9]+:/::/g;
700 # Emit the warnings file, so we can diff...
701 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
702 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
704 # Output something to stdout if something has changed
705 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
706 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
708 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
709 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
713 ##############################################################
715 # If we built the tree successfully, run the nightly programs tests...
717 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" "External")
719 ##############################################################
723 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
725 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
726 #my $ProgramTestLog = "$Prefix-MultiSource-ProgramTest.txt"; #CHANGE ME!
728 # Run the programs tests... creating a report.nightly.csv file
730 print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
731 . "TEST=nightly > $ProgramTestLog 2>&1\n";
732 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
733 . "TEST=nightly > $ProgramTestLog 2>&1";
734 $llcbeta_options=`make print-llcbeta-option`;
738 if (`grep '^make[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
740 $ProgramsTable="Error running test $SubDir\n";
741 print "ERROR TESTING\n";
742 } elsif (`grep '^make[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
744 $ProgramsTable="Makefile error running tests $SubDir!\n";
745 print "ERROR TESTING\n";
750 # Create a list of the tests which were run...
752 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
753 . "| sort > $Prefix-multisourceprogramstable.txt";
755 $ProgramsTable = ReadFile "report.nightly.csv";
757 ChangeDir( "../../..", "Programs Test Parent Directory" );
758 return ($ProgramsTable, $llcbeta_options);
762 if(!$patrickjenkins){
764 print "Modified Multisource Olden test stage\n";
766 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource/");
767 ChangeDir( "../../..", "Programs Test Parent Directory" );
770 WriteFile "$WebDir/multisourceprogramstable.txt", $MultiSourceProgramsTable;
772 if (!$BuildError && $patrickjenkins) {
774 print "SingleSource TEST STAGE\n";
776 ($SingleSourceProgramsTable, $singlesource_llcbeta_options) = TestDirectory("SingleSource");
777 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
779 print "MultiSource TEST STAGE\n";
781 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource");
782 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
783 if ( ! $NOEXTERNALS ) {
785 print "External TEST STAGE\n";
787 ($ExternalProgramsTable, $externalsource_llcbeta_options) = TestDirectory("External");
788 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
789 " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
791 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
793 print "External TEST STAGE SKIPPED\n";
795 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
796 " | sort > $Prefix-Tests.txt";
798 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
802 ##############################################################
805 # gathering tests added removed broken information here
808 ##############################################################
809 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
812 $TestsAdded = "<b>error testing</b><br>";
813 $TestsRemoved = "<b>error testing</b><br>";
814 $TestsFixed = "<b>error testing</b><br>";
815 $TestsBroken = "<b>error testing</b><br>";
817 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
819 my @RawTestsAddedArray = split '\n', $RTestsAdded;
820 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
822 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
823 @RawTestsRemovedArray;
824 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
827 foreach $Test (keys %NewTests) {
828 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
829 $TestsAdded = "$TestsAdded$Test\n";
831 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
832 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
834 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
838 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
839 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
842 #print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
843 #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
844 #print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
845 #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
847 #$TestsAdded = AddPreTag $TestsAdded;
848 #$TestsRemoved = AddPreTag $TestsRemoved;
849 #$TestsFixed = AddPreTag $TestsFixed;
850 #$TestsBroken = AddPreTag $TestsBroken;
853 ##############################################################
855 # If we built the tree successfully, runs of the Olden suite with
856 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
858 ##############################################################
860 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
861 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
862 $MachCodeSize) = ("","","","","","","");
863 if (!$NORUNNINGTESTS) {
864 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
865 "Olden Test Directory");
867 # Clean out previous results...
868 system "$NICE make $MAKEOPTS clean > /dev/null 2>&1";
870 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
871 # GET_STABLE_NUMBERS enabled!
872 if( $VERBOSE ) { print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
873 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1\n"; }
874 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
875 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
876 system "cp report.nightly.csv $OldenTestsLog";
878 #system "gunzip ${OldenTestsLog}.gz";
881 # Now we know we have $OldenTestsLog as the raw output file. Split
882 # it up into records and read the useful information.
883 #my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
884 #shift @Records; # Delete the first (garbage) record
886 # Loop over all of the records, summarizing them into rows for the running
888 #my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
889 #foreach $Rec (@Records) {
890 #my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
891 #my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
892 #my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
893 #my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
894 #my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
895 #my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
897 #$NATTime .= " " . FormatTime($rNATTime);
898 #$CBETime .= " " . FormatTime($rCBETime);
899 #$LLCTime .= " " . FormatTime($rLLCTime);
900 #$JITTime .= " " . FormatTime($rJITTime);
901 #$OptTime .= " $rOptTime";
902 #$BytecodeSize .= " $rBytecodeSize";
905 # Now that we have all of the numbers we want, add them to the running totals
907 #AddRecord($NATTime, "running_Olden_nat_time.txt", $WebDir);
908 #AddRecord($CBETime, "running_Olden_cbe_time.txt", $WebDir);
909 #AddRecord($LLCTime, "running_Olden_llc_time.txt", $WebDir);
910 #AddRecord($JITTime, "running_Olden_jit_time.txt", $WebDir);
911 #AddRecord($OptTime, "running_Olden_opt_time.txt", $WebDir);
912 #AddRecord($BytecodeSize, "running_Olden_bytecode.txt", $WebDir);
916 ##############################################################
918 # Place all the logs neatly into one humungous file
920 ##############################################################
922 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
924 $machine_data = "uname: ".`uname -a`.
925 "hardware: ".`uname -m`.
928 "date: ".`date \"+20%y-%m-%d\"`.
929 "time: ".`date +\"%H:%M:%S\"`;
933 @CVS_DATA = ReadFile "$CVSLog";
934 $cvs_data = join("\n", @CVS_DATA);
938 @BUILD_DATA = ReadFile "$BuildLog";
939 $build_data = join("\n", @BUILD_DATA);
943 my $dejagnutests_log;
944 my $dejagnutests_sum;
945 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
946 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
947 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
948 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
952 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
953 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
955 my $gcc_version_long = `gcc --version`;
956 @GCC_VERSION = split "\n", $gcc_version_long;
957 my $gcc_version = $GCC_VERSION[0];
959 ##############################################################
961 # Send data via a post request
963 ##############################################################
965 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
968 my $host = "llvm.org";
969 my $file = "/nightlytest/NightlyTestAccept.cgi";
970 my %hash_of_data = ('machine_data' => $machine_data,
971 'build_data' => $build_data,
972 'gcc_version' => $gcc_version,
973 'nickname' => $nickname,
974 'dejagnutime_wall' => $DejagnuWallTime,
975 'dejagnutime_cpu' => $DejagnuTime,
976 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
977 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
978 'configtime_wall' => $ConfigWallTime,
979 'configtime_cpu'=> $ConfigTime,
980 'buildtime_wall' => $BuildWallTime,
981 'buildtime_cpu' => $BuildTime,
982 'warnings' => $WarningsFile,
983 'cvsusercommitlist' => $UserCommitList,
984 'cvsuserupdatelist' => $UserUpdateList,
985 'cvsaddedfiles' => $CVSAddedFiles,
986 'cvsmodifiedfiles' => $CVSModifiedFiles,
987 'cvsremovedfiles' => $CVSRemovedFiles,
988 'lines_of_code' => $LOC,
989 'cvs_file_count' => $NumFilesInCVS,
990 'cvs_dir_count' => $NumDirsInCVS,
991 'buildstatus' => $BuildStatus,
992 'singlesource_programstable' => $SingleSourceProgramsTable,
993 'multisource_programstable' => $MultiSourceProgramsTable,
994 'externalsource_programstable' => $ExternalSourceProgramsTable,
995 'llcbeta_options' => $multisource_llcbeta_options,
996 'warnings_removed' => $WarningsRemoved,
997 'warnings_added' => $WarningsAdded,
998 'newly_passing_tests' => $TestsFixed,
999 'newly_failing_tests' => $TestsBroken,
1000 'new_tests' => $TestsAdded,
1001 'removed_tests' => $TestsRemoved,
1002 'unexpfail_tests' => $unexpfail_tests,
1003 'dejagnutests_log' => $dejagnutests_log,
1004 'dejagnutests_sum' => $dejagnutests_sum);
1009 print "============================\n";
1010 foreach $x(keys %hash_of_data){
1011 print "$x => $hash_of_data{$x}\n";
1015 my $response = SendData $host,$file,\%hash_of_data;
1016 print "============================\n$response";
1019 ##############################################################
1021 # Remove the cvs tree...
1023 ##############################################################
1024 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
1025 system ( "$NICE rm -rf $WebDir") if (!$NOCHECKOUT and !$NOREMOVE and !NOREMOVERESULTS);