aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <Sven.Nierlein@consol.de> 2013-09-12 13:55:36 +0200
committerGravatar Sven Nierlein <sven@consol.de> 2013-09-12 23:39:31 +0200
commit07f9a0f6274331ab6e45ac36ac1fe60d120dd2fb (patch)
treee29368b5c06f29a44dfcc0bd14a43cb7e358464b
parentffad261eabd2eceb945a604c6c4f95465a2dfcc3 (diff)
downloadmonitoring-plugins-07f9a0f6274331ab6e45ac36ac1fe60d120dd2fb.tar.gz
tests: make sure tests don't hang
-rw-r--r--NPTest.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/NPTest.pm b/NPTest.pm
index 54a535e7..a2cad192 100644
--- a/NPTest.pm
+++ b/NPTest.pm
@@ -615,7 +615,10 @@ sub testCmd {
my $class = shift;
my $command = shift or die "No command passed to testCmd";
my $object = $class->new;
-
+
+ local $SIG{'ALRM'} = sub { die("timeout in command: $command"); };
+ alarm(120); # no test should take longer than 120 seconds
+
my $output = `$command`;
$object->return_code($? >> 8);
$_ = $? & 127;
@@ -625,6 +628,8 @@ sub testCmd {
chomp $output;
$object->output($output);
+ alarm(0);
+
my ($pkg, $file, $line) = caller(0);
print "Testing: $command", $/;
if ($ENV{'NPTEST_DEBUG'}) {