diff options
author | Sven Nierlein <Sven.Nierlein@consol.de> | 2013-09-12 13:55:36 +0200 |
---|---|---|
committer | Sven Nierlein <sven@consol.de> | 2013-09-12 23:39:31 +0200 |
commit | 07f9a0f6274331ab6e45ac36ac1fe60d120dd2fb (patch) | |
tree | e29368b5c06f29a44dfcc0bd14a43cb7e358464b | |
parent | ffad261eabd2eceb945a604c6c4f95465a2dfcc3 (diff) | |
download | monitoring-plugins-07f9a0f6274331ab6e45ac36ac1fe60d120dd2fb.tar.gz |
tests: make sure tests don't hang
-rw-r--r-- | NPTest.pm | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -615,7 +615,10 @@ sub testCmd { | |||
615 | my $class = shift; | 615 | my $class = shift; |
616 | my $command = shift or die "No command passed to testCmd"; | 616 | my $command = shift or die "No command passed to testCmd"; |
617 | my $object = $class->new; | 617 | my $object = $class->new; |
618 | 618 | ||
619 | local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; | ||
620 | alarm(120); # no test should take longer than 120 seconds | ||
621 | |||
619 | my $output = `$command`; | 622 | my $output = `$command`; |
620 | $object->return_code($? >> 8); | 623 | $object->return_code($? >> 8); |
621 | $_ = $? & 127; | 624 | $_ = $? & 127; |
@@ -625,6 +628,8 @@ sub testCmd { | |||
625 | chomp $output; | 628 | chomp $output; |
626 | $object->output($output); | 629 | $object->output($output); |
627 | 630 | ||
631 | alarm(0); | ||
632 | |||
628 | my ($pkg, $file, $line) = caller(0); | 633 | my ($pkg, $file, $line) = caller(0); |
629 | print "Testing: $command", $/; | 634 | print "Testing: $command", $/; |
630 | if ($ENV{'NPTEST_DEBUG'}) { | 635 | if ($ENV{'NPTEST_DEBUG'}) { |