capture implicit uses and defs in CodeGenInstruction
[oota-llvm.git] / utils / NewNightlyTest.pl
index 7e429da589fd519119dba3736ed7e74dac3243ba..4287cc1da5436543f1d47fce016d02ecb44a48f8 100755 (executable)
@@ -24,6 +24,7 @@ use Socket;
 #                   IMPLEMENTED.
 #  -nickname NAME   The NAME argument specifieds the nickname this script
 #                   will submit to the nightlytest results repository.
+#  -nouname         Don't include uname data (machine will be identified by nickname only).
 #  -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
@@ -43,6 +44,7 @@ use Socket;
 #                   the source tree.
 #  -noremove        Do not remove the BUILDDIR after it has been built.
 #  -noremoveresults Do not remove the WEBDIR after it has been built.
+#  -noclean         Do not run 'make clean' before building.
 #  -nobuild         Do not build llvm. If tests are enabled perform them
 #                   on the llvm build specified in the build directory
 #  -release         Build an LLVM Release version
@@ -53,6 +55,7 @@ use Socket;
 #                   building LLVM.
 #  -use-gmake       Use gmake instead of the default make command to build
 #                   llvm and run tests.
+#  -llvmgccdir      Next argument specifies the llvm-gcc install prefix.
 #
 # TESTING OPTIONS:
 #  -notest          Do not even attempt to run the test programs.
@@ -77,6 +80,7 @@ use Socket;
 # OTHER OPTIONS:
 #  -parallel        Run parallel jobs with GNU Make (see -parallel-jobs).
 #  -parallel-jobs   The number of parallel Make jobs to use (default is two).
+#  -parallel-test   Allow parallel execution of llvm-test
 #  -verbose         Turn on some debug output
 #  -nice            Checkout/Configure/Build with "nice" to reduce impact
 #                   on busy servers.
@@ -114,20 +118,14 @@ $TestSVNURL    = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
 my $BuildDir   = $ENV{'BUILDDIR'};
 my $WebDir     = $ENV{'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...
 #
 ##############################################################
+use POSIX;
 @TIME = localtime;
-my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
+my $DATE = strftime("%Y-%m-%d_%H-%M-%S", localtime());
 
 ##############################################################
 #
@@ -146,6 +144,14 @@ $SUBMIT = 1;
 $PARALLELJOBS = "2";
 my $TESTFLAGS="";
 
+if ($ENV{'LLVMGCCDIR'}) {
+  $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
+  $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
+}
+else {
+  $LLVMGCCPATH = "";
+}
+
 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   shift;
   last if /^--$/;  # Stop processing arguments on --
@@ -153,20 +159,21 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   # List command line options here...
   if (/^-config$/)         { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
   if (/^-nocheckout$/)     { $NOCHECKOUT = 1; next; }
+  if (/^-noclean$/)        { $NOCLEAN = 1; next; }
   if (/^-noremove$/)       { $NOREMOVE = 1; next; }
   if (/^-noremoveatend$/)  { $NOREMOVEATEND = 1; next; }
   if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; 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 (/^-parallel$/)       { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
+  if (/^-parallel-test$/)  { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; next; }
   if (/^-with-clang$/)     { $WITHCLANG = 1; next; }
   if (/^-release$/)        { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
-                             "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
+                             "OPTIMIZE_OPTION=-O2"; next;}
   if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
                              "DISABLE_ASSERTIONS=1 ".
-                             "OPTIMIZE_OPTION=-O2";
-                             $BUILDTYPE="release-asserts"; next;}
+                             "OPTIMIZE_OPTION=-O2"; next;}
   if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
   if (/^-disable-pic$/)    { $CONFIGUREARGS .= " --enable-pic=no"; next; }
   if (/^-enable-lli$/)     { $PROGTESTOPTS .= " ENABLE_LLI=1";
@@ -210,23 +217,20 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   if (/^-test-cxxflags/)   { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
                              shift; next; }
   if (/^-compileflags/)    { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
+  if (/^-llvmgccdir/)      { $CONFIGUREARGS .= " --with-llvmgccdir=\'$ARGV[0]\'";
+                             $LLVMGCCPATH = $ARGV[0] . '/bin';
+                             shift; next;}
+  if (/^-noexternals$/)    { $NOEXTERNALS = 1; next; }
+  if (/^-nouname$/)        { $NOUNAME = 1; next; }
   if (/^-use-gmake/)       { $MAKECMD = "gmake"; shift; next; }
   if (/^-extraflags/)      { $CONFIGUREARGS .=
                              " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
   if (/^-noexternals$/)    { $NOEXTERNALS = 1; next; }
-  if (/^-nodejagnu$/)      { $NODEJAGNU = 1; next; }
+  if (/^-nodejagnu$/)      { next; }
   if (/^-nobuild$/)        { $NOBUILD = 1; next; }
   print "Unknown option: $_ : ignoring!\n";
 }
 
-if ($ENV{'LLVMGCCDIR'}) {
-  $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
-  $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
-}
-else {
-  $LLVMGCCPATH = "";
-}
-
 if ($CONFIGUREARGS !~ /--disable-jit/) {
   $CONFIGUREARGS .= " --enable-jit";
 }
@@ -245,55 +249,48 @@ if (@ARGV == 3) {
   $WebDir     = $ARGV[2];
 }
 
-if ($BuildDir   eq "" or
-    $WebDir     eq "") {
-  die("please specify a build directory, and a web directory");
- }
+if ($CONFIG_PATH ne "") {
+  $BuildDir = "";
+  $SVNURL = $TestSVNURL = "";
+  if ($WebDir     eq "") {
+    die("please specify a web directory");
+  }
+} else {
+  if ($BuildDir   eq "" or
+      $WebDir     eq "") {
+    die("please specify a build directory, and a web directory");
+  }
+}
 
 if ($nickname eq "") {
   die ("Please invoke NewNightlyTest.pl with command line option " .
        "\"-nickname <nickname>\"");
 }
 
-if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
-  $BUILDTYPE = "debug";
-}
-
-if ($CONFIG_PATH ne "") {
-  die "error: -config mode is not yet implemented,";
-}
+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;
 
 ##############################################################
 #
 # Define the file names we'll use
 #
 ##############################################################
+
 my $Prefix = "$WebDir/$DATE";
-my $ConfigureLog = "$Prefix-Configure-Log.txt";
-my $BuildLog = "$Prefix-Build-Log.txt";
-my $COLog = "$Prefix-CVS-Log.txt";
 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
-my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
-my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
-my $DejagnuLog = "$Prefix-DejagnuTests-Log.txt";
-if (! -d $WebDir) {
-  mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
-  if($VERBOSE){
-    warn "$WebDir did not exist; creating it.\n";
-  }
-}
 
-if ($VERBOSE) {
-  print "INITIALIZED\n";
-  print "SVN URL  = $SVNURL\n";
-  print "COLog    = $COLog\n";
-  print "BuildDir = $BuildDir\n";
-  print "WebDir   = $WebDir\n";
-  print "Prefix   = $Prefix\n";
-  print "BuildLog = $BuildLog\n";
-}
+# These are only valid in non-config mode.
+my $ConfigureLog = "", $BuildLog = "", $COLog = "";
+my $DejagnuLog = "", $DejagnuSum = "", $DejagnuLog = "";
+
+# Are we in config mode?
+my $ConfigMode = 0;
 
 ##############################################################
 #
@@ -322,9 +319,9 @@ sub RunLoggedCommand {
   } else {
       if ($VERBOSE) {
           print "$Title\n";
-          print "$Command 2>&1 > $Log\n";
+          print "$Command > $Log 2>&1\n";
       }
-      system "$Command 2>&1 > $Log";
+      system "$Command > $Log 2>&1";
   }
 }
 
@@ -341,9 +338,9 @@ sub RunAppendingLoggedCommand {
   } else {
       if ($VERBOSE) {
           print "$Title\n";
-          print "$Command 2>&1 > $Log\n";
+          print "$Command >> $Log 2>&1\n";
       }
-      system "$Command 2>&1 >> $Log";
+      system "$Command >> $Log 2>&1";
   }
 }
 
@@ -360,7 +357,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 $!\n";
     return false;
   }
   return true;
@@ -392,49 +389,14 @@ sub CopyFile { #filename, newfile
   copy($file, $newfile);
 }
 
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-# 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).
-#
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-sub GetDejagnuTestResults { # (filename, log)
-    my ($filename, $DejagnuLog) = @_;
-    my @lines;
-    $/ = "\n"; #Make sure we're going line at a time.
-
-    if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
-
-    if (open SRCHFILE, $filename) {
-        # Process test results
-        while ( <SRCHFILE> ) {
-            if ( length($_) > 1 ) {
-                chomp($_);
-                if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
-                    push(@lines, "$1: test/$2");
-                }
-            }
-        }
-    }
-    close SRCHFILE;
-
-    my $content = join("\n", @lines);
-    return $content;
-}
-
-
-
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # This function acts as a mini web browswer submitting data
 # to our central server via the post method
 #
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-sub SendData {
-    $host = $_[0];
-    $file = $_[1];
-    $variables = $_[2];
+sub WriteSentData {
+    $variables = $_[0];
 
     # Write out the "...-sentdata.txt" file.
 
@@ -444,6 +406,12 @@ sub SendData {
         $sentdata.= "$x  => $value\n";
     }
     WriteFile "$Prefix-sentdata.txt", $sentdata;
+}
+
+sub SendData {
+    $host = $_[0];
+    $file = $_[1];
+    $variables = $_[2];
 
     if (!($SUBMITAUX eq "")) {
         system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
@@ -499,78 +467,54 @@ sub SendData {
 
 # Create the source repository directory.
 sub CheckoutSource {
-  if (!$NOCHECKOUT) {
-    if (-d $BuildDir) {
-      if (!$NOREMOVE) {
-        if ( $VERBOSE ) {
-          print "Build directory exists! Removing it\n";
-        }
-        system "rm -rf $BuildDir";
-        mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
-      } else {
-        if ( $VERBOSE ) {
-          print "Build directory exists!\n";
-        }
+  die "Invalid call!" unless $ConfigMode == 0;
+  if (-d $BuildDir) {
+    if (!$NOREMOVE) {
+      if ( $VERBOSE ) {
+        print "Build directory exists! Removing it\n";
       }
-    } else {
+      system "rm -rf $BuildDir";
       mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
+    } else {
+      if ( $VERBOSE ) {
+        print "Build directory exists!\n";
+      }
     }
+  } else {
+    mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
+  }
 
-    ChangeDir( $BuildDir, "checkout directory" );
-    my $SVNCMD = "$NICE svn co --non-interactive";
-    RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
-                     "  $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
-                     "CHECKOUT LLVM");
-    if ($WITHCLANG) {
-        RunLoggedCommand("( cd llvm/tools ; " .
-                         "  $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
-                         "CHECKOUT CLANG");
-    }
+  ChangeDir( $BuildDir, "checkout directory" );
+  my $SVNCMD = "$NICE svn co --non-interactive";
+  RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
+                   "  $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
+                   "CHECKOUT LLVM");
+  if ($WITHCLANG) {
+      RunLoggedCommand("( cd llvm/tools ; " .
+                       "  $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
+                       "CHECKOUT CLANG");
   }
 }
 
-# Build the entire tree, saving build messages to the build log.
+# Build the entire tree, saving build messages to the build log. Returns false
+# on build failure.
 sub BuildLLVM {
-  if (!$NOCHECKOUT && !$NOBUILD) {
-    my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
-    RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
-                     $ConfigureLog, "CONFIGURE");
-    # Build the entire tree, capturing the output into $BuildLog
-    RunAppendingLoggedCommand("($NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
-    RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
+  die "Invalid call!" unless $ConfigMode == 0;
+  my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
+  RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
+                   $ConfigureLog, "CONFIGURE");
+  # Build the entire tree, capturing the output into $BuildLog
+  if (!$NOCLEAN) {
+      RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
   }
+  RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
 
-  # Check for build error.
-  my $HadError = 0, $Status = "OK";
-  if ($NOBUILD) {
-    $Status = "Skipped by user";
-  }
-  elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
-    `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
-    $Status = "Error: compilation aborted";
-    $HadError = 1;
+  if (`grep -a '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
+      `grep -a '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
+    return 0;
   }
 
-  return ($HadError, $Status);
-}
-
-# Running dejagnu tests and save results to log.
-sub RunDejaGNUTests {
-  my $Res = "Dejagnu skipped by user choice.";
-
-  if (!$NODEJAGNU) {
-    #Run the feature and regression tests, results are put into testrun.sum
-    #Full log in testrun.log
-    RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $DejagnuLog, "DEJAGNU");
-
-    #Copy the testrun.log and testrun.sum to our webdir
-    CopyFile("test/testrun.log", $DejagnuLog);
-    CopyFile("test/testrun.sum", $DejagnuSum);
-
-    $Res = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
-  }
-
-  return $Res;
+  return 1;
 }
 
 # Run the named tests (i.e. "SingleSource" "MultiSource" "External")
@@ -581,35 +525,28 @@ sub TestDirectory {
 
   my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
 
-  # Run the programs tests... creating a report.nightly.csv file
+  # Make sure to clean the test results.
+  RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
+                   $ProgramTestLog, "TEST DIRECTORY $SubDir");
+
+  # Run the programs tests... creating a report.nightly.csv file.
   my $LLCBetaOpts = "";
-  if (!$NOTEST) {
-    if( $VERBOSE) {
-      print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
-            "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
-    }
-    RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
-                     "$TESTFLAGS TEST=nightly",
-                     $ProgramTestLog, "TEST DIRECTORY $SubDir");
-    $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
-  }
+  RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
+                   "$TESTFLAGS TEST=nightly",
+                   $ProgramTestLog, "TEST DIRECTORY $SubDir");
+  $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
 
   my $ProgramsTable;
-  if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
-    $TestError = 1;
+  if (`grep -a '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
     $ProgramsTable="Error running test $SubDir\n";
     print "ERROR TESTING\n";
-  } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
-    $TestError = 1;
+  } elsif (`grep -a '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
     $ProgramsTable="Makefile error running tests $SubDir!\n";
     print "ERROR TESTING\n";
   } else {
-    $TestError = 0;
-  #
-  # Create a list of the tests which were run...
-  #
-  system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
-         "| sort > $Prefix-$SubDir-Tests.txt";
+    # Create a list of the tests which were run...
+    system "egrep -a 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
+           "| sort > $Prefix-$SubDir-Tests.txt";
   }
   $ProgramsTable = ReadFile "report.nightly.csv";
 
@@ -617,54 +554,97 @@ sub TestDirectory {
   return ($ProgramsTable, $LLCBetaOpts);
 }
 
-# Run all the nightly tests and return the program tables and the number of
+# Run all the nightly tests and return the program tables and the list of tests,
 # passes, fails, and xfails.
 sub RunNightlyTest() {
-  if (!$BuildError) {
-    ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
-    WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
-    ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
-    WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
-    if ( ! $NOEXTERNALS ) {
-      ($ExtProgs, $llcbeta_options) = TestDirectory("External");
-      WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
-      system "cat $Prefix-SingleSource-Tests.txt " .
-                 "$Prefix-MultiSource-Tests.txt ".
-                 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
-      system "cat $Prefix-SingleSource-Performance.txt " .
-                 "$Prefix-MultiSource-Performance.txt ".
-                 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
-    } else {
-      $ExtProgs = "External TEST STAGE SKIPPED\n";
-      if ( $VERBOSE ) {
-        print "External TEST STAGE SKIPPED\n";
-      }
-      system "cat $Prefix-SingleSource-Tests.txt " .
-                 "$Prefix-MultiSource-Tests.txt ".
-                 " | sort > $Prefix-Tests.txt";
-      system "cat $Prefix-SingleSource-Performance.txt " .
-                 "$Prefix-MultiSource-Performance.txt ".
-                 " | sort > $Prefix-Performance.txt";
+  ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
+  WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
+  ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
+  WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
+  if ( ! $NOEXTERNALS ) {
+    ($ExtProgs, $llcbeta_options) = TestDirectory("External");
+    WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
+    system "cat $Prefix-SingleSource-Tests.txt " .
+               "$Prefix-MultiSource-Tests.txt ".
+               "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
+    system "cat $Prefix-SingleSource-Performance.txt " .
+               "$Prefix-MultiSource-Performance.txt ".
+               "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
+  } else {
+    $ExtProgs = "External TEST STAGE SKIPPED\n";
+    if ( $VERBOSE ) {
+      print "External TEST STAGE SKIPPED\n";
     }
+    system "cat $Prefix-SingleSource-Tests.txt " .
+               "$Prefix-MultiSource-Tests.txt ".
+               " | sort > $Prefix-Tests.txt";
+    system "cat $Prefix-SingleSource-Performance.txt " .
+               "$Prefix-MultiSource-Performance.txt ".
+               " | sort > $Prefix-Performance.txt";
+  }
 
-    # Compile passes, fails, xfails.
-    my @TestSuiteResultLines = split "\n", (ReadFile "$Prefix-Tests.txt");
-    my ($Passes, $Fails, $XFails) = "";
+  # Compile passes, fails, xfails.
+  my $All = (ReadFile "$Prefix-Tests.txt");
+  my @TestSuiteResultLines = split "\n", $All;
+  my ($Passes, $Fails, $XFails) = "";
 
-    for ($x=0; $x < @TestSuiteResultLines; $x++) {
-      if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
-        $Passes .= "$TestSuiteResultLines[$x]\n";
-      }
-      elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
-        $Fails .= "$TestSuiteResultLines[$x]\n";
-      }
-      elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
-        $XFails .= "$TestSuiteResultLines[$x]\n";
-      }
+  for ($x=0; $x < @TestSuiteResultLines; $x++) {
+    if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
+      $Passes .= "$TestSuiteResultLines[$x]\n";
+    }
+    elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
+      $Fails .= "$TestSuiteResultLines[$x]\n";
+    }
+    elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
+      $XFails .= "$TestSuiteResultLines[$x]\n";
     }
   }
 
-  return ($SSProgs, $MSProgs, $ExtProgs, $Passes, $Fails, $XFails);
+  return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
+}
+
+##############################################################
+#
+# Initialize filenames
+#
+##############################################################
+
+if (! -d $WebDir) {
+  mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
+  if($VERBOSE){
+    warn "$WebDir did not exist; creating it.\n";
+  }
+}
+
+if ($CONFIG_PATH ne "") {
+  $ConfigMode = 1;
+  $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
+  $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
+  # FIXME: Add llvm-config hook for this?
+  $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
+} else {
+  $ConfigureLog = "$Prefix-Configure-Log.txt";
+  $BuildLog = "$Prefix-Build-Log.txt";
+  $COLog = "$Prefix-CVS-Log.txt";
+}
+
+if ($VERBOSE) {
+  if ($CONFIG_PATH ne "") {
+    print "INITIALIZED (config mode)\n";
+    print "WebDir    = $WebDir\n";
+    print "Prefix    = $Prefix\n";
+    print "LLVM Src  = $LLVMSrcDir\n";
+    print "LLVM Obj  = $LLVMObjDir\n";
+    print "LLVM Test = $LLVMTestDir\n";
+  } else {
+    print "INITIALIZED\n";
+    print "SVN URL  = $SVNURL\n";
+    print "COLog    = $COLog\n";
+    print "BuildDir = $BuildDir\n";
+    print "WebDir   = $WebDir\n";
+    print "Prefix   = $Prefix\n";
+    print "BuildLog = $BuildLog\n";
+  }
 }
 
 ##############################################################
@@ -675,19 +655,38 @@ sub RunNightlyTest() {
 
 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
 
-CheckoutSource();
-ChangeDir( $LLVMSrcDir , "llvm source directory") ;
-($BuildError, $BuildStatus) = BuildLLVM();
-if ($BuildError) {
-    if( $VERBOSE) { print  "\n***ERROR BUILDING TREE\n\n"; }
-    $NODEJAGNU=1;
+my $BuildError = 0, $BuildStatus = "OK";
+if ($ConfigMode == 0) {
+  if (!$NOCHECKOUT) {
+    CheckoutSource();
+  }
+
+  # Build LLVM.
+  ChangeDir( $LLVMSrcDir , "llvm source directory") ;
+  if ($NOCHECKOUT || $NOBUILD) {
+    $BuildStatus = "Skipped by user";
+  } else {
+    if (!BuildLLVM()) {
+      if( $VERBOSE) { print  "\n***ERROR BUILDING TREE\n\n"; }
+      $BuildError = 1;
+      $BuildStatus = "Error: compilation aborted";
+    }
+  }
 }
-my $DejagnuTestResults = RunDejaGNUTests();
+
+# Run the llvm-test tests.
 my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
-    $passes, $fails, $xfails) = RunNightlyTest();
+    $all_tests, $passes, $fails, $xfails) = "";
+if (!$NOTEST && !$BuildError) {
+  ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
+   $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
+}
 
 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
 
+# The last bit of logic is to remove the build and web dirs, after sending data
+# to the server.
+
 ##############################################################
 #
 # Accumulate the information to send to the server.
@@ -696,12 +695,21 @@ $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`.
-                "hardware: ".`uname -m`.
-                "os: ".`uname -sr`.
-                "name: ".`uname -n`.
-                "date: ".`date \"+20%y-%m-%d\"`.
-                "time: ".`date +\"%H:%M:%S\"`;
+if ( ! $NOUNAME ) {
+    $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\"`;
+} else {
+    $machine_data = "uname: (excluded)\n".
+        "hardware: ".`uname -m`.
+        "os: ".`uname -sr`.
+        "name: $nickname\n".
+        "date: ".`date \"+20%y-%m-%d\"`.
+        "time: ".`date +\"%H:%M:%S\"`;
+}
 
 # Get gcc version.
 my $gcc_version_long = "";
@@ -715,6 +723,8 @@ if ($GCCPATH ne "") {
 my $gcc_version = (split '\n', $gcc_version_long)[0];
 
 # Get llvm-gcc target triple.
+#
+# FIXME: This shouldn't be hardwired to llvm-gcc.
 my $llvmgcc_version_long = "";
 if ($LLVMGCCPATH ne "") {
   $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
@@ -724,13 +734,13 @@ if ($LLVMGCCPATH ne "") {
 (split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
 my $targetTriple = $1;
 
-if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
-
 # Logs.
-my $ConfigureLogData = ReadFile $ConfigureLog;
-my $BuildLogData = ReadFile $BuildLog;
-my $DejagnuLogData = ReadFile $DejagnuLog;
-my $CheckoutLogData = ReadFile $COLog;
+my ($ConfigureLogData, $BuildLogData, $CheckoutLogData) = "";
+if ($ConfigMode == 0) {
+  $ConfigureLogData = ReadFile $ConfigureLog;
+  $BuildLogData = ReadFile $BuildLog;
+  $CheckoutLogData = ReadFile $COLog;
+}
 
 # Checkout info.
 my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
@@ -754,27 +764,37 @@ my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
 $BuildTime=-1 unless $BuildTime;
 $BuildWallTime=-1 unless $BuildWallTime;
 
-# DejaGNU info.
-my $DejagnuTimeU = GetRegex "^user ([0-9.]+)", $DejagnuLogData;
-my $DejagnuTimeS = GetRegex "^sys ([0-9.]+)", $DejagnuLogData;
-$DejagnuTime  = $DejagnuTimeU+$DejagnuTimeS;  # DejagnuTime = User+System
-$DejagnuWallTime = GetRegex "^real ([0-9.]+)", $DejagnuLogData;
-$DejagnuTime     = "0.0" unless $DejagnuTime;
-$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
+if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
 
 my %hash_of_data = (
   'machine_data' => $machine_data,
   'build_data' => $ConfigureLogData . $BuildLogData,
   'gcc_version' => $gcc_version,
   'nickname' => $nickname,
-  'dejagnutime_wall' => $DejagnuWallTime,
-  'dejagnutime_cpu' => $DejagnuTime,
+  'dejagnutime_wall' => "0.0",
+  'dejagnutime_cpu' => "0.0",
   'cvscheckouttime_wall' => $CheckoutTime_Wall,
   'cvscheckouttime_cpu' => $CheckoutTime_CPU,
   'configtime_wall' => $ConfigWallTime,
   'configtime_cpu'=> $ConfigTime,
   'buildtime_wall' => $BuildWallTime,
   'buildtime_cpu' => $BuildTime,
+  'buildstatus' => $BuildStatus,
+  'singlesource_programstable' => $SingleSourceProgramsTable,
+  'multisource_programstable' => $MultiSourceProgramsTable,
+  'externalsource_programstable' => $ExternalProgramsTable,
+  'llcbeta_options' => $llcbeta_options,
+  'passing_tests' => $passes,
+  'expfail_tests' => $xfails,
+  'unexpfail_tests' => $fails,
+  'all_tests' => $all_tests,
+  'dejagnutests_results' => "Dejagnu skipped by user choice.",
+  'dejagnutests_log' => "",
+  'starttime' => $starttime,
+  'endtime' => $endtime,
+  'target_triple' => $targetTriple,
+
+  # Unused, but left around for backwards compatability.
   'warnings' => "",
   'cvsusercommitlist' => "",
   'cvsuserupdatelist' => "",
@@ -784,28 +804,17 @@ my %hash_of_data = (
   'lines_of_code' => "",
   'cvs_file_count' => 0,
   'cvs_dir_count' => 0,
-  'buildstatus' => $BuildStatus,
-  'singlesource_programstable' => $SingleSourceProgramsTable,
-  'multisource_programstable' => $MultiSourceProgramsTable,
-  'externalsource_programstable' => $ExternalProgramsTable,
-  'llcbeta_options' => $llcbeta_options,
   'warnings_removed' => "",
   'warnings_added' => "",
-  'passing_tests' => $passes,
-  'expfail_tests' => $xfails,
-  'unexpfail_tests' => $fails,
-  'all_tests' => $dejagnu_test_list,
   'new_tests' => "",
   'removed_tests' => "",
-  'dejagnutests_results' => $DejagnuTestResults,
-  'dejagnutests_log' => $DejagnuLogData,
-  'starttime' => $starttime,
-  'endtime' => $endtime,
   'o_file_sizes' => "",
-  'a_file_sizes' => "",
-  'target_triple' => $targetTriple
+  'a_file_sizes' => ""
 );
 
+# Write out the "...-sentdata.txt" file.
+WriteSentData \%hash_of_data;
+
 if ($SUBMIT || !($SUBMITAUX eq "")) {
   my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
   if( $VERBOSE) { print "============================\n$response"; }