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