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