Add an "implies" field to features. This indicates that, if the current
[oota-llvm.git] / utils / NewNightlyTest.pl
1 #!/usr/bin/perl
2 use POSIX qw(strftime);
3 use File::Copy;
4 use Socket;
5
6 #
7 # Program:  NewNightlyTest.pl
8 #
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.
13 #
14 # Modified heavily by Patrick Jenkins, July 2006
15 #
16 # Syntax:   NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
17 #   where
18 # OPTIONS may include one or more of the following:
19 #  -nocheckout      Do not create, checkout, update, or configure
20 #                   the source tree.
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
26 #                   -norunningtests.
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 #  -enable-lli      Enable testing of lli (interpreter) features, default is off
35 #  -disable-llc     Disable LLC tests in the nightly tester.
36 #  -disable-jit     Disable JIT tests in the nightly tester.
37 #  -disable-cbe     Disable C backend tests in the nightly tester.
38 #  -verbose         Turn on some debug output
39 #  -debug           Print information useful only to maintainers of this script.
40 #  -nice            Checkout/Configure/Build with "nice" to reduce impact
41 #                   on busy servers.
42 #  -f2c             Next argument specifies path to F2C utility
43 #  -nickname        The next argument specifieds the nickname this script
44 #                   will submit to the nightlytest results repository.
45 #  -gccpath         Path to gcc/g++ used to build LLVM
46 #  -cvstag          Check out a specific CVS tag to build LLVM (useful for
47 #                   testing release branches)
48 #  -usesvn          Check code out from a subversion repository. With no
49 #                   argument, use the standard repository. An argument specifies
50 #                   the repository URL to use.
51 #  -svnurl          Specify the SVN URL where LLVM can be found
52 #  -target          Specify the target triplet
53 #  -cflags          Next argument specifies that C compilation options that
54 #                   override the default.
55 #  -cxxflags        Next argument specifies that C++ compilation options that
56 #                   override the default.
57 #  -ldflags         Next argument specifies that linker options that override
58 #                   the default.
59 #  -compileflags    Next argument specifies extra options passed to make when
60 #                   building LLVM.
61 #  -use-gmake       Use gmake instead of the default make command to build
62 #                   llvm and run tests.
63 #
64 #  ---------------- Options to configure llvm-test ----------------------------
65 #  -extraflags      Next argument specifies extra options that are passed to
66 #                   compile the tests.
67 #  -noexternals     Do not run the external tests (for cases where povray
68 #                   or SPEC are not installed)
69 #  -with-externals  Specify a directory where the external tests are located.
70 #  -submit-server   Specifies a server to submit the test results too. If this
71 #                   option is not specified it defaults to 
72 #                   llvm.org. This is basically just the address of the 
73 #                   webserver
74 #  -submit-script   Specifies which script to call on the submit server. If
75 #                   this option is not specified it defaults to
76 #                   /nightlytest/NightlyTestAccept.php. This is basically 
77 #                   everything after the www.yourserver.org.
78 #
79 # CVSROOT is the CVS repository from which the tree will be checked out,
80 #  specified either in the full :method:user@host:/dir syntax, or
81 #  just /dir if using a local repo.
82 # BUILDDIR is the directory where sources for this test run will be checked out
83 #  AND objects for this test run will be built. This directory MUST NOT
84 #  exist before the script is run; it will be created by the cvs checkout
85 #  process and erased (unless -noremove is specified; see above.)
86 # WEBDIR is the directory into which the test results web page will be written,
87 #  AND in which the "index.html" is assumed to be a symlink to the most recent
88 #  copy of the results. This directory will be created if it does not exist.
89 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
90 #  to. This is the same as you would have for a normal LLVM build.
91 #
92 ##############################################################
93 #
94 # Getting environment variables
95 #
96 ##############################################################
97 my $HOME       = $ENV{'HOME'};
98 my $SVNURL     = $ENV{"SVNURL"};
99 $SVNURL        = 'svn://anon@hlvm.org:3691/llvm.svn' unless $SVNURL;
100 my $CVSRootDir = $ENV{'CVSROOT'};
101 $CVSRootDir    = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
102 my $BuildDir   = $ENV{'BUILDDIR'};
103 $BuildDir      = "$HOME/buildtest" unless $BuildDir;
104 my $WebDir     = $ENV{'WEBDIR'};
105 $WebDir        = "$HOME/cvs/testresults-X86" unless $WebDir;
106
107 ##############################################################
108 #
109 # Calculate the date prefix...
110 #
111 ##############################################################
112 @TIME = localtime;
113 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
114 my $DateString = strftime "%B %d, %Y", localtime;
115 my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
116
117 ##############################################################
118 #
119 # Parse arguments...
120 #
121 ##############################################################
122 $CONFIGUREARGS="";
123 $nickname="";
124 $NOTEST=0;
125 $USESVN=0;
126 $NORUNNINGTESTS=0;
127 $MAKECMD="make";
128 $SUBMITSERVER = "llvm.org";
129 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
130
131 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
132   shift;
133   last if /^--$/;  # Stop processing arguments on --
134
135   # List command line options here...
136   if (/^-nocheckout$/)     { $NOCHECKOUT = 1; next; }
137   if (/^-nocvsstats$/)     { $NOCVSSTATS = 1; next; }
138   if (/^-noremove$/)       { $NOREMOVE = 1; next; }
139   if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
140   if (/^-notest$/)         { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
141   if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
142   if (/^-parallel$/)       { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
143   if (/^-release$/)        { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
144                              "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
145   if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
146                              "DISABLE-ASSERTIONS=1 ".
147                              "OPTIMIZE_OPTION=-O2"; 
148                              $BUILDTYPE="release-asserts"; next;}
149   if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
150   if (/^-enable-lli$/)     { $PROGTESTOPTS .= " ENABLE_LLI=1";
151                              $CONFIGUREARGS .= " --enable-lli"; next; } 
152   if (/^-disable-llc$/)    { $PROGTESTOPTS .= " DISABLE_LLC=1";
153                              $CONFIGUREARGS .= " --disable-llc_diffs"; next; } 
154   if (/^-disable-jit$/)    { $PROGTESTOPTS .= " DISABLE_JIT=1";
155                              $CONFIGUREARGS .= " --disable-jit"; next; }
156   if (/^-disable-cbe$/)    { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
157   if (/^-verbose$/)        { $VERBOSE = 1; next; }
158   if (/^-debug$/)          { $DEBUG = 1; next; }
159   if (/^-nice$/)           { $NICE = "nice "; next; }
160   if (/^-f2c$/)            { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; 
161                              shift; next; }
162   if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]"; 
163                              shift; next; }
164   if (/^-submit-server/)   { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
165   if (/^-submit-script/)   { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
166   if (/^-nickname$/)       { $nickname = "$ARGV[0]"; shift; next; } 
167   if (/^-gccpath/)         { $CONFIGUREARGS .= 
168                              " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; 
169                              $GCCPATH=$ARGV[0]; shift;  next; }
170   else                     { $GCCPATH=""; }
171   if (/^-cvstag/)          { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } 
172   else                     { $CVSCOOPT="";}
173   if (/^-usesvn/)          { $USESVN = 1; }
174   if (/^-svnurl/)          { $SVNURL = $ARGV[0]; shift; next; }
175   if (/^-target/)          { $CONFIGUREARGS .= " --target=$ARGV[0]"; 
176                              shift; next; }
177   if (/^-cflags/)          { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; 
178                              shift; next; }
179   if (/^-cxxflags/)        { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; 
180                              shift; next; }
181   if (/^-ldflags/)         { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; 
182                              shift; next; }
183   if (/^-compileflags/)    { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
184   if (/^-use-gmake/)       { $MAKECMD = "gmake"; shift; next; }
185   if (/^-compileflags/)    { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
186   if (/^-extraflags/)      { $CONFIGUREARGS .= 
187                              " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
188   if (/^-noexternals$/)    { $NOEXTERNALS = 1; next; }
189   if (/^-nodejagnu$/)      { $NODEJAGNU = 1; next; }
190   if (/^-nobuild$/)        { $NOBUILD = 1; next; }
191   print "Unknown option: $_ : ignoring!\n";
192 }
193
194 if ($ENV{'LLVMGCCDIR'}) {
195   $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
196   $LLVMGCCPATH = $ENV{'LLVMGCCDIR'};
197 }
198 else {
199   $LLVMGCCPATH = "";
200 }
201
202 if ($CONFIGUREARGS !~ /--disable-jit/) {
203   $CONFIGUREARGS .= " --enable-jit";
204 }
205
206 if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
207   foreach $x (@ARGV) {
208     print "$x\n";
209   }
210   print "Must specify 0 or 3 options!";
211 }
212
213 if (@ARGV == 3) {
214   $CVSRootDir = $ARGV[0];
215   $BuildDir   = $ARGV[1];
216   $WebDir     = $ARGV[2];
217 }
218
219 if ($CVSRootDir eq "" or
220     $BuildDir   eq "" or
221     $WebDir     eq "") {
222   die("please specify a cvs root directory, a build directory, and a ".
223        "web directory");
224  }
225  
226 if ($nickname eq "") {
227   die ("Please invoke NewNightlyTest.pl with command line option " . 
228        "\"-nickname <nickname>\"");
229 }
230
231 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
232   $BUILDTYPE = "debug";
233 }
234
235 ##############################################################
236 #
237 #define the file names we'll use
238 #
239 ##############################################################
240 my $Prefix = "$WebDir/$DATE";
241 my $BuildLog = "$Prefix-Build-Log.txt";
242 my $COLog = "$Prefix-CVS-Log.txt";
243 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
244 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
245 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
246 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
247 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
248 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
249 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
250 if (! -d $WebDir) {
251   mkdir $WebDir, 0777;
252   if($VERBOSE){
253     warn "$WebDir did not exist; creating it.\n";
254   }
255 }
256
257 if ($VERBOSE) {
258   print "INITIALIZED\n";
259   if ($USESVN) {
260     print "SVN URL  = $SVNURL\n";
261   } else {
262     print "CVS Root = $CVSRootDir\n";
263   }
264   print "COLog    = $COLog\n";
265   print "BuildDir = $BuildDir\n";
266   print "WebDir   = $WebDir\n";
267   print "Prefix   = $Prefix\n";
268   print "BuildLog = $BuildLog\n";
269 }
270
271 ##############################################################
272 #
273 # Helper functions
274 #
275 ##############################################################
276 sub GetDir {
277   my $Suffix = shift;
278   opendir DH, $WebDir;
279   my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
280   closedir DH;
281   return @Result;
282 }
283
284 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285 #
286 # DiffFiles - Diff the current version of the file against the last version of
287 # the file, reporting things added and removed.  This is used to report, for
288 # example, added and removed warnings.  This returns a pair (added, removed)
289 #
290 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 sub DiffFiles {
292   my $Suffix = shift;
293   my @Others = GetDir $Suffix;
294   if (@Others == 0) {  # No other files?  We added all entries...
295     return (`cat $WebDir/$DATE$Suffix`, "");
296   }
297 # Diff the files now...
298   my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
299   my $Added   = join "\n", grep /^</, @Diffs;
300   my $Removed = join "\n", grep /^>/, @Diffs;
301   $Added =~ s/^< //gm;
302   $Removed =~ s/^> //gm;
303   return ($Added, $Removed);
304 }
305
306 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
308 sub GetRegex {   # (Regex with ()'s, value)
309   $_[1] =~ /$_[0]/m;
310   return $1 
311     if (defined($1));
312   return "0";
313 }
314
315 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 sub GetRegexNum {
318   my ($Regex, $Num, $Regex2, $File) = @_;
319   my @Items = split "\n", `grep '$Regex' $File`;
320   return GetRegex $Regex2, $Items[$Num];
321 }
322
323 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325 sub ChangeDir { # directory, logical name
326   my ($dir,$name) = @_;
327   chomp($dir);
328   if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
329   $result = chdir($dir);
330   if (!$result) {
331     print "ERROR!!! Cannot change directory to: $name ($dir) because $!"; 
332     return false;
333   }
334   return true;
335 }
336
337 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339 sub ReadFile {
340   if (open (FILE, $_[0])) {
341     undef $/;
342     my $Ret = <FILE>;
343     close FILE;
344     $/ = '\n';
345     return $Ret;
346   } else {
347     print "Could not open file '$_[0]' for reading!\n";
348     return "";
349   }
350 }
351
352 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
353 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354 sub WriteFile {  # (filename, contents)
355   open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
356   print FILE $_[1];
357   close FILE;
358 }
359
360 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362 sub CopyFile { #filename, newfile
363   my ($file, $newfile) = @_;
364   chomp($file);
365   if ($VERBOSE) { print "Copying $file to $newfile\n"; }
366   copy($file, $newfile);
367 }
368
369 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 sub AddRecord {
372   my ($Val, $Filename,$WebDir) = @_;
373   my @Records;
374   if (open FILE, "$WebDir/$Filename") {
375     @Records = grep !/$DATE/, split "\n", <FILE>;
376     close FILE;
377   }
378   push @Records, "$DATE: $Val";
379   WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
380 }
381
382 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383 #
384 # FormatTime - Convert a time from 1m23.45 into 83.45
385 #
386 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
387 sub FormatTime {
388   my $Time = shift;
389   if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
390     $Time = sprintf("%7.4f", $1*60.0+$2);
391   }
392   return $Time;
393 }
394
395 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 #
397 # This function is meant to read in the dejagnu sum file and 
398 # return a string with only the results (i.e. PASS/FAIL/XPASS/
399 # XFAIL).
400 #
401 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402 sub GetDejagnuTestResults { # (filename, log)
403     my ($filename, $DejagnuLog) = @_;
404     my @lines;
405     $/ = "\n"; #Make sure we're going line at a time.
406
407     if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
408
409     if (open SRCHFILE, $filename) {
410         # Process test results
411         while ( <SRCHFILE> ) {
412             if ( length($_) > 1 ) {
413                 chomp($_);
414                 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
415                     push(@lines, "$1: test/$2");
416                 }
417             }
418         }
419     }
420     close SRCHFILE;
421
422     my $content = join("\n", @lines);
423     return $content;
424 }
425
426
427
428 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429 #
430 # This function acts as a mini web browswer submitting data
431 # to our central server via the post method
432 #
433 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
434 sub SendData{
435     $host = $_[0];
436     $file = $_[1];
437     $variables=$_[2];
438
439     $port=80;
440     $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
441     socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or 
442       die "Bad socket\n";
443     connect SOCK, $socketaddr or die "Bad connection\n";
444     select((select(SOCK), $| = 1)[0]);
445
446     #creating content here
447     my $content;
448     foreach $key (keys (%$variables)){
449         $value = $variables->{$key};
450         $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
451         $content .= "$key=$value&";
452     }
453
454     $length = length($content);
455
456     my $send= "POST $file HTTP/1.0\n";
457     $send.= "Host: $host\n";
458     $send.= "Content-Type: application/x-www-form-urlencoded\n";
459     $send.= "Content-length: $length\n\n";
460     $send.= "$content";
461
462     print SOCK $send;
463     my $result;
464     while(<SOCK>){
465         $result  .= $_;
466     }
467     close(SOCK);
468
469     my $sentdata="";
470     foreach $x (keys (%$variables)){
471         $value = $variables->{$x};
472         $sentdata.= "$x  => $value\n";
473     }
474     WriteFile "$Prefix-sentdata.txt", $sentdata;
475     
476
477     return $result;
478 }
479
480 ##############################################################
481 #
482 # Getting Start timestamp
483 #
484 ##############################################################
485 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
486
487 ##############################################################
488 #
489 # Create the CVS repository directory
490 #
491 ##############################################################
492 if (!$NOCHECKOUT) {
493   if (-d $BuildDir) {
494     if (!$NOREMOVE) {
495       if ( $VERBOSE ) {
496         print "Build directory exists! Removing it\n";
497       }
498       system "rm -rf $BuildDir";
499       mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
500     } else {
501       if ( $VERBOSE ) {
502         print "Build directory exists!\n";
503       }
504     }
505   } else {
506     mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
507   }
508 }
509 ChangeDir( $BuildDir, "checkout directory" );
510
511
512 ##############################################################
513 #
514 # Check out the llvm tree, using either SVN or CVS 
515 #
516 ##############################################################
517 if (!$NOCHECKOUT) {
518   if ( $VERBOSE ) { 
519     print "CHECKOUT STAGE:\n"; 
520   }
521   if ($USESVN) {
522     my $SVNCMD = "$NICE svn co $SVNURL";
523     if ($VERBOSE) {
524       print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
525             "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
526       system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
527             "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
528     }
529   } else {
530     my $CVSOPT = "";
531     $CVSOPT = "-z3" # Use compression if going over ssh.
532       if $CVSRootDir =~ /^:ext:/;
533     my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
534     print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
535           "$CVSCMD llvm-test ) > $COLog 2>&1\n";
536     system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
537           "$CVSCMD llvm-test ) > $COLog 2>&1\n";
538   }
539 }
540 ChangeDir( $BuildDir , "Checkout directory") ;
541 ChangeDir( "llvm" , "llvm source directory") ;
542
543 ##############################################################
544 #
545 # Get some static statistics about the current state of CVS
546 #
547 # This can probably be put on the server side
548 #
549 ##############################################################
550 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
551 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
552 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
553 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
554
555 my $NumFilesInCVS = 0;
556 my $NumDirsInCVS  = 0;
557 if ($USESVN) {
558   $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
559   $NumDirsInCVS  = `sed -e 's#/[^/]*$##' $COLog | sort | uniq | wc -l` + 0;
560 } else {
561   $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
562   $NumDirsInCVS  = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
563 }
564
565 ##############################################################
566 #
567 # Extract some information from the CVS history... use a hash so no duplicate
568 # stuff is stored. This gets the history from the previous days worth
569 # of cvs activity and parses it.
570 #
571 ##############################################################
572
573 # This just computes a reasonably accurate #of seconds since 2000. It doesn't
574 # have to be perfect as its only used for comparing date ranges within a couple
575 # of days.
576 sub ConvertToSeconds {
577   my ($sec, $min, $hour, $day, $mon, $yr) = @_;
578   my $Result = ($yr - 2000) * 12;
579   $Result += $mon;
580   $Result *= 31;
581   $Result += $day;
582   $Result *= 24;
583   $Result += $hour;
584   $Result *= 60;
585   $Result += $min;
586   $Result *= 60;
587   $Result += $sec;
588   return $Result;
589 }
590
591 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
592
593 if (!$NOCVSSTATS) {
594   if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
595
596   if ($USESVN) {
597     @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
598     # Skip very first entry because it is the XML header cruft
599     shift @SVNHistory;
600     my $Now = time();
601     foreach $Record (@SVNHistory) {
602       my @Lines = split "\n", $Record;
603       my ($Author, $Date, $Revision);
604       # Get the date and see if its one we want to process.
605       my ($Year, $Month, $Day, $Hour, $Min, $Sec);
606       if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
607         $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
608       }
609       my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
610       # Get the current date and compute when "yesterday" is.
611       my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
612       my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
613       if (($Now - 24*60*60) > $Then) {
614         next;
615       }
616       if ($Lines[1] =~ /   revision="([0-9]*)">/) {
617         $Revision = $1;
618       }
619       if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
620         $Author = $1;
621       }
622       $UsersCommitted{$Author} = 1;
623       $Date = $Year . "-" . $Month . "-" . $Day;
624       $Time = $Hour . ":" . $Min . ":" . $Sec;
625       print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
626       for ($i = 6; $i < $#Lines; $i += 2 ) {
627         if ($Lines[$i] =~ /^   action="(.)">([^<]*)</) {
628           if ($1 == "A") {
629             $AddedFiles{$2} = 1;
630           } elsif ($1 == 'D') {
631             $RemovedFiles{$2} = 1;
632           } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
633             $ModifiedFiles{$2} = 1;
634           } else {
635             print "UNMATCHABLE: $Lines[$i]\n";
636           }
637         }
638       }
639     }
640   } else {
641     @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
642 #print join "\n", @CVSHistory; print "\n";
643
644     my $DateRE = '[-/:0-9 ]+\+[0-9]+';
645
646 # Loop over every record from the CVS history, filling in the hashes.
647     foreach $File (@CVSHistory) {
648         my ($Type, $Date, $UID, $Rev, $Filename);
649         if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
650             ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
651         } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
652             ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
653         } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
654             ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
655         } else {
656             print "UNMATCHABLE: $File\n";
657             next;
658         }
659         # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
660         
661         if ($Filename =~ /^llvm/) {
662             if ($Type eq 'M') {        # Modified
663                 $ModifiedFiles{$Filename} = 1;
664                 $UsersCommitted{$UID} = 1;
665             } elsif ($Type eq 'A') {   # Added
666                 $AddedFiles{$Filename} = 1;
667                 $UsersCommitted{$UID} = 1;
668             } elsif ($Type eq 'R') {   # Removed
669                 $RemovedFiles{$Filename} = 1;
670                 $UsersCommitted{$UID} = 1;
671             } else {
672                 $UsersUpdated{$UID} = 1;
673             }
674         }
675     }
676
677     my $TestError = 1;
678   } #$USESVN
679 }#!NOCVSSTATS
680
681 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
682 my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
683 my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
684 my $UserCommitList = join "\n", sort keys %UsersCommitted;
685 my $UserUpdateList = join "\n", sort keys %UsersUpdated;
686
687 ##############################################################
688 #
689 # Build the entire tree, saving build messages to the build log
690 #
691 ##############################################################
692 if (!$NOCHECKOUT && !$NOBUILD) {
693   my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
694   if ( $VERBOSE ) {
695     print "CONFIGURE STAGE:\n";
696     print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " . 
697           "> $BuildLog 2>&1\n";
698   }
699   system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " . 
700          "> $BuildLog 2>&1";
701   if ( $VERBOSE ) { 
702     print "BUILD STAGE:\n";
703     print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
704   }
705   # Build the entire tree, capturing the output into $BuildLog
706   system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
707 }
708
709 ##############################################################
710 #
711 # Get some statistics about the build...
712 #
713 ##############################################################
714 #this can de done on server
715 #my @Linked = split '\n', `grep Linking $BuildLog`;
716 #my $NumExecutables = scalar(grep(/executable/, @Linked));
717 #my $NumLibraries   = scalar(grep(!/executable/, @Linked));
718 #my $NumObjects     = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
719
720 # Get the number of lines of source code. Must be here after the build is done
721 # because countloc.sh uses the llvm-config script which must be built.
722 my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
723
724 # Get the time taken by the configure script
725 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
726 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
727 my $ConfigTime  = $ConfigTimeU+$ConfigTimeS;  # ConfigTime = User+System
728 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
729
730 $ConfigTime=-1 unless $ConfigTime;
731 $ConfigWallTime=-1 unless $ConfigWallTime;
732
733 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
734 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
735 my $BuildTime  = $BuildTimeU+$BuildTimeS;  # BuildTime = User+System
736 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
737
738 $BuildTime=-1 unless $BuildTime;
739 $BuildWallTime=-1 unless $BuildWallTime;
740
741 my $BuildError = 0, $BuildStatus = "OK";
742 if ($NOBUILD) {
743   $BuildStatus = "Skipped by user";
744   $BuildError = 1;
745 }
746 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
747   `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
748   $BuildStatus = "Error: compilation aborted";
749   $BuildError = 1;
750   if( $VERBOSE) { print  "\n***ERROR BUILDING TREE\n\n"; }
751 }
752 if ($BuildError) { $NODEJAGNU=1; }
753
754 my $a_file_sizes="";
755 my $o_file_sizes="";
756 if (!$BuildError) {
757   print "Organizing size of .o and .a files\n" 
758     if ( $VERBOSE );
759   ChangeDir( "$BuildDir/llvm", "Build Directory" );
760   $afiles.= `find utils/ -iname '*.a' -ls`;
761   $afiles.= `find lib/ -iname '*.a' -ls`;
762   $afiles.= `find tools/ -iname '*.a' -ls`;
763   if($BUILDTYPE eq "release"){
764     $afiles.= `find Release/ -iname '*.a' -ls`;
765   } elsif($BUILDTYPE eq "release-asserts") {
766    $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
767   } else {
768    $afiles.= `find Debug/ -iname '*.a' -ls`;
769   }
770   
771   $ofiles.= `find utils/ -iname '*.o' -ls`;
772   $ofiles.= `find lib/ -iname '*.o' -ls`;
773   $ofiles.= `find tools/ -iname '*.o' -ls`;
774   if($BUILDTYPE eq "release"){
775     $ofiles.= `find Release/ -iname '*.o' -ls`;
776   } elsif($BUILDTYPE eq "release-asserts") {
777     $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
778   } else {
779     $ofiles.= `find Debug/ -iname '*.o' -ls`;
780   }
781   
782   @AFILES = split "\n", $afiles;
783   $a_file_sizes="";
784   foreach $x (@AFILES){
785     $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
786     $a_file_sizes.="$1 $2 $BUILDTYPE\n";
787   }
788   @OFILES = split "\n", $ofiles;
789   $o_file_sizes="";
790   foreach $x (@OFILES){
791     $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
792     $o_file_sizes.="$1 $2 $BUILDTYPE\n";
793   }
794 } else {
795   $a_file_sizes="No data due to a bad build.";
796   $o_file_sizes="No data due to a bad build.";
797 }
798
799 ##############################################################
800 #
801 # Running dejagnu tests
802 #
803 ##############################################################
804 my $DejangnuTestResults=""; # String containing the results of the dejagnu
805 my $dejagnu_output = "$DejagnuTestsLog";
806 if (!$NODEJAGNU) {
807   if($VERBOSE) { 
808     print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n"; 
809     print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
810   }
811
812   #Run the feature and regression tests, results are put into testrun.sum
813   #Full log in testrun.log
814   system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
815   
816   #Copy the testrun.log and testrun.sum to our webdir
817   CopyFile("test/testrun.log", $DejagnuLog);
818   CopyFile("test/testrun.sum", $DejagnuSum);
819   #can be done on server
820   $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
821   $unexpfail_tests = $DejagnuTestResults;
822 }
823
824 #Extract time of dejagnu tests
825 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
826 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
827 $DejagnuTime  = $DejagnuTimeU+$DejagnuTimeS;  # DejagnuTime = User+System
828 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output"; 
829 $DejagnuTestResults = 
830   "Dejagnu skipped by user choice." unless $DejagnuTestResults;
831 $DejagnuTime     = "0.0" unless $DejagnuTime;
832 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
833
834 ##############################################################
835 #
836 # Get warnings from the build
837 #
838 ##############################################################
839 if (!$NODEJAGNU) {
840   if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
841   my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
842   my @Warnings;
843   my $CurDir = "";
844
845   foreach $Warning (@Warn) {
846     if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
847       $CurDir = $1;                 # Keep track of directory warning is in...
848       # Remove buildir prefix if included
849       if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
850     } else {
851       push @Warnings, "$CurDir/$Warning";     # Add directory to warning...
852     }
853   }
854   my $WarningsFile =  join "\n", @Warnings;
855   $WarningsFile =~ s/:[0-9]+:/::/g;
856
857   # Emit the warnings file, so we can diff...
858   WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
859   my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
860
861   # Output something to stdout if something has changed
862   #print "ADDED   WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
863   #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
864
865   #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
866   #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
867
868 } #endif !NODEGAGNU
869
870 ##############################################################
871 #
872 # If we built the tree successfully, run the nightly programs tests...
873 #
874 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" 
875 # "External")
876 #
877 ##############################################################
878 sub TestDirectory {
879   my $SubDir = shift;  
880   ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir", 
881              "Programs Test Subdirectory" ) || return ("", "");
882   
883   my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
884   
885   # Run the programs tests... creating a report.nightly.csv file
886   if (!$NOTEST) {
887     if( $VERBOSE) { 
888       print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
889             "TEST=nightly > $ProgramTestLog 2>&1\n"; 
890     }
891     system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
892            "TEST=nightly > $ProgramTestLog 2>&1";
893     $llcbeta_options=`$MAKECMD print-llcbeta-option`;
894   } 
895
896   my $ProgramsTable;
897   if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
898     $TestError = 1;
899     $ProgramsTable="Error running test $SubDir\n";
900     print "ERROR TESTING\n";
901   } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
902     $TestError = 1;
903     $ProgramsTable="Makefile error running tests $SubDir!\n";
904     print "ERROR TESTING\n";
905   } else {
906     $TestError = 0;
907   #
908   # Create a list of the tests which were run...
909   #
910   system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
911          "| sort > $Prefix-$SubDir-Tests.txt";
912   }
913   $ProgramsTable = ReadFile "report.nightly.csv";
914
915   ChangeDir( "../../..", "Programs Test Parent Directory" );
916   return ($ProgramsTable, $llcbeta_options);
917 } #end sub TestDirectory
918
919 ##############################################################
920 #
921 # Calling sub TestDirectory
922 #
923 ##############################################################
924 if (!$BuildError) {
925   if ( $VERBOSE ) {
926      print "SingleSource TEST STAGE\n";
927   }
928   ($SingleSourceProgramsTable, $llcbeta_options) = 
929     TestDirectory("SingleSource");
930   WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
931   if ( $VERBOSE ) {
932     print "MultiSource TEST STAGE\n";
933   }
934   ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
935   WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
936   if ( ! $NOEXTERNALS ) {
937     if ( $VERBOSE ) {
938       print "External TEST STAGE\n";
939     }
940     ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
941     WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
942     system "cat $Prefix-SingleSource-Tests.txt " . 
943                "$Prefix-MultiSource-Tests.txt ".
944                "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
945     system "cat $Prefix-SingleSource-Performance.txt " . 
946                "$Prefix-MultiSource-Performance.txt ".
947                "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
948   } else {
949     $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
950     if ( $VERBOSE ) {
951       print "External TEST STAGE SKIPPED\n";
952     }
953     system "cat $Prefix-SingleSource-Tests.txt " . 
954                "$Prefix-MultiSource-Tests.txt ".
955                " | sort > $Prefix-Tests.txt";
956     system "cat $Prefix-SingleSource-Performance.txt " . 
957                "$Prefix-MultiSource-Performance.txt ".
958                " | sort > $Prefix-Performance.txt";
959   }
960
961   ##############################################################
962   #
963   # 
964   # gathering tests added removed broken information here 
965   #
966   #
967   ##############################################################
968   my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
969   my @DEJAGNU = split "\n", $dejagnu_test_list;
970   my ($passes, $fails, $xfails) = "";
971
972   if(!$NODEJAGNU) {
973     for ($x=0; $x<@DEJAGNU; $x++) {
974       if ($DEJAGNU[$x] =~ m/^PASS:/) {
975         $passes.="$DEJAGNU[$x]\n";
976       }
977       elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
978         $fails.="$DEJAGNU[$x]\n";
979       }
980       elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
981         $xfails.="$DEJAGNU[$x]\n";
982       }
983     }
984   }
985   
986 } #end if !$BuildError
987
988
989 ##############################################################
990 #
991 # If we built the tree successfully, runs of the Olden suite with
992 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
993 #
994 ##############################################################
995 if (!$BuildError) {
996   if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
997   my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
998   $MachCodeSize) = ("","","","","","","");
999   if (!$NORUNNINGTESTS) {
1000     ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
1001                 "Olden Test Directory");
1002
1003     # Clean out previous results...
1004     system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
1005
1006     # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1007     # GET_STABLE_NUMBERS enabled!
1008     if( $VERBOSE ) { 
1009       print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1010             "TEST=nightly  LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1011             "> /dev/null 2>&1\n"; 
1012     }
1013     system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1014            "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1015            "> /dev/null 2>&1";
1016     system "cp report.nightly.csv $OldenTestsLog";
1017   }  
1018 }
1019
1020 ##############################################################
1021 #
1022 # Getting end timestamp
1023 #
1024 ##############################################################
1025 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1026
1027
1028 ##############################################################
1029 #
1030 # Place all the logs neatly into one humungous file
1031 #
1032 ##############################################################
1033 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1034
1035 $machine_data = "uname: ".`uname -a`. 
1036                 "hardware: ".`uname -m`.
1037                 "os: ".`uname -sr`.
1038                 "name: ".`uname -n`.
1039                 "date: ".`date \"+20%y-%m-%d\"`.
1040                 "time: ".`date +\"%H:%M:%S\"`; 
1041
1042 my @CVS_DATA;
1043 my $cvs_data;
1044 @CVS_DATA = ReadFile "$COLog";
1045 $cvs_data = join("\n", @CVS_DATA);
1046
1047 my @BUILD_DATA;
1048 my $build_data;
1049 @BUILD_DATA = ReadFile "$BuildLog";
1050 $build_data = join("\n", @BUILD_DATA);
1051
1052 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1053 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1054 my ($gcc_version, $gcc_version_long) = "";
1055
1056 $gcc_version_long="";
1057 if ($GCCPATH ne "") {
1058         $gcc_version_long = `$GCCPATH/gcc --version`;
1059 } elsif ($ENV{"CC"}) {
1060         $gcc_version_long = `$ENV{"CC"} --version`;
1061 } else {
1062         $gcc_version_long = `gcc --version`;
1063 }
1064 @GCC_VERSION = split '\n', $gcc_version_long;
1065 $gcc_version = $GCC_VERSION[0];
1066
1067 $llvmgcc_version_long="";
1068 if ($LLVMGCCPATH ne "") {
1069   $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1070 } else {
1071   $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1072 }
1073 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1074 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1075 $llvmgcc_versionTarget =~ /Target: (.+)/;
1076 $targetTriple = $1;
1077
1078 if(!$BuildError){
1079   @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1080   @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1081   $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1082   $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1083
1084   @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1085   $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1086 }
1087
1088 ##############################################################
1089 #
1090 # Send data via a post request
1091 #
1092 ##############################################################
1093
1094 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1095
1096 my %hash_of_data = (
1097   'machine_data' => $machine_data,
1098   'build_data' => $build_data,
1099   'gcc_version' => $gcc_version,
1100   'nickname' => $nickname,
1101   'dejagnutime_wall' => $DejagnuWallTime,
1102   'dejagnutime_cpu' => $DejagnuTime,
1103   'cvscheckouttime_wall' => $CheckoutTime_Wall,
1104   'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1105   'configtime_wall' => $ConfigWallTime,
1106   'configtime_cpu'=> $ConfigTime,
1107   'buildtime_wall' => $BuildWallTime,
1108   'buildtime_cpu' => $BuildTime,
1109   'warnings' => $WarningsFile,
1110   'cvsusercommitlist' => $UserCommitList,
1111   'cvsuserupdatelist' => $UserUpdateList,
1112   'cvsaddedfiles' => $CVSAddedFiles,
1113   'cvsmodifiedfiles' => $CVSModifiedFiles,
1114   'cvsremovedfiles' => $CVSRemovedFiles,
1115   'lines_of_code' => $LOC,
1116   'cvs_file_count' => $NumFilesInCVS,
1117   'cvs_dir_count' => $NumDirsInCVS,
1118   'buildstatus' => $BuildStatus,
1119   'singlesource_programstable' => $SingleSourceProgramsTable,
1120   'multisource_programstable' => $MultiSourceProgramsTable,
1121   'externalsource_programstable' => $ExternalProgramsTable,
1122   'llcbeta_options' => $multisource_llcbeta_options,
1123   'warnings_removed' => $WarningsRemoved,
1124   'warnings_added' => $WarningsAdded,
1125   'passing_tests' => $passes,
1126   'expfail_tests' => $xfails,
1127   'unexpfail_tests' => $fails,
1128   'all_tests' => $dejagnu_test_list,
1129   'new_tests' => "",
1130   'removed_tests' => "",
1131   'dejagnutests_results' => $DejagnuTestResults,
1132   'dejagnutests_log' => $dejagnulog_full,
1133   'starttime' => $starttime,
1134   'endtime' => $endtime,
1135   'o_file_sizes' => $o_file_sizes,
1136   'a_file_sizes' => $a_file_sizes,
1137   'target_triple' => $targetTriple
1138 );
1139
1140 $TESTING = 0;
1141
1142 if ($TESTING) {
1143   print "============================\n";
1144   foreach $x(keys %hash_of_data){
1145       print "$x  => $hash_of_data{$x}\n";
1146   }
1147 } else {
1148   my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1149   if( $VERBOSE) { print "============================\n$response"; }
1150 }
1151
1152 ##############################################################
1153 #
1154 # Remove the cvs tree...
1155 #
1156 ##############################################################
1157 system ( "$NICE rm -rf $BuildDir") 
1158   if (!$NOCHECKOUT and !$NOREMOVE);
1159 system ( "$NICE rm -rf $WebDir") 
1160   if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);