diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-03-27 08:39:28 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-03-27 08:39:28 (GMT) |
commit | 7dc27490479a6fe8ffeccc834f3410bbdb2d9fd9 (patch) | |
tree | 49f2d15fa1c071069ed9227299942ef88a51efeb | |
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
-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 c9228ad..ac1a893 100644 --- a/plugins/t/check_udp.t +++ b/plugins/t/check_udp.t | |||
@@ -38,10 +38,11 @@ SKIP: { | |||
38 | like ( $res->output, '/\[barbar\]/', "Output OK"); | 38 | like ( $res->output, '/\[barbar\]/', "Output OK"); |
39 | close NC; | 39 | close NC; |
40 | 40 | ||
41 | my $pid = open(NC, "nc -l -p 3333 -u |"); # Start up a udp server listening on port 3333 | 41 | # Start up a udp server listening on port 3333, quit after 3 seconds |
42 | alarm(7); | 42 | # Otherwise will hang at close |
43 | sleep 1; | 43 | my $pid = open(NC, "nc -l -p 3333 -u -w 3 </dev/null |"); |
44 | $SIG{ALRM} = sub { kill 'INT', $pid }; | 44 | sleep 1; # Allow nc to startup |
45 | |||
45 | my $start = time; | 46 | my $start = time; |
46 | $res = NPTest->testCmd( "./check_udp2 -H localhost -p 3333 -s foofoo -e barbar -t 5 -4" ); | 47 | $res = NPTest->testCmd( "./check_udp2 -H localhost -p 3333 -s foofoo -e barbar -t 5 -4" ); |
47 | my $duration = time - $start; | 48 | my $duration = time - $start; |
@@ -49,7 +50,6 @@ SKIP: { | |||
49 | like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); | 50 | like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); |
50 | cmp_ok( $duration, '==', 5, "Timeout exactly right"); | 51 | cmp_ok( $duration, '==', 5, "Timeout exactly right"); |
51 | my $read_nc = <NC>; | 52 | my $read_nc = <NC>; |
52 | # nc gets killed here - I think expects a linefeed from stdin, so doesn't exit itself | ||
53 | close NC; | 53 | close NC; |
54 | cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); | 54 | cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); |
55 | } | 55 | } |