[4/6] testbot: Tighten handling of the VM status in the task scripts.

Francois Gouget fgouget at codeweavers.com
Wed Mar 13 10:52:30 CDT 2013


---

Running the scripts from the command line can sometimes be useful to 
debug them and it's the only I can see to care about setting the VM 
status to 'running' (there's of course still the small race but if 
you're debugging the scripts you know what you're doing, right?).

 testbot/bin/WineRunBuild.pl    |   15 +++++++++++++--
 testbot/bin/WineRunReconfig.pl |   17 ++++++++++++++---
 testbot/bin/WineRunTask.pl     |   15 ++++++++++-----
 3 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index 236d3d0..3f5b592 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -61,8 +61,11 @@ sub FatalError($$$$)
   $Job->UpdateStatus();
 
   my $VM = $Task->VM;
-  $VM->Status('dirty');
-  $VM->Save();
+  if ($VM->Status eq 'running')
+  {
+    $VM->Status('dirty');
+    $VM->Save();
+  }
 
   TaskComplete($JobKey, $StepKey, $TaskKey);
   exit 1;
@@ -217,6 +220,13 @@ if (! defined($BaseName))
   FatalError "Can't determine base name\n", $FullErrFileName, $Job, $Task;
 }
 
+# Normally the Engine has already set the VM status to 'running'.
+# Do it anyway in case we're called manually from the command line.
+if ($VM->Status ne "idle" and $VM->Status ne "running")
+{
+  FatalError "The VM is not ready for use (" . $VM->Status . ")\n",
+             $FullErrFileName, $Job, $Task;
+}
 $VM->Status('running');
 my ($ErrProperty, $ErrMessage) = $VM->Save();
 if (defined($ErrMessage))
@@ -224,6 +234,7 @@ if (defined($ErrMessage))
   FatalError "Can't set VM status to running: $ErrMessage\n",
              $FullErrFileName, $Job, $Task;
 }
+
 my $FileName = $Step->FileName;
 if (!$TA->SendFile("$StepDir/$FileName", "staging/$FileName", 0))
 {
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 7588045..0333705 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -61,8 +61,11 @@ sub FatalError($$$$)
   $Job->UpdateStatus();
 
   my $VM = $Task->VM;
-  $VM->Status('dirty');
-  $VM->Save();
+  if ($VM->Status eq 'running')
+  {
+    $VM->Status('dirty');
+    $VM->Save();
+  }
 
   TaskComplete($JobKey, $StepKey, $TaskKey);
   exit 1;
@@ -190,13 +193,21 @@ my $FullRawlogFileName = "$TaskDir/rawlog";
 my $FullLogFileName = "$TaskDir/log";
 my $FullErrFileName = "$TaskDir/err";
 
+# Normally the Engine has already set the VM status to 'running'.
+# Do it anyway in case we're called manually from the command line.
+if ($VM->Status ne "idle" and $VM->Status ne "running")
+{
+  FatalError "The VM is not ready for use (" . $VM->Status . ")\n",
+             $FullErrFileName, $Job, $Task;
+}
 $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;
 }
+
 my $Script = "#!/bin/sh\n" .
              "rm -f Reconfig.log\n" .
              "../bin/build/Reconfig.pl >>Reconfig.log 2>&1\n";
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index ffbb421..abb92e0 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -204,9 +204,16 @@ my $FullLogFileName = "$TaskDir/log";
 my $FullErrFileName = "$TaskDir/err";
 my $FullScreenshotFileName = "$TaskDir/screenshot.png";
 
+# Normally the Engine has already set the VM status to 'running'.
+# Do it anyway in case we're called manually from the command line.
+if ($VM->Status ne "idle" and $VM->Status ne "running")
+{
+  FatalError "The VM is not ready for use (" . $VM->Status . ")\n",
+             $FullErrFileName, $Job, $Step, $Task;
+}
 $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, $Step, $Task;
@@ -349,10 +356,8 @@ if (!defined $TestFailures)
 $Task->TestFailures($TestFailures);
 $Task->Save();
 $Job->UpdateStatus();
-if ($Task->VM->Role ne "base")
-{
-  $Task->VM->PowerOff();
-}
+
+$VM->PowerOff() if ($VM->Role ne "base");
 $VM->Status('dirty');
 $VM->Save();
 
-- 
1.7.10.4




More information about the wine-patches mailing list