[Nagiosplug-checkins] nagiosplug/plugins/t check_udp.t,1.3,1.4

Ton Voon tonvoon at users.sourceforge.net
Mon Mar 27 00:40:01 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins/t
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8844/t

Modified Files:
	check_udp.t 
Log Message:
Set timeout within nc, rather than the test script


Index: check_udp.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_udp.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- check_udp.t	24 Mar 2006 16:12:05 -0000	1.3
+++ check_udp.t	27 Mar 2006 08:39:28 -0000	1.4
@@ -38,10 +38,11 @@
 	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 @@
 	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" );
 }





More information about the Commits mailing list