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