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