Add lowering of ARM 4-element shuffles to multiple instructios via perfectshuffle...
[oota-llvm.git] / utils / NewNightlyTest.pl
index 9b802efca55576a7007819fedfacdb35b333e12d..477df8fc12e0790cf85842d3ccf45e351d53ca03 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 use POSIX qw(strftime);
 use File::Copy;
+use File::Find;
 use Socket;
 
 #
@@ -8,11 +9,9 @@ use Socket;
 #
 # Synopsis: Perform a series of tests which are designed to be run nightly.
 #           This is used to keep track of the status of the LLVM tree, tracking
-#           regressions and performance changes. Submits this information 
+#           regressions and performance changes. Submits this information
 #           to llvm.org where it is placed into the nightlytestresults database.
 #
-# Modified heavily by Patrick Jenkins, July 2006
-#
 # Syntax:   NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
 #   where
 # OPTIONS may include one or more of the following:
@@ -22,19 +21,21 @@ use Socket;
 #  -noremoveresults Do not remove the WEBDIR after it has been built.
 #  -nobuild         Do not build llvm. If tests are enabled perform them
 #                   on the llvm build specified in the build directory
-#  -notest          Do not even attempt to run the test programs. Implies
-#                   -norunningtests.
-#  -norunningtests  Do not run the Olden benchmark suite with
-#                   LARGE_PROBLEM_SIZE enabled.
+#  -notest          Do not even attempt to run the test programs.
 #  -nodejagnu       Do not run feature or regression tests
-#  -parallel        Run two parallel jobs with GNU Make.
+#  -parallel        Run parallel jobs with GNU Make (see -parallel-jobs).
+#  -parallel-jobs   The number of parallel Make jobs to use (default is two).
+#  -with-clang      Checkout Clang source into tools/clang.
 #  -release         Build an LLVM Release version
 #  -release-asserts Build an LLVM ReleaseAsserts version
 #  -enable-llcbeta  Enable testing of beta features in llc.
 #  -enable-lli      Enable testing of lli (interpreter) features, default is off
+#  -disable-pic            Disable building with Position Independent Code.
 #  -disable-llc     Disable LLC tests in the nightly tester.
 #  -disable-jit     Disable JIT tests in the nightly tester.
 #  -disable-cbe     Disable C backend tests in the nightly tester.
+#  -disable-lto     Disable link time optimization.
+#  -disable-bindings     Disable building LLVM bindings.
 #  -verbose         Turn on some debug output
 #  -debug           Print information useful only to maintainers of this script.
 #  -nice            Checkout/Configure/Build with "nice" to reduce impact
@@ -45,10 +46,8 @@ use Socket;
 #  -gccpath         Path to gcc/g++ used to build LLVM
 #  -cvstag          Check out a specific CVS tag to build LLVM (useful for
 #                   testing release branches)
-#  -usesvn          Check code out from a subversion repository.
-#  -svnurl          Specify the SVN URL where LLVM can be found. Needs -usesvn
-#                   to be useful. If -svnurl is not used but -usesvn is then
-#                   the standard (UIUC) repository will be used. 
+#  -usecvs          Check code out from the (old) CVS Repository instead of from
+#                   the standard Subversion repository.
 #  -target          Specify the target triplet
 #  -cflags          Next argument specifies that C compilation options that
 #                   override the default.
@@ -56,6 +55,10 @@ use Socket;
 #                   override the default.
 #  -ldflags         Next argument specifies that linker options that override
 #                   the default.
+#  -test-cflags     Next argument specifies that C compilation options that
+#                   override the default when running the testsuite.
+#  -test-cxxflags   Next argument specifies that C++ compilation options that
+#                   override the default when running the testsuite.
 #  -compileflags    Next argument specifies extra options passed to make when
 #                   building LLVM.
 #  -use-gmake       Use gmake instead of the default make command to build
@@ -68,13 +71,17 @@ use Socket;
 #                   or SPEC are not installed)
 #  -with-externals  Specify a directory where the external tests are located.
 #  -submit-server   Specifies a server to submit the test results too. If this
-#                   option is not specified it defaults to 
-#                   llvm.org. This is basically just the address of the 
+#                   option is not specified it defaults to
+#                   llvm.org. This is basically just the address of the
 #                   webserver
 #  -submit-script   Specifies which script to call on the submit server. If
 #                   this option is not specified it defaults to
-#                   /nightlytest/NightlyTestAccept.php. This is basically 
+#                   /nightlytest/NightlyTestAccept.php. This is basically
 #                   everything after the www.yourserver.org.
+#  -submit-aux      If specified, an auxiliary script to run in addition to the
+#                   normal submit script. The script will be passed the path to
+#                   the "sentdata.txt" file as its sole argument.
+#  -nosubmit        Do not report the test results back to a submit server.
 #
 # CVSROOT is the CVS repository from which the tree will be checked out,
 #  specified either in the full :method:user@host:/dir syntax, or
@@ -96,7 +103,9 @@ use Socket;
 ##############################################################
 my $HOME       = $ENV{'HOME'};
 my $SVNURL     = $ENV{"SVNURL"};
-$SVNURL        = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
+$SVNURL        = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
+my $TestSVNURL = $ENV{"TestSVNURL"};
+$TestSVNURL    = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
 my $CVSRootDir = $ENV{'CVSROOT'};
 $CVSRootDir    = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
 my $BuildDir   = $ENV{'BUILDDIR'};
@@ -104,15 +113,20 @@ $BuildDir      = "$HOME/buildtest" unless $BuildDir;
 my $WebDir     = $ENV{'WEBDIR'};
 $WebDir        = "$HOME/cvs/testresults-X86" unless $WebDir;
 
+my $LLVMSrcDir   = $ENV{'LLVMSRCDIR'};
+$LLVMSrcDir    = "$BuildDir/llvm" unless $LLVMSrcDir;
+my $LLVMObjDir   = $ENV{'LLVMOBJDIR'};
+$LLVMObjDir    = "$BuildDir/llvm" unless $LLVMObjDir;
+my $LLVMTestDir   = $ENV{'LLVMTESTDIR'};
+$LLVMTestDir    = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
+
 ##############################################################
 #
 # Calculate the date prefix...
 #
 ##############################################################
 @TIME = localtime;
-my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
-my $DateString = strftime "%B %d, %Y", localtime;
-my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
+my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
 
 ##############################################################
 #
@@ -123,10 +137,13 @@ $CONFIGUREARGS="";
 $nickname="";
 $NOTEST=0;
 $USESVN=1;
-$NORUNNINGTESTS=0;
 $MAKECMD="make";
 $SUBMITSERVER = "llvm.org";
 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
+$SUBMITAUX="";
+$SUBMIT = 1;
+$PARALLELJOBS = "2";
+my $TESTFLAGS="";
 
 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   shift;
@@ -136,52 +153,68 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   if (/^-nocheckout$/)     { $NOCHECKOUT = 1; next; }
   if (/^-nocvsstats$/)     { $NOCVSSTATS = 1; next; }
   if (/^-noremove$/)       { $NOREMOVE = 1; next; }
+  if (/^-noremoveatend$/)  { $NOREMOVEATEND = 1; next; }
   if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
-  if (/^-notest$/)         { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
-  if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
-  if (/^-parallel$/)       { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
+  if (/^-notest$/)         { $NOTEST = 1; next; }
+  if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
+  if (/^-parallel-jobs$/)  { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
+  if (/^-parallel$/)       { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
+  if (/^-with-clang$/)     { $WITHCLANG = 1; next; }
   if (/^-release$/)        { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
                              "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
   if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
-                             "DISABLE-ASSERTIONS=1 ".
-                             "OPTIMIZE_OPTION=-O2"; 
+                             "DISABLE_ASSERTIONS=1 ".
+                             "OPTIMIZE_OPTION=-O2";
                              $BUILDTYPE="release-asserts"; next;}
   if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
+  if (/^-disable-pic$/)    { $CONFIGUREARGS .= " --enable-pic=no"; next; }
   if (/^-enable-lli$/)     { $PROGTESTOPTS .= " ENABLE_LLI=1";
-                             $CONFIGUREARGS .= " --enable-lli"; next; } 
+                             $CONFIGUREARGS .= " --enable-lli"; next; }
   if (/^-disable-llc$/)    { $PROGTESTOPTS .= " DISABLE_LLC=1";
-                             $CONFIGUREARGS .= " --disable-llc_diffs"; next; } 
+                             $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
   if (/^-disable-jit$/)    { $PROGTESTOPTS .= " DISABLE_JIT=1";
                              $CONFIGUREARGS .= " --disable-jit"; next; }
+  if (/^-disable-bindings$/)    { $CONFIGUREARGS .= " --disable-bindings"; next; }
   if (/^-disable-cbe$/)    { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
+  if (/^-disable-lto$/)    { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
+  if (/^-test-opts$/)      { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
   if (/^-verbose$/)        { $VERBOSE = 1; next; }
+  if (/^-teelogs$/)        { $TEELOGS = 1; next; }
   if (/^-debug$/)          { $DEBUG = 1; next; }
   if (/^-nice$/)           { $NICE = "nice "; next; }
-  if (/^-f2c$/)            { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; 
+  if (/^-f2c$/)            { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
+                             shift; next; }
+  if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
                              shift; next; }
-  if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]"; 
+  if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
                              shift; next; }
   if (/^-submit-server/)   { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
   if (/^-submit-script/)   { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
-  if (/^-nickname$/)       { $nickname = "$ARGV[0]"; shift; next; } 
-  if (/^-gccpath/)         { $CONFIGUREARGS .= 
-                             " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; 
+  if (/^-submit-aux/)      { $SUBMITAUX = "$ARGV[0]"; shift; next; }
+  if (/^-nosubmit$/)       { $SUBMIT = 0; next; }
+  if (/^-nickname$/)       { $nickname = "$ARGV[0]"; shift; next; }
+  if (/^-gccpath/)         { $CONFIGUREARGS .=
+                             " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
                              $GCCPATH=$ARGV[0]; shift;  next; }
   else                     { $GCCPATH=""; }
-  if (/^-cvstag/)          { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } 
+  if (/^-cvstag/)          { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
   else                     { $CVSCOOPT="";}
-  if (/^-svnurl/)          { $SVNURL = $ARGV[0]; shift; next; }
-  if (/^-target/)          { $CONFIGUREARGS .= " --target=$ARGV[0]"; 
+  if (/^-usecvs/)          { $USESVN = 0; }
+  if (/^-target/)          { $CONFIGUREARGS .= " --target=$ARGV[0]";
                              shift; next; }
-  if (/^-cflags/)          { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; 
+  if (/^-cflags/)          { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
                              shift; next; }
-  if (/^-cxxflags/)        { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; 
+  if (/^-cxxflags/)        { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
                              shift; next; }
-  if (/^-ldflags/)         { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; 
+  if (/^-ldflags/)         { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
+                             shift; next; }
+  if (/^-test-cflags/)     { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
+                             shift; next; }
+  if (/^-test-cxxflags/)   { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
                              shift; next; }
   if (/^-compileflags/)    { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
   if (/^-use-gmake/)       { $MAKECMD = "gmake"; shift; next; }
-  if (/^-extraflags/)      { $CONFIGUREARGS .= 
+  if (/^-extraflags/)      { $CONFIGUREARGS .=
                              " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
   if (/^-noexternals$/)    { $NOEXTERNALS = 1; next; }
   if (/^-nodejagnu$/)      { $NODEJAGNU = 1; next; }
@@ -191,7 +224,7 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
 
 if ($ENV{'LLVMGCCDIR'}) {
   $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
-  $LLVMGCCPATH = $ENV{'LLVMGCCDIR'};
+  $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
 }
 else {
   $LLVMGCCPATH = "";
@@ -220,9 +253,9 @@ if ($CVSRootDir eq "" or
   die("please specify a cvs root directory, a build directory, and a ".
        "web directory");
  }
+
 if ($nickname eq "") {
-  die ("Please invoke NewNightlyTest.pl with command line option " . 
+  die ("Please invoke NewNightlyTest.pl with command line option " .
        "\"-nickname <nickname>\"");
 }
 
@@ -238,7 +271,6 @@ if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
 my $Prefix = "$WebDir/$DATE";
 my $BuildLog = "$Prefix-Build-Log.txt";
 my $COLog = "$Prefix-CVS-Log.txt";
-my $OldenTestsLog = "$Prefix-Olden-tests.txt";
 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
@@ -279,6 +311,44 @@ sub GetDir {
   return @Result;
 }
 
+sub RunLoggedCommand {
+  my $Command = shift;
+  my $Log = shift;
+  my $Title = shift;
+  if ($TEELOGS) {
+      if ($VERBOSE) {
+          print "$Title\n";
+          print "$Command 2>&1 | tee $Log\n";
+      }
+      system "$Command 2>&1 | tee $Log";
+  } else {
+      if ($VERBOSE) {
+          print "$Title\n";
+          print "$Command 2>&1 > $Log\n";
+      }
+      system "$Command 2>&1 > $Log";
+  }
+}
+
+sub RunAppendingLoggedCommand {
+  my $Command = shift;
+  my $Log = shift;
+  my $Title = shift;
+  if ($TEELOGS) {
+      if ($VERBOSE) {
+          print "$Title\n";
+          print "$Command 2>&1 | tee -a $Log\n";
+      }
+      system "$Command 2>&1 | tee -a $Log";
+  } else {
+      if ($VERBOSE) {
+          print "$Title\n";
+          print "$Command 2>&1 > $Log\n";
+      }
+      system "$Command 2>&1 >> $Log";
+  }
+}
+
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # DiffFiles - Diff the current version of the file against the last version of
@@ -305,7 +375,7 @@ sub DiffFiles {
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 sub GetRegex {   # (Regex with ()'s, value)
   $_[1] =~ /$_[0]/m;
-  return $1 
+  return $1
     if (defined($1));
   return "0";
 }
@@ -326,7 +396,7 @@ sub ChangeDir { # directory, logical name
   if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
   $result = chdir($dir);
   if (!$result) {
-    print "ERROR!!! Cannot change directory to: $name ($dir) because $!"; 
+    print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
     return false;
   }
   return true;
@@ -392,7 +462,7 @@ sub FormatTime {
 
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
-# This function is meant to read in the dejagnu sum file and 
+# This function is meant to read in the dejagnu sum file and
 # return a string with only the results (i.e. PASS/FAIL/XPASS/
 # XFAIL).
 #
@@ -434,14 +504,25 @@ sub SendData{
     $file = $_[1];
     $variables=$_[2];
 
-    $port=80;
-    $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
-    socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or 
-      die "Bad socket\n";
-    connect SOCK, $socketaddr or die "Bad connection\n";
-    select((select(SOCK), $| = 1)[0]);
+    # Write out the "...-sentdata.txt" file.
+
+    my $sentdata="";
+    foreach $x (keys (%$variables)){
+        $value = $variables->{$x};
+        $sentdata.= "$x  => $value\n";
+    }
+    WriteFile "$Prefix-sentdata.txt", $sentdata;
+
+    if (!($SUBMITAUX eq "")) {
+        system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
+    }
+
+    if (!$SUBMIT) { 
+        return "Skipped standard submit.\n";
+    }
+
+    # Create the content to send to the server.
 
-    #creating content here
     my $content;
     foreach $key (keys (%$variables)){
         $value = $variables->{$key};
@@ -449,6 +530,17 @@ sub SendData{
         $content .= "$key=$value&";
     }
 
+    # Send the data to the server.
+    # 
+    # FIXME: This code should be more robust?
+    
+    $port=80;
+    $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
+    socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
+      die "Bad socket\n";
+    connect SOCK, $socketaddr or die "Bad connection\n";
+    select((select(SOCK), $| = 1)[0]);
+
     $length = length($content);
 
     my $send= "POST $file HTTP/1.0\n";
@@ -464,14 +556,6 @@ sub SendData{
     }
     close(SOCK);
 
-    my $sentdata="";
-    foreach $x (keys (%$variables)){
-        $value = $variables->{$x};
-        $sentdata.= "$x  => $value\n";
-    }
-    WriteFile "$Prefix-sentdata.txt", $sentdata;
-    
-
     return $result;
 }
 
@@ -504,39 +588,37 @@ if (!$NOCHECKOUT) {
     mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
   }
 }
-ChangeDir( $BuildDir, "checkout directory" );
 
 
 ##############################################################
 #
-# Check out the llvm tree, using either SVN or CVS 
+# Check out the llvm tree, using either SVN or CVS
 #
 ##############################################################
 if (!$NOCHECKOUT) {
-  if ( $VERBOSE ) { 
-    print "CHECKOUT STAGE:\n"; 
-  }
+  ChangeDir( $BuildDir, "checkout directory" );
   if ($USESVN) {
-    my $SVNCMD = "$NICE svn co $SVNURL";
-    if ($VERBOSE) {
-      print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
-            "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
-      system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
-            "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
-    }
+      my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
+      my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
+      RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
+                       "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
+                       "CHECKOUT LLVM");
+      if ($WITHCLANG) {
+        my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
+        RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
+                         "CHECKOUT CLANG");
+      }
   } else {
     my $CVSOPT = "";
     $CVSOPT = "-z3" # Use compression if going over ssh.
       if $CVSRootDir =~ /^:ext:/;
     my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
-    print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
-          "$CVSCMD llvm-test ) > $COLog 2>&1\n";
-    system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
-          "$CVSCMD llvm-test ) > $COLog 2>&1\n";
+    RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
+                     "$CVSCMD llvm-test )", $COLog,
+                     "CHECKOUT LLVM-TEST");
   }
 }
-ChangeDir( $BuildDir , "Checkout directory") ;
-ChangeDir( "llvm" , "llvm source directory") ;
+ChangeDir( $LLVMSrcDir , "llvm source directory") ;
 
 ##############################################################
 #
@@ -554,7 +636,7 @@ my $NumFilesInCVS = 0;
 my $NumDirsInCVS  = 0;
 if ($USESVN) {
   $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
-  $NumDirsInCVS  = `sed -e 's#/[^/]*$##' $COLog | sort | uniq | wc -l` + 0;
+  $NumDirsInCVS  = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
 } else {
   $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
   $NumDirsInCVS  = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
@@ -592,7 +674,7 @@ if (!$NOCVSSTATS) {
   if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
 
   if ($USESVN) {
-    @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
+    @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
     # Skip very first entry because it is the XML header cruft
     shift @SVNHistory;
     my $Now = time();
@@ -655,7 +737,7 @@ if (!$NOCVSSTATS) {
             next;
         }
         # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
-        
+
         if ($Filename =~ /^llvm/) {
             if ($Type eq 'M') {        # Modified
                 $ModifiedFiles{$Filename} = 1;
@@ -689,19 +771,11 @@ my $UserUpdateList = join "\n", sort keys %UsersUpdated;
 ##############################################################
 if (!$NOCHECKOUT && !$NOBUILD) {
   my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
-  if ( $VERBOSE ) {
-    print "CONFIGURE STAGE:\n";
-    print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " . 
-          "> $BuildLog 2>&1\n";
-  }
-  system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " . 
-         "> $BuildLog 2>&1";
-  if ( $VERBOSE ) { 
-    print "BUILD STAGE:\n";
-    print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
-  }
+  RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
+                   $BuildLog, "CONFIGURE");
   # Build the entire tree, capturing the output into $BuildLog
-  system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
+  RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
+  RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
 }
 
 ##############################################################
@@ -717,7 +791,7 @@ if (!$NOCHECKOUT && !$NOBUILD) {
 
 # Get the number of lines of source code. Must be here after the build is done
 # because countloc.sh uses the llvm-config script which must be built.
-my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
+my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
 
 # Get the time taken by the configure script
 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
@@ -739,7 +813,6 @@ $BuildWallTime=-1 unless $BuildWallTime;
 my $BuildError = 0, $BuildStatus = "OK";
 if ($NOBUILD) {
   $BuildStatus = "Skipped by user";
-  $BuildError = 1;
 }
 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
   `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
@@ -752,43 +825,23 @@ if ($BuildError) { $NODEJAGNU=1; }
 my $a_file_sizes="";
 my $o_file_sizes="";
 if (!$BuildError) {
-  print "Organizing size of .o and .a files\n" 
+  print "Organizing size of .o and .a files\n"
     if ( $VERBOSE );
-  ChangeDir( "$BuildDir/llvm", "Build Directory" );
-  $afiles.= `find utils/ -iname '*.a' -ls`;
-  $afiles.= `find lib/ -iname '*.a' -ls`;
-  $afiles.= `find tools/ -iname '*.a' -ls`;
-  if($BUILDTYPE eq "release"){
-    $afiles.= `find Release/ -iname '*.a' -ls`;
-  } elsif($BUILDTYPE eq "release-asserts") {
-   $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
-  } else {
-   $afiles.= `find Debug/ -iname '*.a' -ls`;
-  }
-  
-  $ofiles.= `find utils/ -iname '*.o' -ls`;
-  $ofiles.= `find lib/ -iname '*.o' -ls`;
-  $ofiles.= `find tools/ -iname '*.o' -ls`;
+  ChangeDir( "$LLVMObjDir", "Build Directory" );
+
+  my @dirs = ('utils', 'lib', 'tools');
   if($BUILDTYPE eq "release"){
-    $ofiles.= `find Release/ -iname '*.o' -ls`;
+    push @dirs, 'Release';
   } elsif($BUILDTYPE eq "release-asserts") {
-    $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
+    push @dirs, 'Release-Asserts';
   } else {
-    $ofiles.= `find Debug/ -iname '*.o' -ls`;
-  }
-  
-  @AFILES = split "\n", $afiles;
-  $a_file_sizes="";
-  foreach $x (@AFILES){
-    $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
-    $a_file_sizes.="$1 $2 $BUILDTYPE\n";
-  }
-  @OFILES = split "\n", $ofiles;
-  $o_file_sizes="";
-  foreach $x (@OFILES){
-    $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
-    $o_file_sizes.="$1 $2 $BUILDTYPE\n";
+    push @dirs, 'Debug';
   }
+
+  find(sub {
+      $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
+      $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
+    }, @dirs);
 } else {
   $a_file_sizes="No data due to a bad build.";
   $o_file_sizes="No data due to a bad build.";
@@ -802,15 +855,10 @@ if (!$BuildError) {
 my $DejangnuTestResults=""; # String containing the results of the dejagnu
 my $dejagnu_output = "$DejagnuTestsLog";
 if (!$NODEJAGNU) {
-  if($VERBOSE) { 
-    print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n"; 
-    print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
-  }
-
   #Run the feature and regression tests, results are put into testrun.sum
   #Full log in testrun.log
-  system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
-  
+  RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
+
   #Copy the testrun.log and testrun.sum to our webdir
   CopyFile("test/testrun.log", $DejagnuLog);
   CopyFile("test/testrun.sum", $DejagnuSum);
@@ -823,8 +871,8 @@ if (!$NODEJAGNU) {
 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
 $DejagnuTime  = $DejagnuTimeU+$DejagnuTimeS;  # DejagnuTime = User+System
-$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output"; 
-$DejagnuTestResults = 
+$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
+$DejagnuTestResults =
   "Dejagnu skipped by user choice." unless $DejagnuTestResults;
 $DejagnuTime     = "0.0" unless $DejagnuTime;
 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
@@ -844,7 +892,7 @@ if (!$NODEJAGNU) {
     if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
       $CurDir = $1;                 # Keep track of directory warning is in...
       # Remove buildir prefix if included
-      if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
+      if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
     } else {
       push @Warnings, "$CurDir/$Warning";     # Add directory to warning...
     }
@@ -869,27 +917,29 @@ if (!$NODEJAGNU) {
 #
 # If we built the tree successfully, run the nightly programs tests...
 #
-# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" 
+# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
 # "External")
 #
 ##############################################################
+
 sub TestDirectory {
-  my $SubDir = shift;  
-  ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir", 
+  my $SubDir = shift;
+  ChangeDir( "$LLVMTestDir/$SubDir",
              "Programs Test Subdirectory" ) || return ("", "");
-  
+
   my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
-  
+
   # Run the programs tests... creating a report.nightly.csv file
   if (!$NOTEST) {
-    if( $VERBOSE) { 
+    if( $VERBOSE) {
       print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
-            "TEST=nightly > $ProgramTestLog 2>&1\n"; 
+            "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
     }
-    system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
-           "TEST=nightly > $ProgramTestLog 2>&1";
+    RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
+                     "$TESTFLAGS TEST=nightly",
+                     $ProgramTestLog, "TEST DIRECTORY $SubDir");
     $llcbeta_options=`$MAKECMD print-llcbeta-option`;
-  } 
+  }
 
   my $ProgramsTable;
   if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
@@ -920,27 +970,18 @@ sub TestDirectory {
 #
 ##############################################################
 if (!$BuildError) {
-  if ( $VERBOSE ) {
-     print "SingleSource TEST STAGE\n";
-  }
-  ($SingleSourceProgramsTable, $llcbeta_options) = 
+  ($SingleSourceProgramsTable, $llcbeta_options) =
     TestDirectory("SingleSource");
   WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
-  if ( $VERBOSE ) {
-    print "MultiSource TEST STAGE\n";
-  }
   ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
   WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
   if ( ! $NOEXTERNALS ) {
-    if ( $VERBOSE ) {
-      print "External TEST STAGE\n";
-    }
     ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
     WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
-    system "cat $Prefix-SingleSource-Tests.txt " . 
+    system "cat $Prefix-SingleSource-Tests.txt " .
                "$Prefix-MultiSource-Tests.txt ".
                "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
-    system "cat $Prefix-SingleSource-Performance.txt " . 
+    system "cat $Prefix-SingleSource-Performance.txt " .
                "$Prefix-MultiSource-Performance.txt ".
                "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
   } else {
@@ -948,18 +989,18 @@ if (!$BuildError) {
     if ( $VERBOSE ) {
       print "External TEST STAGE SKIPPED\n";
     }
-    system "cat $Prefix-SingleSource-Tests.txt " . 
+    system "cat $Prefix-SingleSource-Tests.txt " .
                "$Prefix-MultiSource-Tests.txt ".
                " | sort > $Prefix-Tests.txt";
-    system "cat $Prefix-SingleSource-Performance.txt " . 
+    system "cat $Prefix-SingleSource-Performance.txt " .
                "$Prefix-MultiSource-Performance.txt ".
                " | sort > $Prefix-Performance.txt";
   }
 
   ##############################################################
   #
-  # 
-  # gathering tests added removed broken information here 
+  #
+  # gathering tests added removed broken information here
   #
   #
   ##############################################################
@@ -980,40 +1021,8 @@ if (!$BuildError) {
       }
     }
   }
-  
-} #end if !$BuildError
-
 
-##############################################################
-#
-# If we built the tree successfully, runs of the Olden suite with
-# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
-#
-##############################################################
-if (!$BuildError) {
-  if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
-  my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
-  $MachCodeSize) = ("","","","","","","");
-  if (!$NORUNNINGTESTS) {
-    ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
-                "Olden Test Directory");
-
-    # Clean out previous results...
-    system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
-
-    # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
-    # GET_STABLE_NUMBERS enabled!
-    if( $VERBOSE ) { 
-      print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
-            "TEST=nightly  LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
-            "> /dev/null 2>&1\n"; 
-    }
-    system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
-           "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
-           "> /dev/null 2>&1";
-    system "cp report.nightly.csv $OldenTestsLog";
-  }  
-}
+} #end if !$BuildError
 
 ##############################################################
 #
@@ -1030,12 +1039,12 @@ $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
 ##############################################################
 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
 
-$machine_data = "uname: ".`uname -a`. 
+$machine_data = "uname: ".`uname -a`.
                 "hardware: ".`uname -m`.
                 "os: ".`uname -sr`.
                 "name: ".`uname -n`.
                 "date: ".`date \"+20%y-%m-%d\"`.
-                "time: ".`date +\"%H:%M:%S\"`; 
+                "time: ".`date +\"%H:%M:%S\"`;
 
 my @CVS_DATA;
 my $cvs_data;
@@ -1135,16 +1144,14 @@ my %hash_of_data = (
   'target_triple' => $targetTriple
 );
 
-$TESTING = 0;
-
-if ($TESTING) {
+if ($SUBMIT || !($SUBMITAUX eq "")) {
+  my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
+  if( $VERBOSE) { print "============================\n$response"; }
+} else {
   print "============================\n";
   foreach $x(keys %hash_of_data){
       print "$x  => $hash_of_data{$x}\n";
   }
-} else {
-  my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
-  if( $VERBOSE) { print "============================\n$response"; }
 }
 
 ##############################################################
@@ -1152,7 +1159,7 @@ if ($TESTING) {
 # Remove the cvs tree...
 #
 ##############################################################
-system ( "$NICE rm -rf $BuildDir") 
-  if (!$NOCHECKOUT and !$NOREMOVE);
-system ( "$NICE rm -rf $WebDir") 
+system ( "$NICE rm -rf $BuildDir")
+  if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
+system ( "$NICE rm -rf $WebDir")
   if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);