We now fail and print an error message if a nightly tester does not specify a nicknam...
[oota-llvm.git] / utils / NewNightlyTest.pl
index 76d477fc36ee033aa53991e8e3e995313644a125..a7137fd09605189aa790b79ccb9d97246b4924d2 100755 (executable)
@@ -20,15 +20,13 @@ use Socket;
 #  -nocheckout      Do not create, checkout, update, or configure
 #                   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.
 #  -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.
-#  -noexternals     Do not run the external tests (for cases where povray
-#                   or SPEC are not installed)
-#  -with-externals  Specify a directory where the external tests are located.
 #  -nodejagnu       Do not run feature or regression tests
 #  -parallel        Run two parallel jobs with GNU Make.
 #  -release         Build an LLVM Release version
@@ -53,14 +51,15 @@ use Socket;
 #                   override the default.
 #  -ldflags         Next argument specifies that linker options that override
 #                   the default.
-#  -extraflags      Next argument specifies extra options that are passed to
-#                   compile the tests.
+#  -compileflags    Next argument specifies extra options passed to make when
+#                   building LLVM.
 #
 #  ---------------- Options to configure llvm-test ----------------------------
-#  -spec2000path    Path to the benchspec directory in the SPEC 2000 distro
-#  -spec95path      Path to the benchspec directory in the SPEC 95 distro.
-#  -povraypath      Path to the povray sources
-#  -namdpath        Path to the namd sources
+#  -extraflags      Next argument specifies extra options that are passed to
+#                   compile the tests.
+#  -noexternals     Do not run the external tests (for cases where povray
+#                   or SPEC are not installed)
+#  -with-externals  Specify a directory where the external tests are located.
 #
 # CVSROOT is the CVS repository from which the tree will be checked out,
 #  specified either in the full :method:user@host:/dir syntax, or
@@ -119,10 +118,12 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
     if (/^-nocheckout$/)     { $NOCHECKOUT = 1; next; }
     if (/^-nocvsstats$/)     { $NOCVSSTATS = 1; next; }
     if (/^-noremove$/)       { $NOREMOVE = 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 (/^-release$/)        { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O2"; next; }
+    if (/^-release$/)        { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
+                                                                                                                                                  "OPTIMIZE_OPTION=-O2"; next; }
     if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
     if (/^-disable-llc$/)    { $PROGTESTOPTS .= " DISABLE_LLC=1";
                               $CONFIGUREARGS .= " --disable-llc_diffs"; next; } 
@@ -138,8 +139,15 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
        $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next;
     }
     if (/^-nickname$/)         { $nickname = "$ARGV[0]"; shift; next; }
-    if (/^-gccpath/)         { $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;}
-    if (/^-cvstag/)          { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } else{ $CVSCOOPT="";}
+    else{ $nickname=""; }
+    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; } 
+    else{ $CVSCOOPT="";}
     if (/^-target/)          {
        $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
     }
@@ -161,18 +169,6 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
     if (/^-noexternals$/)    { $NOEXTERNALS = 1; next; }
     if (/^-nodejagnu$/)      { $NODEJAGNU = 1; next; }
     if (/^-nobuild$/)        { $NOBUILD = 1; next; }
-    if (/^-spec2000path$/)   {
-       $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
-    } else{ $LLVMTESTCONFIGARGS=""; }
-    if (/^-spec95path$/)     {
-       $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
-    }
-    if (/^-povraypath$/)     {
-       $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
-    }
-    if (/^-namdpath$/)       {
-       $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
-    }
     print "Unknown option: $_ : ignoring!\n";
 }
 
@@ -191,6 +187,10 @@ if (@ARGV == 3) {
     $WebDir     = $ARGV[2];
 }
 
+if($nickname eq ""){
+       die ("Please invoke NewNightlyTest.pl with command line option \"-nickname <nickname>\"");
+}
+
 ##############################################################
 #
 #define the file names we'll use
@@ -293,7 +293,7 @@ sub ReadFile {
        $/ = '\n';
        return $Ret;
     } else {
-       print "Could not open file '$_[0]' for reading!";
+       print "Could not open file '$_[0]' for reading!\n";
        return "";
     }
 }
@@ -301,7 +301,7 @@ sub ReadFile {
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 sub WriteFile {  # (filename, contents)
-    open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
+    open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
     print FILE $_[1];
     close FILE;
 }
@@ -413,7 +413,8 @@ sub SendData{
 
     $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";
+    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]);
 
@@ -440,15 +441,22 @@ sub SendData{
     close(SOCK);
 
     my $sentdata="";
-    foreach $x(keys(%hash_of_data)){
-        $senddata.= "$x  => $hash_of_data{$x}\n";
+    foreach $x (keys (%$variables)){
+        $value = $variables->{$x};
+        $sentdata.= "$x  => $value\n";
     }
     WriteFile "$Prefix-sentdata.txt", $sentdata;
-
+    
 
     return $result;
 }
 
+##############################################################
+#
+# Getting Start timestamp
+#
+##############################################################
+$starttime = `date`;
 
 ##############################################################
 #
@@ -458,6 +466,9 @@ sub SendData{
 if (!$NOCHECKOUT) {
     if (-d $BuildDir) {
        if (!$NOREMOVE) {
+               if ( $VERBOSE ){
+                       print "Build directory exists! Removing it\n";
+               }
            system "rm -rf $BuildDir";
        } else {
            die "CVS checkout directory $BuildDir already exists!";
@@ -547,7 +558,7 @@ foreach $File (@CVSHistory) {
            $ModifiedFiles{$Filename} = 1;
            $UsersCommitted{$UID} = 1;
        } elsif ($Type eq 'A') {   # Added
-           $Addediles{$Filename} = 1;
+           $AddedFiles{$Filename} = 1;
            $UsersCommitted{$UID} = 1;
        } elsif ($Type eq 'R') {   # Removed
            $RemovedFiles{$Filename} = 1;
@@ -574,7 +585,7 @@ my $UserUpdateList = join "\n", sort keys %UsersUpdated;
 #
 ##############################################################
 if (!$NOCHECKOUT && !$NOBUILD) {
-    my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
+    my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
     if ( $VERBOSE )
     {
         print "CONFIGURE STAGE:\n";
@@ -771,18 +782,19 @@ if (!$BuildError && $patrickjenkins) {
     if ( $VERBOSE ) {
        print "SingleSource TEST STAGE\n";
     }
-    ($SingleSourceProgramsTable, $singlesource_llcbeta_options) = TestDirectory("SingleSource");
+    ($SingleSourceProgramsTable, $llcbeta_options) = TestDirectory("SingleSource");
     WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
     if ( $VERBOSE ) {
        print "MultiSource TEST STAGE\n";
     }
-    ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource");
+    ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
     WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
     if ( ! $NOEXTERNALS ) {
        if ( $VERBOSE ) {
            print "External TEST STAGE\n";
        }
-       ($ExternalProgramsTable, $externalsource_llcbeta_options) = TestDirectory("External");
+       ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
+       WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
        system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
            " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
     } else {
@@ -794,7 +806,6 @@ if (!$BuildError && $patrickjenkins) {
            " | sort > $Prefix-Tests.txt";
     }
     WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
-
 }
 
 ##############################################################
@@ -804,50 +815,69 @@ if (!$BuildError && $patrickjenkins) {
 #
 #
 ##############################################################
-my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
-
-if ($TestError) {
-    $TestsAdded   = "<b>error testing</b><br>";
-    $TestsRemoved = "<b>error testing</b><br>";
-    $TestsFixed   = "<b>error testing</b><br>";
-    $TestsBroken  = "<b>error testing</b><br>";
-} else {
-    my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
-
-    my @RawTestsAddedArray = split '\n', $RTestsAdded;
-    my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
-
-    my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
-    @RawTestsRemovedArray;
-    my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
-    @RawTestsAddedArray;
-
-    foreach $Test (keys %NewTests) {
-       if (!exists $OldTests{$Test}) {  # TestAdded if in New but not old
-           $TestsAdded = "$TestsAdded$Test\n";
-       } else {
-           if ($OldTests{$Test} =~ /TEST-PASS/) {  # Was the old one a pass?
-               $TestsBroken = "$TestsBroken$Test\n";  # New one must be a failure
-           } else {
-               $TestsFixed = "$TestsFixed$Test\n";    # No, new one is a pass.
-           }
-       }
-    }
-    foreach $Test (keys %OldTests) {  # TestRemoved if in Old but not New
-       $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
-    }
+$dejagnu = ReadFile $DejagnuSum;
+@DEJAGNU = split "\n", $dejagnu;
 
-    #print "\nTESTS ADDED:  \n\n$TestsAdded\n\n"   if (length $TestsAdded);
-    #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
-    #print "\nTESTS FIXED:  \n\n$TestsFixed\n\n"   if (length $TestsFixed);
-    #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n"  if (length $TestsBroken);
+my $passes="",
+my $fails="";
+my $xfails="";
 
-    #$TestsAdded   = AddPreTag $TestsAdded;
-    #$TestsRemoved = AddPreTag $TestsRemoved;
-    #$TestsFixed   = AddPreTag $TestsFixed;
-    #$TestsBroken  = AddPreTag $TestsBroken;
+for($x=0; $x<@DEJAGNU; $x++){
+       if($DEJAGNU[$x] =~ m/^PASS:/){
+               $passes.="$x\n";
+       }
+       elsif($DEJAGNU[$x] =~ m/^FAIL:/){
+               $fails.="$x\n";
+       }
+       elsif($DEJAGNU[$x] =~ m/^XFAIL:/){
+               $xfails.="$x\n";
+       }
 }
 
+# my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
+# 
+# if ($TestError) {
+#     $TestsAdded   = "<b>error testing</b><br>";
+#     $TestsRemoved = "<b>error testing</b><br>";
+#     $TestsFixed   = "<b>error testing</b><br>";
+#     $TestsBroken  = "<b>error testing</b><br>";
+# } else {
+#     my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
+# 
+#     my @RawTestsAddedArray = split '\n', $RTestsAdded;
+#     my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
+# 
+#     my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
+#     @RawTestsRemovedArray;
+#     my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
+#     @RawTestsAddedArray;
+# 
+#     foreach $Test (keys %NewTests) {
+#                      if (!exists $OldTests{$Test}) {  # TestAdded if in New but not old
+#              $TestsAdded = "$TestsAdded$Test\n";
+#                      } else {
+#          if ($OldTests{$Test} =~ /TEST-PASS/) {  # Was the old one a pass?
+#                              $TestsBroken = "$TestsBroken$Test\n";  # New one must be a failure
+#          } else {
+#                              $TestsFixed = "$TestsFixed$Test\n";    # No, new one is a pass.
+#          }
+#              }
+#      }
+#      foreach $Test (keys %OldTests) {  # TestRemoved if in Old but not New
+#              $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
+#      }
+# 
+#     #print "\nTESTS ADDED:  \n\n$TestsAdded\n\n"   if (length $TestsAdded);
+#     #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
+#     #print "\nTESTS FIXED:  \n\n$TestsFixed\n\n"   if (length $TestsFixed);
+#     #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n"  if (length $TestsBroken);
+# 
+#     #$TestsAdded   = AddPreTag $TestsAdded;
+#     #$TestsRemoved = AddPreTag $TestsRemoved;
+#     #$TestsFixed   = AddPreTag $TestsFixed;
+#     #$TestsBroken  = AddPreTag $TestsBroken;
+# }
+
 ##############################################################
 #
 # If we built the tree successfully, runs of the Olden suite with
@@ -910,6 +940,13 @@ if (!$BuildError) {
     #AddRecord($BytecodeSize, "running_Olden_bytecode.txt", $WebDir);
 }
 
+##############################################################
+#
+# Getting end timestamp
+#
+##############################################################
+$endtime = `date`;
+
 
 ##############################################################
 #
@@ -950,10 +987,20 @@ my $dejagnulog_full;
 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
 
-my $gcc_version_long = `gcc --version`;
-@GCC_VERSION = split "\n", $gcc_version_long;
+my $gcc_version_long="";
+if($GCCPATH ne ""){
+  $gcc_version_long = `$GCCPATH/gcc --version`;
+  print "$GCCPATH/gcc --version\n";
+}
+else{
+  $gcc_version_long = `gcc --version`;
+  print "gcc --version\n";
+}
+@GCC_VERSION = split '\n', $gcc_version_long;
 my $gcc_version = $GCC_VERSION[0];
 
+$all_tests = ReadFile, "$Prefix-Tests.txt";
+
 ##############################################################
 #
 # Send data via a post request
@@ -966,40 +1013,43 @@ if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
 my $host = "llvm.org";
 my $file = "/nightlytest/NightlyTestAccept.cgi";
 my %hash_of_data = ('machine_data' => $machine_data,
-              'build_data' => $build_data,
-               'gcc_version' => $gcc_version,
-              'nickname' => $nickname,
-              'dejagnutime_wall' => $DejagnuWallTime,
-              'dejagnutime_cpu' => $DejagnuTime,
-              'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
-              'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
-              'configtime_wall' => $ConfigWallTime,
-              'configtime_cpu'=> $ConfigTime,
-              'buildtime_wall' => $BuildWallTime,
-              'buildtime_cpu' => $BuildTime,
-              'warnings' => $WarningsFile,
-              'cvsusercommitlist' => $UserCommitList,
-              'cvsuserupdatelist' => $UserUpdateList,
-              'cvsaddedfiles' => $CVSAddedFiles,
-              'cvsmodifiedfiles' => $CVSModifiedFiles,
-              'cvsremovedfiles' => $CVSRemovedFiles,
-              'lines_of_code' => $LOC,
-              'cvs_file_count' => $NumFilesInCVS,
-              'cvs_dir_count' => $NumDirsInCVS,
-              'buildstatus' => $BuildStatus,
-              'singlesource_programstable' => $SingleSourceProgramsTable,
-               'multisource_programstable' => $MultiSourceProgramsTable,
-               'externalsource_programstable' => $ExternalSourceProgramsTable,
-              'llcbeta_options' => $multisource_llcbeta_options,
-               'warnings_removed' => $WarningsRemoved,
-               'warnings_added' => $WarningsAdded,
-              'newly_passing_tests' => $TestsFixed,
-               'newly_failing_tests' => $TestsBroken,
-               'new_tests' => $TestsAdded,
-               'removed_tests' => $TestsRemoved,
-              'unexpfail_tests' => $unexpfail_tests,
-              'dejagnutests_log' => $dejagnutests_log,
-              'dejagnutests_sum' => $dejagnutests_sum);
+                                                       'build_data' => $build_data,
+                                       'gcc_version' => $gcc_version,
+                                                       'nickname' => $nickname,
+                                                       'dejagnutime_wall' => $DejagnuWallTime,
+                                                                               'dejagnutime_cpu' => $DejagnuTime,
+                                                                               'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
+                                                                               'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
+                                                                               'configtime_wall' => $ConfigWallTime,
+                                                                               'configtime_cpu'=> $ConfigTime,
+                                                                               'buildtime_wall' => $BuildWallTime,
+                                                                               'buildtime_cpu' => $BuildTime,
+                                                                               'warnings' => $WarningsFile,
+                                                                               'cvsusercommitlist' => $UserCommitList,
+                                                                               'cvsuserupdatelist' => $UserUpdateList,
+                                                                               'cvsaddedfiles' => $CVSAddedFiles,
+                                                                               'cvsmodifiedfiles' => $CVSModifiedFiles,
+                                                                               'cvsremovedfiles' => $CVSRemovedFiles,
+                                                                               'lines_of_code' => $LOC,
+                                                                               'cvs_file_count' => $NumFilesInCVS,
+                                                                               'cvs_dir_count' => $NumDirsInCVS,
+                                                                               'buildstatus' => $BuildStatus,
+                                                                               'singlesource_programstable' => $SingleSourceProgramsTable,
+                                                                               'multisource_programstable' => $MultiSourceProgramsTable,
+                                                                               'externalsource_programstable' => $ExternalProgramsTable,
+                                                                               'llcbeta_options' => $multisource_llcbeta_options,
+                                                                               'warnings_removed' => $WarningsRemoved,
+                                                                               'warnings_added' => $WarningsAdded,
+                                                                               'passing_tests' => $passes,
+                                                                               'expfail_tests' => $xfails,
+                                                                               'unexpfail_tests' => $fails,
+                                                                               'all_tests' => $all_tests,
+                                                                               'new_tests' => "",
+                                                                               'removed_tests' => "",
+                                                                               'dejagnutests_log' => $dejagnutests_log,
+                                                                               'dejagnutests_sum' => $dejagnutests_sum,
+                                                                               'starttime' => $starttime,
+                                                                               'endtime' => $endtime);
 
 $TESTING = 0;
 
@@ -1020,5 +1070,6 @@ else{
 #
 ##############################################################
 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
+system ( "$NICE rm -rf $WebDir") if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);