]> xenbits.xensource.com Git - people/royger/osstest.git/commitdiff
resource allocation: PropEq, PropMinVer: support defaults
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 4 Jul 2018 10:53:11 +0000 (11:53 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 11 Jul 2018 14:55:03 +0000 (15:55 +0100)
Now you can pass another :-separated argument, the default value to
use if none is specified.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Roger Pau Monné <royger@FreeBSD.org>
Osstest/ResourceCondition/PropCompareBase.pm

index 039f64e3b661c82c7b932216ff846eb92811da17..5d1b18d2adef65593961e195dce2eba4be2b2739 100644 (file)
@@ -34,13 +34,14 @@ BEGIN {
 }
 
 sub new {
-    my ($class, $name, $prop, $val) = @_;
+    my ($class, $name, $prop, $val, $defval) = @_;
 
     die "propname: $prop?" unless propname_check($prop);
 
     return bless {
        Prop => $prop,
-       Val => $val
+       Val => $val,
+        DefaultVal => $val,
     }, $class;
 }
 
@@ -64,7 +65,11 @@ END
     $hpropq->finish();
     
     my $v = $row->[0];
-    return $v;
+    return $v if defined $v;
+
+    return $pc->{DefaultVal};
+    # if no default specified, returns undef
+    # then _check gets to decide what to do
 }
 
 sub check {