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