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