Module: tools Branch: master Commit: 1e7c07b2d89ad828c65cc6a61c2762ff9378b356 URL: http://source.winehq.org/git/tools.git/?a=commit;h=1e7c07b2d89ad828c65cc6a61...
Author: Francois Gouget fgouget@codeweavers.com Date: Wed Mar 13 16:53:36 2013 +0100
testbot/build: Improve the WineRun{Build,Reconfig}.pl error handling.
Don't try to copy the generated executables in WineRunBuild.pl if the build failed. Document what happens if we fail to take a new snapshot in WineRunReconfig.pl.
---
testbot/bin/WineRunBuild.pl | 105 ++++++++++++++++++++-------------------- testbot/bin/WineRunReconfig.pl | 29 +++++++---- 2 files changed, 71 insertions(+), 63 deletions(-)
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl index e7dfafd..f750a0b 100755 --- a/testbot/bin/WineRunBuild.pl +++ b/testbot/bin/WineRunBuild.pl @@ -198,29 +198,24 @@ my $TaskDir = "$StepDir/$TaskNo"; my $FullLogFileName = "$TaskDir/log"; my $FullErrFileName = "$TaskDir/err";
-my $BaseName; -my $Run64 = !1; +my ($Run64, $BaseName); foreach my $OtherStep (@{$Job->Steps->GetItems()}) { - if ($OtherStep->No != $StepNo) + next if ($OtherStep->No == $StepNo); + + $Run64 = 1 if ($OtherStep->FileType eq "exe64"); + my $OtherFileName = $OtherStep->FileName; + if ($OtherFileName =~ m/^([\w_-]+)(|.exe)_test(|64).exe$/) { - my $OtherFileName = $OtherStep->FileName; - if ($OtherFileName =~ m/^([\w_-]+)(|.exe)_test(|64).exe$/) + if (defined $BaseName and $BaseName ne $1) { - if (defined $BaseName && $BaseName ne $1) - { - FatalError "$1 doesn't match previously found $BaseName\n", - $FullErrFileName, $Job, $Task; - } - $BaseName = $1; - if ($OtherStep->FileType eq "exe64") - { - $Run64 = 1; - } + FatalError "$1 doesn't match previously found $BaseName\n", + $FullErrFileName, $Job, $Task; } + $BaseName = $1; } } -if (! defined($BaseName)) +if (!defined $BaseName) { FatalError "Can't determine base name\n", $FullErrFileName, $Job, $Task; } @@ -234,7 +229,7 @@ if ($VM->Status ne "idle" and $VM->Status ne "running") } $VM->Status('running'); my ($ErrProperty, $ErrMessage) = $VM->Save(); -if (defined($ErrMessage)) +if (defined $ErrMessage) { FatalError "Can't set VM status to running: $ErrMessage\n", $FullErrFileName, $Job, $Task; @@ -244,7 +239,7 @@ my $FileName = $Step->FileName; if (!$TA->SendFile("$StepDir/$FileName", "staging/$FileName", 0)) { $ErrMessage = $TA->GetLastError(); - FatalError "Can't copy patch to VM: $ErrMessage\n", + FatalError "Could not copy the patch to the VM: $ErrMessage\n", $FullErrFileName, $Job, $Task; } my $Script = "#!/bin/sh\n" . @@ -256,61 +251,67 @@ $Script .= " >>Build.log 2>&1\n"; if (!$TA->SendFileFromString($Script, "task", $TestAgent::SENDFILE_EXE)) { $ErrMessage = $TA->GetLastError(); - FatalError "Can't send the script to VM: $ErrMessage\n", + FatalError "Can't send the build script to the VM: $ErrMessage\n", $FullErrFileName, $Job, $Task; } my $Pid = $TA->Run(["./task"], 0); if (!$Pid or !defined $TA->Wait($Pid, $Task->Timeout)) { $ErrMessage = $TA->GetLastError(); + # Try to grab the build log before reporting the failure } - -if (defined($ErrMessage)) +my $NewStatus; +if ($TA->GetFile("Build.log", $FullLogFileName)) { - $TA->GetFile("Build.log", $FullLogFileName); - ProcessLog($FullLogFileName, $FullErrFileName); - FatalError "Failure running script in VM: $ErrMessage\n", - $FullErrFileName, $Job, $Task; + $NewStatus = ProcessLog($FullLogFileName, $FullErrFileName); } - -if (!$TA->GetFile("Build.log", $FullLogFileName)) +elsif (!defined $ErrMessage) { + # This GetFile() error is the first one so report it $ErrMessage = $TA->GetLastError(); - FatalError "Can't copy log from VM: $ErrMessage\n", + FatalError "Can't copy the build log from the VM: $ErrMessage\n", + $FullErrFileName, $Job, $Task; +} +if (defined $ErrMessage) +{ + # Now we can report the previous Run() / Wait() error + FatalError "Failure running the build script in the VM: $ErrMessage\n", $FullErrFileName, $Job, $Task; } -my $NewStatus = ProcessLog($FullLogFileName, $FullErrFileName);
-foreach my $OtherStep (@{$Job->Steps->GetItems()}) +# Don't try copying the test executables if the build step failed +if ($NewStatus eq "completed") { - if ($OtherStep->No != $StepNo) + foreach my $OtherStep (@{$Job->Steps->GetItems()}) { + next if ($OtherStep->No == $StepNo); + my $OtherFileName = $OtherStep->FileName; - if ($OtherFileName =~ m/^[\w_-]+(|.exe)_test(|64).exe$/) - { - my $OtherStepDir = "$DataDir/jobs/$JobId/" . $OtherStep->No; - mkdir $OtherStepDir; + next if ($OtherFileName !~ /^[\w_-]+(?:|.exe)_test(?:|64).exe$/);
- my $Bits = $OtherStep->FileType eq "exe64" ? "64" : "32"; - my $TestExecutable; - if ($Step->FileType ne "patchprograms") - { - $TestExecutable = "build-mingw$Bits/dlls/$BaseName/tests/${BaseName}_test.exe"; - } - else - { - $TestExecutable = "build-mingw$Bits/programs/$BaseName/tests/${BaseName}.exe_test.exe"; - } - if (!$TA->GetFile($TestExecutable, "$OtherStepDir/$OtherFileName")) - { - $ErrMessage = $TA->GetLastError(); - FatalError "Can't copy generated executable from VM: $ErrMessage\n", - $FullErrFileName, $Job, $Task; - } - chmod 0664, "$OtherStepDir/$OtherFileName"; + my $OtherStepDir = "$DataDir/jobs/$JobId/" . $OtherStep->No; + mkdir $OtherStepDir; + + my $Bits = $OtherStep->FileType eq "exe64" ? "64" : "32"; + my $TestExecutable; + if ($Step->FileType ne "patchprograms") + { + $TestExecutable = "build-mingw$Bits/dlls/$BaseName/tests/${BaseName}_test.exe"; + } + else + { + $TestExecutable = "build-mingw$Bits/programs/$BaseName/tests/${BaseName}.exe_test.exe"; } + if (!$TA->GetFile($TestExecutable, "$OtherStepDir/$OtherFileName")) + { + $ErrMessage = $TA->GetLastError(); + FatalError "Can't copy the generated executable from the VM: $ErrMessage\n", + $FullErrFileName, $Job, $Task; + } + chmod 0664, "$OtherStepDir/$OtherFileName"; } } + $TA->Disconnect();
$Task->Status($NewStatus); diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl index 7460361..5d9d6b3 100755 --- a/testbot/bin/WineRunReconfig.pl +++ b/testbot/bin/WineRunReconfig.pl @@ -219,32 +219,36 @@ my $Script = "#!/bin/sh\n" . if (!$TA->SendFileFromString($Script, "task", $TestAgent::SENDFILE_EXE)) { $ErrMessage = $TA->GetLastError(); - FatalError "Can't send the script to VM: $ErrMessage\n", + FatalError "Can't send the script to the VM: $ErrMessage\n", $FullErrFileName, $Job, $Task; } my $Pid = $TA->Run(["./task"], 0); if (!$Pid or !defined $TA->Wait($Pid, $Task->Timeout)) { $ErrMessage = $TA->GetLastError(); + # Try to grab the reconfig log before reporting the failure } - -if (defined($ErrMessage)) +my $NewStatus; +if ($TA->GetFile("Reconfig.log", $FullLogFileName)) { - $TA->GetFile("Reconfig.log", $FullLogFileName); - ProcessLog($FullLogFileName, $FullErrFileName); - FatalError "Failure running script in VM: $ErrMessage\n", - $FullErrFileName, $Job, $Task; + $NewStatus = ProcessLog($FullLogFileName, $FullErrFileName); } - -if (!$TA->GetFile("Reconfig.log", $FullLogFileName)) +elsif (!defined $ErrMessage) { + # This GetFile() error is the first one so report it $ErrMessage = $TA->GetLastError(); - FatalError "Can't copy log from VM: $ErrMessage\n", + FatalError "Can't copy the reconfig log from the VM: $ErrMessage\n", + $FullErrFileName, $Job, $Task; +} +if (defined $ErrMessage) +{ + # Now we can report the previous Run() / Wait() error + FatalError "Could not run the reconfig script in the VM: $ErrMessage\n", $FullErrFileName, $Job, $Task; } + $TA->Disconnect();
-my $NewStatus = ProcessLog($FullLogFileName, $FullErrFileName); if ($NewStatus eq "completed") { $ErrMessage = $VM->RemoveSnapshot($VM->IdleSnapshot); @@ -257,6 +261,9 @@ if ($NewStatus eq "completed") $ErrMessage = $VM->CreateSnapshot($VM->IdleSnapshot); if (defined($ErrMessage)) { + # Without the snapshot the VM is not usable anymore but FatalError() will + # just mark it as 'dirty'. It's only the next time it is used that the + # problem will be noticed and that it will be taken offline. FatalError "Can't take snapshot: $ErrMessage\n", $FullErrFileName, $Job, $Task; }