diff mbox series

[OSSTEST,27/82] host allocation: *_shared_mark_ready: allow alternative $oldtypes

Message ID 20201007180024.7932-28-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series Reuse test hosts | expand

Commit Message

Ian Jackson Oct. 7, 2020, 5:59 p.m. UTC
From: Ian Jackson <ian.jackson@eu.citrix.com>

$oldtype may now be a hashref, where keys mapping to truthy values are
permitted for the sharetype precondition.

No functional change for existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index fd975590..f2d43464 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1056,6 +1056,7 @@  sub executive_resource_shared_mark_ready ($$$;$$) {
 
     my $oldshr;
     $oldstate //= 'prep';
+    $oldstate = { $oldstate => 1 } unless ref $oldstate;
     $newstate //= 'ready';
 
     my $what= "resource $restype $resname";
@@ -1070,8 +1071,9 @@  sub executive_resource_shared_mark_ready ($$$;$$) {
         if (defined $oldshr) {
             die "$what shared $oldshr->{Type} not $sharetype"
                 unless !defined $sharetype or $oldshr->{Type} eq $sharetype;
-            die "$what shared state $oldshr->{State} not $oldstate"
-                unless $oldshr->{State} eq $oldstate;
+            die "$what shared state $oldshr->{State} not".
+		" one of ".(join ' ', sort keys %$oldstate)
+                unless $oldstate->{ $oldshr->{State} };
             my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname);
                 UPDATE resource_sharing
                    SET state=?