X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FTest.pm;h=0bf89bd6b63206cafc5e5648fb7540a4ddd0a146;hb=11ce7318b4b78e0bd90a7e0a0c89e871bd2456b1;hp=e73061abb3f0bba2920d8d4337a3e0901ff4cd3b;hpb=a33fc154378be5c0b0c3f4fdc1ff4c1d32c379b3;p=irspy-moved-to-github.git diff --git a/lib/ZOOM/IRSpy/Test.pm b/lib/ZOOM/IRSpy/Test.pm index e73061a..0bf89bd 100644 --- a/lib/ZOOM/IRSpy/Test.pm +++ b/lib/ZOOM/IRSpy/Test.pm @@ -1,4 +1,3 @@ -# $Id: Test.pm,v 1.8 2007-04-18 15:24:45 mike Exp $ package ZOOM::IRSpy::Test; @@ -6,6 +5,11 @@ use 5.008; use strict; use warnings; +use Scalar::Util; + +use Exporter 'import'; +our @EXPORT = qw(zoom_error_timeout_update zoom_error_timeout_check); + =head1 NAME ZOOM::IRSpy::Test - base class for tests in IRSpy @@ -20,6 +24,7 @@ I<## To follow> =cut + sub subtests { () } sub timeout { undef } @@ -32,6 +37,29 @@ sub start { } +our $max_timeout_errors = $ZOOM::IRSpy::max_timeout_errors; + +sub zoom_error_timeout_update { + my ($conn, $exception) = @_; + + if ($exception =~ /Timeout/i) { + $conn->record->zoom_error->{TIMEOUT}++; + $conn->log("irspy_test", "Increase timeout error counter to: " . + $conn->record->zoom_error->{TIMEOUT}); + } +} + +sub zoom_error_timeout_check { + my $conn = shift; + + if ($conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) { + $conn->log("irspy_test", "Got $max_timeout_errors or more timeouts, give up..."); + return 1; + } + + return 0; +} + =head1 SEE ALSO ZOOM::IRSpy