[Tools 1/6] testbot/VMs: Fix counting the powered on non-base VMs.

Francois Gouget fgouget at codeweavers.com
Tue Mar 26 05:47:08 CDT 2013


VMs with a 'disabling' role must be ignored.
Make a clear distinction between the 'enabled' VMs which we could use but may currently be powered off (e.g. dirty VMs), and the 'powered on' ones that use resources right now.
Also make it clear that these methods are based on the Status and Role fields, not on what the VM hypervisor thinks.
---
 testbot/lib/WineTestBot/VMs.pm |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 360958e..b519f33 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -442,6 +442,25 @@ sub Status
   return $NewStatus;
 }
 
+sub HasPoweredOnStatus($)
+{
+  my ($self) = @_;
+  my $Status = $self->Status;
+  return $Status eq "reverting" or
+         $Status eq "sleeping" or
+         $Status eq "idle" or
+         $Status eq "running";
+}
+
+sub HasEnabledRole($)
+{
+  my ($self) = @_;
+  my $Role = $self->Role;
+  return $Role eq "extra" or
+         $Role eq "base" or
+         $Role eq "winetest";
+}
+
 sub Validate
 {
   my $self = shift;
@@ -588,12 +607,8 @@ sub CountPoweredOnNonBaseVMs
   my $PoweredOnVMs = 0;
   foreach my $VM (@{$self->GetItems()})
   {
-    my $VMStatus = $VM->Status;
-    if ($VM->Role ne "base" &&
-        ($VMStatus eq "reverting" ||
-         $VMStatus eq "sleeping" ||
-         $VMStatus eq "idle" ||
-         $VMStatus eq "running"))
+    if ($VM->Role ne "base" and $VM->HasEnabledRole() and
+        $VM->HasPoweredOnStatus())
     {
       $PoweredOnVMs++;
     }
-- 
1.7.10.4




More information about the wine-patches mailing list