summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NPTest.pm5
-rwxr-xr-xplugins/tests/check_http.t24
2 files changed, 12 insertions, 17 deletions
diff --git a/NPTest.pm b/NPTest.pm
index 2baed0b..e04ebba 100644
--- a/NPTest.pm
+++ b/NPTest.pm
@@ -627,12 +627,13 @@ sub only_output {
627} 627}
628 628
629sub testCmd { 629sub testCmd {
630 my $class = shift; 630 my $class = shift;
631 my $command = shift or die "No command passed to testCmd"; 631 my $command = shift or die "No command passed to testCmd";
632 my $timeout = shift || 120;
632 my $object = $class->new; 633 my $object = $class->new;
633 634
634 local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; 635 local $SIG{'ALRM'} = sub { die("timeout in command: $command"); };
635 alarm(120); # no test should take longer than 120 seconds 636 alarm($timeout); # no test should take longer than 120 seconds
636 637
637 my $output = `$command`; 638 my $output = `$command`;
638 $object->return_code($? >> 8); 639 $object->return_code($? >> 8);
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 2c89beb..c40bb07 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -392,27 +392,21 @@ sub run_common_tests {
392 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); 392 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
393 $cmd = "$command -f follow -u /redir_external -t 5"; 393 $cmd = "$command -f follow -u /redir_external -t 5";
394 eval { 394 eval {
395 local $SIG{ALRM} = sub { die "alarm\n" }; 395 $result = NPTest->testCmd( $cmd, 2 );
396 alarm(2); 396 };
397 $result = NPTest->testCmd( $cmd ); 397 like( $@, "/timeout in command: $cmd/", $cmd );
398 alarm(0); };
399 is( $@, "alarm\n", $cmd );
400 } 398 }
401 399
402 $cmd = "$command -u /timeout -t 5"; 400 $cmd = "$command -u /timeout -t 5";
403 eval { 401 eval {
404 local $SIG{ALRM} = sub { die "alarm\n" }; 402 $result = NPTest->testCmd( $cmd, 2 );
405 alarm(2); 403 };
406 $result = NPTest->testCmd( $cmd ); 404 like( $@, "/timeout in command: $cmd/", $cmd );
407 alarm(0); };
408 is( $@, "alarm\n", $cmd );
409 405
410 $cmd = "$command -f follow -u /redir_timeout -t 2"; 406 $cmd = "$command -f follow -u /redir_timeout -t 2";
411 eval { 407 eval {
412 local $SIG{ALRM} = sub { die "alarm\n" }; 408 $result = NPTest->testCmd( $cmd, 5 );
413 alarm(5); 409 };
414 $result = NPTest->testCmd( $cmd ); 410 is( $@, "", $cmd );
415 alarm(0); };
416 isnt( $@, "alarm\n", $cmd );
417 411
418} 412}