From: Jerry D. Hedden Date: Fri, 11 Jul 2008 12:08:51 +0000 (-0400) Subject: watchdog() some IO tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=966e8138915c735d0b4894d8edbb294e615d1307;p=p5sagit%2Fp5-mst-13.2.git watchdog() some IO tests From: "Jerry D. Hedden" Message-ID: <1ff86f510807110908q4ac81225see2b11aa4729397d@mail.gmail.com> p4raw-id: //depot/perl@34148 --- diff --git a/ext/IO/t/io_linenum.t b/ext/IO/t/io_linenum.t index a1b1bc6..954c223 100755 --- a/ext/IO/t/io_linenum.t +++ b/ext/IO/t/io_linenum.t @@ -13,6 +13,13 @@ BEGIN { @INC = '../lib'; } require strict; import strict; + + # Import test.pl into its own package + { + package TestPL; + require($ENV{PERL_CORE} ? './test.pl' : './t/test.pl'); + TestPL::watchdog(15); + } } use Test; diff --git a/ext/IO/t/io_udp.t b/ext/IO/t/io_udp.t index 641e409..d89f740 100755 --- a/ext/IO/t/io_udp.t +++ b/ext/IO/t/io_udp.t @@ -5,13 +5,11 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; } -} -use Config; + require($ENV{PERL_CORE} ? './test.pl' : './t/test.pl'); -BEGIN { + use Config; my $reason; - if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) { $reason = 'Socket was not built'; } @@ -22,10 +20,7 @@ BEGIN { $reason = "unknown *FIXME*"; } undef $reason if $^O eq 'VMS' and $Config{d_socket}; - if ($reason) { - print "1..0 # Skip: $reason\n"; - exit 0; - } + skip_all($reason) if $reason; } sub compare_addr { @@ -49,8 +44,8 @@ sub compare_addr { "$a[0]$a[1]" eq "$b[0]$b[1]"; } -$| = 1; -print "1..7\n"; +plan(7); +watchdog(15); use Socket; use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY); @@ -58,35 +53,32 @@ use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY); $udpa = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost') || IO::Socket::INET->new(Proto => 'udp', LocalAddr => '127.0.0.1') or die "$! (maybe your system does not have a localhost at all, 'localhost' or 127.0.0.1)"; - -print "ok 1\n"; +ok(1); $udpb = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost') || IO::Socket::INET->new(Proto => 'udp', LocalAddr => '127.0.0.1') or die "$! (maybe your system does not have a localhost at all, 'localhost' or 127.0.0.1)"; +ok(1); -print "ok 2\n"; - -$udpa->send("ok 4\n",0,$udpb->sockname); +$udpa->send('BORK', 0, $udpb->sockname); -print "not " - unless compare_addr($udpa->peername,$udpb->sockname, 'peername', 'sockname'); -print "ok 3\n"; +ok(compare_addr($udpa->peername,$udpb->sockname, 'peername', 'sockname')); -my $where = $udpb->recv($buf="",5); -print $buf; +my $where = $udpb->recv($buf="", 4); +is($buf, 'BORK'); my @xtra = (); -unless(compare_addr($where,$udpa->sockname, 'recv name', 'sockname')) { - print "not "; - @xtra = (0,$udpa->sockname); +if (! ok(compare_addr($where,$udpa->sockname, 'recv name', 'sockname'))) { + @xtra = (0, $udpa->sockname); } -print "ok 5\n"; -$udpb->send("ok 6\n",@xtra); -$udpa->recv($buf="",5); -print $buf; +$udpb->send('FOObar', @xtra); +$udpa->recv($buf="", 6); +is($buf, 'FOObar'); + +ok(! $udpa->connected); + +exit(0); -print "not " if $udpa->connected; -print "ok 7\n"; +# EOF