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