[Tools] testbot: Tweak the scripts so they print error messages on stderr by default.

Francois Gouget fgouget at codeweavers.com
Tue Oct 10 16:56:51 CDT 2017


When the scripts are started by the Engine their stderr is redirected to
the log in order to also capture Perl errors.
Since the scripts always log error messages, to avoid getting duplicates
they were only printing errors to stderr if given the --debug option.
As a result usage errors were not printed by default.
So the scripts now print the messages to stderr by default and the
Engine can invoke them with the --log-only option where needed to avoid
the stderr duplicates.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/LibvirtTool.pl       | 9 +++++++--
 testbot/bin/WineRunBuild.pl      | 9 +++++++--
 testbot/bin/WineRunReconfig.pl   | 9 +++++++--
 testbot/bin/WineRunTask.pl       | 9 +++++++--
 testbot/lib/WineTestBot/Tasks.pm | 2 +-
 testbot/lib/WineTestBot/VMs.pm   | 2 +-
 6 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index aa256f36..358eebf4 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -51,9 +51,10 @@ sub Debug(@)
   print STDERR @_ if ($Debug);
 }
 
+my $LogOnly;
 sub Error(@)
 {
-  Debug("$Name0:error: ", @_);
+  print STDERR "$Name0:error: ", @_ if (!$LogOnly);
   LogMsg @_;
 }
 
@@ -99,6 +100,10 @@ while (@ARGV)
   {
     $Debug = 1;
   }
+  elsif ($Arg eq "--log-only")
+  {
+    $LogOnly = 1;
+  }
   elsif ($Arg eq "revert")
   {
     $Action = $Arg;
@@ -158,7 +163,7 @@ if (!defined $Usage)
 }
 if (defined $Usage)
 {
-  print "Usage: $Name0 [--debug] [--help] revert VMName\n";
+  print "Usage: $Name0 [--debug] [--log-only] [--help] revert VMName\n";
   exit $Usage;
 }
 
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 85fe568c..f385feeb 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -54,9 +54,10 @@ sub Debug(@)
   print STDERR @_ if ($Debug);
 }
 
+my $LogOnly;
 sub Error(@)
 {
-  Debug("$Name0:error: ", @_);
+  print STDERR "$Name0:error: ", @_ if (!$LogOnly);
   LogMsg @_;
 }
 
@@ -88,6 +89,10 @@ while (@ARGV)
   {
     $Debug = 1;
   }
+  elsif ($Arg eq "--log-only")
+  {
+    $LogOnly = 1;
+  }
   elsif ($Arg =~ /^(?:-\?|-h|--help)$/)
   {
     $Usage = 0;
@@ -130,7 +135,7 @@ if (!defined $Usage)
 }
 if (defined $Usage)
 {
-    print "Usage: $Name0 [--debug] [--help] JobId StepNo TaskNo\n";
+    print "Usage: $Name0 [--debug] [--log-only] [--help] JobId StepNo TaskNo\n";
     exit $Usage;
 }
 
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index b2071cd7..aa529a2d 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -54,9 +54,10 @@ sub Debug(@)
   print STDERR @_ if ($Debug);
 }
 
+my $LogOnly;
 sub Error(@)
 {
-  Debug("$Name0:error: ", @_);
+  print STDERR "$Name0:error: ", @_ if (!$LogOnly);
   LogMsg @_;
 }
 
@@ -88,6 +89,10 @@ while (@ARGV)
   {
     $Debug = 1;
   }
+  elsif ($Arg eq "--log-only")
+  {
+    $LogOnly = 1;
+  }
   elsif ($Arg =~ /^(?:-\?|-h|--help)$/)
   {
     $Usage = 0;
@@ -130,7 +135,7 @@ if (!defined $Usage)
 }
 if (defined $Usage)
 {
-    print "Usage: $Name0 [--debug] [--help] JobId StepNo TaskNo\n";
+    print "Usage: $Name0 [--debug] [--log-only] [--help] JobId StepNo TaskNo\n";
     exit $Usage;
 }
 
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index 2328b31c..fc0bcf3a 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -53,9 +53,10 @@ sub Debug(@)
   print STDERR @_ if ($Debug);
 }
 
+my $LogOnly;
 sub Error(@)
 {
-  Debug("$Name0:error: ", @_);
+  print STDERR "$Name0:error: ", @_ if (!$LogOnly);
   LogMsg @_;
 }
 
@@ -113,6 +114,10 @@ while (@ARGV)
   {
     $Debug = 1;
   }
+  elsif ($Arg eq "--log-only")
+  {
+    $LogOnly = 1;
+  }
   elsif ($Arg =~ /^(?:-\?|-h|--help)$/)
   {
     $Usage = 0;
@@ -155,7 +160,7 @@ if (!defined $Usage)
 }
 if (defined $Usage)
 {
-    print "Usage: $Name0 [--debug] [--help] JobId StepNo TaskNo\n";
+    print "Usage: $Name0 [--debug] [--log-only] [--help] JobId StepNo TaskNo\n";
     exit $Usage;
 }
 
diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm
index 520d4030..b4298fb1 100644
--- a/testbot/lib/WineTestBot/Tasks.pm
+++ b/testbot/lib/WineTestBot/Tasks.pm
@@ -128,7 +128,7 @@ sub Run($$)
     }
     $ENV{PATH} = "/usr/bin:/bin";
     delete $ENV{ENV};
-    exec("$BinDir/${ProjectName}$RunScript", $JobId, $StepNo, $TaskNo) or
+    exec("$BinDir/${ProjectName}$RunScript", "--log-only", $JobId, $StepNo, $TaskNo) or
     require WineTestBot::Log;
     WineTestBot::Log::LogMsg("Unable to exec ${ProjectName}$RunScript: $!\n");
     exit(1);
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 1c6cdd77..af052d93 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -276,7 +276,7 @@ sub RunRevert($)
     delete $ENV{ENV};
     require WineTestBot::Log;
     WineTestBot::Log::SetupRedirects();
-    exec("$BinDir/LibvirtTool.pl", "revert", $self->GetKey()) or
+    exec("$BinDir/LibvirtTool.pl", "--log-only", "revert", $self->GetKey()) or
     WineTestBot::Log::LogMsg("Unable to exec LibvirtTool.pl: $!\n");
     exit(1);
   }
-- 
2.14.2



More information about the wine-patches mailing list