]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
timeouts: Refactor target_adjust_timeout to have $adjust->(), and log
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 20 Jan 2017 11:54:34 +0000 (11:54 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 20 Jan 2017 11:54:36 +0000 (11:54 +0000)
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@eu.citrix.com>
Osstest/TestSupport.pm

index 888f0acd3a0fea41ac91d501b30b624a1fcd97c9..5a10cae196a77ef1e090121f293a0c6442a192e2 100644 (file)
@@ -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");
     }
 }