[18/25] testbot: Separate the per-task task and testbot logs.

Francois Gouget fgouget at codeweavers.com
Tue Jan 14 09:42:46 CST 2020


Each task has pairs of xxx.report and xxx.report.err files where the
.err file contains extra errors detected while parsing xxx.report and
can thus be rebuilt from the report files.
They also have log and log.err files but log.err is completely
independent from the log file:
* log contains the traces printed by the script running on the VM,
  typically the build log or batch file commands.
* log.err contains errors that occurred on the TestBot-server side, such
  as perl errors in the WineRun* scripts, or messages when the TestBot
  had to kill a stuck task.
So rename log to task.log and log.err to testbot.log. This way their
purpose is clearer and log.err does not run the risk of being
confused with the other .err files.
---
 testbot/bin/UpdateTaskLogs          | 24 ++++++++++++++++++++++++
 testbot/bin/WineRunBuild.pl         |  8 ++++----
 testbot/bin/WineRunReconfig.pl      |  8 ++++----
 testbot/bin/WineRunTask.pl          |  6 +++---
 testbot/bin/WineRunWineTest.pl      |  8 ++++----
 testbot/lib/WineTestBot/LogUtils.pm | 22 ++++++++++++----------
 testbot/lib/WineTestBot/Tasks.pm    | 10 +++++-----
 7 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/testbot/bin/UpdateTaskLogs b/testbot/bin/UpdateTaskLogs
index 70a3dd2c1..b069e892e 100755
--- a/testbot/bin/UpdateTaskLogs
+++ b/testbot/bin/UpdateTaskLogs
@@ -302,6 +302,30 @@ sub ProcessTaskLogs($$$)
         $Rc += MoveRefReport($StepDir, "$StepReportName$Suffix", $TaskDir);
       }
     }
+
+    my %LogMap = (
+      "log"         => "task.log",
+      "log.err"     => "testbot.log",
+      "old_log"     => "old_task.log",
+      "old_log.err" => "old_testbot.log");
+    while (my ($OldName, $NewName) = each %LogMap)
+    {
+      if (-f "$TaskDir/$OldName" and !-f "$TaskDir/$NewName" and
+          !rename("$TaskDir/$OldName", "$TaskDir/$NewName"))
+      {
+        Error TaskKey($Task) .": Could not rename $OldName because $NewName already exists\n";
+        $Rc = 1;
+      }
+    }
+
+    # testbot.log is the only log which we expect to be empty.
+    # There is not much point keeping it if that's the case.
+    my $TestBotLog = "$TaskDir/testbot.log";
+    if (-z $TestBotLog)
+    {
+      Debug(TaskKeyStr($Task) .": Deleting empty testbot.log\n");
+      unlink $TestBotLog;
+    }
   }
 
   if (($OptDelete or $OptRebuild) and !$CollectOnly)
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index afbc5ec78..b9698a9fd 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -181,14 +181,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -417,9 +417,9 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
 }
 
 Debug(Elapsed($Start), " Retrieving 'Build.log'\n");
-if ($TA->GetFile("Build.log", "$TaskDir/log"))
+if ($TA->GetFile("Build.log", "$TaskDir/task.log"))
 {
-  my $LogInfo = ParseTaskLog("$TaskDir/log");
+  my $LogInfo = ParseTaskLog("$TaskDir/task.log");
   if ($LogInfo->{Task} eq "ok")
   {
     # We must have gotten the full log and the build did succeed.
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index c82d5fcb5..bf6fc6ff4 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -182,14 +182,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -418,9 +418,9 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
 
 my $LogInfo;
 Debug(Elapsed($Start), " Retrieving 'Reconfig.log'\n");
-if ($TA->GetFile("Reconfig.log", "$TaskDir/log"))
+if ($TA->GetFile("Reconfig.log", "$TaskDir/task.log"))
 {
-  $LogInfo = ParseTaskLog("$TaskDir/log");
+  $LogInfo = ParseTaskLog("$TaskDir/task.log");
   if ($LogInfo->{Task} eq "ok")
   {
     # We must have gotten the full log and the build did succeed.
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index ee910cdf0..5bd13cc7a 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -210,14 +210,14 @@ sub LogTaskError($)
   Debug("$Name0:error: ", $ErrMessage);
 
   my $OldUMask = umask(002);
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
   umask($OldUMask);
 }
@@ -534,7 +534,7 @@ if (!defined $TA->Wait($Pid, $Timeout, $Keepalive))
 }
 
 Debug(Elapsed($Start), " Retrieving 'Task.log'\n");
-if (!$TA->GetFile("Task.log", "$TaskDir/log") and !defined $TAError)
+if (!$TA->GetFile("Task.log", "$TaskDir/task.log") and !defined $TAError)
 {
   $TAError = "An error occurred while retrieving the task log: ". $TA->GetLastError();
 }
diff --git a/testbot/bin/WineRunWineTest.pl b/testbot/bin/WineRunWineTest.pl
index 46e85ec47..6db75a7c5 100755
--- a/testbot/bin/WineRunWineTest.pl
+++ b/testbot/bin/WineRunWineTest.pl
@@ -206,14 +206,14 @@ sub LogTaskError($)
   my ($ErrMessage) = @_;
   Debug("$Name0:error: ", $ErrMessage);
 
-  if (open(my $ErrFile, ">>", "$TaskDir/log.err"))
+  if (open(my $ErrFile, ">>", "$TaskDir/testbot.log"))
   {
     print $ErrFile $ErrMessage;
     close($ErrFile);
   }
   else
   {
-    Error "Unable to open 'log.err' for writing: $!\n";
+    Error "Unable to open 'testbot.log' for writing: $!\n";
   }
 }
 
@@ -506,9 +506,9 @@ if (!defined $TA->Wait($Pid, $Task->Timeout, 60))
 }
 
 Debug(Elapsed($Start), " Retrieving 'Task.log'\n");
-if ($TA->GetFile("Task.log", "$TaskDir/log"))
+if ($TA->GetFile("Task.log", "$TaskDir/task.log"))
 {
-  my $LogInfo = ParseTaskLog("$TaskDir/log");
+  my $LogInfo = ParseTaskLog("$TaskDir/task.log");
   if ($LogInfo->{Task} eq "ok")
   {
     # We must have gotten the full log and the task completed successfully
diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm
index 08c9911d9..9f4035be2 100644
--- a/testbot/lib/WineTestBot/LogUtils.pm
+++ b/testbot/lib/WineTestBot/LogUtils.pm
@@ -622,8 +622,8 @@ sub GetLogFileNames($;$)
                  win32.report win32_*.report
                  wow32.report wow32_*.report
                  wow64.report wow64_*.report
-                 log);
-  push @Globs, "old_log" if ($IncludeOld);
+                 task.log testbot.log);
+  push @Globs, ("old_task.log", "old_testbot.log") if ($IncludeOld);
 
   my (@Logs, %Seen);
   foreach my $Glob (@Globs)
@@ -637,7 +637,7 @@ sub GetLogFileNames($;$)
       {
         $LogName = $1; # untaint
       }
-      elsif ($LogName eq $Glob) # log and old_log cases
+      elsif ($LogName eq $Glob) # (old_) task.log and testbot.log cases
       {
         $LogName = $Glob; # untaint
       }
@@ -659,13 +659,15 @@ sub GetLogFileNames($;$)
 }
 
 my %_LogFileLabels = (
-  "exe32.report" => '32 bit%s report',
-  "exe64.report" => '64 bit%s report',
-  "win32.report" => '32 bit%s report',
-  "wow32.report" => '32 bit%s WoW report',
-  "wow64.report" => '64 bit%s WoW report',
-  "log"          => 'task%s log',
-  "old_log"      => 'old%s logs',
+  "exe32.report"    => '32 bit%s report',
+  "exe64.report"    => '64 bit%s report',
+  "win32.report"    => '32 bit%s report',
+  "wow32.report"    => '32 bit%s WoW report',
+  "wow64.report"    => '64 bit%s WoW report',
+  "task.log"        => 'task%s log',
+  "testbot.log"     => 'testbot%s log',
+  "old_task.log"    => 'old%s task logs',
+  "old_testbot.log" => 'old%s testbot logs',
 );
 
 =pod
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index 7b9ac9b81..541b5558e 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -153,7 +153,7 @@ sub _SetupTask($$)
   if (-d $Dir)
   {
     mkpath("$Dir.new", 0, 0775);
-    foreach my $Filename ("log", "log.err")
+    foreach my $Filename ("task.log", "testbot.log")
     {
       if (-f "$Dir/old_$Filename")
       {
@@ -178,9 +178,9 @@ sub _SetupTask($$)
     rename("$Dir.new", $Dir);
   }
 
-  # Capture Perl errors in the task's generic error log
+  # Capture Perl errors in the per-task TestBot log
   my $TaskDir = $self->CreateDir();
-  if (open(STDERR, ">>", "$TaskDir/log.err"))
+  if (open(STDERR, ">>", "$TaskDir/testbot.log"))
   {
     # Make sure stderr still flushes after each print
     my $tmp=select(STDERR);
@@ -190,7 +190,7 @@ sub _SetupTask($$)
   else
   {
     require WineTestBot::Log;
-    WineTestBot::Log::LogMsg("unable to redirect stderr to '$TaskDir/log.err': $!\n");
+    WineTestBot::Log::LogMsg("unable to redirect stderr to '$TaskDir/testbot.log': $!\n");
   }
 }
 
@@ -253,7 +253,7 @@ sub UpdateStatus($$)
     my ($JobId, $StepNo, $TaskNo) = @{$self->GetMasterKey()};
     my $OldUMask = umask(002);
     my $TaskDir = $self->CreateDir();
-    if (open TASKLOG, ">>$TaskDir/log.err")
+    if (open TASKLOG, ">>$TaskDir/testbot.log")
     {
       print TASKLOG "TestBot process got stuck or died unexpectedly\n";
       close TASKLOG;
-- 
2.20.1




More information about the wine-devel mailing list