Module: tools Branch: master Commit: 2efbe36d11c083b9c7fd66b33d4d937b18064547 URL: http://source.winehq.org/git/tools.git/?a=commit;h=2efbe36d11c083b9c7fd66b33...
Author: Francois Gouget fgouget@codeweavers.com Date: Tue Mar 26 11:47:08 2013 +0100
testbot/VMs: Fix counting the powered on non-base VMs.
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 files 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++; }