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