diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-03-27 08:39:28 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-03-27 08:39:28 +0000 |
commit | 7dc27490479a6fe8ffeccc834f3410bbdb2d9fd9 (patch) | |
tree | 49f2d15fa1c071069ed9227299942ef88a51efeb /plugins/t | |
parent | 0f342875df1cb8f0fb1803bebbfb536b30b51020 (diff) | |
download | monitoring-plugins-7dc27490479a6fe8ffeccc834f3410bbdb2d9fd9.tar.gz |
Set timeout within nc, rather than the test script
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1359 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/check_udp.t | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t index c9228adc..ac1a893c 100644 --- a/plugins/t/check_udp.t +++ b/plugins/t/check_udp.t @@ -38,10 +38,11 @@ SKIP: { like ( $res->output, '/\[barbar\]/', "Output OK"); close NC; - my $pid = open(NC, "nc -l -p 3333 -u |"); # Start up a udp server listening on port 3333 - alarm(7); - sleep 1; - $SIG{ALRM} = sub { kill 'INT', $pid }; + # Start up a udp server listening on port 3333, quit after 3 seconds + # Otherwise will hang at close + my $pid = open(NC, "nc -l -p 3333 -u -w 3 </dev/null |"); + sleep 1; # Allow nc to startup + my $start = time; $res = NPTest->testCmd( "./check_udp2 -H localhost -p 3333 -s foofoo -e barbar -t 5 -4" ); my $duration = time - $start; @@ -49,7 +50,6 @@ SKIP: { like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); cmp_ok( $duration, '==', 5, "Timeout exactly right"); my $read_nc = <NC>; - # nc gets killed here - I think expects a linefeed from stdin, so doesn't exit itself close NC; cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); } |