Module: tools Branch: master Commit: 66b8798d53fb28266290a6b731a8f2007b220326 URL: http://source.winehq.org/git/tools.git/?a=commit;h=66b8798d53fb28266290a6b73...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Feb 25 20:29:26 2013 +0100
testbot/TestAgent: Use the new wait() RPC with the timeout parameter if available.
This lets us distinguish cases where the child process runs for too long from network issues. Note that when connected to an old testagentd server the old RPC will be used to preserve compatibility.
---
testbot/bin/WineRunBuild.pl | 4 +-- testbot/bin/WineRunReconfig.pl | 4 +-- testbot/bin/WineRunTask.pl | 4 +-- testbot/lib/WineTestBot/TestAgent.pm | 35 ++++++++++++++++++++++++++------- testbot/scripts/TestAgent | 2 +- 5 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl index d335214..20a43da 100755 --- a/testbot/bin/WineRunBuild.pl +++ b/testbot/bin/WineRunBuild.pl @@ -256,12 +256,10 @@ if (!$TA->SendFileFromString($Script, "task", $TestAgent::SENDFILE_EXE)) $FullErrFileName, $Job, $Step, $Task; } my $Pid = $TA->Run(["./task"], 0); -my $OldTimeout = $TA->SetTimeout($Task->Timeout); -if (!$Pid or !defined $TA->Wait($Pid)) +if (!$Pid or !defined $TA->Wait($Pid, $Task->Timeout)) { $ErrMessage = $TA->GetLastError(); } -$TA->SetTimeout($OldTimeout);
if (defined($ErrMessage)) { diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl index 0618a48..18d8c69 100755 --- a/testbot/bin/WineRunReconfig.pl +++ b/testbot/bin/WineRunReconfig.pl @@ -209,12 +209,10 @@ if (!$TA->SendFileFromString($Script, "task", $TestAgent::SENDFILE_EXE)) $FullErrFileName, $Job, $Step, $Task; } my $Pid = $TA->Run(["./task"], 0); -my $OldTimeout = $TA->SetTimeout($Task->Timeout); -if (!$Pid or !defined $TA->Wait($Pid)) +if (!$Pid or !defined $TA->Wait($Pid, $Task->Timeout)) { $ErrMessage = $TA->GetLastError(); } -$TA->SetTimeout($OldTimeout);
if (defined($ErrMessage)) { diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl index 9751d3b..73d60ba 100755 --- a/testbot/bin/WineRunTask.pl +++ b/testbot/bin/WineRunTask.pl @@ -300,12 +300,10 @@ if (!$TA->SendFileFromString($Script, "script.bat", $TestAgent::SENDFILE_EXE)) }
my $Pid = $TA->Run(["./script.bat"], 0); -my $OldTimeout = $TA->SetTimeout($Task->Timeout); -if (!$Pid or !defined $TA->Wait($Pid)) +if (!$Pid or !defined $TA->Wait($Pid, $Task->Timeout)) { $ErrMessage = $TA->GetLastError(); } -$TA->SetTimeout($OldTimeout);
my $LogErrMessage; if (!$TA->GetFile($RptFileName, $FullLogFileName)) diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm index cda83a8..c3326d6 100644 --- a/testbot/lib/WineTestBot/TestAgent.pm +++ b/testbot/lib/WineTestBot/TestAgent.pm @@ -35,6 +35,7 @@ my $RPC_SENDFILE = 2; my $RPC_RUN = 3; my $RPC_WAIT = 4; my $RPC_RM = 5; +my $RPC_WAIT2 = 6;
my %RpcNames=( $RPC_PING => 'ping', @@ -43,6 +44,7 @@ my %RpcNames=( $RPC_RUN => 'run', $RPC_WAIT => 'wait', $RPC_RM => 'rm', + $RPC_WAIT2 => 'wait2', );
my $Debug = 0; @@ -1053,21 +1055,38 @@ sub Run($$$;$$$) return $self->_RecvList('Q'); }
-sub Wait($$) +sub Wait($$$) { - my ($self, $Pid) = @_; - debug("Wait $Pid\n"); + my ($self, $Pid, $Timeout) = @_; + debug("Wait $Pid, ", defined $Timeout ? $Timeout : "<undef>", "\n"); + # Add 1 second for the reply to come back + my $OldTimeout = $self->SetTimeout($Timeout + 1) if ($Timeout);
# Send the command - if (!$self->_StartRPC($RPC_WAIT) or - !$self->_SendListSize(1) or - !$self->_SendUInt64($Pid)) + if ($self->{agentversion} =~ / 1.0$/) { - return undef; + if (!$self->_StartRPC($RPC_WAIT) or + !$self->_SendListSize(1) or + !$self->_SendUInt64($Pid)) + { + return undef; + } + } + else + { + if (!$self->_StartRPC($RPC_WAIT2) or + !$self->_SendListSize(2) or + !$self->_SendUInt64($Pid) or + !$self->_SendUInt32($Timeout)) + { + return undef; + } }
# Get the reply - return $self->_RecvList('I'); + my $Result = $self->_RecvList('I'); + $self->SetTimeout($OldTimeout) if ($Timeout); + return $Result; }
sub Rm($@) diff --git a/testbot/scripts/TestAgent b/testbot/scripts/TestAgent index d25a3d6..1424998 100755 --- a/testbot/scripts/TestAgent +++ b/testbot/scripts/TestAgent @@ -303,7 +303,7 @@ elsif ($Cmd eq "run") print "Started process $Pid\n"; if (!($RunFlags & $TestAgent::RUN_DNT)) { - $Result = $TA->Wait($Pid); + $Result = $TA->Wait($Pid, $Timeout); print "Child exit status: $Result\n" if (defined $Result); } }