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