Francois Gouget : testbot: Capture the worker scripts Perl errors in the general log.
Alexandre Julliard
julliard at winehq.org
Tue Dec 11 13:33:32 CST 2012
Module: tools
Branch: master
Commit: 8bcaf6c8510abeb662b0ad0e61232d7c1c2fa432
URL: http://source.winehq.org/git/tools.git/?a=commit;h=8bcaf6c8510abeb662b0ad0e61232d7c1c2fa432
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Dec 11 12:07:45 2012 +0100
testbot: Capture the worker scripts Perl errors in the general log.
Also simplify the fork()+exec() code a bit.
---
testbot/bin/Engine.pl | 50 +++++++++++++++++----------------------
testbot/lib/WineTestBot/Log.pm | 18 ++++++++++++++
testbot/lib/WineTestBot/VMs.pm | 17 ++++++++-----
3 files changed, 50 insertions(+), 35 deletions(-)
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index a26ac17..e233e80 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -120,18 +120,16 @@ sub HandleJobStatusChange
{
$ActiveBackEnds{'WineTestBot'}->PrepareForFork();
my $Pid = fork;
- if (defined($Pid) && ! $Pid)
+ if (!defined $Pid)
{
- exec("$BinDir/${ProjectName}SendLog.pl $JobKey");
+ LogMsg "Unable to fork for ${ProjectName}SendLog.pl: $!\n";
}
- if (defined($Pid) && ! $Pid)
+ elsif (!$Pid)
{
- LogMsg "Unable to exec ${ProjectName}SendLog.pl : $!\n";
- exit;
- }
- if (! defined($Pid))
- {
- LogMsg "Unable to fork for ${ProjectName}SendLog.pl : $!\n";
+ WineTestBot::Log::SetupRedirects();
+ exec("$BinDir/${ProjectName}SendLog.pl $JobKey") or
+ LogMsg "Unable to exec ${ProjectName}SendLog.pl: $!\n";
+ exit(1);
}
}
@@ -214,18 +212,16 @@ sub CheckForWinetestUpdate
$ActiveBackEnds{'WineTestBot'}->PrepareForFork();
my $Pid = fork;
- if (defined($Pid) && ! $Pid)
- {
- exec("$BinDir/CheckForWinetestUpdate.pl $Bits");
- }
- if (defined($Pid) && ! $Pid)
+ if (!defined $Pid)
{
- LogMsg "Unable to exec CheckForWinetestUpdate.pl : $!\n";
- exit;
+ LogMsg "Unable to fork for CheckForWinetestUpdate.pl: $!\n";
}
- if (! defined($Pid))
+ elsif (!$Pid)
{
- LogMsg "Unable to fork for CheckForWinetestUpdate.pl : $!\n";
+ WineTestBot::Log::SetupRedirects();
+ exec("$BinDir/CheckForWinetestUpdate.pl $Bits") or
+ LogMsg "Unable to exec CheckForWinetestUpdate.pl: $!\n";
+ exit(1);
}
}
@@ -365,19 +361,17 @@ sub HandleWinePatchWebNotification
{
$ActiveBackEnds{'WineTestBot'}->PrepareForFork();
my $Pid = fork;
- if (defined($Pid) && ! $Pid)
+ if (!defined $Pid)
{
- exec("$BinDir/WinePatchesWebGet.pl " . ($MaxExistingWebPatchId + 1) .
- " " . $LatestWebPatchId);
- }
- if (defined($Pid) && ! $Pid)
- {
- LogMsg "Unable to exec WinePatchesWebGet.pl : $!\n";
- exit;
+ LogMsg "Unable to fork for WinePatchesWebGet.pl: $!\n";
}
- if (! defined($Pid))
+ elsif (!$Pid)
{
- LogMsg "Unable to fork for WinePatchesWebGet.pl : $!\n";
+ WineTestBot::Log::SetupRedirects();
+ exec("$BinDir/WinePatchesWebGet.pl " . ($MaxExistingWebPatchId + 1) .
+ " " . $LatestWebPatchId) or
+ LogMsg "Unable to exec WinePatchesWebGet.pl: $!\n";
+ exit(1);
}
}
diff --git a/testbot/lib/WineTestBot/Log.pm b/testbot/lib/WineTestBot/Log.pm
index 102b74d..6982943 100644
--- a/testbot/lib/WineTestBot/Log.pm
+++ b/testbot/lib/WineTestBot/Log.pm
@@ -57,4 +57,22 @@ sub LogMsg(@)
print $logfile scalar localtime, " ", $logprefix, ": ", @_ if ($logfile);
}
+sub SetupRedirects()
+{
+ if (defined $logfile)
+ {
+ if (open(STDERR, ">>&", $logfile))
+ {
+ # Make sure stderr still flushes after each print
+ my $tmp=select(STDERR);
+ $| = 1;
+ select($tmp);
+ }
+ else
+ {
+ LogMsg "unable to redirect stderr to the log file\n";
+ }
+ }
+}
+
1;
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 82ad379..a42fb12 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -526,16 +526,19 @@ sub RunRevert
$self->GetBackEnd()->PrepareForFork();
my $Pid = fork;
- if (defined($Pid) && ! $Pid)
+ if (!defined $Pid)
{
- $ENV{PATH} = "/usr/bin:/bin";
- delete $ENV{ENV};
- exec("$BinDir/RevertVM.pl", $self->GetKey());
- exit;
+ return "Unable to start child process: $!";
}
- if (! defined($Pid))
+ elsif (!$Pid)
{
- return "Unable to start child process: $!";
+ $ENV{PATH} = "/usr/bin:/bin";
+ delete $ENV{ENV};
+ WineTestBot::Log::SetupRedirects();
+ exec("$BinDir/RevertVM.pl", $self->GetKey()) or
+ require WineTestBot::Log;
+ WineTestBot::Log::LogMsg "Unable to exec RevertVM.pl: $!\n";
+ exit(1);
}
return undef;
More information about the wine-cvs
mailing list