[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 1/3] timeouts: Refactor target_adjust_timeout to have $adjust->(), and log



If a timeout is adjusted, print a log message.  We are going to want
to reuse this logic in a moment.

Do the defaulting in $adjust->() rather than passing 1 as a default
to the lookup functions, which is slightly neater.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/TestSupport.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 888f0ac..5a10cae 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -334,9 +334,17 @@ END
 
 sub target_adjust_timeout ($$) {
     my ($ho,$timeoutref) = @_; # $ho might be a $gho
+    my $adjust = sub {
+       my ($factor, $what) = @_;
+       return unless defined $factor;
+       return if $factor==1;
+       logm("(adjusting timeout by factor $factor, from $what)");
+       $$timeoutref *= $factor;
+    };
     if ($ho->{Guest}) {
        my $context = $ho->{TimeoutContext} // 'general';
-       $$timeoutref *= guest_var($ho,"${context}_timeoutfactor",1);
+       my $guest_var = "${context}_timeoutfactor";
+       $adjust->(guest_var($ho,$guest_var), "guest variable $guest_var");
     }
 }
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.