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