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 # -release-asserts Build an LLVM ReleaseAsserts version
33 # -enable-llcbeta Enable testing of beta features in llc.
34 # -disable-llc Disable LLC tests in the nightly tester.
35 # -disable-jit Disable JIT tests in the nightly tester.
36 # -disable-cbe Disable C backend tests in the nightly tester.
37 # -verbose Turn on some debug output
38 # -debug Print information useful only to maintainers of this script.
39 # -nice Checkout/Configure/Build with "nice" to reduce impact
41 # -f2c Next argument specifies path to F2C utility
42 # -nickname The next argument specifieds the nickname this script
43 # will submit to the nightlytest results repository.
44 # -gccpath Path to gcc/g++ used to build LLVM
45 # -cvstag Check out a specific CVS tag to build LLVM (useful for
46 # testing release branches)
47 # -target Specify the target triplet
48 # -cflags Next argument specifies that C compilation options that
49 # override the default.
50 # -cxxflags Next argument specifies that C++ compilation options that
51 # override the default.
52 # -ldflags Next argument specifies that linker options that override
54 # -compileflags Next argument specifies extra options passed to make when
56 # -use-gmake Use gmake instead of the default make command to build
59 # ---------------- Options to configure llvm-test ----------------------------
60 # -extraflags Next argument specifies extra options that are passed to
62 # -noexternals Do not run the external tests (for cases where povray
63 # or SPEC are not installed)
64 # -with-externals Specify a directory where the external tests are located.
65 # -submit-server Specifies a server to submit the test results too. If this
66 # option is not specified it defaults to
67 # llvm.org. This is basically just the address of the
69 # -submit-script Specifies which script to call on the submit server. If
70 # this option is not specified it defaults to
71 # /nightlytest/NightlyTestAccept.php. This is basically
72 # everything after the www.yourserver.org.
74 # CVSROOT is the CVS repository from which the tree will be checked out,
75 # specified either in the full :method:user@host:/dir syntax, or
76 # just /dir if using a local repo.
77 # BUILDDIR is the directory where sources for this test run will be checked out
78 # AND objects for this test run will be built. This directory MUST NOT
79 # exist before the script is run; it will be created by the cvs checkout
80 # process and erased (unless -noremove is specified; see above.)
81 # WEBDIR is the directory into which the test results web page will be written,
82 # AND in which the "index.html" is assumed to be a symlink to the most recent
83 # copy of the results. This directory will be created if it does not exist.
84 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
85 # to. This is the same as you would have for a normal LLVM build.
87 ##############################################################
89 # Getting environment variables
91 ##############################################################
92 my $HOME = $ENV{'HOME'};
93 my $CVSRootDir = $ENV{'CVSROOT'};
94 $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
95 my $BuildDir = $ENV{'BUILDDIR'};
96 $BuildDir = "$HOME/buildtest" unless $BuildDir;
97 my $WebDir = $ENV{'WEBDIR'};
98 $WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
100 ##############################################################
102 # Calculate the date prefix...
104 ##############################################################
106 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
107 my $DateString = strftime "%B %d, %Y", localtime;
108 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
110 ##############################################################
114 ##############################################################
120 $SUBMITSERVER = "llvm.org";
121 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
123 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
125 last if /^--$/; # Stop processing arguments on --
127 # List command line options here...
128 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
129 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
130 if (/^-noremove$/) { $NOREMOVE = 1; next; }
131 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
132 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
133 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
134 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
135 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
136 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
137 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
138 "DISABLE-ASSERTIONS=1 ".
139 "OPTIMIZE_OPTION=-O2";
140 $BUILDTYPE="release-asserts"; next;}
141 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
142 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
143 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
144 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
145 $CONFIGUREARGS .= " --disable-jit"; next; }
146 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
147 if (/^-verbose$/) { $VERBOSE = 1; next; }
148 if (/^-debug$/) { $DEBUG = 1; next; }
149 if (/^-nice$/) { $NICE = "nice "; next; }
150 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
152 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
154 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
155 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
156 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
157 if (/^-gccpath/) { $CONFIGUREARGS .=
158 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
159 $GCCPATH=$ARGV[0]; shift; next; }
160 else { $GCCPATH=""; }
161 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
162 else { $CVSCOOPT="";}
163 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
165 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
167 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
169 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
171 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
172 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
173 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
174 if (/^-extraflags/) { $CONFIGUREARGS .=
175 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
176 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
177 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
178 if (/^-nobuild$/) { $NOBUILD = 1; next; }
179 print "Unknown option: $_ : ignoring!\n";
182 if ($ENV{'LLVMGCCDIR'}) {
183 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
185 if ($CONFIGUREARGS !~ /--disable-jit/) {
186 $CONFIGUREARGS .= " --enable-jit";
189 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
193 print "Must specify 0 or 3 options!";
197 $CVSRootDir = $ARGV[0];
198 $BuildDir = $ARGV[1];
202 if ($CVSRootDir eq "" or
205 die("please specify a cvs root directory, a build directory, and a ".
209 if ($nickname eq "") {
210 die ("Please invoke NewNightlyTest.pl with command line option " .
211 "\"-nickname <nickname>\"");
214 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
215 $BUILDTYPE = "debug";
218 ##############################################################
220 #define the file names we'll use
222 ##############################################################
223 my $Prefix = "$WebDir/$DATE";
224 my $BuildLog = "$Prefix-Build-Log.txt";
225 my $CVSLog = "$Prefix-CVS-Log.txt";
226 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
227 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
228 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
229 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
230 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
231 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
232 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
236 warn "$WebDir did not exist; creating it.\n";
241 print "INITIALIZED\n";
242 print "CVS Root = $CVSRootDir\n";
243 print "BuildDir = $BuildDir\n";
244 print "WebDir = $WebDir\n";
245 print "Prefix = $Prefix\n";
246 print "CVSLog = $CVSLog\n";
247 print "BuildLog = $BuildLog\n";
250 ##############################################################
254 ##############################################################
258 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
263 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
265 # DiffFiles - Diff the current version of the file against the last version of
266 # the file, reporting things added and removed. This is used to report, for
267 # example, added and removed warnings. This returns a pair (added, removed)
269 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272 my @Others = GetDir $Suffix;
273 if (@Others == 0) { # No other files? We added all entries...
274 return (`cat $WebDir/$DATE$Suffix`, "");
276 # Diff the files now...
277 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
278 my $Added = join "\n", grep /^</, @Diffs;
279 my $Removed = join "\n", grep /^>/, @Diffs;
281 $Removed =~ s/^> //gm;
282 return ($Added, $Removed);
285 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287 sub GetRegex { # (Regex with ()'s, value)
294 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297 my ($Regex, $Num, $Regex2, $File) = @_;
298 my @Items = split "\n", `grep '$Regex' $File`;
299 return GetRegex $Regex2, $Items[$Num];
302 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304 sub ChangeDir { # directory, logical name
305 my ($dir,$name) = @_;
307 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
308 $result = chdir($dir);
310 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
316 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319 if (open (FILE, $_[0])) {
326 print "Could not open file '$_[0]' for reading!\n";
331 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333 sub WriteFile { # (filename, contents)
334 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
339 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
341 sub CopyFile { #filename, newfile
342 my ($file, $newfile) = @_;
344 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
345 copy($file, $newfile);
348 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351 my ($Val, $Filename,$WebDir) = @_;
353 if (open FILE, "$WebDir/$Filename") {
354 @Records = grep !/$DATE/, split "\n", <FILE>;
357 push @Records, "$DATE: $Val";
358 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
361 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363 # FormatTime - Convert a time from 1m23.45 into 83.45
365 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
369 $Time = sprintf("%7.4f", $1*60.0+$2);
374 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376 # This function is meant to read in the dejagnu sum file and
377 # return a string with only the results (i.e. PASS/FAIL/XPASS/
380 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381 sub GetDejagnuTestResults { # (filename, log)
382 my ($filename, $DejagnuLog) = @_;
384 $/ = "\n"; #Make sure we're going line at a time.
386 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
388 if (open SRCHFILE, $filename) {
389 # Process test results
390 while ( <SRCHFILE> ) {
391 if ( length($_) > 1 ) {
393 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
394 push(@lines, "$1: test/$2");
401 my $content = join("\n", @lines);
407 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409 # This function acts as a mini web browswer submitting data
410 # to our central server via the post method
412 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
419 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
420 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
422 connect SOCK, $socketaddr or die "Bad connection\n";
423 select((select(SOCK), $| = 1)[0]);
425 #creating content here
427 foreach $key (keys (%$variables)){
428 $value = $variables->{$key};
429 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
430 $content .= "$key=$value&";
433 $length = length($content);
435 my $send= "POST $file HTTP/1.0\n";
436 $send.= "Content-Type: application/x-www-form-urlencoded\n";
437 $send.= "Content-length: $length\n\n";
448 foreach $x (keys (%$variables)){
449 $value = $variables->{$x};
450 $sentdata.= "$x => $value\n";
452 WriteFile "$Prefix-sentdata.txt", $sentdata;
458 ##############################################################
460 # Getting Start timestamp
462 ##############################################################
463 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
465 ##############################################################
467 # Create the CVS repository directory
469 ##############################################################
474 print "Build directory exists! Removing it\n";
476 system "rm -rf $BuildDir";
477 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
480 print "Build directory exists!\n";
484 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
487 ChangeDir( $BuildDir, "CVS checkout directory" );
490 ##############################################################
492 # Check out the llvm tree, saving CVS messages to the cvs log...
494 ##############################################################
496 # Use compression if going over ssh.
498 if $CVSRootDir =~ /^:ext:/;
499 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
502 print "CHECKOUT STAGE:\n";
503 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
506 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
507 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
508 ChangeDir( $BuildDir , "CVS Checkout directory") ;
510 ChangeDir( "llvm" , "llvm source directory") ;
512 ##############################################################
514 # Get some static statistics about the current state of CVS
516 # This can probably be put on the server side
518 ##############################################################
519 my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
520 my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
521 my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
522 my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
524 my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
526 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
528 ##############################################################
530 # Extract some information from the CVS history... use a hash so no duplicate
531 # stuff is stored. This gets the history from the previous days worth
532 # of cvs activity and parses it.
534 ##############################################################
536 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
540 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
541 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
542 #print join "\n", @CVSHistory; print "\n";
544 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
546 # Loop over every record from the CVS history, filling in the hashes.
547 foreach $File (@CVSHistory) {
548 my ($Type, $Date, $UID, $Rev, $Filename);
549 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
550 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
551 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
552 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
553 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
554 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
556 print "UNMATCHABLE: $File\n";
559 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
561 if ($Filename =~ /^llvm/) {
562 if ($Type eq 'M') { # Modified
563 $ModifiedFiles{$Filename} = 1;
564 $UsersCommitted{$UID} = 1;
565 } elsif ($Type eq 'A') { # Added
566 $AddedFiles{$Filename} = 1;
567 $UsersCommitted{$UID} = 1;
568 } elsif ($Type eq 'R') { # Removed
569 $RemovedFiles{$Filename} = 1;
570 $UsersCommitted{$UID} = 1;
572 $UsersUpdated{$UID} = 1;
581 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
582 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
583 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
584 my $UserCommitList = join "\n", sort keys %UsersCommitted;
585 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
587 ##############################################################
589 # Build the entire tree, saving build messages to the build log
591 ##############################################################
592 if (!$NOCHECKOUT && !$NOBUILD) {
593 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
595 print "CONFIGURE STAGE:\n";
596 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
597 "> $BuildLog 2>&1\n";
599 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
602 print "BUILD STAGE:\n";
603 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
605 # Build the entire tree, capturing the output into $BuildLog
606 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
609 ##############################################################
611 # Get some statistics about the build...
613 ##############################################################
614 #this can de done on server
615 #my @Linked = split '\n', `grep Linking $BuildLog`;
616 #my $NumExecutables = scalar(grep(/executable/, @Linked));
617 #my $NumLibraries = scalar(grep(!/executable/, @Linked));
618 #my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
620 # Get the number of lines of source code. Must be here after the build is done
621 # because countloc.sh uses the llvm-config script which must be built.
622 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
624 # Get the time taken by the configure script
625 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
626 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
627 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
628 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
630 $ConfigTime=-1 unless $ConfigTime;
631 $ConfigWallTime=-1 unless $ConfigWallTime;
633 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
634 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
635 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
636 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
638 $BuildTime=-1 unless $BuildTime;
639 $BuildWallTime=-1 unless $BuildWallTime;
641 my $BuildError = 0, $BuildStatus = "OK";
643 $BuildStatus = "Skipped by user";
646 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
647 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
648 $BuildStatus = "Error: compilation aborted";
650 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
652 if ($BuildError) { $NODEJAGNU=1; }
657 print "Organizing size of .o and .a files\n"
659 ChangeDir( "$BuildDir/llvm", "Build Directory" );
660 $afiles.= `find utils/ -iname '*.a' -ls`;
661 $afiles.= `find lib/ -iname '*.a' -ls`;
662 $afiles.= `find tools/ -iname '*.a' -ls`;
663 if($BUILDTYPE eq "release"){
664 $afiles.= `find Release/ -iname '*.a' -ls`;
665 } elsif($BUILDTYPE eq "release-asserts") {
666 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
668 $afiles.= `find Debug/ -iname '*.a' -ls`;
671 $ofiles.= `find utils/ -iname '*.o' -ls`;
672 $ofiles.= `find lib/ -iname '*.o' -ls`;
673 $ofiles.= `find tools/ -iname '*.o' -ls`;
674 if($BUILDTYPE eq "release"){
675 $ofiles.= `find Release/ -iname '*.o' -ls`;
676 } elsif($BUILDTYPE eq "release-asserts") {
677 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
679 $ofiles.= `find Debug/ -iname '*.o' -ls`;
682 @AFILES = split "\n", $afiles;
684 foreach $x (@AFILES){
685 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
686 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
688 @OFILES = split "\n", $ofiles;
690 foreach $x (@OFILES){
691 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
692 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
695 $a_file_sizes="No data due to a bad build.";
696 $o_file_sizes="No data due to a bad build.";
699 ##############################################################
701 # Running dejagnu tests
703 ##############################################################
704 my $DejangnuTestResults=""; # String containing the results of the dejagnu
705 my $dejagnu_output = "$DejagnuTestsLog";
708 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
709 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
712 #Run the feature and regression tests, results are put into testrun.sum
713 #Full log in testrun.log
714 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
716 #Copy the testrun.log and testrun.sum to our webdir
717 CopyFile("test/testrun.log", $DejagnuLog);
718 CopyFile("test/testrun.sum", $DejagnuSum);
719 #can be done on server
720 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
721 $unexpfail_tests = $DejagnuTestResults;
724 #Extract time of dejagnu tests
725 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
726 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
727 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
728 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
729 $DejagnuTestResults =
730 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
731 $DejagnuTime = "0.0" unless $DejagnuTime;
732 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
734 ##############################################################
736 # Get warnings from the build
738 ##############################################################
740 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
741 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
745 foreach $Warning (@Warn) {
746 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
747 $CurDir = $1; # Keep track of directory warning is in...
748 # Remove buildir prefix if included
749 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
751 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
754 my $WarningsFile = join "\n", @Warnings;
755 $WarningsFile =~ s/:[0-9]+:/::/g;
757 # Emit the warnings file, so we can diff...
758 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
759 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
761 # Output something to stdout if something has changed
762 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
763 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
765 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
766 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
770 ##############################################################
772 # If we built the tree successfully, run the nightly programs tests...
774 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
777 ##############################################################
780 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
781 "Programs Test Subdirectory" ) || return ("", "");
783 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
785 # Run the programs tests... creating a report.nightly.csv file
788 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
789 "TEST=nightly > $ProgramTestLog 2>&1\n";
791 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
792 "TEST=nightly > $ProgramTestLog 2>&1";
793 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
797 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
799 $ProgramsTable="Error running test $SubDir\n";
800 print "ERROR TESTING\n";
801 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
803 $ProgramsTable="Makefile error running tests $SubDir!\n";
804 print "ERROR TESTING\n";
808 # Create a list of the tests which were run...
810 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
811 "| sort > $Prefix-$SubDir-Tests.txt";
813 $ProgramsTable = ReadFile "report.nightly.csv";
815 ChangeDir( "../../..", "Programs Test Parent Directory" );
816 return ($ProgramsTable, $llcbeta_options);
817 } #end sub TestDirectory
819 ##############################################################
821 # Calling sub TestDirectory
823 ##############################################################
826 print "SingleSource TEST STAGE\n";
828 ($SingleSourceProgramsTable, $llcbeta_options) =
829 TestDirectory("SingleSource");
830 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
832 print "MultiSource TEST STAGE\n";
834 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
835 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
836 if ( ! $NOEXTERNALS ) {
838 print "External TEST STAGE\n";
840 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
841 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
842 system "cat $Prefix-SingleSource-Tests.txt " .
843 "$Prefix-MultiSource-Tests.txt ".
844 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
845 system "cat $Prefix-SingleSource-Performance.txt " .
846 "$Prefix-MultiSource-Performance.txt ".
847 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
849 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
851 print "External TEST STAGE SKIPPED\n";
853 system "cat $Prefix-SingleSource-Tests.txt " .
854 "$Prefix-MultiSource-Tests.txt ".
855 " | sort > $Prefix-Tests.txt";
856 system "cat $Prefix-SingleSource-Performance.txt " .
857 "$Prefix-MultiSource-Performance.txt ".
858 " | sort > $Prefix-Performance.txt";
861 ##############################################################
864 # gathering tests added removed broken information here
867 ##############################################################
868 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
869 my @DEJAGNU = split "\n", $dejagnu_test_list;
870 my ($passes, $fails, $xfails) = "";
873 for ($x=0; $x<@DEJAGNU; $x++) {
874 if ($DEJAGNU[$x] =~ m/^PASS:/) {
875 $passes.="$DEJAGNU[$x]\n";
877 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
878 $fails.="$DEJAGNU[$x]\n";
880 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
881 $xfails.="$DEJAGNU[$x]\n";
886 } #end if !$BuildError
889 ##############################################################
891 # If we built the tree successfully, runs of the Olden suite with
892 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
894 ##############################################################
896 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
897 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
898 $MachCodeSize) = ("","","","","","","");
899 if (!$NORUNNINGTESTS) {
900 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
901 "Olden Test Directory");
903 # Clean out previous results...
904 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
906 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
907 # GET_STABLE_NUMBERS enabled!
909 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
910 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
911 "> /dev/null 2>&1\n";
913 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
914 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
916 system "cp report.nightly.csv $OldenTestsLog";
920 ##############################################################
922 # Getting end timestamp
924 ##############################################################
925 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
928 ##############################################################
930 # Place all the logs neatly into one humungous file
932 ##############################################################
933 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
935 $machine_data = "uname: ".`uname -a`.
936 "hardware: ".`uname -m`.
939 "date: ".`date \"+20%y-%m-%d\"`.
940 "time: ".`date +\"%H:%M:%S\"`;
944 @CVS_DATA = ReadFile "$CVSLog";
945 $cvs_data = join("\n", @CVS_DATA);
949 @BUILD_DATA = ReadFile "$BuildLog";
950 $build_data = join("\n", @BUILD_DATA);
952 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
953 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
954 my ($gcc_version, $gcc_version_long) = "";
956 $gcc_version_long="";
957 if ($GCCPATH ne "") {
958 $gcc_version_long = `$GCCPATH/gcc --version`;
960 $gcc_version_long = `gcc --version`;
962 @GCC_VERSION = split '\n', $gcc_version_long;
963 $gcc_version = $GCC_VERSION[0];
966 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
967 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
968 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
969 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
971 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
972 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
975 ##############################################################
977 # Send data via a post request
979 ##############################################################
981 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
984 'machine_data' => $machine_data,
985 'build_data' => $build_data,
986 'gcc_version' => $gcc_version,
987 'nickname' => $nickname,
988 'dejagnutime_wall' => $DejagnuWallTime,
989 'dejagnutime_cpu' => $DejagnuTime,
990 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
991 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
992 'configtime_wall' => $ConfigWallTime,
993 'configtime_cpu'=> $ConfigTime,
994 'buildtime_wall' => $BuildWallTime,
995 'buildtime_cpu' => $BuildTime,
996 'warnings' => $WarningsFile,
997 'cvsusercommitlist' => $UserCommitList,
998 'cvsuserupdatelist' => $UserUpdateList,
999 'cvsaddedfiles' => $CVSAddedFiles,
1000 'cvsmodifiedfiles' => $CVSModifiedFiles,
1001 'cvsremovedfiles' => $CVSRemovedFiles,
1002 'lines_of_code' => $LOC,
1003 'cvs_file_count' => $NumFilesInCVS,
1004 'cvs_dir_count' => $NumDirsInCVS,
1005 'buildstatus' => $BuildStatus,
1006 'singlesource_programstable' => $SingleSourceProgramsTable,
1007 'multisource_programstable' => $MultiSourceProgramsTable,
1008 'externalsource_programstable' => $ExternalProgramsTable,
1009 'llcbeta_options' => $multisource_llcbeta_options,
1010 'warnings_removed' => $WarningsRemoved,
1011 'warnings_added' => $WarningsAdded,
1012 'passing_tests' => $passes,
1013 'expfail_tests' => $xfails,
1014 'unexpfail_tests' => $fails,
1015 'all_tests' => $dejagnu_test_list,
1017 'removed_tests' => "",
1018 'dejagnutests_results' => $DejagnuTestResults,
1019 'dejagnutests_log' => $dejagnulog_full,
1020 'starttime' => $starttime,
1021 'endtime' => $endtime,
1022 'o_file_sizes' => $o_file_sizes,
1023 'a_file_sizes' => $a_file_sizes
1029 print "============================\n";
1030 foreach $x(keys %hash_of_data){
1031 print "$x => $hash_of_data{$x}\n";
1034 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1035 if( $VERBOSE) { print "============================\n$response"; }
1038 ##############################################################
1040 # Remove the cvs tree...
1042 ##############################################################
1043 system ( "$NICE rm -rf $BuildDir")
1044 if (!$NOCHECKOUT and !$NOREMOVE);
1045 system ( "$NICE rm -rf $WebDir")
1046 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);