From: Ian Jackson Date: Wed, 4 Jul 2018 10:53:11 +0000 (+0100) Subject: resource allocation: PropEq, PropMinVer: support defaults X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fwip.propcompare;p=people%2Fiwj%2Fosstest.git resource allocation: PropEq, PropMinVer: support defaults Now you can pass another :-separated argument, the default value to use if none is specified. Signed-off-by: Ian Jackson CC: Roger Pau Monné --- diff --git a/Osstest/ResourceCondition/PropCompareBase.pm b/Osstest/ResourceCondition/PropCompareBase.pm index 039f64e3..5d1b18d2 100644 --- a/Osstest/ResourceCondition/PropCompareBase.pm +++ b/Osstest/ResourceCondition/PropCompareBase.pm @@ -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 {